http

package
v2.1.3 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: 26 Imported by: 0

Documentation

Overview

Package http contains structures and repositories to create, store, and manage HTTP based Agent listeners

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultOptions

func DefaultOptions() map[string]string

DefaultOptions returns a map of configurable listener options that will subsequently be passed to the NewHTTPListener function

func GetJWT

func GetJWT(agentID uuid.UUID, lifetime time.Duration, key []byte) (string, error)

GetJWT returns a JSON Web Token for the provided agent using the interface JWT Key

Types

type Listener

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

Listener is an aggregate structure that implements the Listener interface used to listen for and handle Agent message traffic

func NewHTTPListener

func NewHTTPListener(server servers.ServerInterface, options map[string]string) (listener Listener, err error)

NewHTTPListener is a factory that creates and returns a Listener aggregate that implements the Listener interface The HTTP listener requires an instantiated server object to send/receive messages with Agents

func (*Listener) Addr

func (l *Listener) Addr() string

Addr returns the network interface and port the peer-to-peer Agent is using

func (*Listener) Authenticate

func (l *Listener) Authenticate(id uuid.UUID, data interface{}) (messages.Base, error)

Authenticate takes data coming into the listener from an agent and passes it to the listener's configured authenticator to authenticate the agent. Once an agent is authenticated, this function will no longer be used.

func (*Listener) Authenticator

func (l *Listener) Authenticator() authenticators.Authenticator

Authenticator returns the authenticator the listener is configured to use

func (*Listener) ConfiguredOptions

func (l *Listener) ConfiguredOptions() map[string]string

ConfiguredOptions returns the server's current configuration for options that can be set by the user

func (*Listener) Construct

func (l *Listener) Construct(msg messages.Base, key []byte) (data []byte, err error)

Construct takes in a messages.Base structure that is ready to be sent to an agent and runs all the data transforms on it to encode and encrypt it. If an empty key is passed in, then the listener's interface encryption key will be used.

func (*Listener) Deconstruct

func (l *Listener) Deconstruct(data, key []byte) (messages.Base, error)

Deconstruct takes in data that an agent sent to the listener and runs all the listener's transforms on it until a messages.Base structure is returned. The key is used for decryption transforms. If an empty key is passed in, then the listener's interface encryption key will be used.

func (*Listener) Description

func (l *Listener) Description() string

Description returns the listener's description

func (*Listener) ID

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

ID returns the listener's unique identifier

func (*Listener) Name

func (l *Listener) Name() string

Name returns the listener's name

func (*Listener) Options

func (l *Listener) Options() map[string]string

Options returns the original map of options passed into the NewHTTPListener function

func (*Listener) PSK

func (l *Listener) PSK() string

PSK returns the listener's pre-shared key used for encrypting & decrypting agent messages

func (*Listener) Protocol

func (l *Listener) Protocol() int

Protocol returns a constant from the listeners package that represents the protocol type of this listener

func (*Listener) Server

func (l *Listener) Server() *servers.ServerInterface

Server returns the listener's embedded server structure

func (*Listener) SetOption

func (l *Listener) SetOption(option string, value string) error

SetOption sets the value for a configurable option on the Listener

func (*Listener) Status

func (l *Listener) Status() string

Status returns the status of the embedded server's state (e.g., running or stopped)

func (*Listener) String

func (l *Listener) String() string

String returns the listener's name

func (*Listener) Transformers

func (l *Listener) Transformers() []transformer.Transformer

Transformers returns a list of transforms the lister is configured to use

type Repository

type Repository interface {
	Add(listener Listener) error
	Exists(name string) bool
	List() func(string) []string
	Listeners() []Listener
	ListenerByID(id uuid.UUID) (Listener, error)
	ListenerByName(name string) (Listener, error)
	RemoveByID(id uuid.UUID) error
	SetOption(id uuid.UUID, option, value string) error
}

Repository is an interface to store and manage HTTP listeners

Directories

Path Synopsis
Package memory is an in-memory database used to store and retrieve HTTP listeners
Package memory is an in-memory database used to store and retrieve HTTP listeners

Jump to

Keyboard shortcuts

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