star

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2021 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConnectionCert tls.Certificate
View Source
var ConnectionConfig *tls.Config

Functions

func CheckNoActivePorts added in v1.1.0

func CheckNoActivePorts()

func GobEncode

func GobEncode(d interface{}) []byte

GobEncode gob encodes the provided data(d)

func HandleStreamAcknowledge

func HandleStreamAcknowledge(msg *Message)

func HandleStreamClose

func HandleStreamClose(msg *Message)

func HandleStreamCreate

func HandleStreamCreate(msg *Message)

func HandleStreamFlow

func HandleStreamFlow(msg *Message)

func NewActiveStream

func NewActiveStream(tracker *StreamMeta)

func NewFileServerConnection

func NewFileServerConnection(address string, t ConnectorType, requester NodeID, FileConnID ConnectID)

func NewFileServerListener

func NewFileServerListener(address string, t ConnectorType, requester NodeID, FileConnID ConnectID)

func NewPortForwardConnection added in v1.1.0

func NewPortForwardConnection(address string, t ConnectorType, dstNode NodeID, dstAddress string, dstType ConnectorType)

func NewPortForwardListener added in v1.1.0

func NewPortForwardListener(address string, t ConnectorType, dstNode NodeID, dstAddress string, dstType ConnectorType)

func NewShellConnection

func NewShellConnection(address string, t ConnectorType, requester NodeID)

func NewShellListener

func NewShellListener(address string, t ConnectorType, requester NodeID)

func NewTCPConnection

func NewTCPConnection(address string)

func NewTCPListener

func NewTCPListener(address string)

func NewUID

func NewUID(id []byte)

NewUID fills a byte array with random data

func ParameterHandling

func ParameterHandling()

Allows for the creation of listeners (bind) and connections (connect) via command-line arguments.

func ProcessMessagePortForward added in v1.1.0

func ProcessMessagePortForward(msg *Message)

func RandString

func RandString(seed string, n int) string

func RemoveActiveStream

func RemoveActiveStream(id StreamID)

func STARCoreSetup

func STARCoreSetup()

func SetupConnectionCertificate

func SetupConnectionCertificate(certPEMBlock []byte, keyPEMBlock []byte) (err error)

func SqrtedString

func SqrtedString(b []byte, sep string) string

SqrtedString turns a []byte into a hexadecimal string that is split into substrings demarcated by the specified separator string. The number of substrings is equal to the square root of the length of []byte. (Note: If "len([]byte)" is not a square number, not all data will be included).

func StringifySubarray

func StringifySubarray(arr []string, starti int, endi int) (s string)

func UnregisterConnection

func UnregisterConnection(connID ConnectID)

UnregisterConnection removes a Connection from the tracker

func UnregisterListener

func UnregisterListener(connID ConnectID)

Types

type ConnectID

type ConnectID [9]byte

The ConnectID type is a fixed-length byte array which should serve as a UUID for each Connection

func NewConnectID

func NewConnectID() (id ConnectID)

func RegisterConnection

func RegisterConnection(conn Connection) ConnectID

RegisterConnection adds a Connection to the tracker

func RegisterListener

func RegisterListener(conn Connector) ConnectID

RegisterListener adds a Listener to the tracker

func (ConnectID) IsNone

func (id ConnectID) IsNone() bool

func (ConnectID) String

func (id ConnectID) String() string

Formats a ConnectID into a print-friendly string

type Connection

type Connection interface {
	Handle()
	MessageDuration() time.Duration
	Send(msg Message) (err error)
	Read(data []byte) (n int, err error)
	Write(data []byte) (n int, err error)
	Close()
	DataSize() (s int)
}

The Connection interface provides the standard functions for using STAR node communications.

func GetConnectionById

func GetConnectionById(connID ConnectID) (c Connection, ok bool)

func GetConnectionByString

func GetConnectionByString(connID string) (c Connection, ok bool)

type Connector

type Connector interface {
	Connect() (err error)
	Listen() (err error)
	Close()
}

The Connector interface provides the standard functions for creating STAR node connections.

func GetListener

func GetListener(connID ConnectID) (c Connector, ok bool)

type ConnectorType

