navigator

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2020 License: AGPL-3.0 Imports: 17 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrIAmLonely = errors.New("could not find any ports")
)

Functions

func GetHub

func GetHub(ID string) *hub.Hub

func InitializeNavigator

func InitializeNavigator()

InitializeNavigator loads all Hubs and adds them to the navigator.

func IsPortTrusted

func IsPortTrusted(port *Port) bool

func Optimize

func Optimize(self *hub.Hub) (connectTo *hub.Hub, err error)

func RemovePublicHub

func RemovePublicHub(id string)

func SetPrimaryPort

func SetPrimaryPort(port *Port)

SetPrimaryPort sets the primary port for map calculations

func UpdateHub

func UpdateHub(h *hub.Hub)

func UpdateTrustedPorts

func UpdateTrustedPorts(list map[string]struct{})

Types

type Map

type Map struct {
	Collection     map[string]*Port
	CollectionLock sync.Locker
	PrimaryPort    *Port
	GoodEnough     int
	IgnoreAbove    int
	// contains filtered or unexported fields
}

Dijkstra "#AI"

func NewMap

func NewMap(primaryPort *Port, collection map[string]*Port, lock sync.Locker) *Map

func (*Map) FindNearestPorts

func (m *Map) FindNearestPorts(ips []net.IP) (*ProximityCollection, error)

FindNearestPorts returns the nearest ports to a set of IP addresses.

func (*Map) FindShortestPath

func (m *Map) FindShortestPath(considerActiveRoutes bool, destinations ...*Port) (path []*Port, ok bool, err error)

func (*Map) Reset

func (m *Map) Reset()

type Port

type Port struct {
	sync.RWMutex

	Hub            *hub.Hub
	IgnoreUntil    int64 // e.g. if an error occurred with this port
	Trusted        bool
	Location4      *geoip.Location
	Location6      *geoip.Location
	Routes         []*Route
	ActiveAPI      *docks.API // API to active Port
	ActiveRoute    []*Port    // list of Ports this connection runs through
	DependingPorts []*Port    // list of Ports that use this Port for a connection
	Load           int        // estimated in microseconds this port adds to latency
}

Port represents a node in the Port17 network.

func FindPathToPorts

func FindPathToPorts(ports []*Port) ([]*Port, error)

func GetPublicPort

func GetPublicPort(portName string) *Port

func GetRandomPort added in v0.2.1

func GetRandomPort() *Port

func NewPort

func NewPort(h *hub.Hub) *Port

func (*Port) ActiveCost

func (p *Port) ActiveCost() int

func (*Port) ActiveRouteCost

func (p *Port) ActiveRouteCost() int

func (*Port) AddPortDependent

func (p *Port) AddPortDependent(dependentPort *Port)

func (*Port) AddRoute

func (p *Port) AddRoute(newPort *Port, cost int)

func (*Port) CheckLocation

func (p *Port) CheckLocation()

func (*Port) CheckTrustStatus

func (p *Port) CheckTrustStatus()

func (*Port) Cost

func (p *Port) Cost() int

func (*Port) Equal

func (p *Port) Equal(other *Port) bool

func (*Port) HasActiveRoute

func (p *Port) HasActiveRoute() bool

func (*Port) Ignored

func (p *Port) Ignored() bool

func (*Port) Name

func (p *Port) Name() string

func (*Port) RemovePortDependent

func (p *Port) RemovePortDependent(dependentPort *Port)

func (*Port) RemoveRoute

func (p *Port) RemoveRoute(newPort *Port)

func (*Port) String

func (p *Port) String() string

func (*Port) UpdateLoad

func (p *Port) UpdateLoad(load int)

type ProximityCollection

type ProximityCollection struct {
	All          []*ProximityResult
	MinProximity int
}

func FindNearestPorts

func FindNearestPorts(ips []net.IP) (*ProximityCollection, error)

FindNearestPorts returns the nearest ports to a set of IP addresses.

func NewProximityCollection

func NewProximityCollection(elements int) *ProximityCollection

func (*ProximityCollection) Add

func (pc *ProximityCollection) Add(result *ProximityResult)

func (*ProximityCollection) Clean

func (pc *ProximityCollection) Clean()

func (*ProximityCollection) Len

func (pc *ProximityCollection) Len() int

Len is the number of elements in the collection.

func (*ProximityCollection) Less

func (pc *ProximityCollection) Less(i, j int) bool

Less reports whether the element with index i should sort before the element with index j.

func (*ProximityCollection) Swap

func (pc *ProximityCollection) Swap(i, j int)

Swap swaps the elements with indexes i and j.

type ProximityResult

type ProximityResult struct {
	IP        net.IP
	Port      *Port
	Proximity int
}

func (*ProximityResult) String

func (pr *ProximityResult) String() string

type Route

type Route struct {
	Port *Port
	Cost int
}

func (*Route) String

func (r *Route) String() string

type Solution

type Solution struct {
	Cost      int
	Current   *Port
	Path      []*Port
	Processed bool
}

func NewSolution

func NewSolution(port *Port, cost int) *Solution

func NewSolutionFromDestination

func NewSolutionFromDestination(port *Port) *Solution

func (*Solution) AddToPath

func (s *Solution) AddToPath(port *Port)

func (*Solution) CalculateConnectCost

func (s *Solution) CalculateConnectCost(route *Route) int

func (*Solution) CalculateCost

func (s *Solution) CalculateCost(route *Route) int

func (*Solution) Export

func (s *Solution) Export() []*Port

func (*Solution) TakeCourse

func (s *Solution) TakeCourse(route *Route, cost int) *Solution

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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