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: 13 Imported by: 0

Documentation

Overview

Package p2p is a service to process and return peer-to-peer connection links and delegate messages

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

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

Service is the structure used to interact with Link and Delegate objects

func NewP2PService

func NewP2PService() *Service

NewP2PService is a factory to create a Service object for interacting with Link and Delegate message objects

func (*Service) AddDelegate

func (s *Service) AddDelegate(delegate messages.Delegate)

AddDelegate takes the provided delegate message and adds it to outgoing message channel to be sent to the Merlin server

func (s *Service) AddLink(link *p2p.Link)

AddLink stores a Link object in the repository

func (*Service) Check

func (s *Service) Check() (delegates []messages.Delegate)

Check does not block and returns all delegate messages in the out channel, if any

func (*Service) Connected

func (s *Service) Connected(agentType int, ip string) (*p2p.Link, bool)

Connected determines if this Agent is already connected to the target IP address and port and returns it if it is

func (*Service) Delete

func (s *Service) Delete(id uuid.UUID)

Delete removes the peer-to-peer link from the repository without trying to gracefully close the connection

func (*Service) GetDelegates

func (s *Service) GetDelegates() []messages.Delegate

GetDelegates blocks waiting for a delegate message that needs to be sent to the parent Agent

func (s *Service) GetLink(id uuid.UUID) (*p2p.Link, error)

GetLink finds the Link by the provided id from the repository and returns it

func (*Service) Handle

func (s *Service) Handle(delegates []messages.Delegate)

Handle takes in a list of incoming Delegate messages to this parent Agent and sends it to the child or linked Agent

func (*Service) List

func (s *Service) List() (list string)

List returns a numbered list of peer-to-peer Links that exist each seperated by a new line

func (*Service) Refresh

func (s *Service) Refresh() (list string)

Refresh sends an empty delegate message to the server for each peer-to-peer Link in the repository to update the server with this Agent's links

func (*Service) Remove

func (s *Service) Remove(id uuid.UUID) error

Remove closes the peer-to-peer Link's network connection and deletes the peer-to-peer Link from the repository

func (*Service) UpdateConnection

func (s *Service) UpdateConnection(id uuid.UUID, conn interface{}, remote net.Addr) error

UpdateConnection updates the peer-to-peer Link's network connection with the provided conn

Jump to

Keyboard shortcuts

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