gserverlib

package
v0.0.0-...-5759212 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2022 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetClientInfoFromCtx

func GetClientInfoFromCtx(ctx context.Context) (string, string, error)

GetClientInfoFromCtx will return the bearer token string from the auth header within the ctx structure.

Types

type AdminServiceServer

type AdminServiceServer struct {
	as.UnimplementedAdminServiceServer
	// contains filtered or unexported fields
}

AdminServiceServer is a structure that implements all of the grpc functions for the AdminServiceServer

func NewAdminServiceServer

func NewAdminServiceServer(gServer *GServer) *AdminServiceServer

NewAdminServiceServer is a constructor that returns an AdminServiceServer grpc server.

func (*AdminServiceServer) ClientDisconnect

ClientDisconnect will disconnect a gClient from gServer.

func (*AdminServiceServer) ClientList

ClientList will list all configured clients for the gServer and their connection status as well as the configured ip, port, and bearer token

func (*AdminServiceServer) ClientRegister

ClientRegister will create a gClient binary and send it back in a binary stream.

func (*AdminServiceServer) ConnectionList

ConnectionList will list all the connections associated with the provided tunnel ID.

func (*AdminServiceServer) SocksStart

SocksStart will start a Socksv5 proxy server on the provided client ID

func (*AdminServiceServer) SocksStop

SocksStop will stop a SocksV5 proxy server running on the provided client ID.

func (*AdminServiceServer) Start

func (s *AdminServiceServer) Start(port int)

Start will start the grpc server

func (*AdminServiceServer) TunnelAdd

TunnelAdd adds a tunnel to an endpoint specified in the request.

func (*AdminServiceServer) TunnelDelete

TunnelDelete deletes a tunnel with the provided tunnel ID

func (*AdminServiceServer) TunnelList

TunnelList lists all tunnels associated with the provided client ID.

type ClientServiceServer

type ClientServiceServer struct {
	cs.UnimplementedClientServiceServer
	// contains filtered or unexported fields
}

func NewClientServiceServer

func NewClientServiceServer(gserver *GServer) *ClientServiceServer

func (*ClientServiceServer) CreateConnectionStream

func (s *ClientServiceServer) CreateConnectionStream(
	stream cs.ClientService_CreateConnectionStreamServer) error

CreateConnectionStream is a gRPC function that the client will call to create a bi-directional data stream to carry data that gets delivered over the TCP connection.

func (*ClientServiceServer) CreateEndpointControlStream

func (s *ClientServiceServer) CreateEndpointControlStream(
	ctrlMessage *cs.EndpointControlMessage,
	stream cs.ClientService_CreateEndpointControlStreamServer) error

CreateEndpointControl stream is a gRPC function that the client calls to establish a one way stream that the server uses to issue control messages to the remote endpoint.

func (*ClientServiceServer) CreateTunnelControlStream

func (s *ClientServiceServer) CreateTunnelControlStream(
	stream cs.ClientService_CreateTunnelControlStreamServer) error

CreateTunnelControlStream is a gRPC function that the client will call to establish a bi-directional stream to relay control messages about new and disconnected TCP connections.

func (*ClientServiceServer) GetConfigurationMessage

GetConfigurationMessage returns the client ID and kill date to a gClient based on the bearer token provided.

func (*ClientServiceServer) Start

func (s *ClientServiceServer) Start(
	port int,
	tls bool,
	certFile string,
	keyFile string)

Start starts the grpc client service.

type ConfigStore

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

ConfigStore is a structure that represents all of the configurations of the gServer and will keep state to a json file

func NewConfigStore

func NewConfigStore() *ConfigStore

func (*ConfigStore) AddConfiguredClient

func (c *ConfigStore) AddConfiguredClient(client *ConfiguredClient) error

AddConfiguredClient will take a ConfiguredClient structure and add it to the redis datastore

func (*ConfigStore) DeleteConfiguredClient

func (c *ConfigStore) DeleteConfiguredClient(key string) error

func (*ConfigStore) GetConfiguredClient

func (c *ConfigStore) GetConfiguredClient(key string) *ConfiguredClient

func (*ConfigStore) Initialize