type ConnectorType byte
const (
	// ConnectorType_TCPTLS is used by the terminal to tell an agent that a TCP
	// connector should be used when requesting a bind or a connect. This is the
	// required means of connections between S.T.A.R. nodes.
	ConnectorType_TCPTLS ConnectorType = iota + 1

	ConnectorType_ShellTCP
	ConnectorType_ShellTCPTLS
	ConnectorType_ShellUDP
	ConnectorType_ShellUDPTLS

	ConnectorType_FileServerTCP
	ConnectorType_FileServerTCPTLS
	ConnectorType_FileServerUDP
	ConnectorType_FileServerUDPTLS

	ConnectorType_PortForwardTCP
	ConnectorType_PortForwardUDP
)

type FileServer_Connection

type FileServer_Connection struct {
	Type        ConnectorType
	NetConn     net.Conn
	TLSConn     *tls.Conn
	ID          ConnectID
	FileConnID  ConnectID
	StreamID    StreamID
	Destination NodeID
}

func (FileServer_Connection) Close

func (c FileServer_Connection) Close()

func (FileServer_Connection) DataSize added in v1.1.0

func (c FileServer_Connection) DataSize() (s int)

func (FileServer_Connection) Handle

func (c FileServer_Connection) Handle()

func (FileServer_Connection) MessageDuration

func (c FileServer_Connection) MessageDuration() (d time.Duration)

func (FileServer_Connection) Read

func (c FileServer_Connection) Read(data []byte) (n int, err error)

func (FileServer_Connection) Send

func (c FileServer_Connection) Send(msg Message) (err error)

func (FileServer_Connection) Write

func (c FileServer_Connection) Write(data []byte) (n int, err error)

type FileServer_Connector

type FileServer_Connector struct {
	Type       ConnectorType
	Address    string
	Listener   *net.Listener
	Requester  NodeID
	FileConnID ConnectID
}

func (*FileServer_Connector) Close

func (connector *FileServer_Connector) Close()

func (*FileServer_Connector) Connect

func (connector *FileServer_Connector) Connect() (err error)

func (*FileServer_Connector) Listen

func (connector *FileServer_Connector) Listen() (err error)

type Message

type Message struct {
	ID          MessageID
	Source      NodeID
	Destination NodeID
	Type        MessageType
	Data        []byte
}

The Message type serves as the overarching data structure for STAR messages.

func NewConnection

func NewConnection(address string) (msg *Message)

func NewMessage

func NewMessage() (msg *Message)

NewMessage creates and sets up a bare-bones STAR Message

func NewMessageBindTCP

func NewMessageBindTCP(address string) (msg *Message)

func NewMessageChatRequest

func NewMessageChatRequest(Nickname string, Content string) (msg *Message)

func NewMessageConnectTCP

func NewMessageConnectTCP(address string) (msg *Message)

func NewMessageError

func NewMessageError(errorType MessageErrorResponseType, context string) (msg *Message)

func NewMessageFileServerBindRequest

func NewMessageFileServerBindRequest(t ConnectorType, address string, fileconnid ConnectID) (msg *Message)

func NewMessageFileServerConnectRequest

func NewMessageFileServerConnectRequest(t ConnectorType, address string, fileconnid ConnectID) (msg *Message)

func NewMessageFileServerInitiateTransferRequest

func NewMessageFileServerInitiateTransferRequest(FileConnID ConnectID, AgentConnID ConnectID) (msg *Message)

func NewMessageHello

func NewMessageHello() (msg *Message)

func NewMessageKillSwitch

func NewMessageKillSwitch() (msg *Message)

func NewMessageNewBind

func NewMessageNewBind(address string) (msg *Message)

func NewMessagePortForwardRequest added in v1.1.0

func NewMessagePortForwardRequest(SrcAddress string, SrcType ConnectorType, DstNode NodeID, DstAddress string, DstType ConnectorType) (msg *Message)

func NewMessageRemoteCDRequest

func NewMessageRemoteCDRequest(Directory string) (msg *Message)

func NewMessageRemoteCDResponse

func NewMessageRemoteCDResponse(NewDirectory string, OldDirectory string, Requester NodeID) (msg *Message)

func NewMessageRemoteLSRequest

func NewMessageRemoteLSRequest(Directory string) (msg *Message)

func NewMessageRemoteLSResponse

func NewMessageRemoteLSResponse(Directory string, FileInfos []os.FileInfo) (msg *Message)

func NewMessageRemoteMkDirRequest

func NewMessageRemoteMkDirRequest(Directory string) (msg *Message)

func NewMessageRemoteMkDirResponse

