Documentation
¶
Index ¶
- Constants
- Variables
- func AddAddressParsers()
- func GetLoggerFields(msg *channel.Message) logrus.Fields
- func NewBindMsg(connId uint32, token string, pubKey []byte, options *ListenOptions) *channel.Message
- func NewConnInspectResponse(connId uint32, connType ConnType, state string) *channel.Message
- func NewConnectMsg(connId uint32, token string, pubKey []byte, options *DialOptions) *channel.Message
- func NewDataMsg(connId uint32, data []byte) *channel.Message
- func NewDialFailedMsg(connId uint32, message string) *channel.Message
- func NewDialMsg(connId uint32, token string, callerId string) *channel.Message
- func NewDialSuccessMsg(connId uint32, newConnId uint32) *channel.Message
- func NewHealthEventMsg(connId uint32, token string, pass bool) *channel.Message
- func NewInspectRequest(connId *uint32, requestedValues ...string) *channel.Message
- func NewInspectResponse(connId uint32, resp *inspect.SdkInspectResponse) (*channel.Message, error)
- func NewProbeMsg() *channel.Message
- func NewStateClosedMsg(connId uint32, message string) *channel.Message
- func NewStateConnectedMsg(connId uint32) *channel.Message
- func NewTraceRouteMsg(connId uint32, hops uint32, timestamp uint64) *channel.Message
- func NewTraceRouteResponseMsg(connId uint32, hops uint32, timestamp uint64, hopType, hopId string) *channel.Message
- func NewUnbindMsg(connId uint32, token string) *channel.Message
- func NewUpdateBindMsg(connId uint32, token string, cost *uint16, precedence *Precedence) *channel.Message
- func NewUpdateTokenFailedMsg(err error) *channel.Message
- func NewUpdateTokenMsg(token []byte) *channel.Message
- func NewUpdateTokenSuccessMsg() *channel.Message
- func ParseServiceConfig(service *rest_model.ServiceDetail, configType string, target interface{}) (bool, error)
- type Addr
- type BaseSdkChannel
- func (self *BaseSdkChannel) GetChannel() channel.Channel
- func (self *BaseSdkChannel) GetControlSender() channel.Sender
- func (self *BaseSdkChannel) GetDefaultSender() channel.Sender
- func (self *BaseSdkChannel) GetMessageSource(underlay channel.Underlay) channel.MessageSourceF
- func (self *BaseSdkChannel) GetNextControlMsg(notifier *channel.CloseNotifier) (channel.Sendable, error)
- func (self *BaseSdkChannel) GetNextMsgDefault(notifier *channel.CloseNotifier) (channel.Sendable, error)
- func (self *BaseSdkChannel) HandleTxFailed(_ channel.Underlay, sendable channel.Sendable) bool
- func (self *BaseSdkChannel) HandleUnderlayAccepted(ch channel.MultiChannel, underlay channel.Underlay)
- func (self *BaseSdkChannel) InitChannel(ch channel.MultiChannel)
- func (self *BaseSdkChannel) UpdateCtrlChannelAvailable(ch channel.MultiChannel)
- type ClientConfig
- type CloseWriter
- type Conn
- type ConnMux
- type ConnMuxImpl
- func (mux *ConnMuxImpl[T]) Add(sink MsgSink[T]) error
- func (mux *ConnMuxImpl[T]) Close()
- func (mux *ConnMuxImpl[T]) ContentType() int32
- func (mux *ConnMuxImpl[T]) GetActiveConnIds() []uint32
- func (mux *ConnMuxImpl[T]) GetConnCount() int
- func (mux *ConnMuxImpl[T]) GetNextId() uint32
- func (mux *ConnMuxImpl[T]) GetSinks() map[uint32]MsgSink[T]
- func (mux *ConnMuxImpl[T]) HandleClose(channel.Channel)
- func (mux *ConnMuxImpl[T]) HandleInspect(msg *channel.Message, ch channel.Channel)
- func (mux *ConnMuxImpl[T]) HandleReceive(msg *channel.Message, ch channel.Channel)
- func (mux *ConnMuxImpl[T]) HasConn(connId uint32) bool
- func (mux *ConnMuxImpl[T]) Remove(sink MsgSink[T])
- func (mux *ConnMuxImpl[T]) RemoveByConnId(connId uint32)
- type ConnOptions
- type ConnType
- type CryptoMethod
- type DialOptions
- type DialResult
- type DialSdkChannel
- func (self *DialSdkChannel) CreateGroupedUnderlay(groupId string, groupSecret []byte, underlayType string, timeout time.Duration) (channel.Underlay, error)
- func (self *DialSdkChannel) DialFailed(_ channel.MultiChannel, _ string, attempt int)
- func (self *DialSdkChannel) HandleUnderlayClose(ch channel.MultiChannel, underlay channel.Underlay)
- func (self *DialSdkChannel) Start(channel channel.MultiChannel)
- type DomainName
- type Identifiable
- type InspectResult
- type InterceptDialOptions
- type InterceptV1Config
- type ListenOptions
- type Listener
- type ListenerEvent
- type ListenerEventType
- type MsgChannel
- func (ec *MsgChannel) GetRouterId() string
- func (ec *MsgChannel) Id() uint32
- func (ec *MsgChannel) NextMsgId() uint32
- func (ec *MsgChannel) SendState(msg *channel.Message) error
- func (ec *MsgChannel) SetWriteDeadline(t time.Time) error
- func (ec *MsgChannel) TraceMsg(source string, msg *channel.Message)
- func (ec *MsgChannel) Write(data []byte) (n int, err error)
- func (ec *MsgChannel) WriteTraced(data []byte, msgUUID []byte, hdrs map[int32][]byte) (int, error)
- type MsgEvent
- type MsgSink
- type PortRange
- type Precedence
- type RouterClient
- type RouterConn
- type SdkChannel
- type ServiceConn
- type SessionListener
- type SingleSdkChannel
- type TraceRouteResult
- type UnderlayHandlerSdkChannel
- type ZitiAddress
Constants ¶
const ( ChannelTypeControl string = "edge.control" ChannelTypeDefault string = "edge.default" )
const ( ContentTypeConnect = int32(edge_client_pb.ContentType_ConnectType) ContentTypeStateConnected = int32(edge_client_pb.ContentType_StateConnectedType) ContentTypeStateClosed = int32(edge_client_pb.ContentType_StateClosedType) ContentTypeData = int32(edge_client_pb.ContentType_DataType) ContentTypeDial = int32(edge_client_pb.ContentType_DialType) ContentTypeDialSuccess = int32(edge_client_pb.ContentType_DialSuccessType) ContentTypeDialFailed = int32(edge_client_pb.ContentType_DialFailedType) ContentTypeBind = int32(edge_client_pb.ContentType_BindType) ContentTypeUnbind = int32(edge_client_pb.ContentType_UnbindType) ContentTypeProbe = int32(edge_client_pb.ContentType_ProbeType) ContentTypeUpdateBind = int32(edge_client_pb.ContentType_UpdateBindType) ContentTypeHealthEvent = int32(edge_client_pb.ContentType_HealthEventType) ContentTypeTraceRoute = int32(edge_client_pb.ContentType_TraceRouteType) ContentTypeTraceRouteResponse = int32(edge_client_pb.ContentType_TraceRouteResponseType) ContentTypeConnInspectRequest = int32(edge_client_pb.ContentType_ConnInspectRequest) ContentTypeConnInspectResponse = int32(edge_client_pb.ContentType_InspectResponse) ContentTypeInspectRequest = int32(edge_client_pb.ContentType_InspectRequest) ContentTypeInspectResponse = int32(edge_client_pb.ContentType_ConnInspectResponse) ContentTypeBindSuccess = int32(edge_client_pb.ContentType_BindSuccess) ContentTypeUpdateToken = int32(edge_client_pb.ContentType_UpdateTokenType) ContentTypeUpdateTokenSuccess = int32(edge_client_pb.ContentType_UpdateTokenSuccessType) ContentTypeUpdateTokenFailure = int32(edge_client_pb.ContentType_UpdateTokenFailureType) ContentTypePostureResponse = int32(edge_client_pb.ContentType_PostureResponseType) ContentTypeXgPayload = int32(edge_client_pb.ContentType_XgPayloadType) ContentTypeXgAcknowledgement = int32(edge_client_pb.ContentType_XgAcknowledgementType) ContentTypeXgControl = int32(edge_client_pb.ContentType_XgControlType) ContentTypeXgClose = int32(edge_client_pb.ContentType_XgCloseType) )
const ( // UUIDHeader is put in the reflected range so replies will share the same UUID UUIDHeader = int32(edge_client_pb.HeaderId_UUID) ConnIdHeader = int32(edge_client_pb.HeaderId_ConnId) SeqHeader = int32(edge_client_pb.HeaderId_Seq) SessionTokenHeader = int32(edge_client_pb.HeaderId_SessionToken) PublicKeyHeader = int32(edge_client_pb.HeaderId_PublicKey) CostHeader = int32(edge_client_pb.HeaderId_Cost) PrecedenceHeader = int32(edge_client_pb.HeaderId_Precedence) TerminatorIdentityHeader = int32(edge_client_pb.HeaderId_TerminatorIdentity) TerminatorIdentitySecretHeader = int32(edge_client_pb.HeaderId_TerminatorIdentitySecret) CallerIdHeader = int32(edge_client_pb.HeaderId_CallerId) CryptoMethodHeader = int32(edge_client_pb.HeaderId_CryptoMethod) FlagsHeader = int32(edge_client_pb.HeaderId_Flags) AppDataHeader = int32(edge_client_pb.HeaderId_AppData) RouterProvidedConnId = int32(edge_client_pb.HeaderId_RouterProvidedConnId) HealthStatusHeader = int32(edge_client_pb.HeaderId_HealthStatus) ErrorCodeHeader = int32(edge_client_pb.HeaderId_ErrorCode) TimestampHeader = int32(edge_client_pb.HeaderId_Timestamp) TraceHopCountHeader = int32(edge_client_pb.HeaderId_TraceHopCount) TraceHopTypeHeader = int32(edge_client_pb.HeaderId_TraceHopType) TraceHopIdHeader = int32(edge_client_pb.HeaderId_TraceHopId) TraceSourceRequestIdHeader = int32(edge_client_pb.HeaderId_TraceSourceRequestId) TraceError = int32(edge_client_pb.HeaderId_TraceError) ListenerId = int32(edge_client_pb.HeaderId_ListenerId) ConnTypeHeader = int32(edge_client_pb.HeaderId_ConnType) SupportsInspectHeader = int32(edge_client_pb.HeaderId_SupportsInspect) SupportsBindSuccessHeader = int32(edge_client_pb.HeaderId_SupportsBindSuccess) ConnectionMarkerHeader = int32(edge_client_pb.HeaderId_ConnectionMarker) CircuitIdHeader = int32(edge_client_pb.HeaderId_CircuitId) StickinessTokenHeader = int32(edge_client_pb.HeaderId_StickinessToken) UseXgressToSdkHeader = int32(edge_client_pb.HeaderId_UseXgressToSdk) XgressCtrlIdHeader = int32(edge_client_pb.HeaderId_XgressCtrlId) XgressAddressHeader = int32(edge_client_pb.HeaderId_XgressAddress) InspectRequestValuesHeader = int32(edge_client_pb.HeaderId_InspectRequestedValues) )
const ( ErrorCodeInternal = int32(edge_client_pb.Error_Internal) ErrorCodeInvalidApiSession = int32(edge_client_pb.Error_InvalidApiSession) ErrorCodeInvalidSession = int32(edge_client_pb.Error_InvalidSession) ErrorCodeWrongSessionType = int32(edge_client_pb.Error_WrongSessionType) ErrorCodeInvalidEdgeRouterForSession = int32(edge_client_pb.Error_InvalidEdgeRouterForSession) ErrorCodeInvalidService = int32(edge_client_pb.Error_InvalidService) ErrorCodeTunnelingNotEnabled = int32(edge_client_pb.Error_TunnelingNotEnabled) ErrorCodeInvalidTerminator = int32(edge_client_pb.Error_InvalidTerminator) ErrorCodeInvalidPrecedence = int32(edge_client_pb.Error_InvalidPrecedence) ErrorCodeInvalidCost = int32(edge_client_pb.Error_InvalidCost) ErrorCodeEncryptionDataMissing = int32(edge_client_pb.Error_EncryptionDataMissing) )
const ( PrecedenceDefault = Precedence(edge_client_pb.PrecedenceValue_Default) PrecedenceRequired = Precedence(edge_client_pb.PrecedenceValue_Required) PrecedenceFailed = Precedence(edge_client_pb.PrecedenceValue_Failed) )
const ( // FIN is an edge payload flag used to signal communication ends FIN = uint32(edge_client_pb.Flag_FIN) // TRACE_UUID indicates that peer will send data messages with specially constructed UUID headers TRACE_UUID = uint32(edge_client_pb.Flag_TRACE_UUID) // MULTIPART indicates that peer can accept multipart data messages MULTIPART = uint32(edge_client_pb.Flag_MULTIPART) // STREAM indicates connection with stream semantics // this allows consolidation of payloads to lower overhead STREAM = uint32(edge_client_pb.Flag_STREAM) // MULTIPART_MSG set on data message with multiple payloads MULTIPART_MSG = uint32(edge_client_pb.Flag_MULTIPART_MSG) )
const (
ConnFlagIdxFirstMsgSent = 0
)
const InterceptV1 = "intercept.v1"
Variables ¶
var ContentTypeNames = map[int32]string{ ContentTypeConnect: "EdgeConnectType", ContentTypeStateConnected: "EdgeStateConnectedType", ContentTypeStateClosed: "EdgeStateClosedType", ContentTypeData: "EdgeDataType", ContentTypeDial: "EdgeDialType", ContentTypeDialSuccess: "EdgeDialSuccessType", ContentTypeDialFailed: "EdgeDialFailedType", ContentTypeBind: "EdgeBindType", ContentTypeUnbind: "EdgeUnbindType", ContentTypeProbe: "EdgeProbeType", ContentTypeUpdateToken: "EdgeUpdateTokenType", ContentTypeUpdateTokenSuccess: "EdgeUpdateTokenSuccessType", ContentTypeUpdateTokenFailure: "EdgeUpdateTokenFailureType", }
var ContentTypeValue = map[string]int32{ "EdgeConnectType": ContentTypeConnect, "EdgeStateConnectedType": ContentTypeStateConnected, "EdgeStateClosedType": ContentTypeStateClosed, "EdgeDataType": ContentTypeData, "EdgeDialType": ContentTypeDial, "EdgeDialSuccessType": ContentTypeDialSuccess, "EdgeDialFailedType": ContentTypeDialFailed, "EdgeBindType": ContentTypeBind, "EdgeUnbindType": ContentTypeUnbind, "EdgeProbeType": ContentTypeProbe, "EdgeUpdateTokenType": ContentTypeUpdateToken, "EdgeUpdateTokenSuccessType": ContentTypeUpdateTokenSuccess, "EdgeUpdateTokenFailureType": ContentTypeUpdateTokenFailure, }
Functions ¶
func AddAddressParsers ¶ added in v0.20.46
func AddAddressParsers()
func GetLoggerFields ¶
func NewBindMsg ¶
func NewBindMsg(connId uint32, token string, pubKey []byte, options *ListenOptions) *channel.Message
func NewConnInspectResponse ¶ added in v0.20.139
func NewConnectMsg ¶
func NewConnectMsg(connId uint32, token string, pubKey []byte, options *DialOptions) *channel.Message
func NewDataMsg ¶
func NewDialFailedMsg ¶
func NewDialMsg ¶
func NewDialSuccessMsg ¶
func NewHealthEventMsg ¶ added in v0.15.30
func NewInspectRequest ¶ added in v1.1.0
func NewInspectResponse ¶ added in v1.1.0
func NewInspectResponse(connId uint32, resp *inspect.SdkInspectResponse) (*channel.Message, error)
func NewProbeMsg ¶
func NewProbeMsg() *channel.Message
func NewStateClosedMsg ¶
func NewStateConnectedMsg ¶
func NewStateConnectedMsg(connId uint32) *channel.Message
func NewTraceRouteMsg ¶ added in v0.15.105
func NewTraceRouteResponseMsg ¶ added in v0.15.105
func NewUnbindMsg ¶
func NewUpdateBindMsg ¶
func NewUpdateBindMsg(connId uint32, token string, cost *uint16, precedence *Precedence) *channel.Message
func NewUpdateTokenFailedMsg ¶ added in v0.22.6
func NewUpdateTokenFailedMsg(err error) *channel.Message
NewUpdateTokenFailedMsg is returned in response to a token update where the token failed validation.
func NewUpdateTokenMsg ¶ added in v0.22.6
func NewUpdateTokenMsg(token []byte) *channel.Message
NewUpdateTokenMsg creates a message sent to edge routers to update the token that allows the client to stay connection. If the token is not update before the current one expires, the connection and all service connections through it will be terminated.
func NewUpdateTokenSuccessMsg ¶ added in v0.22.6
func NewUpdateTokenSuccessMsg() *channel.Message
NewUpdateTokenSuccessMsg is returned in response to a toke update where the token was accepted.
func ParseServiceConfig ¶ added in v0.19.0
func ParseServiceConfig(service *rest_model.ServiceDetail, configType string, target interface{}) (bool, error)
Types ¶
type Addr ¶
type Addr struct {
MsgCh MsgChannel
}
type BaseSdkChannel ¶ added in v1.0.0
type BaseSdkChannel struct { channel.SenderContext // contains filtered or unexported fields }
func NewBaseSdkChannel ¶ added in v1.0.0
func NewBaseSdkChannel(underlay channel.Underlay) *BaseSdkChannel
func (*BaseSdkChannel) GetChannel ¶ added in v1.0.0
func (self *BaseSdkChannel) GetChannel() channel.Channel
func (*BaseSdkChannel) GetControlSender ¶ added in v1.0.0
func (self *BaseSdkChannel) GetControlSender() channel.Sender
func (*BaseSdkChannel) GetDefaultSender ¶ added in v1.0.0
func (self *BaseSdkChannel) GetDefaultSender() channel.Sender
func (*BaseSdkChannel) GetMessageSource ¶ added in v1.0.0
func (self *BaseSdkChannel) GetMessageSource(underlay channel.Underlay) channel.MessageSourceF
func (*BaseSdkChannel) GetNextControlMsg ¶ added in v1.0.0
func (self *BaseSdkChannel) GetNextControlMsg(notifier *channel.CloseNotifier) (channel.Sendable, error)
func (*BaseSdkChannel) GetNextMsgDefault ¶ added in v1.0.0
func (self *BaseSdkChannel) GetNextMsgDefault(notifier *channel.CloseNotifier) (channel.Sendable, error)
func (*BaseSdkChannel) HandleTxFailed ¶ added in v1.0.0
func (self *BaseSdkChannel) HandleTxFailed(_ channel.Underlay, sendable channel.Sendable) bool
func (*BaseSdkChannel) HandleUnderlayAccepted ¶ added in v1.0.0
func (self *BaseSdkChannel) HandleUnderlayAccepted(ch channel.MultiChannel, underlay channel.Underlay)
func (*BaseSdkChannel) InitChannel ¶ added in v1.0.0
func (self *BaseSdkChannel) InitChannel(ch channel.MultiChannel)
func (*BaseSdkChannel) UpdateCtrlChannelAvailable ¶ added in v1.0.0
func (self *BaseSdkChannel) UpdateCtrlChannelAvailable(ch channel.MultiChannel)
type ClientConfig ¶ added in v0.17.0
type ClientConfig struct { Protocol string Hostname ZitiAddress Port int }
func (*ClientConfig) String ¶ added in v0.17.0
func (self *ClientConfig) String() string
func (*ClientConfig) ToInterceptV1Config ¶ added in v0.17.0
func (self *ClientConfig) ToInterceptV1Config() *InterceptV1Config
type CloseWriter ¶ added in v0.14.0
type CloseWriter interface {
CloseWrite() error
}
type Conn ¶
type Conn interface { ServiceConn Identifiable GetRouterId() string GetState() string CompleteAcceptSuccess() error CompleteAcceptFailed(err error) }
type ConnMux ¶ added in v1.2.6
type ConnMux[T any] interface { // Add registers a message handler for a specific connection. // The sink's ID() method determines which connection ID it handles. // Returns an error if the connection ID is already registered or if // registration fails for any other reason. // // Example: // conn := &edgeXgressConn{connId: 12345, ...} // err := mux.Add(conn) Add(sink MsgSink[T]) error // Remove unregisters the specified message handler. // This removes the connection from the multiplexer's routing table. // The method is idempotent - removing a non-existent sink is not an error. // // Example: // mux.Remove(conn) Remove(sink MsgSink[T]) // RemoveByConnId removes a connection by its ID from the multiplexer. // This is a convenience method that removes the connection without // requiring a reference to the original MsgSink. // The method is idempotent - removing a non-existent connection ID is not an error. // // Parameters: // connId - the connection ID to remove // // Example: // mux.RemoveByConnId(12345) RemoveByConnId(connId uint32) // Close shuts down the multiplexer and all managed connections. // After calling Close, the multiplexer should not accept new connections // or route any more messages. All registered message sinks will be notified // of the closure. // // This method should be called when the underlying channel is being closed // to ensure proper cleanup of all multiplexed connections. Close() // GetActiveConnIds returns a slice of all active connection IDs. // This method provides visibility into which connections are currently // being managed by the multiplexer. // // Returns: // []uint32 - slice of active connection IDs, may be empty if no connections exist // // Example: // connIds := mux.GetActiveConnIds() // fmt.Printf("Active connections: %v\n", connIds) GetActiveConnIds() []uint32 // HasConn checks if a specific connection ID is currently active. // This is useful for validation before attempting operations on a connection. // // Parameters: // connId - the connection ID to check // // Returns: // bool - true if the connection exists, false otherwise // // Example: // if mux.HasConn(12345) { // // connection exists, safe to send messages // } HasConn(connId uint32) bool // GetConnCount returns the number of active connections. // This provides a quick way to check multiplexer load without // allocating a slice of connection IDs. // // Returns: // int - number of active connections // // Example: // count := mux.GetConnCount() // if count > maxConnections { // // handle overload condition // } GetConnCount() int // GetSinks returns a snapshot of all currently active message sinks managed by this multiplexer. // This method provides access to the complete set of active connections and their associated // message handlers, indexed by their connection IDs. // // The returned map is a snapshot taken at the time of the call and will not reflect // subsequent additions or removals of connections. This method is useful for: // - Administrative operations that need to inspect all active connections // - Debugging and monitoring tools // - Broadcasting operations across all connections // - Connection lifecycle management and cleanup // // Returns: // map[uint32]MsgSink[T] - a map of connection IDs to their corresponding message sinks // // Thread Safety: This method is safe for concurrent use. // // Example: // sinks := mux.GetSinks() // for connId, sink := range sinks { // fmt.Printf("Connection %d: %v\n", connId, sink.GetData()) // } GetSinks() map[uint32]MsgSink[T] // GetNextId generates the next available connection ID for creating new connections. // This method ensures that connection IDs are unique within the multiplexer's scope // and handles ID allocation automatically. The implementation may use sequential // numbering, random generation, or other strategies to avoid collisions. // // The returned ID is guaranteed to be unique among currently active connections // and can be safely used for creating new MsgSink instances. // // Returns: // uint32 - a unique connection ID that can be used for a new connection // // Example: // connId := mux.GetNextId() // conn := &myConnection{id: connId} // mux.Add(conn) GetNextId() uint32 // TypedReceiveHandler is an embedded interface // // TypedReceiveHandler provides typed message handling capabilities for the multiplexer. // This allows the ConnMux to be registered as a message handler with the underlying // channel infrastructure, enabling automatic message routing based on message types. // // The embedded interface typically includes methods like: // - ContentType() int32 - returns the message content type this handler processes // - HandleReceive(msg *channel.Message, ch channel.Channel) - processes typed messages // // This integration allows the ConnMux to participate in the channel's message // dispatch system while maintaining its connection multiplexing functionality. channel.TypedReceiveHandler // CloseHandler is an embedded interface // // CloseHandler provides automatic cleanup capabilities when the underlying channel closes. // This ensures that all multiplexed connections are properly notified and cleaned up // when the physical channel connection is terminated. // // The embedded interface typically includes: // - HandleClose(ch channel.Channel) - called when the channel is closing // // When the channel closes, the ConnMux should: // - Notify all registered MsgSinks via their HandleMuxClose() method // - Clean up internal routing tables and connection state // - Release any held resources // // This automatic integration ensures graceful shutdown of all multiplexed // connections without requiring manual cleanup by the application. channel.CloseHandler }
ConnMux (Connection Multiplexer) manages multiple logical connections over a single channel. It provides message routing and connection lifecycle management based on connection IDs (connId).
The multiplexer enables efficient use of transport resources by allowing many application-level connections to share a single underlying channel connection. Each logical connection is identified by a unique uint32 connection ID.
Thread Safety: Implementations must be safe for concurrent use by multiple goroutines.
func NewChannelConnMapMux ¶ added in v1.2.6
type ConnMuxImpl ¶ added in v1.2.6
type ConnMuxImpl[T any] struct { // contains filtered or unexported fields }
func (*ConnMuxImpl[T]) Add ¶ added in v1.2.6
func (mux *ConnMuxImpl[T]) Add(sink MsgSink[T]) error
func (*ConnMuxImpl[T]) Close ¶ added in v1.2.6
func (mux *ConnMuxImpl[T]) Close()
func (*ConnMuxImpl[T]) ContentType ¶ added in v1.2.6
func (mux *ConnMuxImpl[T]) ContentType() int32
func (*ConnMuxImpl[T]) GetActiveConnIds ¶ added in v1.2.6
func (mux *ConnMuxImpl[T]) GetActiveConnIds() []uint32
func (*ConnMuxImpl[T]) GetConnCount ¶ added in v1.2.6
func (mux *ConnMuxImpl[T]) GetConnCount() int
func (*ConnMuxImpl[T]) GetNextId ¶ added in v1.2.6
func (mux *ConnMuxImpl[T]) GetNextId() uint32
func (*ConnMuxImpl[T]) GetSinks ¶ added in v1.2.6
func (mux *ConnMuxImpl[T]) GetSinks() map[uint32]MsgSink[T]
func (*ConnMuxImpl[T]) HandleClose ¶ added in v1.2.6
func (mux *ConnMuxImpl[T]) HandleClose(channel.Channel)
func (*ConnMuxImpl[T]) HandleInspect ¶ added in v1.2.6
func (mux *ConnMuxImpl[T]) HandleInspect(msg *channel.Message, ch channel.Channel)
func (*ConnMuxImpl[T]) HandleReceive ¶ added in v1.2.6
func (mux *ConnMuxImpl[T]) HandleReceive(msg *channel.Message, ch channel.Channel)
func (*ConnMuxImpl[T]) HasConn ¶ added in v1.2.6
func (mux *ConnMuxImpl[T]) HasConn(connId uint32) bool
func (*ConnMuxImpl[T]) Remove ¶ added in v1.2.6
func (mux *ConnMuxImpl[T]) Remove(sink MsgSink[T])
func (*ConnMuxImpl[T]) RemoveByConnId ¶ added in v1.2.6
func (mux *ConnMuxImpl[T]) RemoveByConnId(connId uint32)
type ConnOptions ¶
type CryptoMethod ¶ added in v0.13.55
type CryptoMethod byte
const ( // CryptoMethodLibsodium are used to indicate the crypto engine in use CryptoMethodLibsodium CryptoMethod = 0 // default: crypto_kx_*, crypto_secretstream_* CryptoMethodSSL CryptoMethod = 1 // OpenSSL(possibly with FIPS): ECDH, AES256-GCM )
type DialOptions ¶ added in v0.13.47
type DialOptions struct { ConnectTimeout time.Duration Identity string CallerId string AppData []byte StickinessToken []byte SdkFlowControl bool }
func (DialOptions) GetConnectTimeout ¶ added in v0.13.47
func (d DialOptions) GetConnectTimeout() time.Duration
type DialResult ¶
func UnmarshalDialResult ¶
func UnmarshalDialResult(msg *channel.Message) (*DialResult, error)
type DialSdkChannel ¶ added in v1.0.0
type DialSdkChannel struct { BaseSdkChannel // contains filtered or unexported fields }
func (*DialSdkChannel) CreateGroupedUnderlay ¶ added in v1.0.0
func (*DialSdkChannel) DialFailed ¶ added in v1.0.0
func (self *DialSdkChannel) DialFailed(_ channel.MultiChannel, _ string, attempt int)
func (*DialSdkChannel) HandleUnderlayClose ¶ added in v1.0.0
func (self *DialSdkChannel) HandleUnderlayClose(ch channel.MultiChannel, underlay channel.Underlay)
func (*DialSdkChannel) Start ¶ added in v1.0.0
func (self *DialSdkChannel) Start(channel channel.MultiChannel)
type DomainName ¶ added in v0.17.0
type DomainName string
func (DomainName) Match ¶ added in v0.17.0
func (dn DomainName) Match(hostname string) int
type Identifiable ¶
type Identifiable interface {
Id() uint32
}
type InspectResult ¶ added in v0.20.139
func UnmarshalInspectResult ¶ added in v0.20.139
func UnmarshalInspectResult(msg *channel.Message) (*InspectResult, error)
type InterceptDialOptions ¶ added in v0.19.0
type InterceptV1Config ¶ added in v0.17.0
type InterceptV1Config struct { Addresses []ZitiAddress PortRanges []*PortRange Protocols []string SourceIp *string DialOptions *InterceptDialOptions `json:"dialOptions"` Service *rest_model.ServiceDetail }
func (*InterceptV1Config) Match ¶ added in v0.17.0
func (intercept *InterceptV1Config) Match(network, hostname string, port uint16) int
Match returns the matching score of the given target address against this intercept. A negative one (-1) is returned if no match is found. If the address is matched, a 32bit integer with upper bits set to the hostname match and lower bits to port match.
type ListenOptions ¶
type ListenOptions struct { Cost uint16 Precedence Precedence ConnectTimeout time.Duration MaxTerminators int Identity string IdentitySecret string BindUsingEdgeIdentity bool ManualStart bool SdkFlowControl bool ListenerId string KeyPair *kx.KeyPair // contains filtered or unexported fields }
func NewListenOptions ¶ added in v0.21.2
func NewListenOptions() *ListenOptions
func (*ListenOptions) GetConnectTimeout ¶
func (options *ListenOptions) GetConnectTimeout() time.Duration
func (*ListenOptions) GetEventChannel ¶ added in v0.21.2
func (options *ListenOptions) GetEventChannel() chan *ListenerEvent
func (*ListenOptions) String ¶
func (options *ListenOptions) String() string
type Listener ¶
type Listener interface { net.Listener Identifiable AcceptEdge() (Conn, error) IsClosed() bool UpdateCost(cost uint16) error UpdatePrecedence(precedence Precedence) error UpdateCostAndPrecedence(cost uint16, precedence Precedence) error SendHealthEvent(pass bool) error }
type ListenerEvent ¶ added in v0.21.2
type ListenerEvent struct {
EventType ListenerEventType
}
type ListenerEventType ¶ added in v0.21.2
type ListenerEventType int
const (
ListenerEstablished ListenerEventType = 1
)
type MsgChannel ¶
type MsgChannel struct { SdkChannel // contains filtered or unexported fields }
func NewEdgeMsgChannel ¶
func NewEdgeMsgChannel(ch SdkChannel, connId uint32) *MsgChannel
func (*MsgChannel) GetRouterId ¶ added in v1.1.2
func (ec *MsgChannel) GetRouterId() string
func (*MsgChannel) Id ¶
func (ec *MsgChannel) Id() uint32
func (*MsgChannel) NextMsgId ¶ added in v0.15.0
func (ec *MsgChannel) NextMsgId() uint32
func (*MsgChannel) SendState ¶
func (ec *MsgChannel) SendState(msg *channel.Message) error
func (*MsgChannel) SetWriteDeadline ¶
func (ec *MsgChannel) SetWriteDeadline(t time.Time) error
func (*MsgChannel) TraceMsg ¶
func (ec *MsgChannel) TraceMsg(source string, msg *channel.Message)
func (*MsgChannel) WriteTraced ¶
type MsgSink ¶
type MsgSink[T any] interface { // Id returns the unique connection ID that this sink handles. // This ID is used by the ConnMux to route messages to the correct sink. // The ID must remain constant for the lifetime of the sink. // // Returns: // uint32 - the connection ID for this message sink // // Example: // connId := sink.Id() // // Use connId for routing decisions Id() uint32 // Accept processes an incoming message for this connection. // The message is guaranteed to be intended for this sink's connection ID. // The sink should handle the message appropriately based on its type and content. // // Parameters: // msg - the incoming message to process // // Example: // func (s *myMsgSink) Accept(msg *channel.Message) { // switch msg.ContentType { // case edge.ContentTypeData: // s.handleData(msg) // case edge.ContentTypeStateClosed: // s.handleClose(msg) // } // } Accept(msg *channel.Message) // HandleMuxClose is called when the underlying multiplexer is closing. // This gives the sink an opportunity to perform cleanup operations // and notify any dependent components that the connection is being terminated. // // The sink should: // - Release any held resources // - Notify dependent components of the closure // - Complete any pending operations gracefully // // Returns: // error - any error encountered during cleanup, nil if successful // // Example: // func (s *myMsgSink) HandleMuxClose() error { // s.cleanup() // return s.conn.Close() // } HandleMuxClose() error // GetData retrieves arbitrary context data associated with this connection. // This allows implementing code to store and retrieve connection-specific // context, state, or metadata that may be needed across different operations. // // The data is connection-scoped and persists for the lifetime of the MsgSink. // Returns nil if no data has been set. // // Returns: // T - the stored context data, or nil if none exists // // Example: // userData := sink.GetData() // if edgeCtx, ok := userData.(*EdgeConnContext); ok { // // Use context // } GetData() T // SetData stores arbitrary context data associated with this connection. // This allows implementing code to attach connection-specific context, // state, or metadata that can be retrieved later during the connection's lifetime. // // The data should be treated as connection-scoped and will be available // until the connection is closed or the data is overwritten. // // Parameters: // data - arbitrary context data to associate with this connection // // Example: // authCtx := &AuthContext{UserID: "user123", Permissions: perms} // sink.SetData(authCtx) // // // Later retrieve it // if ctx := sink.GetData(); ctx != nil { // edgeCtx := ctx.(*EdgeConnContext) // // Use context // } SetData(data T) }
MsgSink represents a message handler that can receive and process messages for a specific connection in a multiplexed channel. Each MsgSink is associated with a unique connection ID and handles the message flow for that logical connection.
MsgSink implementations are responsible for:
- Processing incoming messages from the multiplexer
- Providing a unique connection ID for routing
- Handling connection lifecycle events (setup, teardown)
- Managing connection-specific state and sequencing
- Storing and retrieving arbitrary context data
Thread Safety: Implementations should be safe for concurrent use, as messages may be delivered from multiple goroutines.
type Precedence ¶
type Precedence byte
type RouterClient ¶ added in v0.15.5
type RouterClient interface { Connect(service *rest_model.ServiceDetail, session *rest_model.SessionDetail, options *DialOptions, envF func() xgress.Env) (Conn, error) Listen(service *rest_model.ServiceDetail, session *rest_model.SessionDetail, options *ListenOptions, envF func() xgress.Env) (Listener, error) //UpdateToken will attempt to send token updates to the connected router. A success/failure response is expected //within the timeout period. UpdateToken(token []byte, timeout time.Duration) error }
type RouterConn ¶
type SdkChannel ¶ added in v1.0.0
type SdkChannel interface { InitChannel(channel.MultiChannel) GetChannel() channel.Channel GetDefaultSender() channel.Sender GetControlSender() channel.Sender }
func NewSingleSdkChannel ¶ added in v1.0.0
func NewSingleSdkChannel(ch channel.Channel) SdkChannel
type ServiceConn ¶ added in v0.12.0
type SessionListener ¶ added in v0.13.2
type SessionListener interface { Listener GetCurrentSession() *rest_model.SessionDetail SetConnectionChangeHandler(func(conn []Listener)) SetErrorEventHandler(func(error)) GetErrorEventHandler() func(error) }
type SingleSdkChannel ¶ added in v1.0.0
type SingleSdkChannel struct {
// contains filtered or unexported fields
}
func (*SingleSdkChannel) GetChannel ¶ added in v1.0.0
func (self *SingleSdkChannel) GetChannel() channel.Channel
func (*SingleSdkChannel) GetControlSender ¶ added in v1.0.0
func (self *SingleSdkChannel) GetControlSender() channel.Sender
func (*SingleSdkChannel) GetDefaultSender ¶ added in v1.0.0
func (self *SingleSdkChannel) GetDefaultSender() channel.Sender
func (*SingleSdkChannel) InitChannel ¶ added in v1.0.0
func (self *SingleSdkChannel) InitChannel(channel.MultiChannel)
type TraceRouteResult ¶ added in v0.15.105
type UnderlayHandlerSdkChannel ¶ added in v1.0.0
type UnderlayHandlerSdkChannel interface { SdkChannel channel.UnderlayHandler }
func NewDialSdkChannel ¶ added in v1.0.0
func NewDialSdkChannel(dialer channel.DialUnderlayFactory, underlay channel.Underlay, maxDefaultChannels, maxControlChannel int) UnderlayHandlerSdkChannel
type ZitiAddress ¶ added in v0.17.0
type ZitiAddress struct {
// contains filtered or unexported fields
}
func NewZitiAddress ¶ added in v0.17.0
func NewZitiAddress(str string) (*ZitiAddress, error)
func (*ZitiAddress) Matches ¶ added in v0.17.0
func (self *ZitiAddress) Matches(v any) int
func (*ZitiAddress) UnmarshalText ¶ added in v0.17.0
func (self *ZitiAddress) UnmarshalText(data []byte) error