p2p

package
v2.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package p2p is used for Agent based peer-to-peer communications

Index

Constants

View Source
const (
	TCPBIND    = 0
	TCPREVERSE = 1
	UDPBIND    = 2
	UDPREVERSE = 3
	SMBBIND    = 4
	SMBREVERSE = 5
)

Types of peer-to-peer links/connections

View Source
const (
	// MaxSizeUDP is the maximum size of a UDP fragment
	// http://ithare.com/udp-from-mog-perspective/
	MaxSizeUDP = 1450
	// MaxSizeSMB is the maximum size of an SMB fragment
	// The WriteFileEx Windows API function says:
	// "Pipe write operations across a network are limited to 65,535 bytes per write"
	// https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-writefileex
	MaxSizeSMB = 65535
)

Variables

This section is empty.

Functions

func String

func String(linkType int) string

String converts the peer-to-peer Link type from a constant to a string

Types

type Link struct {
	sync.Mutex // Mutex is used to lock the Link object for thread safety
	// contains filtered or unexported fields
}

Link holds information about peer-to-peer linked agents

func NewLink(id uuid.UUID, listener uuid.UUID, conn interface{}, linkType int, remote net.Addr) *Link

NewLink is a factory to build and return a Link structure

func (*Link) AddIn

func (l *Link) AddIn(base messages.Base)

AddIn takes in a base message from a parent Agent or the Merlin server and adds it to the incoming message channel, so it can be sent to the child Agent

func (*Link) AddOut

func (l *Link) AddOut(base messages.Base)

AddOut takes in a base message from a child Agent and adds it to the outgoing message channel, so it can be sent to the Merlin server

func (*Link) Conn

func (l *Link) Conn() interface{}

Conn returns the peer-to-peer network connection used to read and write network traffic

func (*Link) GetIn

func (l *Link) GetIn() messages.Base

GetIn blocks waiting for a Base message from the incoming message channel and returns it

func (*Link) GetOut

func (l *Link) GetOut() messages.Base

GetOut blocks waiting for a Base message from the outgoing message channel and returns it

func (*Link) ID

func (l *Link) ID() uuid.UUID

ID returns the peer-to-peer Link's id

func (*Link) Listener

func (l *Link) Listener() uuid.UUID

Listener returns the peer-to-peer Link's listener id

func (*Link) Remote

func (l *Link) Remote() net.Addr

Remote returns the address the peer-to-peer Link is connected to

func (*Link) String

func (l *Link) String() string

String returns the peer-to-peer Link's type as a string

func (*Link) Type

func (l *Link) Type() int

Type returns what type of peer-to-peer Link this is (e.g., TCP reverse or SMB bind)

func (*Link) UpdateConn

func (l *Link) UpdateConn(conn interface{}, remote net.Addr)

UpdateConn updates the peer-to-peer Link's network connection The updated object must be subsequently stored in the repository

type Repository

type Repository interface {
	// Delete removes the peer-to-peer Link from the in-memory datastore
	Delete(id uuid.UUID)
	// Get finds the peer-to-peer Link by the provided id and returns it
	Get(id uuid.UUID) (link *Link, err error)
	// GetAll returns all peer-to-peer Links in the in-memory datastore
	GetAll() (links []*Link)
	// Store saves the provided peer-to-peer link into the in-memory datastore
	Store(link *Link)
	// UpdateConn updates the peer-to-peer Link's embedded conn field with the provided network connection
	UpdateConn(id uuid.UUID, conn interface{}, remote net.Addr) error
}

Directories

Path Synopsis
Package memory is an in-memory repository for storing and managing peer-to-peer Link objects
Package memory is an in-memory repository for storing and managing peer-to-peer Link objects

Jump to

Keyboard shortcuts

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