func (c *ConfigStore) Initialize() error

type ConfiguredClient

type ConfiguredClient struct {
	Arch     string
	BinType  string
	Name     string
	Platform string
	Port     uint32
	Proxy    string
	Server   string
	Token    string
}

func NewConfiguredClient

func NewConfiguredClient(clientData map[string]interface{}) *ConfiguredClient

type ConnectedClient

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

type GServer

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

func NewGServer

func NewGServer() *GServer

NewGServer is a constructor that will initialize all gServer internal data structures and load any existing configuration files.

func (*GServer) AddConnectedClient

func (s *GServer) AddConnectedClient(uuid string, client *ConnectedClient) bool

AddConnectedClient will take in a unique ID and a ConnectedClient structure and insert them into the connectedClients map with the unique ID as the key.

func (*GServer) AddTunnel

func (s *GServer) AddTunnel(
	clientID string,
	tunnelID string,
	direction uint32,
	listenIP net.IP,
	listenPort uint32,
	destinationIP net.IP,
	destinationPort uint32) error

AddTunnel adds a tunnel to the gRPC server and then messages the gclient to perform actions on the other end.

func (*GServer) DeleteTunnel

func (s *GServer) DeleteTunnel(
	clientID string,
	tunnelID string) error

DeleteTunnel will kill all TCP connections under the tunnel and remove them from the list of managed tunnels.

func (*GServer) DisconnectEndpoint

func (s *GServer) DisconnectEndpoint(
	clientID string) error

DisconnectEndpoint will send a control message to the current endpoint to disconnect and end execution.

func (*GServer) GetClientServer

func (s *GServer) GetClientServer() *ClientServiceServer

GetClientServer gets the grpc client server

func (*GServer) GetEndpoint

func (s *GServer) GetEndpoint(clientID string) (*common.Endpoint, bool)

GetEndpoint will retreive an endpoint struct with the provided endpoint ID.

func (*GServer) RegisterClient

func (s *GServer) RegisterClient(req *ConfiguredClient) error

RegisterClient is responsible for building a client executable with the provided parameters.

func (*GServer) Start

func (s *GServer) Start(
	clientPort int,
	adminPort int,
	tls bool,
	certFile string,
	keyFile string)

Start will start the client and admin gprc servers.

func (*GServer) StartProxy

func (s *GServer) StartProxy(
	clientID string,
	socksPort uint32) error

StartProxy starts a proxy on the provided endpoint ID

func (*GServer) StopProxy

func (s *GServer) StopProxy(
	clientID string) error

StopProxy stops a proxy on the provided endpointID

func (*GServer) StreamAuthInterceptor

func (s *GServer) StreamAuthInterceptor(srv interface{},
	ss grpc.ServerStream,
	info *grpc.StreamServerInfo,
	handler grpc.StreamHandler) error

StreamAuthInterceptor will check for proper authorization for all stream based gRPC calls.

func (*GServer) UnaryAuthInterceptor

func (s *GServer) UnaryAuthInterceptor(ctx context.Context,
	req interface{},
	info *grpc.UnaryServerInfo,
	handler grpc.UnaryHandler) (interface{}, error)

UnaryAuthInterceptor is called for all unary gRPC functions to validate that the caller is authorized.

type ServerConnectionHandler

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

ServerConnectionHandler TODO

func (*ServerConnectionHandler) Acknowledge

func (s *ServerConnectionHandler) Acknowledge(tunnel *common.Tunnel,
	ctrlMessage *cs.TunnelControlMessage) common.ByteStream

Acknowledge is called when the remote client acknowledges that a tcp connection can be established on the remote side.

func (*ServerConnectionHandler) CloseStream

func (s *ServerConnectionHandler) CloseStream(tunnel *common.Tunnel, connID string)

CloseStream will kill a TCP connection locally

func (*ServerConnectionHandler) GetByteStream

func (s *ServerConnectionHandler) GetByteStream(tunnel *common.Tunnel,
	ctrlMessage *cs.TunnelControlMessage) common.ByteStream

GetByteStream will return the gRPC stream associated with a particular TCP connection.

Jump to

Keyboard shortcuts

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