mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 19:56:51 +08:00
20 lines
384 B
Go
20 lines
384 B
Go
package adapters
|
|
|
|
import (
|
|
"net"
|
|
"net/http"
|
|
)
|
|
|
|
// NewHTTPS is HTTPAdapter generator
|
|
func NewHTTPS(request *http.Request, conn net.Conn) *SocketAdapter {
|
|
metadata := parseHTTPAddr(request)
|
|
if ip, port, err := parseAddr(conn.RemoteAddr().String()); err == nil {
|
|
metadata.SrcIP = ip
|
|
metadata.SrcPort = port
|
|
}
|
|
return &SocketAdapter{
|
|
metadata: metadata,
|
|
Conn: conn,
|
|
}
|
|
}
|