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