connect Target修复
This commit is contained in:
parent
6d72721cab
commit
9f45590246
10
http.go
10
http.go
@ -52,6 +52,7 @@ func (c *httpConnector) ConnectContext(ctx context.Context, conn net.Conn, netwo
|
||||
ua = DefaultUserAgent
|
||||
}
|
||||
|
||||
origAddress := address
|
||||
if opts.Host != "" {
|
||||
address = opts.Host
|
||||
}
|
||||
@ -70,6 +71,10 @@ func (c *httpConnector) ConnectContext(ctx context.Context, conn net.Conn, netwo
|
||||
req.Header.Set("User-Agent", ua)
|
||||
req.Header.Set("Proxy-Connection", "keep-alive")
|
||||
|
||||
if origAddress != address {
|
||||
req.Header.Set("Target", origAddress)
|
||||
}
|
||||
|
||||
user := opts.User
|
||||
if user == nil {
|
||||
user = c.User
|
||||
@ -163,6 +168,10 @@ func (h *httpHandler) handleRequest(conn net.Conn, req *http.Request) {
|
||||
}
|
||||
|
||||
host := req.Host
|
||||
actualTarget := req.Header.Get("Target")
|
||||
if actualTarget != "" {
|
||||
host = actualTarget
|
||||
}
|
||||
if _, port, _ := net.SplitHostPort(host); port == "" {
|
||||
host = net.JoinHostPort(host, "80")
|
||||
}
|
||||
@ -180,6 +189,7 @@ func (h *httpHandler) handleRequest(conn net.Conn, req *http.Request) {
|
||||
}
|
||||
|
||||
req.Header.Del("Gost-Target")
|
||||
req.Header.Del("Target")
|
||||
|
||||
resp := &http.Response{
|
||||
ProtoMajor: 1,
|
||||
|
Loading…
Reference in New Issue
Block a user