clash/adapter/inbound/http.go

19 lines
529 B
Go
Raw Normal View History

2019-12-08 04:17:24 +00:00
package inbound
import (
2018-08-11 14:51:30 +00:00
"net"
C "github.com/Dreamacro/clash/constant"
2021-06-15 09:13:40 +00:00
"github.com/Dreamacro/clash/transport/socks5"
)
2021-04-29 03:23:14 +00:00
// NewHTTP receive normal http request and return HTTPContext
2023-10-11 02:55:12 +00:00
func NewHTTP(target socks5.Addr, source net.Addr, conn net.Conn, additions ...Addition) (net.Conn, *C.Metadata) {
metadata := parseSocksAddr(target)
2021-06-15 09:13:40 +00:00
metadata.NetWork = C.TCP
metadata.Type = C.HTTP
2023-10-11 14:54:19 +00:00
ApplyAdditions(metadata, WithSrcAddr(source), WithInAddr(conn.LocalAddr()))
ApplyAdditions(metadata, additions...)
2023-10-11 02:55:12 +00:00
return conn, metadata
2021-03-10 08:23:19 +00:00
}