proxy

package
v0.0.0-...-49ee127 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2025 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const PACKET_READ_SIZE = 1024 * 1024 // 1MB
View Source
const SOCKET_CHANNEL_CREATE_TIMEOUT = 5 * time.Second

Variables

This section is empty.

Functions

func NewStateManager

func NewStateManager(clientManager *ClientManager) *stateManager

NewStateManager creates a new state manager

Types

type ClientManager

type ClientManager struct {
	Client          *proxy.ProxyClient
	StateManager    *stateManager
	SocketManager   *SocketManager
	Initialized     bool
	ForwardingRules []*proxcom.ForwardingRule
	ProxyUrl        url.URL

	// NotificationString is displayed to the user
	// at the bottom of the panel. put error messages here.
	// This is important to use, as normal logging will corrupt the display.
	NotificationString string
}

func NewClientManager

func NewClientManager(client *proxy.ProxyClient, forwardingRules []*proxcom.ForwardingRule, proxyUrl url.URL, debugPackets bool) *ClientManager

NewClientManager creates a new client manager

func (*ClientManager) AllForwardingRules

func (manager *ClientManager) AllForwardingRules() []*proxcom.ForwardingRule

AllForwardingRules returns all forwarding rules for this client and all remote clients

func (*ClientManager) AllForwardingRulesTargetingClient

func (manager *ClientManager) AllForwardingRulesTargetingClient(clientName string) []*proxcom.ForwardingRule

AllForwardingRulesTargetingClient returns all forwarding rules that target a specific client @param clientName the name of the client we are looking for rules targeting

func (*ClientManager) AllRulesTargetingUs

func (manager *ClientManager) AllRulesTargetingUs() []*proxcom.ForwardingRule

AllRulesTargetingUs returns all forwarding rules that target this client

func (*ClientManager) Close

func (manager *ClientManager) Close()

Close closes the client manager

func (*ClientManager) GetChannelMemberInfo

func (manager *ClientManager) GetChannelMemberInfo() *proxcom.ChannelMember

GetChannelMemberInfo returns the channel member info for THIS client

func (*ClientManager) ListenOnAllForwardingRules

func (manager *ClientManager) ListenOnAllForwardingRules()

func (*ClientManager) ReconnectToProxyServer

func (manager *ClientManager) ReconnectToProxyServer()

ReconnectToProxyServer attempts to reconnect this client to the proxy server IT WILL TRY FOREVER, until it succeeds or the user kills the program

func (*ClientManager) Start

func (manager *ClientManager) Start()

Start starts the client manager

func (*ClientManager) WaitForInitialization

func (manager *ClientManager) WaitForInitialization()

type SocketManager

type SocketManager struct {
	ClientManager *ClientManager
	Listeners     []*net.TCPListener
	// map, channel id -> socket
	Sockets map[string][]*net.TCPConn
	Closed  bool

	// metrics
	Rx                       uint64
	Tx                       uint64
	BytesSentAccumulator     uint64
	BytesReceivedAccumulator uint64
	// contains filtered or unexported fields
}

func NewSocketManager

func NewSocketManager(clientManager *ClientManager, debugPackets bool) *SocketManager

NewSocketManager creates a new socket manager

func (*SocketManager) AddChannelSocket

func (socketManager *SocketManager) AddChannelSocket(channelId string, conn *net.TCPConn)

AddChannelSocket adds a socket to the socket manager linked to a channel

func (*SocketManager) Close

func (socketManager *SocketManager) Close()

Close closes the socket manager. Closing all listeners and sockets

func (*SocketManager) ConnectOutbound

func (socketManager *SocketManager) ConnectOutbound(socketChannel proxcom.CreateSocketChannelPacket)

ConnectOutbound connects to the server on the specified port in the forwarding rule

func (*SocketManager) DisconnectSocketChannel

func (socketManager *SocketManager) DisconnectSocketChannel(channelId string) error

DisconnectSocketChannel disconnects a socket channel internally and sends a disconnect packet to the server @param channelId the id of the channel to disconnect @return an error if one occurred

func (*SocketManager) DisconnectSocketChannelInternal

func (socketManager *SocketManager) DisconnectSocketChannelInternal(channelId string) error

DisconnectSocketChannelInternal disconnects a socket channel internally @param channelId the id of the channel to disconnect @return an error if one occurred

func (*SocketManager) EstablishSocketChannel

func (socketManager *SocketManager) EstablishSocketChannel(rule *proxcom.ForwardingRule) (string, error)

EstablishSocketChannel establishes a socket channel with the server This channel is used to proxy packets between the source and sink defined in the forwarding rule

func (*SocketManager) Listen

func (socketManager *SocketManager) Listen(port int, tcpType string, rule *proxcom.ForwardingRule)

Listen starts the socket manager listening on the specified port @param port the port to listen on @param tcpType the type of tcp to listen on, can be either "tcp" or "tcp4" or "tcp6"

func (*SocketManager) RecordBytesReceived

func (socketManager *SocketManager) RecordBytesReceived(received uint64)

RecordBytesReceived records the number of bytes received for metrics @param received the number of bytes received

func (*SocketManager) RecordBytesSent

func (socketManager *SocketManager) RecordBytesSent(sent uint64)

RecordBytesSent records the number of bytes sent for metrics @param sent the number of bytes sent

func (*SocketManager) SendDataToSocket

func (socketManager *SocketManager) SendDataToSocket(packet *proxy.Packet) error

SendDataToSocket sends data in the packet to a socket based on active socket channels @param packet the packet to send @return an error if one occurred

func (*SocketManager) Start

func (socketManager *SocketManager) Start()

func (*SocketManager) UpdateMetricsRoutine

func (socketManager *SocketManager) UpdateMetricsRoutine()

UpdateMetrics updates the metrics for the socket manager, Tx and Rx every second

Jump to

Keyboard shortcuts

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