func NewMessageRemoteMkDirResponse(Directory string) (msg *Message)

func NewMessageRemotePWDRequest

func NewMessageRemotePWDRequest() (msg *Message)

func NewMessageRemotePWDResponse

func NewMessageRemotePWDResponse(Directory string) (msg *Message)

func NewMessageRemoteTmpDirRequest

func NewMessageRemoteTmpDirRequest() (msg *Message)

func NewMessageRemoteTmpDirResponse

func NewMessageRemoteTmpDirResponse(Directory string) (msg *Message)

func NewMessageShellBindRequest

func NewMessageShellBindRequest(t ConnectorType, address string) (msg *Message)

func NewMessageShellConnectionRequest

func NewMessageShellConnectionRequest(t ConnectorType, address string) (msg *Message)

func NewMessageSyncRequest

func NewMessageSyncRequest() (msg *Message)

func NewMessageSyncResponse

func NewMessageSyncResponse() (msg *Message)

func NewMessageTerminate

func NewMessageTerminate(t MessageTerminateType, index uint) (msg *Message)

func (*Message) GobDecodeMessage

func (msg *Message) GobDecodeMessage(reqMsg interface{}) (err error)

GobDecode gob decodes the provided data(d) into a type(t) pointer

func (*Message) Handle

func (msg *Message) Handle(src ConnectID)

func (*Message) HandleStream

func (msg *Message) HandleStream()

func (*Message) Process

func (msg *Message) Process()

func (*Message) Send

func (msg *Message) Send(src ConnectID)

type MessageBindRequest

type MessageBindRequest struct {
	Type ConnectorType
	Data []byte
}

type MessageChatRequest

type MessageChatRequest struct {
	Nickname string
	Content  string
}

type MessageConnectRequest

type MessageConnectRequest struct {
	Type ConnectorType
	Data []byte
}

type MessageErrorResponse

type MessageErrorResponse struct {
	Type    MessageErrorResponseType
	Context string
}

MessageError holds values related to any error messages returned by an Agent Node. Termainal Nodes *should not* send error messages to Agent Nodes.

type MessageErrorResponseType

type MessageErrorResponseType byte
const (
	MessageErrorResponseTypeX509KeyPair MessageErrorResponseType = iota + 1
	MessageErrorResponseTypeConnectionLost
	MessageErrorResponseTypeBindDropped
	MessageErrorResponseTypeGobDecodeError
	MessageErrorResponseTypeAgentExitSignal
	MessageErrorResponseTypeUnsupportedConnectorType
	MessageErrorResponseTypeUnsupportedTerminationType
	MessageErrorResponseTypeInvalidTerminationIndex
	MessageErrorResponseTypeCommandEnded
	MessageErrorResponseTypeShellConnectionLost
	MessageErrorResponseTypeFileDownloadOpenFileError
	MessageErrorResponseTypeFileUploadOpenFileError
	MessageErrorResponseTypeFileDownloadCompleted
	MessageErrorResponseTypeFileUploadCompleted
	MessageErrorResponseTypeDirectoryCreationError
	MessageErrorResponseTypeFileServerConnectionLost
	MessageErrorResponseTypeFileServerConnectionNotFound
	MessageErrorResponseTypePortForwardingConnectionNotFound
	MessageErrorResponseTypePortForwardingSourceAddressUnavailable
	MessageErrorResponseTypePortForwardingDestinationAddressUnavailable
	MessageErrorResponseTypePortForwardingConnectionLost
)

type MessageFileServerBindRequest

type MessageFileServerBindRequest struct {
	Address    string
	Type       ConnectorType
	Requester  NodeID
	FileConnID ConnectID
}

type MessageFileServerConnectRequest

type MessageFileServerConnectRequest struct {
	Address    string
	Type       ConnectorType
	Requester  NodeID
	FileConnID ConnectID
}

type MessageFileServerInitiateTransferRequest

type MessageFileServerInitiateTransferRequest struct {
	FileConnID  ConnectID
	AgentConnID ConnectID
}

type MessageHelloResponse

type MessageHelloResponse struct {
	Node Node
	Info NodeInfo
}

type MessageID

type MessageID [16]byte

The MessageID type is a fixed-length byte array which should serve as a UUID for each Message

func (MessageID) String

func (id MessageID) String() string

Formats a MessageID into a print-friendly string

type MessageKillSwitchRequest

