Skip to content

Commit 0d785fd

Browse files
committed
update docs, default alpn settings
1 parent 2fef3a7 commit 0d785fd

File tree

9 files changed

+25
-18
lines changed

9 files changed

+25
-18
lines changed

build/base.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,5 @@ import (
55
_ "github.com/p4gefau1t/trojan-go/common"
66
_ "github.com/p4gefau1t/trojan-go/log"
77
_ "github.com/p4gefau1t/trojan-go/log/golog"
8-
_ "github.com/p4gefau1t/trojan-go/version"
98
//_ "github.com/p4gefau1t/trojan-go/log/simplelog" //for android
109
)

build/other.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ package build
55
import (
66
_ "github.com/p4gefau1t/trojan-go/daemon"
77
_ "github.com/p4gefau1t/trojan-go/easy"
8+
_ "github.com/p4gefau1t/trojan-go/version"
89
)

cert/cert.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func (u *User) GetPrivateKey() crypto.PrivateKey {
4646
func createAndSaveUserKey() (*ecdsa.PrivateKey, error) {
4747
_, err := os.Stat("user.key")
4848
if os.IsExist(err) {
49-
return nil, common.NewError("User.key exists, cannot create new user")
49+
return nil, common.NewError("user.key exists, unable to create new user")
5050
}
5151
userKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
5252
common.Must(err)

common/net.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func (a *Address) Marshal(r io.Reader) error {
8787
byteBuf := [1]byte{}
8888
_, err := r.Read(byteBuf[:])
8989
if err != nil {
90-
return NewError("Cannot read atype").Base(err)
90+
return NewError("Unable to read atype").Base(err)
9191
}
9292
a.AddressType = AddressType(byteBuf[0])
9393
switch a.AddressType {

conf/parse.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,11 @@ func ParseJSON(data []byte) (*GlobalConfig, error) {
360360
VerifyHostname: true,
361361
SessionTicket: true,
362362
ReuseSession: true,
363-
Fingerprint: "firefox",
363+
ALPN: []string{
364+
"h2",
365+
"http/1.1",
366+
},
367+
Fingerprint: "firefox",
364368
},
365369
Mux: MuxConfig{
366370
IdleTimeout: 60,

docs/content/basic/full-config.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ weight: 30
4545
"curves": "",
4646
"prefer_server_cipher": false,
4747
"sni": "",
48-
"alpn": [],
48+
"alpn": [
49+
"h2",
50+
"http/1.1"
51+
],
4952
"session_ticket": true,
5053
"reuse_session": true,
5154
"plain_http_response": "",
@@ -165,11 +168,11 @@ weight: 30
165168

166169
```sni```指的是证书的Common Name,如果你使用letsencrypt等机构签名的证书,这里填入你的域名。如果这一项未填,将使用```remote_addr```填充。你应当指定一个有效的SNI(和远端证书CN一致),否则客户端可能无法验证远端证书有效性从而无法连接。
167170

168-
```alpn```为TLS的应用层协议协商指定协议。在TLS Client/Server Hello中传输,协商应用层使用的协议,仅用作指纹伪造,并无实际作用。**如果使用了CDN,错误的alpn字段可能导致与CDN握手失败**
171+
```alpn```为TLS的应用层协议协商指定协议。在TLS Client/Server Hello中传输,协商应用层使用的协议,仅用作指纹伪造,并无实际作用。**如果使用了CDN,错误的alpn字段可能导致与CDN协商错误的应用层协议**
169172

170173
```prefer_server_cipher```客户端是否偏好选择服务端在协商中提供的密码学套件。
171174

172-
```cipher``````cipher13```指TLS使用的密码学套件。只有在你明确知道自己在做什么的情况下,才应该去填写此项以修改trojan-go使用的TLS密码学套件。**正常情况下,你应该将其留空或者不填**,trojan-go会根据当前硬件平台以及远端的情况,自动选择最合适的加密算法以提升性能和安全性。如果需要填写,密码学套件名用分号(":")分隔。Go的TLS库中弃用了TLS1.2中不安全的密码学套件,并完全支持TLS1.3。默认情况下,trojan-go将优先使用更安全的TLS1.3
175+
```cipher``````cipher13```指TLS使用的密码学套件。只有在你明确知道自己在做什么的情况下,才应该去填写此项以修改trojan-go使用的TLS密码学套件。**正常情况下,你应该将其留空或者不填**,trojan-go会根据当前硬件平台以及远端的情况,自动选择最合适的加密算法以提升性能和安全性。如果需要填写,密码学套件名用分号(":")分隔。Go的TLS库中弃用了TLS1.2中不安全的密码学套件,并完全支持TLS1.3。默认情况下,trojan-go将优先使用更安全的TLS1.3
173176

174177
```curves```指定TLS在ECDHE中偏好使用的椭圆曲线。只有你明确知道自己在做什么的情况下,才应该填写此项。曲线名称用分号(":")分隔。
175178

@@ -191,7 +194,7 @@ weight: 30
191194

192195
```fallback_port```指TLS握手失败时,trojan-go将该连接代理到该端口上。这是trojan-go的特性,以便更好地隐蔽Trojan服务器,抵抗GFW的主动检测,使得服务器的443端口在遭遇非TLS协议的探测时,行为与正常服务器完全一致。当服务器接受了一个连接但无法进行TLS握手时,如果```fallback_port```不为空,则流量将会被代理至remote_addr:fallback_port。例如,你可以在本地使用nginx开启一个https服务,当你的服务器443端口被非TLS协议请求时(比如http请求),trojan-go将代理至本地https服务器,nginx将使用http协议明文返回一个400 Bad Request页面。你可以通过使用浏览器访问```http://your_domain_name.com:443```进行验证。
193196

194-
```serve_plain_text```服务端直接是否直接接受TCP连接并处理明文。此选项的意义在于支持nginx等Web服务器的分流。
197+
```serve_plain_text```服务端直接是否直接接受TCP连接并处理trojan协议明文。开启此选项后,```ssl```的其他选项将失效,trojan-go将直接处理连入的TCP连接而不使用TLS。此选项的意义在于支持nginx等Web服务器的分流。如果开启,请不要将trojan-go服务对外暴露
195198

196199
### ```mux```多路复用选项
197200

docs/content/developer/api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ draft: false
44
weight: 100
55
---
66

7-
Trojan-Go基于grpc实现了API,使用protobuf交换数据。客户端可获取流量和速度信息;服务端可获取各用户流量,速度,在线情况,并动态增删用户和限制速度。可以通过在配置文件中添加```api```选项激活API模块。下面是一个例子
7+
Trojan-Go基于gRPC实现了API,使用protobuf交换数据。客户端可获取流量和速度信息;服务端可获取各用户流量,速度,在线情况,并动态增删用户和限制速度。可以通过在配置文件中添加```api```选项激活API模块。下面是一个例子
88

99
```json
1010
"api": {
@@ -14,4 +14,4 @@ Trojan-Go基于grpc实现了API,使用protobuf交换数据。客户端可获
1414
}
1515
```
1616

17-
目前API处于开发阶段,服务和rpc定义可以参考api文件夹下api.proto文件。
17+
目前API处于开发阶段,服务和RPC定义可以参考api文件夹下api.proto文件。

protocol/direct/outbound.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ func (o *DirectOutboundPacketSession) WritePacket(req *protocol.Request, packet
207207
}
208208
conn, err := net.DialUDP("udp", nil, remote)
209209
if err != nil {
210-
return 0, common.NewError("cannot dial udp").Base(err)
210+
return 0, common.NewError("Failed to dial udp").Base(err)
211211
}
212212
log.Debug("udp directly dialing to", remote)
213213
go o.listenConn(req, conn)

proxy/server/server.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,6 @@ func (s *Server) ListenTCP(errChan chan error) {
131131
return
132132
}
133133

134-
tlsConfig := &tls.Config{
135-
Certificates: s.config.TLS.KeyPair,
136-
CipherSuites: s.config.TLS.CipherSuites,
137-
PreferServerCipherSuites: s.config.TLS.PreferServerCipher,
138-
SessionTicketsDisabled: !s.config.TLS.SessionTicket,
139-
NextProtos: s.config.TLS.ALPN,
140-
}
141134
for {
142135
conn, err := listener.Accept()
143136
if err != nil {
@@ -161,6 +154,13 @@ func (s *Server) ListenTCP(errChan chan error) {
161154
rewindConn := common.NewRewindConn(conn)
162155
rewindConn.R.SetBufferSize(2048)
163156

157+
tlsConfig := &tls.Config{
158+
Certificates: s.config.TLS.KeyPair,
159+
CipherSuites: s.config.TLS.CipherSuites,
160+
PreferServerCipherSuites: s.config.TLS.PreferServerCipher,
161+
SessionTicketsDisabled: !s.config.TLS.SessionTicket,
162+
NextProtos: s.config.TLS.ALPN,
163+
}
164164
tlsConn := tls.Server(rewindConn, tlsConfig)
165165
err = tlsConn.Handshake()
166166
rewindConn.R.StopBuffering()

0 commit comments

Comments
 (0)