Documentation
¶
Index ¶
- Constants
- Variables
- type Mux
- func (m *Mux) Accept() (net.Conn, error)
- func (m *Mux) Addr() net.Addr
- func (m *Mux) Close() error
- func (m *Mux) DialContext(ctx context.Context) (net.Conn, error)
- func (m *Mux) ExportSessionInfoList() *appctlpb.SessionInfoList
- func (m *Mux) SetClientDNSConfig(clientDNSConfig *apicommon.ClientDNSConfig) *Mux
- func (m *Mux) SetClientMultiplexFactor(n int) *Mux
- func (m *Mux) SetClientUserNamePassword(username string, password []byte) *Mux
- func (m *Mux) SetDialer(dialer apicommon.Dialer) *Mux
- func (m *Mux) SetEndpoints(endpoints []UnderlayProperties) *Mux
- func (m *Mux) SetPacketDialer(packetDialer apicommon.PacketDialer) *Mux
- func (m *Mux) SetPacketListenerFactory(listenerFactory apicommon.PacketListenerFactory) *Mux
- func (m *Mux) SetResolver(resolver apicommon.DNSResolver) *Mux
- func (m *Mux) SetServerTCPIdleTimeout(timeout time.Duration) *Mux
- func (m *Mux) SetServerUserHintIsMandatory(userHintIsMandatory bool) *Mux
- func (m *Mux) SetServerUsers(users map[string]*appctlpb.User) *Mux
- func (m *Mux) SetStreamListenerFactory(listenerFactory apicommon.StreamListenerFactory) *Mux
- func (m *Mux) SetTrafficPattern(trafficPattern *trafficpattern.Config) *Mux
- func (m *Mux) Start() error
- func (m *Mux) UpdateEndpoints(endpoints []UnderlayProperties) error
- type PacketUnderlay
- func (b *PacketUnderlay) Accept() (net.Conn, error)
- func (u *PacketUnderlay) AddSession(s *Session, remoteAddr net.Addr) error
- func (b *PacketUnderlay) Addr() net.Addr
- func (u *PacketUnderlay) Close() error
- func (b *PacketUnderlay) Done() chan struct{}
- func (b *PacketUnderlay) InBytes() int64
- func (u *PacketUnderlay) LocalAddr() net.Addr
- func (b *PacketUnderlay) MTU() int
- func (b *PacketUnderlay) OutBytes() int64
- func (u *PacketUnderlay) RemoteAddr() net.Addr
- func (b *PacketUnderlay) RemoveSession(s *Session) error
- func (u *PacketUnderlay) RunEventLoop(ctx context.Context) error
- func (b *PacketUnderlay) Scheduler() *ScheduleController
- func (b *PacketUnderlay) SessionCount() int
- func (b *PacketUnderlay) SessionInfos() []*appctlpb.SessionInfo
- func (u *PacketUnderlay) String() string
- func (u *PacketUnderlay) TransportProtocol() common.TransportProtocol
- type ScheduleController
- func (c *ScheduleController) DecPending()
- func (c *ScheduleController) DisableTime() time.Time
- func (c *ScheduleController) Idle() bool
- func (c *ScheduleController) IncPending() (ok bool)
- func (c *ScheduleController) IsDisabled() bool
- func (c *ScheduleController) SetRemainingTime(d time.Duration)
- func (c *ScheduleController) TryDisableIdle() (ok bool)
- type Session
- func (s *Session) Close() error
- func (s *Session) LocalAddr() net.Addr
- func (s *Session) Read(b []byte) (n int, err error)
- func (s *Session) RemoteAddr() net.Addr
- func (s *Session) SetDeadline(t time.Time) error
- func (s *Session) SetReadDeadline(t time.Time) error
- func (s *Session) SetWriteDeadline(t time.Time) error
- func (s *Session) String() string
- func (s *Session) ToSessionInfo() *appctlpb.SessionInfo
- func (s *Session) UserName() string
- func (s *Session) Write(b []byte) (n int, err error)
- type StreamUnderlay
- func (b *StreamUnderlay) Accept() (net.Conn, error)
- func (t *StreamUnderlay) AddSession(s *Session, remoteAddr net.Addr) error
- func (t *StreamUnderlay) Addr() net.Addr
- func (t *StreamUnderlay) Close() error
- func (b *StreamUnderlay) Done() chan struct{}
- func (b *StreamUnderlay) InBytes() int64
- func (t *StreamUnderlay) LocalAddr() net.Addr
- func (b *StreamUnderlay) MTU() int
- func (b *StreamUnderlay) OutBytes() int64
- func (t *StreamUnderlay) RemoteAddr() net.Addr
- func (b *StreamUnderlay) RemoveSession(s *Session) error
- func (t *StreamUnderlay) RunEventLoop(ctx context.Context) error
- func (b *StreamUnderlay) Scheduler() *ScheduleController
- func (b *StreamUnderlay) SessionCount() int
- func (b *StreamUnderlay) SessionInfos() []*appctlpb.SessionInfo
- func (t *StreamUnderlay) String() string
- func (t *StreamUnderlay) TransportProtocol() common.TransportProtocol
- type Underlay
- type UnderlayProperties
Constants ¶
const ( // Number of bytes used by metadata before encryption. MetadataLength = 32 // Maximum payload that cat be attached to open session request and open session response. MaxSessionOpenPayload = 1024 )
Variables ¶
var ( UnderlayMaxConn = metrics.RegisterMetric("underlay", "MaxConn", metrics.GAUGE) UnderlayActiveOpens = metrics.RegisterMetric("underlay", "ActiveOpens", metrics.COUNTER) UnderlayPassiveOpens = metrics.RegisterMetric("underlay", "PassiveOpens", metrics.COUNTER) UnderlayCurrEstablished = metrics.RegisterMetric("underlay", "CurrEstablished", metrics.GAUGE) UnderlayMalformedUDP = metrics.RegisterMetric("underlay", "UnderlayMalformedUDP", metrics.COUNTER) UnderlayUnsolicitedUDP = metrics.RegisterMetric("underlay", "UnsolicitedUDP", metrics.COUNTER) )
Functions ¶
This section is empty.
Types ¶
type Mux ¶
type Mux struct {
// contains filtered or unexported fields
}
Mux manages the sessions and underlays.
func (*Mux) DialContext ¶
DialContext returns a network connection for the client to consume. The connection may be a session established from an existing underlay.
func (*Mux) ExportSessionInfoList ¶ added in v3.12.0
func (m *Mux) ExportSessionInfoList() *appctlpb.SessionInfoList
func (*Mux) SetClientDNSConfig ¶ added in v3.26.0
func (m *Mux) SetClientDNSConfig(clientDNSConfig *apicommon.ClientDNSConfig) *Mux
SetClientDNSConfig updates the client DNS configuration used by the mux.
func (*Mux) SetClientMultiplexFactor ¶
SetClientMultiplexFactor panics if the mux is already started.
func (*Mux) SetClientUserNamePassword ¶
SetClientUserNamePassword panics if the mux is already started.
func (*Mux) SetEndpoints ¶
func (m *Mux) SetEndpoints(endpoints []UnderlayProperties) *Mux
SetEndpoints updates the endpoints that mux is listening to. If mux is started and new endpoints are added, mux also starts to listen to those new endpoints. In that case, old endpoints are not impacted. Listener failures are logged. Use UpdateEndpoints to receive the errors.
func (*Mux) SetPacketDialer ¶ added in v3.23.0
func (m *Mux) SetPacketDialer(packetDialer apicommon.PacketDialer) *Mux
SetPacketDialer updates the packet dialer used by the mux.
func (*Mux) SetPacketListenerFactory ¶ added in v3.22.0
func (m *Mux) SetPacketListenerFactory(listenerFactory apicommon.PacketListenerFactory) *Mux
SetPacketListenerFactory updates the packet oriented network listener factory used by the mux.
func (*Mux) SetResolver ¶ added in v3.8.0
func (m *Mux) SetResolver(resolver apicommon.DNSResolver) *Mux
SetResolver updates the DNS resolver used by the mux.
func (*Mux) SetServerTCPIdleTimeout ¶ added in v3.39.0
SetServerTCPIdleTimeout sets how long a server TCP underlay can be idle in both directions before it is closed. Zero disables the timeout. Changes apply to existing and new underlays at the next maintenance cycle.
func (*Mux) SetServerUserHintIsMandatory ¶ added in v3.31.0
SetServerUserHintIsMandatory atomically sets whether the user hint is mandatory.
func (*Mux) SetServerUsers ¶
SetServerUsers builds and atomically updates the registered users.
func (*Mux) SetStreamListenerFactory ¶ added in v3.22.0
func (m *Mux) SetStreamListenerFactory(listenerFactory apicommon.StreamListenerFactory) *Mux
SetStreamListenerFactory updates the stream oriented network listener factory used by the mux.
func (*Mux) SetTrafficPattern ¶ added in v3.28.0
func (m *Mux) SetTrafficPattern(trafficPattern *trafficpattern.Config) *Mux
SetTrafficPattern updates the traffic pattern configuration used by the mux.
func (*Mux) Start ¶
Start listens on all the server addresses for incoming connections. Call this method in client results in an error. Mux is automatically closed when accept underlay fails.
func (*Mux) UpdateEndpoints ¶ added in v3.37.0
func (m *Mux) UpdateEndpoints(endpoints []UnderlayProperties) error
UpdateEndpoints updates the configured endpoints before startup or on a client. On a running server, it adds listeners while retaining all existing endpoints. It returns listener errors without stopping the mux. Successful additions remain active even if another endpoint fails; failed endpoints can be retried.
type PacketUnderlay ¶ added in v3.8.0
type PacketUnderlay struct {
// contains filtered or unexported fields
}
func NewPacketUnderlay ¶ added in v3.8.0
func NewPacketUnderlay( ctx context.Context, packetDialer apicommon.PacketDialer, resolver apicommon.DNSResolver, network string, addr string, mtu int, block cipher.BlockCipher, trafficPattern *appctlpb.TrafficPattern, ) (*PacketUnderlay, error)
NewPacketUnderlay connects to the remote address "addr" on the network with packet encryption. "block" is the block encryption algorithm to encrypt packets.
This function is only used by proxy client.
func (*PacketUnderlay) AddSession ¶ added in v3.8.0
func (u *PacketUnderlay) AddSession(s *Session, remoteAddr net.Addr) error
func (*PacketUnderlay) Close ¶ added in v3.8.0
func (u *PacketUnderlay) Close() error
func (*PacketUnderlay) LocalAddr ¶ added in v3.8.0
func (u *PacketUnderlay) LocalAddr() net.Addr
func (*PacketUnderlay) RemoteAddr ¶ added in v3.8.0
func (u *PacketUnderlay) RemoteAddr() net.Addr
func (*PacketUnderlay) RemoveSession ¶ added in v3.8.0
func (*PacketUnderlay) RunEventLoop ¶ added in v3.8.0
func (u *PacketUnderlay) RunEventLoop(ctx context.Context) error
func (*PacketUnderlay) Scheduler ¶ added in v3.8.0
func (b *PacketUnderlay) Scheduler() *ScheduleController
func (*PacketUnderlay) SessionCount ¶ added in v3.8.0
func (b *PacketUnderlay) SessionCount() int
func (*PacketUnderlay) SessionInfos ¶ added in v3.12.0
func (b *PacketUnderlay) SessionInfos() []*appctlpb.SessionInfo
func (*PacketUnderlay) String ¶ added in v3.8.0
func (u *PacketUnderlay) String() string
func (*PacketUnderlay) TransportProtocol ¶ added in v3.8.0
func (u *PacketUnderlay) TransportProtocol() common.TransportProtocol
type ScheduleController ¶
type ScheduleController struct {
// contains filtered or unexported fields
}
ScheduleController controls scheduling a new client session to a underlay.
func (*ScheduleController) DecPending ¶
func (c *ScheduleController) DecPending()
DecPending decreases the number of pending sessions by 1.
func (*ScheduleController) DisableTime ¶ added in v3.24.0
func (c *ScheduleController) DisableTime() time.Time
DisableTime returns the underlay disable time.
func (*ScheduleController) Idle ¶
func (c *ScheduleController) Idle() bool
Idle returns true if the scheduling has been disabled for the given interval.
func (*ScheduleController) IncPending ¶
func (c *ScheduleController) IncPending() (ok bool)
IncPending increases the number of pending sessions by 1. The number of pending sessions can't increase if the scheduler is disabled.
func (*ScheduleController) IsDisabled ¶
func (c *ScheduleController) IsDisabled() bool
IsDisabled returns true if scheduling new sessions to the underlay is disabled.
func (*ScheduleController) SetRemainingTime ¶
func (c *ScheduleController) SetRemainingTime(d time.Duration)
SetRemainingTime unconditionally disables the scheduler after the given duration. Do nothing if the scheduler has already been disabled.
func (*ScheduleController) TryDisableIdle ¶ added in v3.24.0
func (c *ScheduleController) TryDisableIdle() (ok bool)
TryDisableIdle tries to disable scheduling new sessions on idle underlay.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
func NewSession ¶
func NewSession(id uint32, isClient bool, mtu int, users map[string]*appctlpb.User, trafficPattern *appctlpb.TrafficPattern) *Session
NewSession creates a new session.
func (*Session) Read ¶
Read lets a user to read data from receive queue. Read is allowed even after the session has been closed.
func (*Session) RemoteAddr ¶
func (*Session) SetDeadline ¶
SetDeadline implements net.Conn.
func (*Session) SetReadDeadline ¶
SetReadDeadline implements net.Conn.
func (*Session) SetWriteDeadline ¶
SetWriteDeadline implements net.Conn.
func (*Session) ToSessionInfo ¶
func (s *Session) ToSessionInfo() *appctlpb.SessionInfo
ToSessionInfo creates related SessionInfo protobuf object.
type StreamUnderlay ¶ added in v3.8.0
type StreamUnderlay struct {
// contains filtered or unexported fields
}
func NewStreamUnderlay ¶ added in v3.8.0
func NewStreamUnderlay( ctx context.Context, dialer apicommon.Dialer, resolver apicommon.DNSResolver, dnsConfig *apicommon.ClientDNSConfig, network string, addr string, mtu int, block cipher.BlockCipher, trafficPattern *appctlpb.TrafficPattern, ) (*StreamUnderlay, error)
NewStreamUnderlay connects to the remote address "addr" on the network with packet encryption. "block" is the block encryption algorithm to encrypt packets.
This function is only used by proxy client.
func (*StreamUnderlay) AddSession ¶ added in v3.8.0
func (t *StreamUnderlay) AddSession(s *Session, remoteAddr net.Addr) error
func (*StreamUnderlay) Addr ¶ added in v3.8.0
func (t *StreamUnderlay) Addr() net.Addr
func (*StreamUnderlay) Close ¶ added in v3.8.0
func (t *StreamUnderlay) Close() error
func (*StreamUnderlay) LocalAddr ¶ added in v3.8.0
func (t *StreamUnderlay) LocalAddr() net.Addr
func (*StreamUnderlay) RemoteAddr ¶ added in v3.8.0
func (t *StreamUnderlay) RemoteAddr() net.Addr
func (*StreamUnderlay) RemoveSession ¶ added in v3.8.0
func (*StreamUnderlay) RunEventLoop ¶ added in v3.8.0
func (t *StreamUnderlay) RunEventLoop(ctx context.Context) error
func (*StreamUnderlay) Scheduler ¶ added in v3.8.0
func (b *StreamUnderlay) Scheduler() *ScheduleController
func (*StreamUnderlay) SessionCount ¶ added in v3.8.0
func (b *StreamUnderlay) SessionCount() int
func (*StreamUnderlay) SessionInfos ¶ added in v3.12.0
func (b *StreamUnderlay) SessionInfos() []*appctlpb.SessionInfo
func (*StreamUnderlay) String ¶ added in v3.8.0
func (t *StreamUnderlay) String() string
func (*StreamUnderlay) TransportProtocol ¶ added in v3.8.0
func (t *StreamUnderlay) TransportProtocol() common.TransportProtocol
type Underlay ¶
type Underlay interface {
// Accept incoming sessions.
net.Listener
// Store basic network properties.
UnderlayProperties
// Add a session to the underlay connection.
// Optionally, the remote network address can be specified for the session.
// The session is ready to use when this returns.
AddSession(*Session, net.Addr) error
// Remove a session from the underlay connection.
// The session is destroyed when this returns.
RemoveSession(*Session) error
// Returns the number of sessions.
SessionCount() int
// Returns detailed information of all the sessions.
SessionInfos() []*appctlpb.SessionInfo
// Number of bytes received from the network.
InBytes() int64
// Number of bytes sent to the network.
OutBytes() int64
// Run event loop.
// The underlay needs to be closed when this returns.
RunEventLoop(context.Context) error
// Return the schedule controller.
Scheduler() *ScheduleController
// Indicate the underlay is closed.
Done() chan struct{}
}
Underlay contains methods implemented by a underlay network connection.
type UnderlayProperties ¶
type UnderlayProperties interface {
// Maximum transission unit of this network connection
// in the current network layer.
MTU() int
// The transport protocol used to implement the underlay.
TransportProtocol() common.TransportProtocol
// LocalAddr implements net.Conn interface.
LocalAddr() net.Addr
// RemoteAddr implements net.Conn interface.
RemoteAddr() net.Addr
}
UnderlayProperties defines network properties of a underlay.
func NewUnderlayProperties ¶
func NewUnderlayProperties(mtu int, transportProtocol common.TransportProtocol, localAddr net.Addr, remoteAddr net.Addr) UnderlayProperties
NewUnderlayProperties creates a new instance of UnderlayProperties.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package serveruser authenticates server users and caches successful source-to-user associations.
|
Package serveruser authenticates server users and caches successful source-to-user associations. |