2019-12-08 12:17:24 +08:00
|
|
|
package inbound
|
2018-07-26 00:04:59 +08:00
|
|
|
|
|
|
|
import (
|
2018-08-11 22:51:30 +08:00
|
|
|
"net"
|
2018-07-26 00:04:59 +08:00
|
|
|
|
2023-11-03 21:01:45 +08:00
|
|
|
C "github.com/metacubex/mihomo/constant"
|
|
|
|
"github.com/metacubex/mihomo/transport/socks5"
|
2018-07-26 00:04:59 +08:00
|
|
|
)
|
|
|
|
|
2021-04-29 11:23:14 +08:00
|
|
|
// NewHTTP receive normal http request and return HTTPContext
|
2023-10-23 16:45:22 +08:00
|
|
|
func NewHTTP(target socks5.Addr, srcConn net.Conn, conn net.Conn, additions ...Addition) (net.Conn, *C.Metadata) {
|
2021-09-13 23:46:39 +08:00
|
|
|
metadata := parseSocksAddr(target)
|
2021-06-15 17:13:40 +08:00
|
|
|
metadata.NetWork = C.TCP
|
2019-10-27 21:44:07 +08:00
|
|
|
metadata.Type = C.HTTP
|
2023-11-17 01:19:20 +08:00
|
|
|
metadata.RawSrcAddr = srcConn.RemoteAddr()
|
|
|
|
metadata.RawDstAddr = srcConn.LocalAddr()
|
2024-04-04 21:25:27 +08:00
|
|
|
ApplyAdditions(metadata, WithSrcAddr(srcConn.RemoteAddr()), WithInAddr(srcConn.LocalAddr()))
|
2023-10-11 22:54:19 +08:00
|
|
|
ApplyAdditions(metadata, additions...)
|
2023-10-11 10:55:12 +08:00
|
|
|
return conn, metadata
|
2021-03-10 16:23:19 +08:00
|
|
|
}
|