agent

package
v0.0.0-...-b19f0a7 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2019 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TaskTypeSocks = iota
	//TaskTypeUpdateConfig
	//TaskTypeVpn
	TaskTypePing
)

Variables

This section is empty.

Functions

func GenerateRandomBytes

func GenerateRandomBytes(n int) ([]byte, error)

GenerateRandomBytes returns securely generated random bytes. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.

func GenerateRandomString

func GenerateRandomString(s int) string

GenerateRandomString returns a URL-safe, base64 encoded securely generated random string. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.

func GenerateSocks5Req

func GenerateSocks5Req(task *TaskInfo) *socks5.Request

func ReadBytes

func ReadBytes(r io.Reader, count int) ([]byte, error)

func ReadShortString

func ReadShortString(r io.Reader) (string, error)

func ReadString

func ReadString(r io.Reader) (string, error)

func ReadUint32

func ReadUint32(r io.Reader) (uint32, error)

func ReadUint8

func ReadUint8(r io.Reader) (uint8, error)

func WriteShortString

func WriteShortString(w io.Writer, str string) error

func WriteString

func WriteString(w io.Writer, str string) error

Types

type AgentConfig

type AgentConfig struct {
	Servers              []ListenerConfig `json:"servers"`
	Connections          []TetherConfig   `json:"tethers"`
	NetworkConfiguration ClientConfig     `json:"netConf"`
	Proxy                *ProxyInfo       `json:"proxy,omitempty"`
	NumConnsPerTether    int              `json:"numConnsPerTether"`
}

type ClientConfig

type ClientConfig struct {
	Secret   string            `json:"secret"`
	ClientId string            `json:"clientId"`
	Mapping  map[string]string `json:"networkMapping"` // "<ip or domain>" : "<clientId>"
}

type IMux

type IMux interface {
	Open() (net.Conn, error)
	Accept() (net.Conn, error)
	AddConnection(c io.ReadWriteCloser)
}

type ListenerConfig

type ListenerConfig struct {
	Port              int               `json:"port"`
	Type              string            `json:"type"`
	LocalOnly         bool              `json:"acceptLocalOnly"`
	UseAuthentication bool              `json:"useAuthentication"`
	AuthorizedClients map[string]string `json:"authClients"`
}

type MultiMux

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

MultiMux is a client for multiple mux channels, it presents a facade which makes multiple channels seem like one channel

func NewMultiMux

func NewMultiMux(isClient bool) *MultiMux

NewMultiMux creates a new multi connection mux

func (*MultiMux) Accept

func (m *MultiMux) Accept() (net.Conn, error)

Accept returns an incoming client connection or waits until one is initiated

func (*MultiMux) AddConnection

func (m *MultiMux) AddConnection(c io.ReadWriteCloser)

AddConnection adds a connection to the multi-mux

func (*MultiMux) Open

func (m *MultiMux) Open() (net.Conn, error)

type ProxyInfo

type ProxyInfo struct {
	Address string `json:"address"`
	User    string `json:"user"`
	Pass    string `json:"pass"`
}

type Router

type Router struct {
	NetworkConfig *ClientConfig

	AuthenticateSocks5 bool
	Proxy              *ProxyInfo
	// contains filtered or unexported fields
}

Router holds all connections for the current snap-node, along with the network configuration & routing logic it recieves network connections and routes them to the correct destination

func NewRouter

func NewRouter() *Router

func (*Router) Connect

func (rtr *Router) Connect(connConf *TetherConfig, numConnsPerTether int) error

Connect creates a new bundle of physical connections to the server (AKA: thether)

func (*Router) Serve

func (rtr *Router) Serve(serverConf ListenerConfig) error

Serve creates a listener of given type and runs it on the given port

type TaskInfo

type TaskInfo struct {
	Type          TaskType
	TargetAddress string //final target address (intermediate steps decided by network configurations)
	TargetPort    string
	Local         bool // indicates whether or not the message passed over a relay
}

type TaskType

type TaskType uint8

type Tether

type Tether struct {
	IMux
	RemoteConfig *ClientConfig
}

Tether is a generalized network connection for tunneling it usually holds a bundle of connections, multiplexed into endless virtual connections along with any additional information about the remote part of the call

func NewTether

func NewTether(isClient bool) *Tether

NewTether creates a tether which is a generalized network connection for tunneling

type TetherConfig

type TetherConfig struct {
	TargetPort     int        `json:"port"`
	TargetHost     string     `json:"host"`
	ConnectionType string     `json:"connectionType"`
	ConnectionName string     `json:"connectionName"`
	Proxy          *ProxyInfo `json:"proxy,omitempty"`
	ClientPassword string     `json:"password"`
}

type TunnelTask

type TunnelTask struct {
	net.Conn
	Header *TaskInfo
	// contains filtered or unexported fields
}

func NewTunnelTask

func NewTunnelTask(conn net.Conn, taskInfo *TaskInfo) *TunnelTask

NewTunnelTask creates a new TunnelTask

func ReadTunnelTask

func ReadTunnelTask(conn net.Conn) (*TunnelTask, error)

ReadTunnelTask reads the task details from the connection and returns a new TunnelTask object

func (*TunnelTask) PrefixSend

func (t *TunnelTask) PrefixSend(b []byte) (int, error)

PrefixSend adds bytes to be sent before the connections are welded

func (*TunnelTask) PrefixTaskInfo

func (t *TunnelTask) PrefixTaskInfo() error

PrefixTaskInfo the task info onto the head of the stream to be sent

func (*TunnelTask) Read

func (t *TunnelTask) Read(b []byte) (int, error)

Read overrides the connection read to send the prefixed content first

func (*TunnelTask) ReadPresend

func (t *TunnelTask) ReadPresend() []byte

ReadPresend returns the bytes that are in the presend buffer and zeroes it

func (*TunnelTask) Write

func (t *TunnelTask) Write(b []byte) (int, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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