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