mirror of
https://github.com/openziti/ziti.git
synced 2026-09-10 00:35:41 +00:00
45b5046f52
- keys router capability bits off the sdk-golang RouterCapability enum - adds a generic capabilities.Mask[T ~int] bitmask, centralizing capability set/check behind one value-to-bit translation - adds capabilities.RouterCapability and ControllerCapability types, with RouterCapabilityMask/ControllerCapabilityMask aliases, so masks and checks are typed per namespace - supports control-plane-only router capabilities as negative values that index down from the top of the mask, collision-free with the SDK's upward-numbered bits and invisible to the SDK and edge-api - references the sdk-golang RouterCapability enum as the source of truth for shared router capability bits - holds the router's advertised capability mask as an instance on the router env rather than a global, so in-process test routers do not share state - advertises PostureChecks and BindSuccess as capability bits on both channels while still sending the legacy boolean edge headers for backwards compatibility - routes GetCapabilities/IsCapable and the controller's Router.Capabilities field through the typed mask - adds a provenance test that verifies, via go/packages, that every positive router capability is SDK-sourced, every negative is control-plane-only, and no two resolve to the same bit - update sdk to v2.0.0-pre2
39 lines
1.3 KiB
Go
39 lines
1.3 KiB
Go
package tests
|
|
|
|
import (
|
|
"github.com/openziti/channel/v5"
|
|
"github.com/openziti/foundation/v2/versions"
|
|
"github.com/openziti/transport/v2"
|
|
"github.com/openziti/ziti/v2/common/capabilities"
|
|
"github.com/openziti/ziti/v2/common/pb/ctrl_pb"
|
|
"github.com/openziti/ziti/v2/controller/config"
|
|
)
|
|
|
|
func (ctx *TestContext) NewControlChannelListener() channel.UnderlayListener {
|
|
config, err := config.LoadConfig(ctx.configSet.CtrlConfig)
|
|
ctx.Req.NoError(err)
|
|
ctx.Req.NoError(config.Db.Close())
|
|
|
|
versionHeader, err := versions.StdVersionEncDec.Encode(versions.NewDefaultVersionProvider().AsVersionInfo())
|
|
ctx.Req.NoError(err)
|
|
|
|
capabilityMask := capabilities.NewMask(
|
|
capabilities.ControllerCreateTerminatorV2,
|
|
capabilities.ControllerSingleRouterLinkSource,
|
|
capabilities.ControllerSupportsJWTLegacySessions,
|
|
)
|
|
headers := map[int32][]byte{
|
|
channel.HelloVersionHeader: versionHeader,
|
|
int32(ctrl_pb.ControlHeaders_CapabilitiesHeader): capabilityMask.Bytes(),
|
|
}
|
|
|
|
ctrlChannelListenerConfig := channel.ListenerConfig{
|
|
ConnectOptions: config.Ctrl.Options.ConnectOptions,
|
|
Headers: headers,
|
|
TransportConfig: transport.Configuration{"protocol": "ziti-ctrl"},
|
|
}
|
|
ctrlListener := channel.NewClassicListener(config.Id, config.Ctrl.Listener, ctrlChannelListenerConfig)
|
|
ctx.Req.NoError(ctrlListener.Listen())
|
|
return ctrlListener
|
|
}
|