connmgr

package
v1.4.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 29, 2025 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GenericConnectionChan = make(chan GenericConnection)

GenericConnectionChan is a channel that carries GenericConnection updates reflecting the state of network connections.

Functions

func LoaderModPsnet

func LoaderModPsnet(ctx context.Context) lua.LGFunction

LoaderModPsnet is a function that registers the "psnet" module in the given Lua state. It creates a new Lua table, assigns functions from exportsModPsnet to it, and pushes it onto the Lua stack. It returns 1 to indicate that one value has been pushed onto the stack.

Types

type ConnectionManager

type ConnectionManager struct {
	// contains filtered or unexported fields
}

ConnectionManager manages network connections, keeps track of targets and their connection counts, and handles synchronization.

func GetConnectionManager

func GetConnectionManager() *ConnectionManager

GetConnectionManager returns the global instance of ConnectionManager, facilitating access to network connection management.

func NewConnectionManager

func NewConnectionManager() *ConnectionManager

NewConnectionManager returns a new instance of ConnectionManager with an initialized targets map.

func (*ConnectionManager) GetCount

func (m *ConnectionManager) GetCount(target string) (int, bool)

GetCount retrieves the connection count for the specified target. Returns the count of connections and a boolean indicating if the target was found.

func (*ConnectionManager) Register

func (m *ConnectionManager) Register(ctx context.Context, target, direction string, description string)

Register adds a new target with the specified description and direction to the ConnectionManager if it does not already exist.

func (*ConnectionManager) StartMonitoring

func (m *ConnectionManager) StartMonitoring(ctx context.Context)

StartMonitoring begins monitoring IP updates at regular intervals using a ticker and a goroutine.

func (*ConnectionManager) StartTicker

func (m *ConnectionManager) StartTicker(interval time.Duration)

StartTicker launches a ticker that triggers the update of connection counts at the specified interval.

func (*ConnectionManager) UpdateCounts

func (m *ConnectionManager) UpdateCounts()

UpdateCounts refreshes the connection counts for all registered targets based on the current network connections.

type GenericConnection

type GenericConnection struct {
	// Target represents the endpoint address for a connection in the format host:port.
	Target string

	*TargetInfo
}

GenericConnection represents a connection target along with its connection count.

type TargetInfo

type TargetInfo struct {
	// Description provides a textual explanation of the target's purpose or other contextual information.
	Description string

	// Count represents the number of active connections to the target.
	Count int

	// Direction specifies the direction of the connection, indicating whether it is incoming or outgoing.
	Direction string
}

TargetInfo represents information about a target connection including its count and direction.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL