mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-07-08 12:48:58 +00:00
TUN inbound: autoOutboundsInterface bypasses loopback addresses (#6276)
Fixes https://github.com/XTLS/Xray-core/issues/6269
This commit is contained in:
@@ -2,6 +2,8 @@ package tun
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"net/netip"
|
||||||
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/xtls/xray-core/common"
|
"github.com/xtls/xray-core/common"
|
||||||
@@ -85,6 +87,11 @@ func (t *Handler) Start() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return c.Control(func(fd uintptr) {
|
return c.Control(func(fd uintptr) {
|
||||||
|
addrPort, _ := netip.ParseAddrPort(address)
|
||||||
|
// skip loopback
|
||||||
|
if addrPort.Addr().IsLoopback() || strings.HasPrefix(strings.ToLower(address), "localhost:") {
|
||||||
|
return
|
||||||
|
}
|
||||||
err := setinterface(network, address, fd, iface)
|
err := setinterface(network, address, fd, iface)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errors.LogInfoInner(context.Background(), err, "[tun] falied to set interface")
|
errors.LogInfoInner(context.Background(), err, "[tun] falied to set interface")
|
||||||
|
|||||||
Reference in New Issue
Block a user