type MessageKillSwitchRequest struct {
}

type MessageNewBindResponse

type MessageNewBindResponse struct {
	Address string
}

type MessageNewConnectionResponse

type MessageNewConnectionResponse struct {
	Address string
}

type MessagePortForwardRequest added in v1.1.0

type MessagePortForwardRequest struct {
	DstNode    NodeID
	SrcType    ConnectorType
	DstType    ConnectorType
	SrcAddress string
	DstAddress string
}

type MessageRemoteCDRequest

type MessageRemoteCDRequest struct {
	Directory string
}

type MessageRemoteCDResponse

type MessageRemoteCDResponse struct {
	NewDirectory string
	OldDirectory string
	Requester    NodeID
}

type MessageRemoteLSFileFormat

type MessageRemoteLSFileFormat struct {
	Name    string
	ModTime time.Time
	Mode    fs.FileMode
	Size    int64
	IsDir   bool
}

type MessageRemoteLSRequest

type MessageRemoteLSRequest struct {
	Directory string
}

type MessageRemoteLSResponse

type MessageRemoteLSResponse struct {
	Directory string
	Files     []MessageRemoteLSFileFormat
}

type MessageRemoteMkDirRequest

type MessageRemoteMkDirRequest struct {
	Directory string
}

type MessageRemoteMkDirResponse

type MessageRemoteMkDirResponse struct {
	Directory string
}

type MessageRemotePWDRequest

type MessageRemotePWDRequest struct {
}

type MessageRemotePWDResponse

type MessageRemotePWDResponse struct {
	Directory string
}

type MessageRemoteTmpDirRequest

type MessageRemoteTmpDirRequest struct {
}

type MessageRemoteTmpDirResponse

type MessageRemoteTmpDirResponse struct {
	Directory string
}

type MessageShellBindRequest

type MessageShellBindRequest struct {
	Address   string
	Type      ConnectorType
	Requester NodeID
}

type MessageShellConnectionRequest

type MessageShellConnectionRequest struct {
	Address   string
	Type      ConnectorType
	Requester NodeID
}

type MessageSyncRequest

type MessageSyncRequest struct {
}

type MessageSyncResponse

type MessageSyncResponse struct {
	Node Node
	Info NodeInfo
}

type MessageTerminateRequest

type MessageTerminateRequest struct {
	Type  MessageTerminateType
	Index uint
}

type MessageTerminateType

type MessageTerminateType byte
const (
	MessageTerminateTypeAgent MessageTerminateType = iota + 1
	MessageTerminateTypeConnection
	MessageTerminateTypeListener
	MessageTerminateTypeShell
	MessageTerminateTypeStream
)

type MessageType

type MessageType byte

The MessageType type indicates the type of Message

const (
	// MessageTypeError identifies the Message as being in relation to an
	// error that occurred on the Agent and is being relayed to the Terminal
	// user.
	MessageTypeError MessageType = iota + 1

	// MessageTypeSyncRequest identifies the Message as being a synchronization
	// request from the Terminal to Agents. The Message will be forwarded to
	// all neighboring Agents.
	MessageTypeSyncRequest

	// MessageTypeSyncResponse identifies the Message as being a
	// synchronization response from Agents to the Terminal. The Message
	// will be forwarded to all neighboring Agents.
	MessageTypeSyncResponse

	// MessageTypeKillSwitch identifies the Message as being a self-destruct
	// request from the Terminal to Agents. The Message will *only* be
	// forwarded if the correct confirmation code is passed.
	MessageTypeKillSwitch

	// MessageTypeStream* identifies the Message as being related to
	// bi-directional interactive traffic (i.e., a command prompt)
	MessageTypeStream
	MessageTypeStreamCreate
	MessageTypeStreamAcknowledge
	MessageTypeStreamClose
	MessageTypeStreamTakeover

	// MessageTypeStreamTakenOver is not handled by the stream, but rather
	// the terminal who previously had access to the stream.
	MessageTypeStreamTakenOver

	// MessageTypeBind indentifies the Message as being related to
	// the creation of a Listener on an agent
	MessageTypeBind

	// MessageTypeConnect identifies the Message as being related to
	// the creation of a Connection on an agent
	MessageTypeConnect

	// MessageTypeHello identifies the Message as being related to a
	// new node joining the constellation
	MessageTypeHello

	// MessageTypeNewBind identifies the message as being related to
	// the successful creation of a new listener. This is separate
	// from the MessageTypeBind Response in that this is sent to the
	// broadcast NodeID, so all terminals will be aware.
	MessageTypeNewBind

	// MessageTypeNewConnection identifies the message as being related to
	// the successful creation of a new connection. This is separate from the
	// MessageTypeConnection Response in that this is sent to the broadcast
	// NodeID, so all terminals will be aware.
	MessageTypeNewConnection

	// MessageTypeTerminateAgent identifies the message as being related to
	// the termination request of an agent.
	MessageTypeTerminate

	// MessageTypeShellBind identifies the message as being related to the
	// creation of a new shell listener.
	MessageTypeShellBind

	// MessageTypeShellConnection identifies the message as being related to the
	// creation of a new shell connection.
	MessageTypeShellConnection

	// MessageTypeFileServerBind identifies the message as being related to the
	// creation of a new single-use file server.
	MessageTypeFileServerBind

	// MessageTypeFileServerConnection identifies the message as being related to the
	// creation of a new file server connection.
	MessageTypeFileServerConnect

	// MessageTypeFileServerInitiateTransfer identifies the message as being related to
	// the transfer initiation of a file server file.
	MessageTypeFileServerInitiateTransfer

	// MessageTypeRemoteCD identifies the message as being related to the changing
	// of the working directory for the remote node (agent).
	MessageTypeRemoteCDRequest
	MessageTypeRemoteCDResponse

	// MessageTypeRemoteLS identifies the message as being related to the listing
	// of files and directories for the remote node (agent).
	MessageTypeRemoteLSRequest
	MessageTypeRemoteLSResponse

	// MessageTypeRemoteMkDir identifies the message as being related to the creation
	// of a directory for the remote node (agent).
	MessageTypeRemoteMkDirRequest
	MessageTypeRemoteMkDirResponse

	// MessageTypeRemotePWD identifies the message as being related to the listing
	// of the present working directory
	MessageTypeRemotePWDRequest
	MessageTypeRemotePWDResponse

	// MessageTypeRemoteTmpDir identifies the message as being related to the creation
	// of a temporary directory for the remote node (agent.)
	MessageTypeRemoteTmpDirRequest
	MessageTypeRemoteTmpDirResponse

	// MessageTypeChat identifies the message as being related to chatting
	MessageTypeChat

	// MessageTypePortForwardRequest identifies the message as being related to the
	// setting up of port forwarding
	MessageTypePortForwardRequest
)

type Node

type Node struct {
	ID               NodeID
	Type             NodeType
	Neighbors        []NodeID
	MessageProcessor func(*Message)
	Printer          func(NodeID, StreamID, ...interface{})
}

The Node type serves as the overarching data structure for tracking STAR nodes.

var ThisNode Node

func NewNode

func NewNode(t NodeType) (node Node)

NewNode creates and sets up a new STAR Node

type NodeID

type NodeID [9]byte

The NodeID type is a fixed-length byte array which should serve as a UUID for each Node

func (NodeID) IsBroadcastNodeID

func (id NodeID) IsBroadcastNodeID() bool

Is the NodeID the Broadcast NodeID?

func (NodeID) String

func (id NodeID) String() string

Formats a NodeID into a print-friendly string

type NodeInfo

type NodeInfo struct {
	ConnectionIDs   map[uint]ConnectID
	ConnectionInfos map[uint]string
	ConnectionTypes map[uint]ConnectorType
	ListenerIDs     map[uint]ConnectID
	ListenerInfos   map[uint]string
	ListenerTypes   map[uint]ConnectorType
	StreamIDs       map[uint]StreamID
	StreamInfos     map[uint]string
	StreamOwners    map[uint]NodeID
	StreamTypes     map[uint]StreamType

	GOOS   string
	GOARCH string

	OS_egid       int
	OS_environ    []string
	OS_euid       int
	OS_gid        int
	OS_groups     []int
	OS_hostname   string
	OS_pagesize   int
	OS_pid        int
	OS_ppid       int
	OS_uid        int
	OS_workingdir string

	Interfaces []net.Interface
	// contains filtered or unexported fields
}
var ThisNodeInfo NodeInfo

func (*NodeInfo) AddConnector

func (ni *NodeInfo) AddConnector(id ConnectID, t ConnectorType, info string)

func (*NodeInfo) AddListener

