github.com/yaling888/clash@v1.53.0/adapter/inbound/http.go (about) 1 package inbound 2 3 import ( 4 "net" 5 "net/netip" 6 7 C "github.com/yaling888/clash/constant" 8 "github.com/yaling888/clash/context" 9 "github.com/yaling888/clash/transport/socks5" 10 ) 11 12 // NewHTTP receive normal http request and return HTTPContext 13 func NewHTTP(target socks5.Addr, source net.Addr, originTarget net.Addr, conn net.Conn) *context.ConnContext { 14 metadata := parseSocksAddr(target) 15 metadata.NetWork = C.TCP 16 metadata.Type = C.HTTP 17 if ip, port, err := parseAddr(source); err == nil { 18 metadata.SrcIP = ip 19 metadata.SrcPort = C.Port(port) 20 } 21 if ip, port, err := parseAddr(originTarget); err == nil { 22 metadata.OriginDst = netip.AddrPortFrom(ip, uint16(port)) 23 } 24 return context.NewConnContext(conn, metadata) 25 }