2019-12-08 04:17:24 +00:00
|
|
|
package inbound
|
2018-07-25 16:04:59 +00:00
|
|
|
|
|
|
|
import (
|
2018-08-11 14:51:30 +00:00
|
|
|
"net"
|
2018-07-25 16:04:59 +00:00
|
|
|
|
|
|
|
C "github.com/Dreamacro/clash/constant"
|
2021-01-23 06:49:46 +00:00
|
|
|
"github.com/Dreamacro/clash/context"
|
2021-06-15 09:13:40 +00:00
|
|
|
"github.com/Dreamacro/clash/transport/socks5"
|
2018-07-25 16:04:59 +00:00
|
|
|
)
|
|
|
|
|
2021-04-29 03:23:14 +00:00
|
|
|
// NewHTTP receive normal http request and return HTTPContext
|
2021-09-13 15:46:39 +00:00
|
|
|
func NewHTTP(target socks5.Addr, source net.Addr, conn net.Conn) *context.ConnContext {
|
|
|
|
metadata := parseSocksAddr(target)
|
2021-06-15 09:13:40 +00:00
|
|
|
metadata.NetWork = C.TCP
|
2019-10-27 13:44:07 +00:00
|
|
|
metadata.Type = C.HTTP
|
2021-06-15 09:13:40 +00:00
|
|
|
if ip, port, err := parseAddr(source.String()); err == nil {
|
2019-05-09 13:00:29 +00:00
|
|
|
metadata.SrcIP = ip
|
|
|
|
metadata.SrcPort = port
|
|
|
|
}
|
2021-06-15 09:13:40 +00:00
|
|
|
return context.NewConnContext(conn, metadata)
|
2021-03-10 08:23:19 +00:00
|
|
|
}
|