github.com/chwjbn/xclash@v0.2.0/adapter/inbound/https.go (about)

     1  package inbound
     2  
     3  import (
     4  	"net"
     5  	"net/http"
     6  
     7  	C "github.com/chwjbn/xclash/constant"
     8  	"github.com/chwjbn/xclash/context"
     9  )
    10  
    11  // NewHTTPS receive CONNECT request and return ConnContext
    12  func NewHTTPS(request *http.Request, conn net.Conn) *context.ConnContext {
    13  	metadata := parseHTTPAddr(request)
    14  	metadata.Type = C.HTTPCONNECT
    15  	if ip, port, err := parseAddr(conn.RemoteAddr().String()); err == nil {
    16  		metadata.SrcIP = ip
    17  		metadata.SrcPort = port
    18  	}
    19  	return context.NewConnContext(conn, metadata)
    20  }