mirror of
https://github.com/SagerNet/sing-box.git
synced 2025-01-25 18:26:34 +00:00
Exclude gVisor for unsupported arch
This commit is contained in:
parent
4094c94971
commit
cf845d946e
|
@ -1,3 +1,5 @@
|
||||||
|
//go:build linux || windows
|
||||||
|
|
||||||
package inbound
|
package inbound
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
16
inbound/tun_stub.go
Normal file
16
inbound/tun_stub.go
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
//go:build !linux && !windows
|
||||||
|
|
||||||
|
package inbound
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/sagernet/sing-box/adapter"
|
||||||
|
"github.com/sagernet/sing-box/log"
|
||||||
|
"github.com/sagernet/sing-box/option"
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewTun(ctx context.Context, router adapter.Router, logger log.ContextLogger, tag string, options option.TunInboundOptions) (adapter.Inbound, error) {
|
||||||
|
return nil, os.ErrInvalid
|
||||||
|
}
|
22
route/iface.go
Normal file
22
route/iface.go
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
package route
|
||||||
|
|
||||||
|
import "github.com/sagernet/sing/common/x/list"
|
||||||
|
|
||||||
|
type (
|
||||||
|
NetworkUpdateCallback = func() error
|
||||||
|
DefaultInterfaceUpdateCallback = func()
|
||||||
|
)
|
||||||
|
|
||||||
|
type NetworkUpdateMonitor interface {
|
||||||
|
Start() error
|
||||||
|
Close() error
|
||||||
|
RegisterCallback(callback NetworkUpdateCallback) *list.Element[NetworkUpdateCallback]
|
||||||
|
UnregisterCallback(element *list.Element[NetworkUpdateCallback])
|
||||||
|
}
|
||||||
|
|
||||||
|
type DefaultInterfaceMonitor interface {
|
||||||
|
Start() error
|
||||||
|
Close() error
|
||||||
|
DefaultInterfaceName() string
|
||||||
|
DefaultInterfaceIndex() int
|
||||||
|
}
|
17
route/iface_stub.go
Normal file
17
route/iface_stub.go
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
//go:build !linux && !windows
|
||||||
|
|
||||||
|
package route
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
|
||||||
|
E "github.com/sagernet/sing/common/exceptions"
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewNetworkUpdateMonitor(errorHandler E.Handler) (NetworkUpdateMonitor, error) {
|
||||||
|
return nil, os.ErrInvalid
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewDefaultInterfaceMonitor(networkMonitor NetworkUpdateMonitor, callback DefaultInterfaceUpdateCallback) (DefaultInterfaceMonitor, error) {
|
||||||
|
return nil, os.ErrInvalid
|
||||||
|
}
|
16
route/iface_tun.go
Normal file
16
route/iface_tun.go
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
//go:build linux || windows
|
||||||
|
|
||||||
|
package route
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/sagernet/sing-tun"
|
||||||
|
E "github.com/sagernet/sing/common/exceptions"
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewNetworkUpdateMonitor(errorHandler E.Handler) (NetworkUpdateMonitor, error) {
|
||||||
|
return tun.NewNetworkUpdateMonitor(errorHandler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewDefaultInterfaceMonitor(networkMonitor NetworkUpdateMonitor, callback DefaultInterfaceUpdateCallback) (DefaultInterfaceMonitor, error) {
|
||||||
|
return tun.NewDefaultInterfaceMonitor(networkMonitor, callback)
|
||||||
|
}
|
|
@ -22,7 +22,6 @@ import (
|
||||||
"github.com/sagernet/sing-box/log"
|
"github.com/sagernet/sing-box/log"
|
||||||
"github.com/sagernet/sing-box/option"
|
"github.com/sagernet/sing-box/option"
|
||||||
"github.com/sagernet/sing-dns"
|
"github.com/sagernet/sing-dns"
|
||||||
"github.com/sagernet/sing-tun"
|
|
||||||
"github.com/sagernet/sing/common"
|
"github.com/sagernet/sing/common"
|
||||||
"github.com/sagernet/sing/common/buf"
|
"github.com/sagernet/sing/common/buf"
|
||||||
"github.com/sagernet/sing/common/bufio"
|
"github.com/sagernet/sing/common/bufio"
|
||||||
|
@ -66,10 +65,10 @@ type Router struct {
|
||||||
transportMap map[string]dns.Transport
|
transportMap map[string]dns.Transport
|
||||||
|
|
||||||
interfaceBindManager control.BindManager
|
interfaceBindManager control.BindManager
|
||||||
networkMonitor tun.NetworkUpdateMonitor
|
networkMonitor NetworkUpdateMonitor
|
||||||
autoDetectInterface bool
|
autoDetectInterface bool
|
||||||
defaultInterface string
|
defaultInterface string
|
||||||
interfaceMonitor tun.DefaultInterfaceMonitor
|
interfaceMonitor DefaultInterfaceMonitor
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewRouter(ctx context.Context, logger log.ContextLogger, dnsLogger log.ContextLogger, options option.RouteOptions, dnsOptions option.DNSOptions) (*Router, error) {
|
func NewRouter(ctx context.Context, logger log.ContextLogger, dnsLogger log.ContextLogger, options option.RouteOptions, dnsOptions option.DNSOptions) (*Router, error) {
|
||||||
|
@ -199,7 +198,7 @@ func NewRouter(ctx context.Context, logger log.ContextLogger, dnsLogger log.Cont
|
||||||
router.transportMap = transportMap
|
router.transportMap = transportMap
|
||||||
|
|
||||||
if router.interfaceBindManager != nil || options.AutoDetectInterface {
|
if router.interfaceBindManager != nil || options.AutoDetectInterface {
|
||||||
networkMonitor, err := tun.NewNetworkUpdateMonitor(router)
|
networkMonitor, err := NewNetworkUpdateMonitor(router)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
router.networkMonitor = networkMonitor
|
router.networkMonitor = networkMonitor
|
||||||
if router.interfaceBindManager != nil {
|
if router.interfaceBindManager != nil {
|
||||||
|
@ -209,7 +208,7 @@ func NewRouter(ctx context.Context, logger log.ContextLogger, dnsLogger log.Cont
|
||||||
}
|
}
|
||||||
|
|
||||||
if router.networkMonitor != nil && options.AutoDetectInterface {
|
if router.networkMonitor != nil && options.AutoDetectInterface {
|
||||||
interfaceMonitor, err := tun.NewDefaultInterfaceMonitor(router.networkMonitor, func() {
|
interfaceMonitor, err := NewDefaultInterfaceMonitor(router.networkMonitor, func() {
|
||||||
router.logger.Info("updated default interface ", router.interfaceMonitor.DefaultInterfaceName(), ", index ", router.interfaceMonitor.DefaultInterfaceIndex())
|
router.logger.Info("updated default interface ", router.interfaceMonitor.DefaultInterfaceName(), ", index ", router.interfaceMonitor.DefaultInterfaceIndex())
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue