Clash.Meta/adapter/inbound/http.go

21 lines
562 B
Go
Raw Normal View History

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