Set search domain for systemd-resolved
This commit is contained in:
parent
980d4bf9a3
commit
8848c0e4cb
1 changed files with 12 additions and 0 deletions
12
tun_linux.go
12
tun_linux.go
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"net/netip"
|
"net/netip"
|
||||||
"os"
|
"os"
|
||||||
|
"os/exec"
|
||||||
"runtime"
|
"runtime"
|
||||||
"syscall"
|
"syscall"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
@ -13,6 +14,7 @@ import (
|
||||||
"github.com/sagernet/sing/common"
|
"github.com/sagernet/sing/common"
|
||||||
E "github.com/sagernet/sing/common/exceptions"
|
E "github.com/sagernet/sing/common/exceptions"
|
||||||
"github.com/sagernet/sing/common/rw"
|
"github.com/sagernet/sing/common/rw"
|
||||||
|
"github.com/sagernet/sing/common/shell"
|
||||||
"github.com/sagernet/sing/common/x/list"
|
"github.com/sagernet/sing/common/x/list"
|
||||||
|
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
|
|
@ -165,6 +167,8 @@ func (t *NativeTun) configure(tunLink netlink.Link) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setSearchDomainForSystemdResolved(t.options.Name)
|
||||||
|
|
||||||
if t.options.AutoRoute && runtime.GOOS == "android" {
|
if t.options.AutoRoute && runtime.GOOS == "android" {
|
||||||
t.interfaceCallback = t.options.InterfaceMonitor.RegisterCallback(t.routeUpdate)
|
t.interfaceCallback = t.options.InterfaceMonitor.RegisterCallback(t.routeUpdate)
|
||||||
}
|
}
|
||||||
|
|
@ -594,3 +598,11 @@ func (t *NativeTun) routeUpdate(event int) error {
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func setSearchDomainForSystemdResolved(interfaceName string) {
|
||||||
|
ctlPath, err := exec.LookPath("resolvectl")
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
shell.Exec(ctlPath, "domain", interfaceName, "~.").Run()
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue