update sni handler

This commit is contained in:
ginuerzh
2022-04-14 14:53:13 +08:00
parent 7a334c173c
commit dca2a79c54
4 changed files with 102 additions and 84 deletions

View File

@ -84,7 +84,7 @@ func (h *httpHandler) Handle(ctx context.Context, conn net.Conn, opts ...handler
}
func (h *httpHandler) handleRequest(ctx context.Context, conn net.Conn, req *http.Request, log logger.Logger) error {
if h.md.sni && !req.URL.IsAbs() && govalidator.IsDNSName(req.Host) {
if !req.URL.IsAbs() && govalidator.IsDNSName(req.Host) {
req.URL.Scheme = "http"
}

View File

@ -10,7 +10,6 @@ import (
type metadata struct {
probeResistance *probeResistance
sni bool
enableUDP bool
header http.Header
}
@ -20,7 +19,6 @@ func (h *httpHandler) parseMetadata(md mdata.Metadata) error {
header = "header"
probeResistKey = "probeResistance"
knock = "knock"
sni = "sni"
enableUDP = "udp"
)
@ -41,7 +39,6 @@ func (h *httpHandler) parseMetadata(md mdata.Metadata) error {
}
}
}
h.md.sni = mdx.GetBool(md, sni)
h.md.enableUDP = mdx.GetBool(md, enableUDP)
return nil