github.com/yaling888/clash@v1.53.0/adapter/inbound/https.go (about) 1 package inbound 2 3 import ( 4 "net" 5 "net/http" 6 "net/netip" 7 8 C "github.com/yaling888/clash/constant" 9 "github.com/yaling888/clash/context" 10 ) 11 12 // NewHTTPS receive CONNECT request and return ConnContext 13 func NewHTTPS(request *http.Request, conn net.Conn) *context.ConnContext { 14 metadata := parseHTTPAddr(request) 15 metadata.Type = C.HTTPCONNECT 16 if ip, port, err := parseAddr(conn.RemoteAddr()); err == nil { 17 metadata.SrcIP = ip 18 metadata.SrcPort = C.Port(port) 19 } 20 if ip, port, err := parseAddr(conn.LocalAddr()); err == nil { 21 metadata.OriginDst = netip.AddrPortFrom(ip, uint16(port)) 22 } 23 return context.NewConnContext(conn, metadata) 24 }