support wss between frpc and frps (#3503)

This commit is contained in:
fatedier
2023-06-29 11:20:45 +08:00
committed by GitHub
parent b146989703
commit 801e8c6742
10 changed files with 116 additions and 42 deletions

View File

@@ -21,9 +21,15 @@ func DialHookCustomTLSHeadByte(enableTLS bool, disableCustomTLSHeadByte bool) li
}
}
func DialHookWebsocket() libdial.AfterHookFunc {
func DialHookWebsocket(protocol string, host string) libdial.AfterHookFunc {
return func(ctx context.Context, c net.Conn, addr string) (context.Context, net.Conn, error) {
addr = "ws://" + addr + FrpWebsocketPath
if protocol != "wss" {
protocol = "ws"
}
if host == "" {
host = addr
}
addr = protocol + "://" + host + FrpWebsocketPath
uri, err := url.Parse(addr)
if err != nil {
return nil, nil, err