Feature: support trojan websocket

This commit is contained in:
Dreamacro
2021-10-16 20:19:59 +08:00
parent 68753b4ae1
commit df3a491d40
8 changed files with 154 additions and 23 deletions

View File

@ -45,8 +45,7 @@ type WebsocketConfig struct {
Path string
Headers http.Header
TLS bool
SkipCertVerify bool
ServerName string
TLSConfig *tls.Config
MaxEarlyData int
EarlyDataHeaderName string
}
@ -254,17 +253,7 @@ func streamWebsocketConn(conn net.Conn, c *WebsocketConfig, earlyData *bytes.Buf
scheme := "ws"
if c.TLS {
scheme = "wss"
dialer.TLSClientConfig = &tls.Config{
ServerName: c.Host,
InsecureSkipVerify: c.SkipCertVerify,
NextProtos: []string{"http/1.1"},
}
if c.ServerName != "" {
dialer.TLSClientConfig.ServerName = c.ServerName
} else if host := c.Headers.Get("Host"); host != "" {
dialer.TLSClientConfig.ServerName = host
}
dialer.TLSClientConfig = c.TLSConfig
}
uri := url.URL{