Documentation ¶
Index ¶
- Constants
- func GenerateString(length int) string
- func GenerateToken() (string, error)
- func Int32ToIP(i uint32) net.IP
- func IpToInt32(ip net.IP) uint32
- type ByteStream
- type Connection
- type ConnectionStreamHandler
- type Endpoint
- type SocksServer
- type TokenAuth
- type Tunnel
- func (t *Tunnel) AddConnection(c *Connection)
- func (t *Tunnel) AddListener(clientID string) bool
- func (t *Tunnel) GetConnection(connID string) *Connection
- func (t *Tunnel) GetConnections() map[string]*Connection
- func (t *Tunnel) GetControlStream() TunnelControlStream
- func (t *Tunnel) GetDestinationIP() net.IP
- func (t *Tunnel) GetDestinationPort() uint32
- func (t *Tunnel) GetDirection() uint32
- func (t *Tunnel) GetListenIP() net.IP
- func (t *Tunnel) GetListenPort() uint32
- func (t *Tunnel) RemoveConnection(connID string)
- func (t *Tunnel) SetControlStream(s TunnelControlStream)
- func (t *Tunnel) Start()
- func (t *Tunnel) Stop()
- type TunnelControlStream
Constants ¶
const ( // BearerString is the string used to designate an auth token BearerString = "Bearer " // MaxTokenSize is the maximum number of characters for a bearer token MaxTokenSize = 48 // MinTokenSize is the minimum number of characters for a bearer token MinTokenSize = 32 )
const ( EndpointCtrlDisconnect = iota EndpointCtrlAddRTunnel EndpointCtrlAddTunnel EndpointCtrlSocksProxy EndpointCtrlSocksProxyAck EndpointCtrlSocksKill EndpointCtrlDeleteTunnel )
const ( TunnelDirectionForward = iota TunnelDirectionReverse )
const ( TunnelCtrlConnect = iota TunnelCtrlAck TunnelCtrlDisconnect )
const ( ConnectionStatusCreated = iota ConnectionStatusConnected ConnectionStatusClosed )
const ClientIDSize = 8
ClientIDSize is the constant used for the string size of a generated client ID
const TunnelIDSize = 8
TunnelIDSize is the constant used for the string size of a generated tunnel ID
Variables ¶
This section is empty.
Functions ¶
func GenerateString ¶
GenerateString will generate a random string of length Credit to: https://www.calhoun.io/creating-random-strings-in-go/
func GenerateToken ¶
GenerateToken will generate a random string to be used as a client authorization.
Types ¶
type ByteStream ¶
type ByteStream interface { Send(*cs.BytesMessage) error Recv() (*cs.BytesMessage, error) }
type Connection ¶
type Connection struct { ID string TCPConn net.TCPConn Kill chan bool Status int32 Connected chan bool // contains filtered or unexported fields }
A structure to handle the TCP connection and map them to the gRPC byte stream.
func NewConnection ¶
func NewConnection(tcpConn net.TCPConn) *Connection
NewConnection is a constructor function for Connection.
func (*Connection) Close ¶
func (c *Connection) Close()
Close will close a TCP connection and close the Kill channel.
func (*Connection) GetStream ¶
func (c *Connection) GetStream() ByteStream
GetStream will return the byteStream for a connection
func (*Connection) SendCloseMessage ¶
func (c *Connection) SendCloseMessage()
SendCloseMessage will send a zero sized message to the remote endpoint, indicating that a TCP connection has been closed locally.
func (*Connection) SetStream ¶
func (c *Connection) SetStream(s ByteStream)
SetStream will set the byteStream for a connection
func (*Connection) Start ¶
func (c *Connection) Start()
Start will start two goroutines for handling the TCP socket and the gRPC stream.
type ConnectionStreamHandler ¶
type ConnectionStreamHandler interface { GetByteStream(tunnel *Tunnel, ctrlMessage *cs.TunnelControlMessage) ByteStream CloseStream(tunnel *Tunnel, connID string) Acknowledge(tunnel *Tunnel, ctrlMessage *cs.TunnelControlMessage) ByteStream }
type Endpoint ¶
type Endpoint struct { Id string // contains filtered or unexported fields }
func NewEndpoint ¶
func NewEndpoint() *Endpoint
NewEndpoint is a constructor for the endpoint class. It takes an endpoint ID string as an argument.
func (*Endpoint) AddTunnel ¶
AddTunnel adds a tunnel instance to the list of tunnels maintained by the endpoint
func (*Endpoint) GetTunnel ¶
GetTunnel will take in a tunnel ID string as an argument and return a Tunnel pointer of the corresponding ID.
func (*Endpoint) GetTunnels ¶
GetTunnels returns all of the active tunnels maintained by the endpoint
func (*Endpoint) Stop ¶
func (e *Endpoint) Stop()
Stop will close all tunnels and the associated TCP connections with each tunnel.
func (*Endpoint) StopAndDeleteTunnel ¶
StopAndDeleteTunnel takes in a tunnelID as an argument and removes the tunnel from the endpoint. Returns true if successful and false otherwise.
type SocksServer ¶
type SocksServer struct {
// contains filtered or unexported fields
}
SocksServer is a structure that handles starting and stopping a socks v5 proxy on the gClient.
func NewSocksServer ¶
func NewSocksServer(port uint32) *SocksServer
NewSocksServer is a constructor for the SocksServer struct. It takes in a port as an argument, wich will be the port on which the socks server listens.
func (*SocksServer) Start ¶
func (s *SocksServer) Start() bool
Start will start the socks server. Simple enough.
type TokenAuth ¶
type TokenAuth struct {
// contains filtered or unexported fields
}
TokenAuth is a structure repesenting a bearer token for client auth
func NewToken ¶
NewToken will generate a new TokenAuth structure with the provided string set to the token member.
func (*TokenAuth) GetRequestMetadata ¶
func (t *TokenAuth) GetRequestMetadata(ctx context.Context, in ...string) ( map[string]string, error)
GetRequestMetadata will return the bearer token as an authorization header
func (*TokenAuth) RequireTransportSecurity ¶
RequireTransportSecurity always returns true
type Tunnel ¶
type Tunnel struct { Kill chan bool ConnectionHandler ConnectionStreamHandler // contains filtered or unexported fields }
func NewTunnel ¶
func NewTunnel(id string, direction uint32, listenIP net.IP, listenPort uint32, destinationIP net.IP, destinationPort uint32) *Tunnel
NewTunnel is a constructor for the tunnel struct. It takes in id, direction, listenIP, lisetnPort, destinationIP, and destinationPort as parameters.
func (*Tunnel) AddConnection ¶
func (t *Tunnel) AddConnection(c *Connection)
Addconnection will generate an ID for the connection and add it to the map.
func (*Tunnel) AddListener ¶
AddListener will start a tcp listener on a specific port and forward all accepted TCP connections to the associated tunnel.
func (*Tunnel) GetConnection ¶
func (t *Tunnel) GetConnection(connID string) *Connection
GetConnection will return a Connection object with the given connection id
func (*Tunnel) GetConnections ¶
func (t *Tunnel) GetConnections() map[string]*Connection
GetConnections will return the connection map
func (*Tunnel) GetControlStream ¶
func (t *Tunnel) GetControlStream() TunnelControlStream
GetControlStream will return the control stream for the associated tunnel
func (*Tunnel) GetDestinationIP ¶
GetDestinationIP gets the destination IP of the tunnel.
func (*Tunnel) GetDestinationPort ¶
GetDestinationPort gets the destination port of the tunnel.
func (*Tunnel) GetDirection ¶
GetDirection gets the direction of the tunnel (forward or reverse)
func (*Tunnel) GetListenIP ¶
GetListenIP gets the ip address that the tunnel is listening on.
func (*Tunnel) GetListenPort ¶
GetListenPort gets the port that the tunnel is listening on.
func (*Tunnel) RemoveConnection ¶
RemoveConnection will remove the Connection object from the connections map.
func (*Tunnel) SetControlStream ¶
func (t *Tunnel) SetControlStream(s TunnelControlStream)
SetControlStream will set the provided control stream for the associated tunnel
type TunnelControlStream ¶
type TunnelControlStream interface { Send(*cs.TunnelControlMessage) error Recv() (*cs.TunnelControlMessage, error) }