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
|
|
|
)
|
|
|
|
|
|
|
|
// NewHTTPS is HTTPAdapter generator
|
|
|
|
func NewHTTPS(request *http.Request, conn net.Conn) *SocketAdapter {
|
2019-02-02 21:03:13 +08:00
|
|
|
metadata := parseHTTPAddr(request)
|
2019-10-27 21:44:07 +08:00
|
|
|
metadata.Type = C.HTTPCONNECT
|
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{
|
2019-02-02 21:03:13 +08:00
|
|
|
metadata: metadata,
|
2019-04-23 23:29:36 +08:00
|
|
|
Conn: conn,
|
2018-08-27 00:06:40 +08:00
|
|
|
}
|
|
|
|
}
|