Refactor: refactor find process (#2781)
This commit is contained in:
@@ -12,7 +12,7 @@ import (
|
||||
"github.com/Dreamacro/clash/transport/socks5"
|
||||
)
|
||||
|
||||
func newClient(source net.Addr, in chan<- C.ConnContext) *http.Client {
|
||||
func newClient(source net.Addr, originTarget net.Addr, in chan<- C.ConnContext) *http.Client {
|
||||
return &http.Client{
|
||||
Transport: &http.Transport{
|
||||
// from http.DefaultTransport
|
||||
@@ -32,7 +32,7 @@ func newClient(source net.Addr, in chan<- C.ConnContext) *http.Client {
|
||||
|
||||
left, right := net.Pipe()
|
||||
|
||||
in <- inbound.NewHTTP(dstAddr, source, right)
|
||||
in <- inbound.NewHTTP(dstAddr, source, originTarget, right)
|
||||
|
||||
return left, nil
|
||||
},
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
)
|
||||
|
||||
func HandleConn(c net.Conn, in chan<- C.ConnContext, cache *cache.LruCache) {
|
||||
client := newClient(c.RemoteAddr(), in)
|
||||
client := newClient(c.RemoteAddr(), c.LocalAddr(), in)
|
||||
defer client.CloseIdleConnections()
|
||||
|
||||
conn := N.NewBufferedConn(c)
|
||||
|
||||
@@ -41,7 +41,7 @@ func handleUpgrade(conn net.Conn, request *http.Request, in chan<- C.ConnContext
|
||||
|
||||
left, right := net.Pipe()
|
||||
|
||||
in <- inbound.NewHTTP(dstAddr, conn.RemoteAddr(), right)
|
||||
in <- inbound.NewHTTP(dstAddr, conn.RemoteAddr(), conn.LocalAddr(), right)
|
||||
|
||||
bufferedLeft := N.NewBufferedConn(left)
|
||||
defer bufferedLeft.Close()
|
||||
|
||||
@@ -79,7 +79,7 @@ func handleSocksUDP(pc net.PacketConn, in chan<- *inbound.PacketAdapter, buf []b
|
||||
bufRef: buf,
|
||||
}
|
||||
select {
|
||||
case in <- inbound.NewPacket(target, packet, C.SOCKS5):
|
||||
case in <- inbound.NewPacket(target, pc.LocalAddr(), packet, C.SOCKS5):
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ func handlePacketConn(in chan<- *inbound.PacketAdapter, buf []byte, lAddr, rAddr
|
||||
buf: buf,
|
||||
}
|
||||
select {
|
||||
case in <- inbound.NewPacket(target, pkt, C.TPROXY):
|
||||
case in <- inbound.NewPacket(target, target.UDPAddr(), pkt, C.TPROXY):
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ func (l *PacketConn) handleUDP(pc net.PacketConn, in chan<- *inbound.PacketAdapt
|
||||
payload: buf,
|
||||
}
|
||||
|
||||
ctx := inbound.NewPacket(l.target, packet, C.TUNNEL)
|
||||
ctx := inbound.NewPacket(l.target, pc.LocalAddr(), packet, C.TUNNEL)
|
||||
ctx.Metadata().SpecialProxy = l.proxy
|
||||
select {
|
||||
case in <- ctx:
|
||||
|
||||
Reference in New Issue
Block a user