clash/adapter/inbound/https.go

21 lines
502 B
Go
Raw Normal View History

2019-12-08 04:17:24 +00:00
package inbound
2018-08-26 16:06:40 +00:00
import (
"net"
"net/http"
C "github.com/Dreamacro/clash/constant"
"github.com/Dreamacro/clash/context"
2018-08-26 16:06:40 +00:00
)
2021-04-29 03:23:14 +00:00
// NewHTTPS receive CONNECT request and return ConnContext
func NewHTTPS(request *http.Request, conn net.Conn) *context.ConnContext {
metadata := parseHTTPAddr(request)
metadata.Type = C.HTTPCONNECT
2019-05-09 13:00:29 +00:00
if ip, port, err := parseAddr(conn.RemoteAddr().String()); err == nil {
metadata.SrcIP = ip
metadata.SrcPort = port
}
return context.NewConnContext(conn, metadata)
2018-08-26 16:06:40 +00:00
}