mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-10-10 16:15:43 +00:00
Merge tag 'v1.14.0'
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
//go:build with_acme
|
||||
|
||||
package include
|
||||
|
||||
import (
|
||||
"github.com/sagernet/sing-box/adapter/certificate"
|
||||
"github.com/sagernet/sing-box/service/acme"
|
||||
)
|
||||
|
||||
func registerACMECertificateProvider(registry *certificate.Registry) {
|
||||
acme.RegisterCertificateProvider(registry)
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
//go:build !with_acme
|
||||
|
||||
package include
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/sagernet/sing-box/adapter"
|
||||
"github.com/sagernet/sing-box/adapter/certificate"
|
||||
C "github.com/sagernet/sing-box/constant"
|
||||
"github.com/sagernet/sing-box/log"
|
||||
"github.com/sagernet/sing-box/option"
|
||||
E "github.com/sagernet/sing/common/exceptions"
|
||||
)
|
||||
|
||||
func registerACMECertificateProvider(registry *certificate.Registry) {
|
||||
certificate.Register[option.ACMECertificateProviderOptions](registry, C.TypeACME, func(ctx context.Context, logger log.ContextLogger, tag string, options option.ACMECertificateProviderOptions) (adapter.CertificateProviderService, error) {
|
||||
return nil, E.New(`ACME is not included in this build, rebuild with -tags with_acme`)
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
//go:build with_cloudflared
|
||||
|
||||
package include
|
||||
|
||||
import (
|
||||
"github.com/sagernet/sing-box/adapter/inbound"
|
||||
"github.com/sagernet/sing-box/protocol/cloudflare"
|
||||
)
|
||||
|
||||
func registerCloudflaredInbound(registry *inbound.Registry) {
|
||||
cloudflare.RegisterInbound(registry)
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
//go:build !with_cloudflared
|
||||
|
||||
package include
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/sagernet/sing-box/adapter"
|
||||
"github.com/sagernet/sing-box/adapter/inbound"
|
||||
C "github.com/sagernet/sing-box/constant"
|
||||
"github.com/sagernet/sing-box/log"
|
||||
"github.com/sagernet/sing-box/option"
|
||||
E "github.com/sagernet/sing/common/exceptions"
|
||||
)
|
||||
|
||||
func registerCloudflaredInbound(registry *inbound.Registry) {
|
||||
inbound.Register[option.CloudflaredInboundOptions](registry, C.TypeCloudflared, func(ctx context.Context, router adapter.Router, logger log.ContextLogger, tag string, options option.CloudflaredInboundOptions) (adapter.Inbound, error) {
|
||||
return nil, E.New(`Cloudflared is not included in this build, rebuild with -tags with_cloudflared`)
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
//go:build with_openconnect
|
||||
|
||||
package include
|
||||
|
||||
import (
|
||||
"github.com/sagernet/sing-box/adapter/endpoint"
|
||||
"github.com/sagernet/sing-box/dns"
|
||||
"github.com/sagernet/sing-box/protocol/openconnect"
|
||||
)
|
||||
|
||||
func registerOpenConnectEndpoint(registry *endpoint.Registry) {
|
||||
openconnect.RegisterEndpoint(registry)
|
||||
}
|
||||
|
||||
func registerOpenConnectDNSTransport(registry *dns.TransportRegistry) {
|
||||
openconnect.RegisterDNSTransport(registry)
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
//go:build !with_openconnect
|
||||
|
||||
package include
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/sagernet/sing-box/adapter"
|
||||
"github.com/sagernet/sing-box/adapter/endpoint"
|
||||
C "github.com/sagernet/sing-box/constant"
|
||||
"github.com/sagernet/sing-box/dns"
|
||||
"github.com/sagernet/sing-box/log"
|
||||
"github.com/sagernet/sing-box/option"
|
||||
E "github.com/sagernet/sing/common/exceptions"
|
||||
)
|
||||
|
||||
func registerOpenConnectEndpoint(registry *endpoint.Registry) {
|
||||
endpoint.Register[option.OpenConnectEndpointOptions](registry, C.TypeOpenConnect, func(ctx context.Context, router adapter.Router, logger log.ContextLogger, tag string, options option.OpenConnectEndpointOptions) (adapter.Endpoint, error) {
|
||||
if !options.System {
|
||||
return nil, E.New(`OpenConnect is not included in this build, rebuild with -tags with_openconnect,with_gvisor for system:false`)
|
||||
}
|
||||
return nil, E.New(`OpenConnect is not included in this build, rebuild with -tags with_openconnect`)
|
||||
})
|
||||
}
|
||||
|
||||
func registerOpenConnectDNSTransport(registry *dns.TransportRegistry) {
|
||||
dns.RegisterTransport[option.OpenConnectDNSServerOptions](registry, C.DNSTypeOpenConnect, func(ctx context.Context, logger log.ContextLogger, tag string, options option.OpenConnectDNSServerOptions) (adapter.DNSTransport, error) {
|
||||
return nil, E.New(`OpenConnect is not included in this build, rebuild with -tags with_openconnect`)
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
//go:build with_openvpn
|
||||
|
||||
package include
|
||||
|
||||
import (
|
||||
"github.com/sagernet/sing-box/adapter/endpoint"
|
||||
"github.com/sagernet/sing-box/dns"
|
||||
"github.com/sagernet/sing-box/protocol/openvpn"
|
||||
)
|
||||
|
||||
func registerOpenVPNEndpoints(registry *endpoint.Registry) {
|
||||
openvpn.RegisterEndpoint(registry)
|
||||
}
|
||||
|
||||
func registerOpenVPNDNSTransport(registry *dns.TransportRegistry) {
|
||||
openvpn.RegisterDNSTransport(registry)
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
//go:build !with_openvpn
|
||||
|
||||
package include
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/sagernet/sing-box/adapter"
|
||||
"github.com/sagernet/sing-box/adapter/endpoint"
|
||||
C "github.com/sagernet/sing-box/constant"
|
||||
"github.com/sagernet/sing-box/dns"
|
||||
"github.com/sagernet/sing-box/log"
|
||||
"github.com/sagernet/sing-box/option"
|
||||
E "github.com/sagernet/sing/common/exceptions"
|
||||
)
|
||||
|
||||
func registerOpenVPNEndpoints(registry *endpoint.Registry) {
|
||||
endpoint.Register[option.OpenVPNClientEndpointOptions](registry, C.TypeOpenVPNClient, func(ctx context.Context, router adapter.Router, logger log.ContextLogger, tag string, options option.OpenVPNClientEndpointOptions) (adapter.Endpoint, error) {
|
||||
if !options.System {
|
||||
return nil, E.New(`OpenVPN is not included in this build, rebuild with -tags with_openvpn,with_gvisor for system:false`)
|
||||
}
|
||||
return nil, E.New(`OpenVPN is not included in this build, rebuild with -tags with_openvpn`)
|
||||
})
|
||||
endpoint.Register[option.OpenVPNServerEndpointOptions](registry, C.TypeOpenVPNServer, func(ctx context.Context, router adapter.Router, logger log.ContextLogger, tag string, options option.OpenVPNServerEndpointOptions) (adapter.Endpoint, error) {
|
||||
if !options.System {
|
||||
return nil, E.New(`OpenVPN is not included in this build, rebuild with -tags with_openvpn,with_gvisor for system:false`)
|
||||
}
|
||||
return nil, E.New(`OpenVPN is not included in this build, rebuild with -tags with_openvpn`)
|
||||
})
|
||||
}
|
||||
|
||||
func registerOpenVPNDNSTransport(registry *dns.TransportRegistry) {
|
||||
dns.RegisterTransport[option.OpenVPNDNSServerOptions](registry, C.DNSTypeOpenVPN, func(ctx context.Context, logger log.ContextLogger, tag string, options option.OpenVPNDNSServerOptions) (adapter.DNSTransport, error) {
|
||||
return nil, E.New(`OpenVPN is not included in this build, rebuild with -tags with_openvpn`)
|
||||
})
|
||||
}
|
||||
@@ -5,6 +5,7 @@ package include
|
||||
import (
|
||||
"github.com/sagernet/sing-box/adapter/inbound"
|
||||
"github.com/sagernet/sing-box/adapter/outbound"
|
||||
"github.com/sagernet/sing-box/adapter/service"
|
||||
"github.com/sagernet/sing-box/dns"
|
||||
"github.com/sagernet/sing-box/dns/transport/quic"
|
||||
"github.com/sagernet/sing-box/protocol/hysteria"
|
||||
@@ -30,3 +31,7 @@ func registerQUICTransports(registry *dns.TransportRegistry) {
|
||||
quic.RegisterTransport(registry)
|
||||
quic.RegisterHTTP3Transport(registry)
|
||||
}
|
||||
|
||||
func registerQUICServices(registry *service.Registry) {
|
||||
hysteria2.RegisterRealmService(registry)
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/sagernet/sing-box/adapter"
|
||||
"github.com/sagernet/sing-box/adapter/inbound"
|
||||
"github.com/sagernet/sing-box/adapter/outbound"
|
||||
"github.com/sagernet/sing-box/adapter/service"
|
||||
"github.com/sagernet/sing-box/common/listener"
|
||||
"github.com/sagernet/sing-box/common/tls"
|
||||
C "github.com/sagernet/sing-box/constant"
|
||||
@@ -69,3 +70,9 @@ func registerQUICTransports(registry *dns.TransportRegistry) {
|
||||
return nil, C.ErrQUICNotIncluded
|
||||
})
|
||||
}
|
||||
|
||||
func registerQUICServices(registry *service.Registry) {
|
||||
service.Register[option.HysteriaRealmServiceOptions](registry, C.TypeHysteriaRealm, func(ctx context.Context, logger log.ContextLogger, tag string, options option.HysteriaRealmServiceOptions) (adapter.Service, error) {
|
||||
return nil, C.ErrQUICNotIncluded
|
||||
})
|
||||
}
|
||||
|
||||
+29
-1
@@ -5,6 +5,7 @@ import (
|
||||
|
||||
"github.com/sagernet/sing-box"
|
||||
"github.com/sagernet/sing-box/adapter"
|
||||
"github.com/sagernet/sing-box/adapter/certificate"
|
||||
"github.com/sagernet/sing-box/adapter/endpoint"
|
||||
"github.com/sagernet/sing-box/adapter/inbound"
|
||||
"github.com/sagernet/sing-box/adapter/outbound"
|
||||
@@ -17,11 +18,13 @@ import (
|
||||
"github.com/sagernet/sing-box/dns/transport/fallback"
|
||||
"github.com/sagernet/sing-box/dns/transport/hosts"
|
||||
"github.com/sagernet/sing-box/dns/transport/local"
|
||||
"github.com/sagernet/sing-box/dns/transport/mdns"
|
||||
"github.com/sagernet/sing-box/log"
|
||||
"github.com/sagernet/sing-box/option"
|
||||
"github.com/sagernet/sing-box/protocol/anytls"
|
||||
"github.com/sagernet/sing-box/protocol/block"
|
||||
"github.com/sagernet/sing-box/protocol/bond"
|
||||
"github.com/sagernet/sing-box/protocol/bridge"
|
||||
"github.com/sagernet/sing-box/protocol/direct"
|
||||
"github.com/sagernet/sing-box/protocol/failover"
|
||||
"github.com/sagernet/sing-box/protocol/group"
|
||||
@@ -37,6 +40,7 @@ import (
|
||||
"github.com/sagernet/sing-box/protocol/redirect"
|
||||
"github.com/sagernet/sing-box/protocol/shadowsocks"
|
||||
"github.com/sagernet/sing-box/protocol/shadowtls"
|
||||
"github.com/sagernet/sing-box/protocol/snell"
|
||||
"github.com/sagernet/sing-box/protocol/socks"
|
||||
"github.com/sagernet/sing-box/protocol/ssh"
|
||||
"github.com/sagernet/sing-box/protocol/tor"
|
||||
@@ -48,17 +52,19 @@ import (
|
||||
localProvider "github.com/sagernet/sing-box/provider/local"
|
||||
remoteProvider "github.com/sagernet/sing-box/provider/remote"
|
||||
"github.com/sagernet/sing-box/service/admin_panel"
|
||||
"github.com/sagernet/sing-box/service/api"
|
||||
"github.com/sagernet/sing-box/service/manager"
|
||||
"github.com/sagernet/sing-box/service/manager_api"
|
||||
"github.com/sagernet/sing-box/service/node"
|
||||
"github.com/sagernet/sing-box/service/node_manager_api"
|
||||
originca "github.com/sagernet/sing-box/service/origin_ca"
|
||||
"github.com/sagernet/sing-box/service/resolved"
|
||||
"github.com/sagernet/sing-box/service/ssmapi"
|
||||
E "github.com/sagernet/sing/common/exceptions"
|
||||
)
|
||||
|
||||
func Context(ctx context.Context) context.Context {
|
||||
return box.Context(ctx, InboundRegistry(), OutboundRegistry(), EndpointRegistry(), ProviderRegistry(), DNSTransportRegistry(), ServiceRegistry())
|
||||
return box.Context(ctx, InboundRegistry(), OutboundRegistry(), EndpointRegistry(), ProviderRegistry(), DNSTransportRegistry(), ServiceRegistry(), CertificateProviderRegistry())
|
||||
}
|
||||
|
||||
func InboundRegistry() *inbound.Registry {
|
||||
@@ -74,6 +80,7 @@ func InboundRegistry() *inbound.Registry {
|
||||
mixed.RegisterInbound(registry)
|
||||
|
||||
shadowsocks.RegisterInbound(registry)
|
||||
snell.RegisterInbound(registry)
|
||||
vmess.RegisterInbound(registry)
|
||||
trojan.RegisterInbound(registry)
|
||||
naive.RegisterInbound(registry)
|
||||
@@ -88,6 +95,7 @@ func InboundRegistry() *inbound.Registry {
|
||||
registerTrustTunnelInbound(registry)
|
||||
|
||||
registerQUICInbounds(registry)
|
||||
registerCloudflaredInbound(registry)
|
||||
registerStubForRemovedInbounds(registry)
|
||||
registerMTProxyInbound(registry)
|
||||
registerSudokuInbound(registry)
|
||||
@@ -100,6 +108,7 @@ func OutboundRegistry() *outbound.Registry {
|
||||
registry := outbound.NewRegistry()
|
||||
|
||||
direct.RegisterOutbound(registry)
|
||||
bridge.RegisterOutbound(registry)
|
||||
|
||||
block.RegisterOutbound(registry)
|
||||
|
||||
@@ -110,6 +119,7 @@ func OutboundRegistry() *outbound.Registry {
|
||||
socks.RegisterOutbound(registry)
|
||||
http.RegisterOutbound(registry)
|
||||
shadowsocks.RegisterOutbound(registry)
|
||||
snell.RegisterOutbound(registry)
|
||||
vmess.RegisterOutbound(registry)
|
||||
trojan.RegisterOutbound(registry)
|
||||
registerNaiveOutbound(registry)
|
||||
@@ -147,6 +157,8 @@ func EndpointRegistry() *endpoint.Registry {
|
||||
vpn.RegisterClientEndpoint(registry)
|
||||
|
||||
registerWireGuardEndpoint(registry)
|
||||
registerOpenConnectEndpoint(registry)
|
||||
registerOpenVPNEndpoints(registry)
|
||||
registerTailscaleEndpoint(registry)
|
||||
|
||||
return registry
|
||||
@@ -172,6 +184,7 @@ func DNSTransportRegistry() *dns.TransportRegistry {
|
||||
transport.RegisterSDNS(registry)
|
||||
hosts.RegisterTransport(registry)
|
||||
local.RegisterTransport(registry)
|
||||
mdns.RegisterTransport(registry)
|
||||
fakeip.RegisterTransport(registry)
|
||||
fallback.RegisterTransport(registry)
|
||||
resolved.RegisterTransport(registry)
|
||||
@@ -179,6 +192,8 @@ func DNSTransportRegistry() *dns.TransportRegistry {
|
||||
registerQUICTransports(registry)
|
||||
registerDHCPTransport(registry)
|
||||
registerTailscaleTransport(registry)
|
||||
registerOpenConnectDNSTransport(registry)
|
||||
registerOpenVPNDNSTransport(registry)
|
||||
|
||||
return registry
|
||||
}
|
||||
@@ -191,14 +206,27 @@ func ServiceRegistry() *service.Registry {
|
||||
manager_api.RegisterService(registry)
|
||||
node.RegisterService(registry)
|
||||
node_manager_api.RegisterService(registry)
|
||||
api.RegisterService(registry)
|
||||
resolved.RegisterService(registry)
|
||||
ssmapi.RegisterService(registry)
|
||||
|
||||
registerQUICServices(registry)
|
||||
registerDERPService(registry)
|
||||
registerCCMService(registry)
|
||||
registerOCMService(registry)
|
||||
registerOOMKillerService(registry)
|
||||
registerProfilerService(registry)
|
||||
registerUSBIPServices(registry)
|
||||
|
||||
return registry
|
||||
}
|
||||
|
||||
func CertificateProviderRegistry() *certificate.Registry {
|
||||
registry := certificate.NewRegistry()
|
||||
|
||||
registerACMECertificateProvider(registry)
|
||||
registerTailscaleCertificateProvider(registry)
|
||||
originca.RegisterCertificateProvider(registry)
|
||||
|
||||
return registry
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
package include
|
||||
|
||||
import (
|
||||
"github.com/sagernet/sing-box/adapter/certificate"
|
||||
"github.com/sagernet/sing-box/adapter/endpoint"
|
||||
"github.com/sagernet/sing-box/adapter/service"
|
||||
"github.com/sagernet/sing-box/dns"
|
||||
@@ -18,6 +19,10 @@ func registerTailscaleTransport(registry *dns.TransportRegistry) {
|
||||
tailscale.RegistryTransport(registry)
|
||||
}
|
||||
|
||||
func registerTailscaleCertificateProvider(registry *certificate.Registry) {
|
||||
tailscale.RegisterCertificateProvider(registry)
|
||||
}
|
||||
|
||||
func registerDERPService(registry *service.Registry) {
|
||||
derp.Register(registry)
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/sagernet/sing-box/adapter"
|
||||
"github.com/sagernet/sing-box/adapter/certificate"
|
||||
"github.com/sagernet/sing-box/adapter/endpoint"
|
||||
"github.com/sagernet/sing-box/adapter/service"
|
||||
C "github.com/sagernet/sing-box/constant"
|
||||
@@ -27,6 +28,12 @@ func registerTailscaleTransport(registry *dns.TransportRegistry) {
|
||||
})
|
||||
}
|
||||
|
||||
func registerTailscaleCertificateProvider(registry *certificate.Registry) {
|
||||
certificate.Register[option.TailscaleCertificateProviderOptions](registry, C.TypeTailscale, func(ctx context.Context, logger log.ContextLogger, tag string, options option.TailscaleCertificateProviderOptions) (adapter.CertificateProviderService, error) {
|
||||
return nil, E.New(`Tailscale is not included in this build, rebuild with -tags with_tailscale`)
|
||||
})
|
||||
}
|
||||
|
||||
func registerDERPService(registry *service.Registry) {
|
||||
service.Register[option.DERPServiceOptions](registry, C.TypeDERP, func(ctx context.Context, logger log.ContextLogger, tag string, options option.DERPServiceOptions) (adapter.Service, error) {
|
||||
return nil, E.New(`DERP is not included in this build, rebuild with -tags with_tailscale`)
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
//go:build with_usbip && (linux || (darwin && cgo) || windows)
|
||||
|
||||
package include
|
||||
|
||||
import (
|
||||
"github.com/sagernet/sing-box/adapter/service"
|
||||
"github.com/sagernet/sing-box/service/usbip"
|
||||
)
|
||||
|
||||
func registerUSBIPServices(registry *service.Registry) {
|
||||
usbip.RegisterService(registry)
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
//go:build !with_usbip || !(linux || (darwin && cgo) || windows)
|
||||
|
||||
package include
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/sagernet/sing-box/adapter"
|
||||
"github.com/sagernet/sing-box/adapter/service"
|
||||
C "github.com/sagernet/sing-box/constant"
|
||||
"github.com/sagernet/sing-box/log"
|
||||
"github.com/sagernet/sing-box/option"
|
||||
E "github.com/sagernet/sing/common/exceptions"
|
||||
)
|
||||
|
||||
func registerUSBIPServices(registry *service.Registry) {
|
||||
service.Register[option.USBIPServerServiceOptions](registry, C.TypeUSBIPServer, func(ctx context.Context, logger log.ContextLogger, tag string, options option.USBIPServerServiceOptions) (adapter.Service, error) {
|
||||
return nil, E.New(`USB/IP is not included in this build, rebuild with -tags with_usbip (supported on Linux, Windows, and macOS with CGO)`)
|
||||
})
|
||||
service.Register[option.USBIPClientServiceOptions](registry, C.TypeUSBIPClient, func(ctx context.Context, logger log.ContextLogger, tag string, options option.USBIPClientServiceOptions) (adapter.Service, error) {
|
||||
return nil, E.New(`USB/IP is not included in this build, rebuild with -tags with_usbip (supported on Linux, Windows, and macOS with CGO)`)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user