Add openvpn and openconnect

This commit is contained in:
世界
2026-08-30 17:41:43 +08:00
parent 23ca3b415f
commit 2df7a9bac7
65 changed files with 12495 additions and 386 deletions
+12
View File
@@ -0,0 +1,12 @@
//go:build with_openconnect
package include
import (
"github.com/sagernet/sing-box/adapter/endpoint"
"github.com/sagernet/sing-box/protocol/openconnect"
)
func registerOpenConnectEndpoint(registry *endpoint.Registry) {
openconnect.RegisterEndpoint(registry)
}
+23
View File
@@ -0,0 +1,23 @@
//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/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`)
})
}
+12
View File
@@ -0,0 +1,12 @@
//go:build with_openvpn
package include
import (
"github.com/sagernet/sing-box/adapter/endpoint"
"github.com/sagernet/sing-box/protocol/openvpn"
)
func registerOpenVPNEndpoints(registry *endpoint.Registry) {
openvpn.RegisterEndpoint(registry)
}
+29
View File
@@ -0,0 +1,29 @@
//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/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`)
})
}
+2
View File
@@ -111,6 +111,8 @@ func EndpointRegistry() *endpoint.Registry {
registry := endpoint.NewRegistry()
registerWireGuardEndpoint(registry)
registerOpenConnectEndpoint(registry)
registerOpenVPNEndpoints(registry)
registerTailscaleEndpoint(registry)
return registry