func (ni *NodeInfo) AddListener(id ConnectID, t ConnectorType, info string)

func (*NodeInfo) AddStream

func (ni *NodeInfo) AddStream(id StreamID, t StreamType, info string, owner NodeID)

func (*NodeInfo) RemoveConnector

func (ni *NodeInfo) RemoveConnector(id ConnectID)

func (*NodeInfo) RemoveListener

func (ni *NodeInfo) RemoveListener(id ConnectID)

func (*NodeInfo) RemoveStream

func (ni *NodeInfo) RemoveStream(id StreamID)

func (*NodeInfo) Setup

func (ni *NodeInfo) Setup()

func (*NodeInfo) Update

func (ni *NodeInfo) Update()

type NodeType

type NodeType byte

NodeType determines what kind of STAR Node we are dealing with (e.g., a terminal or an agent).

const (
	// NodeTypeTerminal identifies the STAR Node as being a Terminal Node
	NodeTypeTerminal NodeType = iota + 1

	// NodeTypeAgent identifies the STAR Node as being an Agent Node
	NodeTypeAgent
)

type PortForward_Connection added in v1.1.0

type PortForward_Connection struct {
	Type       ConnectorType
	NetConn    net.Conn
	DstNode    NodeID
	DstAddress string
	DstType    ConnectorType
	ID         ConnectID
	StreamID   StreamID
}

func (PortForward_Connection) Close added in v1.1.0

func (c PortForward_Connection) Close()

func (PortForward_Connection) DataSize added in v1.1.0

func (c PortForward_Connection) DataSize() (s int)

func (PortForward_Connection) Handle added in v1.1.0

func (c PortForward_Connection) Handle()

func (PortForward_Connection) MessageDuration added in v1.1.0

func (c PortForward_Connection) MessageDuration() (d time.Duration)

func (PortForward_Connection) Read added in v1.1.0

func (c PortForward_Connection) Read(data []byte) (n int, err error)

func (PortForward_Connection) Send added in v1.1.0

func (c PortForward_Connection) Send(msg Message) (err error)

func (PortForward_Connection) Write added in v1.1.0

func (c PortForward_Connection) Write(data []byte) (n int, err error)

type PortForward_Connector added in v1.1.0

type PortForward_Connector struct {
	Type       ConnectorType
	Address    string
	DstNode    NodeID
	DstAddress string
	DstType    ConnectorType
	Listener   *net.Listener
}

func (*PortForward_Connector) Close added in v1.1.0

func (connector *PortForward_Connector) Close()

func (*PortForward_Connector) Connect added in v1.1.0

func (connector *PortForward_Connector) Connect() (err error)

func (*PortForward_Connector) Listen added in v1.1.0

func (connector *PortForward_Connector) Listen() (err error)

type Shell_Connection

type Shell_Connection struct {
	Type        ConnectorType
	NetConn     net.Conn
	TLSConn     *tls.Conn
	ID          ConnectID
	StreamID    StreamID
	Destination NodeID
}

func (Shell_Connection) Close

func (c Shell_Connection) Close()

func (Shell_Connection) DataSize added in v1.1.0

func (c Shell_Connection) DataSize() (s int)

func (Shell_Connection) Handle

func (c Shell_Connection) Handle()

func (Shell_Connection) MessageDuration

func (c Shell_Connection) MessageDuration() (d time.Duration)

func (Shell_Connection) Read

func (c Shell_Connection) Read(data []byte) (n int, err error)

func (Shell_Connection) Send

func (c Shell_Connection) Send(msg Message) (err error)

func (Shell_Connection) Write

func (c Shell_Connection) Write(data []byte) (n int, err error)

type Shell_Connector

type Shell_Connector struct {
	Type      ConnectorType
	Address   string
	Listener  *net.Listener
	Requester NodeID
}

func (*Shell_Connector) Close

func (connector *Shell_Connector) Close()

func (*Shell_Connector) Connect

func (connector *Shell_Connector) Connect() (err error)

func (*Shell_Connector) Listen

func (connector *Shell_Connector) Listen() (err error)

type Stream

type Stream struct {
	ID   StreamID
	Data []byte
}

type StreamID

type StreamID [9]byte

func (StreamID) IsEmptyStreamID

func (id StreamID) IsEmptyStreamID() bool

Is the StreamID an empty StreamID?

func (StreamID) String

func (id StreamID) String() string

