Fix route-level network strategy ignoring outbound restrictions

This commit is contained in:
世界
2026-11-25 21:25:46 +08:00
parent ce2448e1a9
commit 59069b3373
10 changed files with 40 additions and 82 deletions
+3 -3
View File
@@ -245,7 +245,7 @@ func (h *Outbound) WritePackets(packets [][]byte) error {
}
func (h *Outbound) DialParallel(ctx context.Context, network string, destination M.Socksaddr, destinationAddresses []netip.Addr) (net.Conn, error) {
if h.isMyLoopbackAddress(destinationAddresses...) {
if h.isMyLoopbackAddress(destinationAddresses...) || destination.IsIP() && h.isMyLoopbackAddress(destination.Addr) {
return nil, E.New("loopback connection to TUN range")
}
ctx, metadata := adapter.ExtendContext(ctx)
@@ -262,7 +262,7 @@ func (h *Outbound) DialParallel(ctx context.Context, network string, destination
}
func (h *Outbound) DialParallelNetwork(ctx context.Context, network string, destination M.Socksaddr, destinationAddresses []netip.Addr, networkStrategy *C.NetworkStrategy, networkType []C.InterfaceType, fallbackNetworkType []C.InterfaceType, fallbackDelay time.Duration) (net.Conn, error) {
if h.isMyLoopbackAddress(destinationAddresses...) {
if h.isMyLoopbackAddress(destinationAddresses...) || destination.IsIP() && h.isMyLoopbackAddress(destination.Addr) {
return nil, E.New("loopback connection to TUN range")
}
ctx, metadata := adapter.ExtendContext(ctx)
@@ -279,7 +279,7 @@ func (h *Outbound) DialParallelNetwork(ctx context.Context, network string, dest
}
func (h *Outbound) ListenSerialNetworkPacket(ctx context.Context, destination M.Socksaddr, destinationAddresses []netip.Addr, networkStrategy *C.NetworkStrategy, networkType []C.InterfaceType, fallbackNetworkType []C.InterfaceType, fallbackDelay time.Duration) (net.PacketConn, netip.Addr, error) {
if h.isMyLoopbackAddress(destinationAddresses...) {
if h.isMyLoopbackAddress(destinationAddresses...) || destination.IsIP() && h.isMyLoopbackAddress(destination.Addr) {
return nil, netip.Addr{}, E.New("loopback connection to TUN range")
}
ctx, metadata := adapter.ExtendContext(ctx)