github.com/igoogolx/clash@v1.19.8/adapter/inbound/https.go (about) 1 package inbound 2 3 import ( 4 "net" 5 "net/http" 6 "net/netip" 7 8 C "github.com/igoogolx/clash/constant" 9 "github.com/igoogolx/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 addrPort, err := netip.ParseAddrPort(conn.LocalAddr().String()); err == nil { 21 metadata.OriginDst = addrPort 22 } 23 return context.NewConnContext(conn, metadata) 24 }