mihomo/adapter/inbound/https.go

21 lines
556 B
Go
Raw Normal View History

2019-12-08 12:17:24 +08:00
package inbound
2018-08-27 00:06:40 +08:00
import (
"net"
"net/http"
C "github.com/Dreamacro/clash/constant"
"github.com/Dreamacro/clash/context"
2018-08-27 00:06:40 +08:00
)
2021-04-29 11:23:14 +08:00
// NewHTTPS receive CONNECT request and return ConnContext
func NewHTTPS(request *http.Request, conn net.Conn, additions ...Addition) *context.ConnContext {
metadata := parseHTTPAddr(request)
metadata.Type = C.HTTPS
2023-10-10 19:43:26 +08:00
additions = append(additions, WithSrcAddr(conn.RemoteAddr()), WithInAddr(conn.LocalAddr()))
for _, addition := range additions {
addition.Apply(metadata)
}
return context.NewConnContext(conn, metadata)
2018-08-27 00:06:40 +08:00
}