mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-08-07 14:25:17 +03:00
tailscale: Fix system interface network category on Windows
This commit is contained in:
2
go.mod
2
go.mod
@@ -9,6 +9,7 @@ require (
|
|||||||
github.com/coder/websocket v1.8.14
|
github.com/coder/websocket v1.8.14
|
||||||
github.com/cretz/bine v0.2.0
|
github.com/cretz/bine v0.2.0
|
||||||
github.com/database64128/tfo-go/v2 v2.3.2
|
github.com/database64128/tfo-go/v2 v2.3.2
|
||||||
|
github.com/dblohm7/wingoes v0.0.0-20240119213807-a09d6be7affa
|
||||||
github.com/go-chi/chi/v5 v5.2.5
|
github.com/go-chi/chi/v5 v5.2.5
|
||||||
github.com/go-chi/render v1.0.3
|
github.com/go-chi/render v1.0.3
|
||||||
github.com/godbus/dbus/v5 v5.2.2
|
github.com/godbus/dbus/v5 v5.2.2
|
||||||
@@ -73,7 +74,6 @@ require (
|
|||||||
github.com/coreos/go-iptables v0.7.1-0.20240112124308-65c67c9f46e6 // indirect
|
github.com/coreos/go-iptables v0.7.1-0.20240112124308-65c67c9f46e6 // indirect
|
||||||
github.com/database64128/netx-go v0.1.1 // indirect
|
github.com/database64128/netx-go v0.1.1 // indirect
|
||||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
||||||
github.com/dblohm7/wingoes v0.0.0-20240119213807-a09d6be7affa // indirect
|
|
||||||
github.com/dgrijalva/jwt-go/v4 v4.0.0-preview1 // indirect
|
github.com/dgrijalva/jwt-go/v4 v4.0.0-preview1 // indirect
|
||||||
github.com/ebitengine/purego v0.10.0 // indirect
|
github.com/ebitengine/purego v0.10.0 // indirect
|
||||||
github.com/florianl/go-nfqueue/v2 v2.0.2 // indirect
|
github.com/florianl/go-nfqueue/v2 v2.0.2 // indirect
|
||||||
|
|||||||
@@ -11,6 +11,9 @@ import (
|
|||||||
singTun "github.com/sagernet/sing-tun"
|
singTun "github.com/sagernet/sing-tun"
|
||||||
"github.com/sagernet/sing/common/logger"
|
"github.com/sagernet/sing/common/logger"
|
||||||
wgTun "github.com/sagernet/wireguard-go/tun"
|
wgTun "github.com/sagernet/wireguard-go/tun"
|
||||||
|
|
||||||
|
"github.com/dblohm7/wingoes/com"
|
||||||
|
"golang.org/x/sys/windows/svc"
|
||||||
)
|
)
|
||||||
|
|
||||||
type tunDeviceAdapter struct {
|
type tunDeviceAdapter struct {
|
||||||
@@ -21,7 +24,23 @@ type tunDeviceAdapter struct {
|
|||||||
closeOnce sync.Once
|
closeOnce sync.Once
|
||||||
}
|
}
|
||||||
|
|
||||||
func newTunDeviceAdapter(tun singTun.Tun, mtu int, _ logger.ContextLogger) (wgTun.Device, error) {
|
var comRuntimeOnce sync.Once
|
||||||
|
|
||||||
|
func newTunDeviceAdapter(tun singTun.Tun, mtu int, contextLogger logger.ContextLogger) (wgTun.Device, error) {
|
||||||
|
// wgengine/router/osrouter/ifconfig_windows.go setPrivateNetwork assumes COM
|
||||||
|
// is initialized process-wide, which upstream performs only in tailscaled's
|
||||||
|
// main package; library consumers must do it themselves.
|
||||||
|
comRuntimeOnce.Do(func() {
|
||||||
|
processType := com.ConsoleApp
|
||||||
|
isService, serviceErr := svc.IsWindowsService()
|
||||||
|
if serviceErr == nil && isService {
|
||||||
|
processType = com.Service
|
||||||
|
}
|
||||||
|
err := com.StartRuntime(processType)
|
||||||
|
if err != nil {
|
||||||
|
contextLogger.Warn("initialize COM runtime: ", err)
|
||||||
|
}
|
||||||
|
})
|
||||||
winTun, ok := tun.(singTun.WinTun)
|
winTun, ok := tun.(singTun.WinTun)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, errors.New("not a windows tun device")
|
return nil, errors.New("not a windows tun device")
|
||||||
|
|||||||
Reference in New Issue
Block a user