cty123 / TrojanRust

Trojan-rust is a rust implementation for Trojan protocol that is targeted to circumvent GFW. This implementation focus on performance and stability above everything else.
MIT License
112 stars 24 forks source link

编译ARM64版本失败 #17

Closed ArcCal closed 1 year ago

ArcCal commented 1 year ago

一、编译环境 Distributor ID: Ubuntu Description: Ubuntu 22.04.2 LTS Release: 22.04 Codename: jammy

Linux version 5.15.0-1030-oracle (buildd@bos02-arm64-061) (gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #36-Ubuntu SMP Wed Feb 15 05:57:14 UTC 2023

二、编译过程及错误信息 /tmp/TrojanRust# cargo build --release Compiling serde_json v1.0.64 Compiling quinn v0.9.3 Compiling trojan-rust v0.7.2 (/tmp/TrojanRust) Compiling constant_time_eq v0.2.4 error: failed to run custom build command for trojan-rust v0.7.2 (/tmp/TrojanRust)

Caused by: process didn't exit successfully: /tmp/TrojanRust/target/release/build/trojan-rust-8bbe07b6d9abc75a/build-script-build (exit status: 101) --- stdout cargo:rerun-if-changed=proto/transport.proto cargo:rerun-if-changed=proto

--- stderr thread 'main' panicked at ' Could not find protoc installation and this build crate cannot proceed without this knowledge. If protoc is installed and this crate had trouble finding it, you can set the PROTOC environment variable with the specific path to your installed protoc binary.

For more information: https://docs.rs/prost-build/#sourcing-protoc ', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/prost-build-0.11.0/src/lib.rs:1227:10 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace warning: build failed, waiting for other jobs to finish...

ArcCal commented 1 year ago

同一系统环境,编译trojan-r成功

ArcCal commented 1 year ago

重启 重新编译 结果依然失败 cargo build --release Compiling proc-macro2 v1.0.40 Compiling unicode-ident v1.0.1 Compiling syn v1.0.98 Compiling libc v0.2.139 Compiling autocfg v1.1.0 Compiling cfg-if v1.0.0 Compiling memchr v2.5.0 Compiling log v0.4.14 Compiling quote v1.0.9 Compiling pin-project-lite v0.2.9 Compiling bytes v1.4.0 Compiling futures-core v0.3.21 Compiling lock_api v0.4.7 Compiling parking_lot_core v0.9.3 Compiling num_cpus v1.13.0 Compiling lazy_static v1.4.0 Compiling scopeguard v1.1.0 Compiling smallvec v1.6.1 Compiling socket2 v0.4.4 Compiling tokio v1.25.0 Compiling slab v0.4.5 Compiling parking_lot v0.12.0 Compiling mio v0.8.5 Compiling signal-hook-registry v1.3.0 Compiling futures-sink v0.3.21 Compiling futures-task v0.3.21 Compiling futures-channel v0.3.21 Compiling tracing-core v0.1.21 Compiling futures-util v0.3.21 Compiling either v1.6.1 Compiling cc v1.0.67 Compiling anyhow v1.0.52 Compiling getrandom v0.2.3 Compiling pin-utils v0.1.0 Compiling futures-io v0.3.21 Compiling ring v0.16.20 Compiling rand_core v0.6.3 Compiling itertools v0.10.3 Compiling indexmap v1.7.0 Compiling ppv-lite86 v0.2.16 Compiling rand_chacha v0.3.1 Compiling tokio-macros v1.7.0 Compiling tracing-attributes v0.1.18 Compiling futures-macro v0.3.21 Compiling prost-derive v0.11.0 Compiling tracing v0.1.29 Compiling untrusted v0.7.1 Compiling spin v0.5.2 Compiling hashbrown v0.11.2 Compiling once_cell v1.17.0 Compiling rand v0.8.4 Compiling itoa v1.0.1 Compiling fnv v1.0.7 Compiling http v0.2.6 Compiling webpki v0.22.0 Compiling rustls v0.20.6 Compiling typenum v1.15.0 Compiling version_check v0.9.3 Compiling bitflags v1.3.2 Compiling generic-array v0.14.4 Compiling http-body v0.4.4 Compiling sct v0.7.0 Compiling pin-project-internal v1.0.10 Compiling serde_derive v1.0.125 Compiling base64 v0.13.0 Compiling io-lifetimes v1.0.5 Compiling tower-service v0.3.1 Compiling httparse v1.5.1 Compiling pin-project v1.0.10 Compiling prost v0.11.0 Compiling rustls-pemfile v1.0.0 Compiling tokio-util v0.6.9 Compiling aho-corasick v0.7.18 Compiling num-traits v0.2.14 Compiling itoa v0.4.7 Compiling regex-syntax v0.6.25 Compiling remove_dir_all v0.5.3 Compiling openssl-probe v0.1.4 Compiling try-lock v0.2.3 Compiling fixedbitset v0.4.1 Compiling async-trait v0.1.56 Compiling serde v1.0.125 Compiling rustix v0.36.8 Compiling petgraph v0.6.0 Compiling want v0.3.0 Compiling rustls-native-certs v0.6.2 Compiling regex v1.5.5 Compiling tempfile v3.2.0 Compiling h2 v0.3.9 Compiling prost-types v0.11.0 Compiling tokio-util v0.7.3 Compiling which v4.2.2 Compiling thiserror-impl v1.0.31 Compiling httpdate v1.0.2 Compiling tinyvec_macros v0.1.0 Compiling tower-layer v0.3.1 Compiling multimap v0.8.3 Compiling heck v0.4.0 Compiling linux-raw-sys v0.1.4 Compiling prost-build v0.11.0 Compiling tower v0.4.12 Compiling hyper v0.14.16 Compiling tinyvec v1.6.0 Compiling thiserror v1.0.31 Compiling prettyplease v0.1.10 Compiling http-range-header v0.3.0 Compiling predicates-core v1.0.2 Compiling rustc-hash v1.1.0 Compiling mime v0.3.16 Compiling ryu v1.0.5 Compiling axum-core v0.2.3 Compiling quinn-proto v0.9.2 Compiling tower-http v0.3.2 Compiling tonic-build v0.8.0 Compiling float-cmp v0.9.0 Compiling is-terminal v0.4.3 Compiling crypto-common v0.1.3 Compiling block-buffer v0.10.0 Compiling tokio-io-timeout v1.2.0 Compiling async-stream-impl v0.3.2 Compiling difflib v0.4.0 Compiling matchit v0.5.0 Compiling normalize-line-endings v0.3.0 Compiling termcolor v1.1.2 Compiling percent-encoding v2.1.0 Compiling os_str_bytes v6.0.0 Compiling treeline v0.1.0 Compiling sync_wrapper v0.1.1 Compiling serde_json v1.0.64 Compiling predicates-tree v1.0.3 Compiling clap_lex v0.3.1 Compiling predicates v2.1.0 Compiling hyper-timeout v0.4.1 Compiling axum v0.5.4 Compiling async-stream v0.3.2 Compiling quinn-udp v0.3.2 Compiling digest v0.10.3 Compiling trojan-rust v0.7.2 (/tmp/TrojanRust) Compiling tokio-rustls v0.23.4 Compiling tracing-futures v0.2.5 Compiling webpki-roots v0.22.4 Compiling futures-executor v0.3.21 Compiling tokio-stream v0.1.9 Compiling mockall_derive v0.11.1 Compiling cpufeatures v0.2.1 Compiling fragile v1.0.0 Compiling humantime v2.1.0 Compiling strsim v0.10.0 Compiling downcast v0.11.0 Compiling clap v4.1.4 Compiling mockall v0.11.1 Compiling env_logger v0.10.0 Compiling sha2 v0.10.2 Compiling tonic v0.8.0 Compiling futures v0.3.21 error: failed to run custom build command for trojan-rust v0.7.2 (/tmp/TrojanRust)

Caused by: process didn't exit successfully: /tmp/TrojanRust/target/release/build/trojan-rust-8bbe07b6d9abc75a/build-script-build (exit status: 101) --- stdout cargo:rerun-if-changed=proto/transport.proto cargo:rerun-if-changed=proto

--- stderr thread 'main' panicked at ' Could not find protoc installation and this build crate cannot proceed without this knowledge. If protoc is installed and this crate had trouble finding it, you can set the PROTOC environment variable with the specific path to your installed protoc binary.

For more information: https://docs.rs/prost-build/#sourcing-protoc ', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/prost-build-0.11.0/src/lib.rs:1227:10 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace warning: build failed, waiting for other jobs to finish...

ArcCal commented 1 year ago

同一系统环境,编译tuic成功

ArcCal commented 1 year ago

大佬们 能帮忙诊断一下不

ArcCal commented 1 year ago

macbook air M2下编译,一模一样的错误 cargo build --release Updating crates.io index Downloaded http-range-header v0.3.0 Downloaded pin-utils v0.1.0 Downloaded hyper-timeout v0.4.1 Downloaded base64 v0.13.0 Downloaded ppv-lite86 v0.2.16 Downloaded parking_lot v0.12.0 Downloaded rand_chacha v0.3.1 Downloaded pin-project v1.0.10 Downloaded quote v1.0.9 Downloaded rand v0.8.4 Downloaded autocfg v1.1.0 Downloaded aho-corasick v0.7.18 Downloaded proc-macro2 v1.0.40 Downloaded difflib v0.4.0 Downloaded errno v0.2.8 Downloaded fnv v1.0.7 Downloaded futures-core v0.3.21 Downloaded futures-io v0.3.21 Downloaded heck v0.4.0 Downloaded httpdate v1.0.2 Downloaded humantime v2.1.0 Downloaded io-lifetimes v1.0.5 Downloaded httparse v1.5.1 Downloaded h2 v0.3.9 Downloaded lazy_static v1.4.0 Downloaded itoa v1.0.1 Downloaded mime v0.3.16 Downloaded lock_api v0.4.7 Downloaded indexmap v1.7.0 Downloaded multimap v0.8.3 Downloaded once_cell v1.17.0 Downloaded pin-project-lite v0.2.9 Downloaded predicates v2.1.0 Downloaded parking_lot_core v0.9.3 Downloaded quinn v0.9.3 Downloaded quinn-udp v0.3.2 Downloaded prost-derive v0.11.0 Downloaded remove_dir_all v0.5.3 Downloaded rand_core v0.6.3 Downloaded prost-build v0.11.0 Downloaded pin-project-internal v1.0.10 Downloaded quinn-proto v0.9.2 Downloaded prost v0.11.0 Downloaded predicates-tree v1.0.3 Downloaded predicates-core v1.0.2 Downloaded petgraph v0.6.0 Downloaded num-traits v0.2.14 Downloaded normalize-line-endings v0.3.0 Downloaded log v0.4.14 Downloaded memchr v2.5.0 Downloaded matchit v0.5.0 Downloaded itoa v0.4.7 Downloaded is-terminal v0.4.3 Downloaded http v0.2.6 Downloaded http-body v0.4.4 Downloaded futures-util v0.3.21 Downloaded getrandom v0.2.3 Downloaded rustls-native-certs v0.6.2 Downloaded scopeguard v1.1.0 Downloaded itertools v0.10.3 Downloaded sct v0.7.0 Downloaded generic-array v0.14.4 Downloaded rustls v0.20.6 Downloaded ryu v1.0.5 Downloaded security-framework v2.3.1 Downloaded os_str_bytes v6.0.0 Downloaded rustls-pemfile v1.0.0 Downloaded byteorder v1.4.3 Downloaded smallvec v1.6.1 Downloaded slab v0.4.5 Downloaded tokio-rustls v0.23.4 Downloaded tracing-futures v0.2.5 Downloaded tower-http v0.3.2 Downloaded regex v1.5.5 Downloaded float-cmp v0.9.0 Downloaded security-framework-sys v2.4.2 Downloaded futures-sink v0.3.21 Downloaded serde v1.0.125 Downloaded rustix v0.36.8 Downloaded try-lock v0.2.3 Downloaded tracing-attributes v0.1.18 Downloaded tracing-core v0.1.21 Downloaded tracing v0.1.29 Downloaded downcast v0.11.0 Downloaded treeline v0.1.0 Downloaded tower-service v0.3.1 Downloaded tower-layer v0.3.1 Downloaded sha2 v0.10.2 Downloaded serde_derive v1.0.125 Downloaded serde_json v1.0.64 Downloaded want v0.3.0 Downloaded version_check v0.9.3 Downloaded tinyvec v1.6.0 Downloaded thiserror-impl v1.0.31 Downloaded thiserror v1.0.31 Downloaded tinyvec_macros v0.1.0 Downloaded tokio-io-timeout v1.2.0 Downloaded tokio-macros v1.7.0 Downloaded termcolor v1.1.2 Downloaded tempfile v3.2.0 Downloaded tokio v1.25.0 Downloaded syn v1.0.98 Downloaded sync_wrapper v0.1.1 Downloaded strsim v0.10.0 Downloaded socket2 v0.4.4 Downloaded cc v1.0.67 Downloaded bytes v1.4.0 Downloaded which v4.2.2 Downloaded libc v0.2.139 Downloaded tokio-stream v0.1.9 Downloaded regex-syntax v0.6.25 Downloaded tokio-util v0.6.9 Downloaded rustc-hash v1.1.0 Downloaded webpki-roots v0.22.4 Downloaded num_cpus v1.13.0 Downloaded mio v0.8.5 Downloaded futures-task v0.3.21 Downloaded futures-executor v0.3.21 Downloaded hashbrown v0.11.2 Downloaded futures-macro v0.3.21 Downloaded futures v0.3.21 Downloaded futures-channel v0.3.21 Downloaded fragile v1.0.0 Downloaded ring v0.16.20 Downloaded untrusted v0.7.1 Downloaded tonic-build v0.8.0 Downloaded typenum v1.15.0 Downloaded tower v0.4.12 Downloaded webpki v0.22.0 Downloaded unicode-ident v1.0.1 Downloaded clap_lex v0.3.1 Downloaded bitflags v1.3.2 Downloaded clap v4.1.4 Downloaded axum-core v0.2.3 Downloaded tokio-util v0.7.3 Downloaded prettyplease v0.1.10 Downloaded mockall v0.11.1 Downloaded mockall_derive v0.11.1 Downloaded prost-types v0.11.0 Downloaded async-stream v0.3.2 Downloaded uninit v0.5.0 Downloaded signal-hook-registry v1.3.0 Downloaded anyhow v1.0.52 Downloaded hyper v0.14.16 Downloaded async-stream-impl v0.3.2 Downloaded tonic v0.8.0 Downloaded axum v0.5.4 Downloaded percent-encoding v2.1.0 Downloaded async-trait v0.1.56 Downloaded fixedbitset v0.4.1 Downloaded either v1.6.1 Downloaded env_logger v0.10.0 Downloaded digest v0.10.3 Downloaded cpufeatures v0.2.1 Downloaded crypto-common v0.1.3 Downloaded core-foundation-sys v0.8.3 Downloaded core-foundation v0.9.2 Downloaded constant_time_eq v0.2.4 Downloaded cfg-if v1.0.0 Downloaded block-buffer v0.10.0 Downloaded 160 crates (13.3 MB) in 2.87s (largest was ring at 5.1 MB) Compiling proc-macro2 v1.0.40 Compiling unicode-ident v1.0.1 Compiling syn v1.0.98 Compiling libc v0.2.139 Compiling autocfg v1.1.0 Compiling cfg-if v1.0.0 Compiling memchr v2.5.0 Compiling log v0.4.14 Compiling pin-project-lite v0.2.9 Compiling bytes v1.4.0 Compiling futures-core v0.3.21 Compiling lock_api v0.4.7 Compiling parking_lot_core v0.9.3 Compiling smallvec v1.6.1 Compiling lazy_static v1.4.0 Compiling scopeguard v1.1.0 Compiling tokio v1.25.0 Compiling slab v0.4.5 Compiling futures-task v0.3.21 Compiling futures-channel v0.3.21 Compiling num_cpus v1.13.0 Compiling socket2 v0.4.4 Compiling mio v0.8.5 Compiling quote v1.0.9 Compiling signal-hook-registry v1.3.0 Compiling futures-sink v0.3.21 Compiling tracing-core v0.1.21 Compiling either v1.6.1 Compiling cc v1.0.67 Compiling parking_lot v0.12.0 Compiling anyhow v1.0.52 Compiling futures-util v0.3.21 Compiling getrandom v0.2.3 Compiling futures-io v0.3.21 Compiling bitflags v1.3.2 Compiling pin-utils v0.1.0 Compiling rand_core v0.6.3 Compiling itertools v0.10.3 Compiling indexmap v1.7.0 Compiling ring v0.16.20 Compiling ppv-lite86 v0.2.16 Compiling untrusted v0.7.1 Compiling rand_chacha v0.3.1 Compiling core-foundation-sys v0.8.3 Compiling hashbrown v0.11.2 Compiling fnv v1.0.7 Compiling rand v0.8.4 Compiling itoa v1.0.1 Compiling http v0.2.6 Compiling version_check v0.9.3 Compiling rustls v0.20.6 Compiling typenum v1.15.0 Compiling generic-array v0.14.4 Compiling http-body v0.4.4 Compiling security-framework-sys v2.4.2 Compiling core-foundation v0.9.2 Compiling serde_derive v1.0.125 Compiling base64 v0.13.0 Compiling io-lifetimes v1.0.5 Compiling httparse v1.5.1 Compiling tower-service v0.3.1 Compiling rustls-pemfile v1.0.0 Compiling security-framework v2.3.1 Compiling aho-corasick v0.7.18 Compiling num-traits v0.2.14 Compiling serde v1.0.125 Compiling remove_dir_all v0.5.3 Compiling rustix v0.36.8 Compiling async-trait v0.1.56 Compiling tokio-macros v1.7.0 Compiling tracing-attributes v0.1.18 Compiling futures-macro v0.3.21 Compiling prost-derive v0.11.0 Compiling pin-project-internal v1.0.10 Compiling tracing v0.1.29 Compiling webpki v0.22.0 Compiling sct v0.7.0 Compiling prost v0.11.0 Compiling pin-project v1.0.10 Compiling try-lock v0.2.3 Compiling fixedbitset v0.4.1 Compiling regex-syntax v0.6.25 Compiling itoa v0.4.7 Compiling petgraph v0.6.0 Compiling want v0.3.0 Compiling prost-types v0.11.0 Compiling regex v1.5.5 Compiling tokio-util v0.6.9 Compiling tokio-util v0.7.3 Compiling h2 v0.3.9 Compiling thiserror-impl v1.0.31 Compiling tempfile v3.2.0 Compiling rustls-native-certs v0.6.2 Compiling which v4.2.2 Compiling errno v0.2.8 Compiling heck v0.4.0 Compiling httpdate v1.0.2 Compiling multimap v0.8.3 Compiling tinyvec_macros v0.1.0 Compiling tower-layer v0.3.1 Compiling tinyvec v1.6.0 Compiling tower v0.4.12 Compiling prost-build v0.11.0 Compiling thiserror v1.0.31 Compiling prettyplease v0.1.10 Compiling http-range-header v0.3.0 Compiling rustc-hash v1.1.0 Compiling predicates-core v1.0.2 Compiling ryu v1.0.5 Compiling mime v0.3.16 Compiling quinn-proto v0.9.2 Compiling axum-core v0.2.3 Compiling tonic-build v0.8.0 Compiling tower-http v0.3.2 Compiling float-cmp v0.9.0 Compiling is-terminal v0.4.3 Compiling crypto-common v0.1.3 Compiling block-buffer v0.10.0 Compiling tokio-io-timeout v1.2.0 Compiling async-stream-impl v0.3.2 Compiling normalize-line-endings v0.3.0 Compiling percent-encoding v2.1.0 Compiling difflib v0.4.0 Compiling sync_wrapper v0.1.1 Compiling os_str_bytes v6.0.0 Compiling treeline v0.1.0 Compiling serde_json v1.0.64 Compiling termcolor v1.1.2 Compiling matchit v0.5.0 Compiling predicates-tree v1.0.3 Compiling clap_lex v0.3.1 Compiling hyper v0.14.16 Compiling predicates v2.1.0 Compiling quinn-udp v0.3.2 Compiling async-stream v0.3.2 Compiling digest v0.10.3 Compiling trojan-rust v0.7.2 (/private/tmp/TrojanRust) Compiling tokio-stream v0.1.9 Compiling tokio-rustls v0.23.4 Compiling futures-executor v0.3.21 Compiling tracing-futures v0.2.5 Compiling webpki-roots v0.22.4 Compiling mockall_derive v0.11.1 Compiling cpufeatures v0.2.1 Compiling fragile v1.0.0 Compiling humantime v2.1.0 Compiling downcast v0.11.0 Compiling strsim v0.10.0 Compiling clap v4.1.4 Compiling env_logger v0.10.0 Compiling sha2 v0.10.2 Compiling futures v0.3.21 error: failed to run custom build command for trojan-rust v0.7.2 (/private/tmp/TrojanRust)

Caused by: process didn't exit successfully: /private/tmp/TrojanRust/target/release/build/trojan-rust-e38344850675ad5f/build-script-build (exit status: 101) --- stdout cargo:rerun-if-changed=proto/transport.proto cargo:rerun-if-changed=proto

--- stderr thread 'main' panicked at ' Could not find protoc installation and this build crate cannot proceed without this knowledge. If protoc is installed and this crate had trouble finding it, you can set the PROTOC environment variable with the specific path to your installed protoc binary.

For more information: https://docs.rs/prost-build/#sourcing-protoc ', /Users/attorneyfan/.cargo/registry/src/github.com-1ecc6299db9ec823/prost-build-0.11.0/src/lib.rs:1227:10 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace warning: build failed, waiting for other jobs to finish...

ArcCal commented 1 year ago

搞定了

ArcCal commented 1 year ago

编译成功了还是无法运行:

root@ubuntu:/tmp# trojan-rust --config /tmp/config.json thread 'main' panicked at 'Mismatch between definition and access of config. Could not downcast to TypeId { t: 9919015677752515272 }, need to downcast to TypeId { t: 4274174963818954440 } ', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-4.1.4/src/parser/error.rs:30:9 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

cty123 commented 1 year ago

编译需要安装protoc编译器https://grpc.io/docs/protoc-installation/

本来是不用的,后来tonic包改成默认调用系统的protoc所以就需要了

cty123 commented 1 year ago

错误显示的是config.json格式错误,我猜你是不是把trojan的密码当成了整数的形式?比如说应该是

{
  ...
  "secret": "123123"
}

你看看你的引号有没有加,或者你把你的config文件发上来看看

ArcCal commented 1 year ago

{ "inbound": { "protocol": "SOCKS", "address": "0.0.0.0", "port": 10808 }, "outbound": { "protocol": "TROJAN", "address": "1.1.1.1", "port": 443, "secret": "uKwOT6bgIq87Iq37WxWO0lgGOZs8mIuSM", "mode": "TCP", "tls": { "host_name": "www.ggggg.com", "allow_insecure": false } } }

ArcCal commented 1 year ago

是因为密码太复杂了吗

ArcCal commented 1 year ago

另外请教一个问题,您的实现有回落机制不,对非trojan流量服务端会怎么处理

cty123 commented 1 year ago

Inbound没有mode,你可以借鉴这里https://github.com/cty123/TrojanRust/blob/main/example/tcp_trojan/client.json#L3.

{
    "inbound": {
        "protocol": "SOCKS",
        "address": "0.0.0.0",
        "port": 10808,
        "mode": "TCP"
    },
    "outbound": {
        "protocol": "TROJAN",
        "address": "1.1.1.1",
        "port": 443,
        "secret": "uKwOT6bgIq87Iq37WxWO0lgGOZs8mIuSM",
        "mode": "TCP",
        "tls": {
            "host_name": "www.ggggg.com",
            "allow_insecure": false
        }
    }
}
ArcCal commented 1 year ago

Inbound没有mode,你可以借鉴这里https://github.com/cty123/TrojanRust/blob/main/example/tcp_trojan/client.json#L3.


{

    "inbound": {

        "protocol": "SOCKS",

        "address": "0.0.0.0",

        "port": 10808,

        "mode": "TCP"

    },

    "outbound": {

        "protocol": "TROJAN",

        "address": "1.1.1.1",

        "port": 443,

        "secret": "uKwOT6bgIq87Iq37WxWO0lgGOZs8mIuSM",

        "mode": "TCP",

        "tls": {

            "host_name": "www.ggggg.com",

            "allow_insecure": false

        }

    }

}

不是的,您看上面张贴的。 另外参照repo里的文件,改了好几版,都不行,不清楚原因

ArcCal commented 1 year ago

Inbound没有mode

您说“Inbound没有mode”,您贴出来的示例却有

cty123 commented 1 year ago

我的意思是你贴出来的配置文件里面inbound没有写,所以导致的报错,你给我的那个配置文件里面没有mode,所以会出问题。不过你贴出来的那个错误确实是一个bug,之前在更新clap的时候改的有问题,你重新拉取一下更新 git pull,然后再编译应该就好了。

ArcCal commented 1 year ago

重新编译了,不报错,但还是不能工作 运行trojan-rust --config ./config.json后,不产生任何日志,也不能翻墙

cty123 commented 1 year ago
RUST_LOG=info ./trojan-rust ...

需要设置环境变量打开log,这个readme有写,默认没有log。至于为什么不能翻墙要看具体错误才能知道。

ArcCal commented 1 year ago

[2023-03-07T01:09:06Z INFO trojan_rust] Starting TCP server to accept inbound traffic [2023-03-07T01:09:07Z INFO trojan_rust::proxy::tcp::server] Received new connection from 127.0.0.1:49606 [2023-03-07T01:09:07Z INFO trojan_rust::proxy::tcp::handler] Connection finished [2023-03-07T01:09:07Z INFO trojan_rust::proxy::tcp::server] Connection from 127.0.0.1:49606 has finished [2023-03-07T01:09:09Z INFO trojan_rust::proxy::tcp::server] Received new connection from 127.0.0.1:49608 [2023-03-07T01:09:09Z INFO trojan_rust::proxy::tcp::handler] Connection finished [2023-03-07T01:09:09Z INFO trojan_rust::proxy::tcp::server] Connection from 127.0.0.1:49608 has finished [2023-03-07T01:09:10Z INFO trojan_rust::proxy::tcp::server] Received new connection from 127.0.0.1:49610 [2023-03-07T01:09:11Z INFO trojan_rust::proxy::tcp::handler] Connection finished [2023-03-07T01:09:11Z INFO trojan_rust::proxy::tcp::server] Connection from 127.0.0.1:49610 has finished [2023-03-07T01:09:11Z INFO trojan_rust::proxy::tcp::server] Received new connection from 127.0.0.1:49612 [2023-03-07T01:09:11Z INFO trojan_rust::proxy::tcp::handler] Connection finished [2023-03-07T01:09:11Z INFO trojan_rust::proxy::tcp::server] Connection from 127.0.0.1:49612 has finished [2023-03-07T01:09:14Z INFO trojan_rust::proxy::tcp::server] Received new connection from 127.0.0.1:49614 [2023-03-07T01:09:14Z INFO trojan_rust::proxy::tcp::handler] Connection finished [2023-03-07T01:09:14Z INFO trojan_rust::proxy::tcp::server] Connection from 127.0.0.1:49614 has finished [2023-03-07T01:09:18Z INFO trojan_rust::proxy::tcp::server] Received new connection from 127.0.0.1:49616 [2023-03-07T01:09:19Z INFO trojan_rust::proxy::tcp::handler] Connection finished [2023-03-07T01:09:19Z INFO trojan_rust::proxy::tcp::server] Connection from 127.0.0.1:49616 has finished

ArcCal commented 1 year ago

产生日志了,但还是不能翻墙 确认服务端是正常的,使用trojan-r等trojan客户端都能连上

cty123 commented 1 year ago

看起来没有什么错误,你看看你trojan服务器这边有没有收到连接请求。还有你是怎么用什么把流量转发到socks端的?好像你的inbound流量不是socks的

ArcCal commented 1 year ago
image

都是Firefox浏览器的流量

cty123 commented 1 year ago

看着没问题,我自己也是用firefox代理的,我本地测试一下

ArcCal commented 1 year ago

[2023-03-07T01:09:06Z INFO trojan_rust] Starting TCP server to accept inbound traffic [2023-03-07T01:09:07Z INFO trojan_rust::proxy::tcp::server] Received new connection from 127.0.0.1:49606 [2023-03-07T01:09:07Z INFO trojan_rust::proxy::tcp::handler] Connection finished [2023-03-07T01:09:07Z INFO trojan_rust::proxy::tcp::server] Connection from 127.0.0.1:49606 has finished [2023-03-07T01:09:09Z INFO trojan_rust::proxy::tcp::server] Received new connection from 127.0.0.1:49608 [2023-03-07T01:09:09Z INFO trojan_rust::proxy::tcp::handler] Connection finished [2023-03-07T01:09:09Z INFO trojan_rust::proxy::tcp::server] Connection from 127.0.0.1:49608 has finished [2023-03-07T01:09:10Z INFO trojan_rust::proxy::tcp::server] Received new connection from 127.0.0.1:49610 [2023-03-07T01:09:11Z INFO trojan_rust::proxy::tcp::handler] Connection finished [2023-03-07T01:09:11Z INFO trojan_rust::proxy::tcp::server] Connection from 127.0.0.1:49610 has finished [2023-03-07T01:09:11Z INFO trojan_rust::proxy::tcp::server] Received new connection from 127.0.0.1:49612 [2023-03-07T01:09:11Z INFO trojan_rust::proxy::tcp::handler] Connection finished [2023-03-07T01:09:11Z INFO trojan_rust::proxy::tcp::server] Connection from 127.0.0.1:49612 has finished [2023-03-07T01:09:14Z INFO trojan_rust::proxy::tcp::server] Received new connection from 127.0.0.1:49614 [2023-03-07T01:09:14Z INFO trojan_rust::proxy::tcp::handler] Connection finished [2023-03-07T01:09:14Z INFO trojan_rust::proxy::tcp::server] Connection from 127.0.0.1:49614 has finished [2023-03-07T01:09:18Z INFO trojan_rust::proxy::tcp::server] Received new connection from 127.0.0.1:49616 [2023-03-07T01:09:19Z INFO trojan_rust::proxy::tcp::handler] Connection finished [2023-03-07T01:09:19Z INFO trojan_rust::proxy::tcp::server] Connection from 127.0.0.1:49616 has finished

从日志看,每一个connection的生命周期以微秒计,收到请求后立马就finish了

ArcCal commented 1 year ago
image

都是Firefox浏览器的流量

Firefox的配置一直都这样,配合其他代理工具一直都能正常工作

cty123 commented 1 year ago

我试了一下,确实有bug,socks5协议从一开始时间就有个小bug会导致读不到domain name,另外写trojan request的时候也会丢掉这个domain name的长度信息。我之前一直没发现,因为我之前没打开doh, 所以所有请求都是先查dns然后再连,所以这个个问题一直没有发现。你再拉取一下最新的更新,应该就好了

ArcCal commented 1 year ago

重新拉取和编译了,貌似还是不行

[2023-03-07T06:01:56Z INFO trojan_rust] Starting TCP server to accept inbound traffic [2023-03-07T06:01:58Z INFO trojan_rust::proxy::tcp::server] Received new connection from 127.0.0.1:53422 [2023-03-07T06:01:58Z INFO trojan_rust::proxy::tcp::handler] Connection finished [2023-03-07T06:01:58Z INFO trojan_rust::proxy::tcp::server] Connection from 127.0.0.1:53422 has finished [2023-03-07T06:01:59Z INFO trojan_rust::proxy::tcp::server] Received new connection from 127.0.0.1:53424 [2023-03-07T06:01:59Z INFO trojan_rust::proxy::tcp::handler] Connection finished [2023-03-07T06:01:59Z INFO trojan_rust::proxy::tcp::server] Connection from 127.0.0.1:53424 has finished [2023-03-07T06:01:59Z INFO trojan_rust::proxy::tcp::server] Received new connection from 127.0.0.1:53426 [2023-03-07T06:02:00Z INFO trojan_rust::proxy::tcp::handler] Connection finished [2023-03-07T06:02:00Z INFO trojan_rust::proxy::tcp::server] Connection from 127.0.0.1:53426 has finished [2023-03-07T06:02:00Z INFO trojan_rust::proxy::tcp::server] Received new connection from 127.0.0.1:53428 [2023-03-07T06:02:00Z INFO trojan_rust::proxy::tcp::server] Received new connection from 127.0.0.1:53430 [2023-03-07T06:02:01Z INFO trojan_rust::proxy::tcp::handler] Connection finished [2023-03-07T06:02:01Z INFO trojan_rust::proxy::tcp::server] Connection from 127.0.0.1:53428 has finished [2023-03-07T06:02:01Z INFO trojan_rust::proxy::tcp::handler] Connection finished [2023-03-07T06:02:01Z INFO trojan_rust::proxy::tcp::server] Connection from 127.0.0.1:53430 has finished [2023-03-07T06:02:01Z INFO trojan_rust::proxy::tcp::server] Received new connection from 127.0.0.1:53432 [2023-03-07T06:02:02Z INFO trojan_rust::proxy::tcp::handler] Connection finished [2023-03-07T06:02:02Z INFO trojan_rust::proxy::tcp::server] Connection from 127.0.0.1:53432 has finished [2023-03-07T06:02:02Z INFO trojan_rust::proxy::tcp::server] Received new connection from 127.0.0.1:53434 [2023-03-07T06:02:03Z INFO trojan_rust::proxy::tcp::handler] Connection finished [2023-03-07T06:02:03Z INFO trojan_rust::proxy::tcp::server] Connection from 127.0.0.1:53434 has finished [2023-03-07T06:02:17Z INFO trojan_rust::proxy::tcp::server] Received new connection from 127.0.0.1:53436 [2023-03-07T06:02:18Z INFO trojan_rust::proxy::tcp::handler] Connection finished [2023-03-07T06:02:18Z INFO trojan_rust::proxy::tcp::server] Connection from 127.0.0.1:53436 has finished [2023-03-07T06:02:27Z INFO trojan_rust::proxy::tcp::server] Received new connection from 127.0.0.1:53438 [2023-03-07T06:02:27Z INFO trojan_rust::proxy::tcp::server] Received new connection from 127.0.0.1:53440 [2023-03-07T06:02:28Z INFO trojan_rust::proxy::tcp::handler] Connection finished [2023-03-07T06:02:28Z INFO trojan_rust::proxy::tcp::server] Connection from 127.0.0.1:53438 has finished [2023-03-07T06:02:28Z INFO trojan_rust::proxy::tcp::handler] Connection finished [2023-03-07T06:02:28Z INFO trojan_rust::proxy::tcp::server] Connection from 127.0.0.1:53440 has finished [2023-03-07T06:02:28Z INFO trojan_rust::proxy::tcp::server] Received new connection from 127.0.0.1:53442 [2023-03-07T06:02:28Z INFO trojan_rust::proxy::tcp::handler] Connection finished [2023-03-07T06:02:28Z INFO trojan_rust::proxy::tcp::server] Connection from 127.0.0.1:53442 has finished [2023-03-07T06:02:28Z INFO trojan_rust::proxy::tcp::server] Received new connection from 127.0.0.1:53444 [2023-03-07T06:02:29Z INFO trojan_rust::proxy::tcp::handler] Connection finished [2023-03-07T06:02:29Z INFO trojan_rust::proxy::tcp::server] Connection from 127.0.0.1:53444 has finished [2023-03-07T06:02:30Z INFO trojan_rust::proxy::tcp::server] Received new connection from 127.0.0.1:53446 [2023-03-07T06:02:30Z INFO trojan_rust::proxy::tcp::handler] Connection finished [2023-03-07T06:02:30Z INFO trojan_rust::proxy::tcp::server] Connection from 127.0.0.1:53446 has finished [2023-03-07T06:02:31Z INFO trojan_rust::proxy::tcp::server] Received new connection from 127.0.0.1:53448 [2023-03-07T06:02:31Z INFO trojan_rust::proxy::tcp::handler] Connection finished [2023-03-07T06:02:31Z INFO trojan_rust::proxy::tcp::server] Connection from 127.0.0.1:53448 has finished [2023-03-07T06:02:32Z INFO trojan_rust::proxy::tcp::server] Received new connection from 127.0.0.1:53450 [2023-03-07T06:02:32Z INFO trojan_rust::proxy::tcp::handler] Connection finished [2023-03-07T06:02:32Z INFO trojan_rust::proxy::tcp::server] Connection from 127.0.0.1:53450 has finished [2023-03-07T06:02:32Z INFO trojan_rust::proxy::tcp::server] Received new connection from 127.0.0.1:53452 [2023-03-07T06:02:33Z INFO trojan_rust::proxy::tcp::handler] Connection finished [2023-03-07T06:02:33Z INFO trojan_rust::proxy::tcp::server] Connection from 127.0.0.1:53452 has finished [2023-03-07T06:02:35Z INFO trojan_rust::proxy::tcp::server] Received new connection from 127.0.0.1:53454 [2023-03-07T06:02:35Z INFO trojan_rust::proxy::tcp::handler] Connection finished [2023-03-07T06:02:35Z INFO trojan_rust::proxy::tcp::server] Connection from 127.0.0.1:53454 has finished [2023-03-07T06:02:35Z INFO trojan_rust::proxy::tcp::server] Received new connection from 127.0.0.1:53456 [2023-03-07T06:02:36Z INFO trojan_rust::proxy::tcp::handler] Connection finished [2023-03-07T06:02:36Z INFO trojan_rust::proxy::tcp::server] Connection from 127.0.0.1:53456 has finished [2023-03-07T06:02:36Z INFO trojan_rust::proxy::tcp::server] Received new connection from 127.0.0.1:53458 [2023-03-07T06:02:37Z INFO trojan_rust::proxy::tcp::handler] Connection finished [2023-03-07T06:02:37Z INFO trojan_rust::proxy::tcp::server] Connection from 127.0.0.1:53458 has finished [2023-03-07T06:02:37Z INFO trojan_rust::proxy::tcp::server] Received new connection from 127.0.0.1:53460 [2023-03-07T06:02:38Z INFO trojan_rust::proxy::tcp::handler] Connection finished [2023-03-07T06:02:38Z INFO trojan_rust::proxy::tcp::server] Connection from 127.0.0.1:53460 has finished [2023-03-07T06:02:38Z INFO trojan_rust::proxy::tcp::server] Received new connection from 127.0.0.1:53462 [2023-03-07T06:02:39Z INFO trojan_rust::proxy::tcp::handler] Connection finished [2023-03-07T06:02:39Z INFO trojan_rust::proxy::tcp::server] Connection from 127.0.0.1:53462 has finished [2023-03-07T06:02:46Z INFO trojan_rust::proxy::tcp::server] Received new connection from 127.0.0.1:53464 [2023-03-07T06:02:47Z INFO trojan_rust::proxy::tcp::handler] Connection finished [2023-03-07T06:02:47Z INFO trojan_rust::proxy::tcp::server] Connection from 127.0.0.1:53464 has finished [2023-03-07T06:02:50Z INFO trojan_rust::proxy::tcp::server] Received new connection from 127.0.0.1:53466 [2023-03-07T06:02:50Z INFO trojan_rust::proxy::tcp::handler] Connection finished [2023-03-07T06:02:50Z INFO trojan_rust::proxy::tcp::server] Connection from 127.0.0.1:53466 has finished [2023-03-07T06:02:52Z INFO trojan_rust::proxy::tcp::server] Received new connection from 127.0.0.1:53468 [2023-03-07T06:02:52Z INFO trojan_rust::proxy::tcp::handler] Connection finished [2023-03-07T06:02:52Z INFO trojan_rust::proxy::tcp::server] Connection from 127.0.0.1:53468 has finished

ArcCal commented 1 year ago

彻底禁用doh也一样不行

cty123 commented 1 year ago

我本地测试了没有任何问题,这是我客户端配置的文件,你看看你的服务端有没有收到请求

{
    "inbound": {
        "protocol": "SOCKS",
        "address": "0.0.0.0",
        "port": 10808,
        "mode": "TCP"
    },
    "outbound": {
        "protocol": "TROJAN",
        "address": "127.0.0.1",
        "port": 8081,
        "secret": "123123",
        "mode": "TCP",
        "tls": {
            "host_name": "example.com",
            "allow_insecure": false
        }
    }
}
ArcCal commented 1 year ago

服务端日志如下: Mar 07 06:13:40 workstation[29822]: [2023-03-07 06:13:40] [ERROR] ip.ip.ip.ip:54977 SSL handshake failed: wrong version number Mar 07 06:13:40 workstation[29822]: [2023-03-07 06:13:40] [INFO] ip.ip.ip.ip:54977 disconnected, 0 bytes received, 0 bytes sent, lasted for 0 seconds Mar 07 06:13:41 workstation[29822]: [2023-03-07 06:13:41] [ERROR] ip.ip.ip.ip:54980 SSL handshake failed: wrong version number Mar 07 06:13:41 workstation[29822]: [2023-03-07 06:13:41] [INFO] ip.ip.ip.ip:54980 disconnected, 0 bytes received, 0 bytes sent, lasted for 0 seconds Mar 07 06:13:42 workstation[29822]: [2023-03-07 06:13:42] [ERROR] ip.ip.ip.ip:54985 SSL handshake failed: wrong version number Mar 07 06:13:42 workstation[29822]: [2023-03-07 06:13:42] [INFO] ip.ip.ip.ip:54985 disconnected, 0 bytes received, 0 bytes sent, lasted for 0 seconds Mar 07 06:13:42 workstation[29822]: [2023-03-07 06:13:42] [ERROR] ip.ip.ip.ip:54986 SSL handshake failed: wrong version number Mar 07 06:13:42 workstation[29822]: [2023-03-07 06:13:42] [INFO] ip.ip.ip.ip:54986 disconnected, 0 bytes received, 0 bytes sent, lasted for 0 seconds Mar 07 06:13:42 workstation[29822]: [2023-03-07 06:13:42] [ERROR] ip.ip.ip.ip:54984 SSL handshake failed: wrong version number Mar 07 06:13:42 workstation[29822]: [2023-03-07 06:13:42] [INFO] ip.ip.ip.ip:54984 disconnected, 0 bytes received, 0 bytes sent, lasted for 0 seconds

cty123 commented 1 year ago

应该是ssl版本号的问题,你服务端支持tls1.3吗?你用的是什么代理来处理tls?

ArcCal commented 1 year ago

服务端使用的是原版的trojan-gfw,并且指定了只能使用tls 1.3的cihper suite,不知道是不是这个原因导致上述报错

"cipher": "TLS_AES_128_GCM_SHA256:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_256_GCM_SHA384", "prefer_server_cipher": true,

ArcCal commented 1 year ago

服务端使用的是原版的trojan-gfw,并且指定了只能使用tls 1.3的cihper suite,不知道是不是这个原因导致上述报错

"cipher": "TLS_AES_128_GCM_SHA256:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_256_GCM_SHA384", "prefer_server_cipher": true,

服务端删掉相关字段,一模一样的报错,提示ssl版本错误

cty123 commented 1 year ago

你这个server可能不支持tls1.3,默认的话rustls只支持tls1.3, 如果要打开1.2的话,你要去项目目录下的Cargo.toml, 然后把

rustls = { version = "0.20", features = ["dangerous_configuration"] }

改成

rustls = { version = "0.20", features = ["dangerous_configuration", "tls12"] }
cty123 commented 1 year ago

然后你重新编译一下试试,代码我就不提交了,自搭vps其实没必要用tls12

cty123 commented 1 year ago

这个地方 https://github.com/cty123/TrojanRust/blob/main/Cargo.toml#L18

ArcCal commented 1 year ago

好的 谢谢大佬