Improve OpenVPN & OpenConnect interoperability

This commit is contained in:
世界
2026-07-21 09:38:21 +08:00
parent 5cad5ad42d
commit 2ff294c4f4
47 changed files with 3915 additions and 440 deletions
+5
View File
@@ -4,9 +4,14 @@ 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)
}
+7
View File
@@ -8,6 +8,7 @@ import (
"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"
@@ -21,3 +22,9 @@ func registerOpenConnectEndpoint(registry *endpoint.Registry) {
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`)
})
}
+5
View File
@@ -4,9 +4,14 @@ 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)
}
+7
View File
@@ -8,6 +8,7 @@ import (
"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"
@@ -27,3 +28,9 @@ func registerOpenVPNEndpoints(registry *endpoint.Registry) {
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`)
})
}
+2
View File
@@ -134,6 +134,8 @@ func DNSTransportRegistry() *dns.TransportRegistry {
registerQUICTransports(registry)
registerDHCPTransport(registry)
registerTailscaleTransport(registry)
registerOpenConnectDNSTransport(registry)
registerOpenVPNDNSTransport(registry)
return registry
}