type StreamMeta

type StreamMeta struct {
	ID StreamID

	Type StreamType
	// Context is the command to run for command execution, and agent's file system file path/name for upload/download
	Context string
	// contains filtered or unexported fields
}

func GetActiveStream

func GetActiveStream(id StreamID) (tracker *StreamMeta, ok bool)

func NewStreamMeta

func NewStreamMeta(t StreamType, dstID NodeID, context string, writer func(data []byte), closer func(s StreamID)) (meta *StreamMeta)

NewStreamMeta is called by the terminal to setup a stream meta

func NewStreamMetaCommand

func NewStreamMetaCommand(dstID NodeID, context string, writer func(data []byte), closer func(s StreamID)) (meta *StreamMeta)

func NewStreamMetaDownload

func NewStreamMetaDownload(dstID NodeID, context string, writer func(data []byte), closer func(s StreamID)) (meta *StreamMeta)

func NewStreamMetaFileServer

func NewStreamMetaFileServer(dstID NodeID, context string, writer func(data []byte), closer func(s StreamID)) (meta *StreamMeta)

func NewStreamMetaMirror

func NewStreamMetaMirror(metaOrig *StreamMeta, dstID NodeID) (metaNew *StreamMeta)

NewStreamMetaMirror is called by the agent to mirror/setup a stream meta

func NewStreamMetaPortForwardingTCP added in v1.1.0

func NewStreamMetaPortForwardingTCP(dstID NodeID, context string, writer func(data []byte), closer func(s StreamID)) (meta *StreamMeta)

func NewStreamMetaPortForwardingUDP added in v1.1.0

func NewStreamMetaPortForwardingUDP(dstID NodeID, context string, writer func(data []byte), closer func(s StreamID)) (meta *StreamMeta)

func NewStreamMetaShell

func NewStreamMetaShell(dstID NodeID, context string, writer func(data []byte), closer func(s StreamID)) (meta *StreamMeta)

func NewStreamMetaUpload

func NewStreamMetaUpload(dstID NodeID, context string, writer func(data []byte), closer func(s StreamID)) (meta *StreamMeta)

func (*StreamMeta) Close

func (meta *StreamMeta) Close()

func (*StreamMeta) SendMessageAcknowledge

func (meta *StreamMeta) SendMessageAcknowledge()

func (*StreamMeta) SendMessageClose

func (meta *StreamMeta) SendMessageClose()

func (*StreamMeta) SendMessageCreate

func (meta *StreamMeta) SendMessageCreate()

func (*StreamMeta) SendMessageWrite

func (meta *StreamMeta) SendMessageWrite(data []byte)

func (*StreamMeta) Write

func (stream *StreamMeta) Write(p []byte) (n int, err error)

type StreamTakeover

type StreamTakeover struct {
	ID StreamID
}

type StreamType

type StreamType byte
const (
	StreamTypeCommand StreamType = iota + 1
	StreamTypeFileDownload
	StreamTypeFileServer
	StreamTypeFileUpload
	StreamTypeShell
	StreamTypePortForwardTCP
	StreamTypePortForwardUDP
)

type TCP_Connection

type TCP_Connection struct {
	TLSConn *tls.Conn
	NetConn net.Conn
	ID      ConnectID
	Encoder *gob.Encoder
	Decoder *gob.Decoder
}

func (TCP_Connection) Close

func (c TCP_Connection) Close()

func (TCP_Connection) DataSize added in v1.1.0

func (c TCP_Connection) DataSize() (s int)

func (TCP_Connection) Handle

func (c TCP_Connection) Handle()

func (TCP_Connection) MessageDuration

func (c TCP_Connection) MessageDuration() (d time.Duration)

func (TCP_Connection) Read

func (c TCP_Connection) Read(data []byte) (n int, err error)

func (TCP_Connection) Send

func (c TCP_Connection) Send(msg Message) (err error)

func (TCP_Connection) Write

func (c TCP_Connection) Write(data []byte) (n int, err error)

type TCP_Connector

type TCP_Connector struct {
	Address  string
	Listener *net.Listener
}

func (*TCP_Connector) Close

func (connector *TCP_Connector) Close()

func (*TCP_Connector) Connect

func (connector *TCP_Connector) Connect() (err error)

func (*TCP_Connector) Listen

func (connector *TCP_Connector) Listen() error

Jump to

Keyboard shortcuts

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