mihomo/adapters/inbound/https.go

20 lines
384 B
Go
Raw Normal View History

2018-08-27 00:06:40 +08:00
package adapters
import (
"net"
"net/http"
)
// NewHTTPS is HTTPAdapter generator
func NewHTTPS(request *http.Request, conn net.Conn) *SocketAdapter {
metadata := parseHTTPAddr(request)
2019-05-09 21:00:29 +08:00
if ip, port, err := parseAddr(conn.RemoteAddr().String()); err == nil {
metadata.SrcIP = ip
metadata.SrcPort = port
}
2018-08-27 00:06:40 +08:00
return &SocketAdapter{
metadata: metadata,
2019-04-23 23:29:36 +08:00
Conn: conn,
2018-08-27 00:06:40 +08:00
}
}