update forward handler

This commit is contained in:
ginuerzh
2023-10-16 23:16:47 +08:00
parent 5ab729b166
commit 5dfbb59f8a
17 changed files with 253 additions and 174 deletions

View File

@ -38,6 +38,10 @@ func Sniffing(ctx context.Context, rdw io.ReadWriter) (rw io.ReadWriter, host st
if err == nil {
host = r.Host
protocol = ProtoHTTP
if r.Header.Get("Upgrade") == "websocket" {
protocol = ProtoWebsocket
}
return
}
}
@ -89,9 +93,10 @@ func isHTTP(s string) bool {
}
const (
ProtoHTTP = "http"
ProtoTLS = "tls"
ProtoSSHv2 = "SSH-2"
ProtoHTTP = "http"
ProtoWebsocket = "ws"
ProtoTLS = "tls"
ProtoSSHv2 = "SSH-2"
)
func sniffProtocol(hdr []byte) string {