Skip to content

Commit

Permalink
fix: Trojan websocket header panic
Browse files Browse the repository at this point in the history
  • Loading branch information
H1JK authored and Larvan2 committed Nov 20, 2023
1 parent b9d48f4 commit bb9ad6c
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions adapter/outbound/trojan.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,17 @@ func (t *Trojan) plainStream(ctx context.Context, c net.Conn) (net.Conn, error)
Port: port,
Path: t.option.WSOpts.Path,
V2rayHttpUpgrade: t.option.WSOpts.V2rayHttpUpgrade,
Headers: http.Header{},
}

if t.option.SNI != "" {
wsOpts.Host = t.option.SNI
}

if len(t.option.WSOpts.Headers) != 0 {
header := http.Header{}
for key, value := range t.option.WSOpts.Headers {
header.Add(key, value)
wsOpts.Headers.Add(key, value)
}
wsOpts.Headers = header
}

return t.instance.StreamWebsocketConn(ctx, c, wsOpts)
Expand Down

0 comments on commit bb9ad6c

Please sign in to comment.