Documentation ¶
Index ¶
- Constants
- Variables
- type Hop
- type HubType
- type Lane
- type LaneExport
- type Map
- func (m *Map) AddBootstrapHubs(bootstrapTransports []string) error
- func (m *Map) Close()
- func (m *Map) DefaultOptions() *Options
- func (m *Map) FindNearestHubs(locationV4, locationV6 *geoip.Location, opts *Options, matchFor HubType, ...) ([]*hub.Hub, error)
- func (m *Map) FindRoutes(ip net.IP, opts *Options, maxRoutes int) (*Routes, error)
- func (m *Map) GetHome() (*Pin, *docks.CraneTerminal)
- func (m *Map) GetPin(hubID string) (pin *Pin, ok bool)
- func (m *Map) InitializeFromDatabase()
- func (m *Map) Optimize(opts *Options) (connectTo *hub.Hub, err error)
- func (m *Map) PushPinChanges()
- func (m *Map) RegisterHubUpdateHook() error
- func (m *Map) RemoveHub(id string)
- func (m *Map) SetHome(id string, t *docks.CraneTerminal) (ok bool)
- func (m *Map) Stats() *MapStats
- func (m *Map) UpdateHub(h *hub.Hub)
- func (m *Map) UpdateIntel(update *hub.Intel) error
- type MapStats
- type Options
- type Pin
- func (pin *Pin) Export() *PinExport
- func (pin *Pin) GetActiveTerminal() *docks.ExpansionTerminal
- func (pin *Pin) HasActiveTerminal() bool
- func (pin *Pin) Lock()
- func (pin *Pin) NotifyTerminalChange()
- func (pin *Pin) SetActiveTerminal(pc *PinConnection)
- func (pin *Pin) String() string
- func (pin *Pin) Unlock()
- type PinConnection
- type PinExport
- type PinMatcher
- type PinState
- type Route
- type Routes
- type RoutingProfile
- type StorageInterface
- type UpdateHook
Constants ¶
const ( RoutingProfileDefaultName = "default" RoutingProfileShortestName = "shortest" RoutingProfileHomeName = "home" )
Variables ¶
var ( // ErrHomeHubUnset is returned when the Home Hub is required and not set. ErrHomeHubUnset = errors.New("map has no Home Hub set") // ErrEmptyMap is returned when the Map is empty. ErrEmptyMap = errors.New("map is empty") )
var ( RoutingProfileDefault = &RoutingProfile{ ID: RoutingProfileDefaultName, MinHops: 3, MaxHops: 5, MaxExtraHops: 2, MaxExtraCost: 100, } RoutingProfileShortest = &RoutingProfile{ ID: RoutingProfileShortestName, MinHops: 1, MaxHops: 5, MaxExtraHops: 1, MaxExtraCost: 100, } )
Functions ¶
This section is empty.
Types ¶
type Hop ¶ added in v0.3.0
type Lane ¶ added in v0.3.0
type Lane struct { // Pin is the Pin/Hub this Lane connects to. Pin *Pin // Capacity designates the available bandwidth between these Hubs. // It is specified in bit/s. Capacity int // Lateny designates the latency between these Hubs. // It is specified in nanoseconds. Latency time.Duration // contains filtered or unexported fields }
Lane is a connection to another Hub.
type LaneExport ¶ added in v0.3.7
type LaneExport struct { HubID string // Capacity designates the available bandwidth between these Hubs. // It is specified in bit/s. Capacity int // Lateny designates the latency between these Hubs. // It is specified in nanoseconds. Latency time.Duration }
LaneExport is the exportable version of a Lane.
type Map ¶
Map represent a collection of Pins and their relationship and status.
var (
Main *Map
)
func (*Map) AddBootstrapHubs ¶ added in v0.3.0
AddBootstrapHubs adds the given bootstrap hubs to the map
func (*Map) DefaultOptions ¶ added in v0.3.0
DefaultOptions returns the default options for this Map.
func (*Map) FindNearestHubs ¶ added in v0.3.0
func (m *Map) FindNearestHubs(locationV4, locationV6 *geoip.Location, opts *Options, matchFor HubType, maxMatches int) ([]*hub.Hub, error)
FindNearestHubs searches for the nearest Hubs to the given IP address. The returned Hubs must not be modified in any way.
func (*Map) FindRoutes ¶ added in v0.3.0
func (*Map) GetHome ¶ added in v0.3.0
func (m *Map) GetHome() (*Pin, *docks.CraneTerminal)
GetHome returns the current home and it's accompanying terminal. Both may be nil.
func (*Map) InitializeFromDatabase ¶ added in v0.3.0
func (m *Map) InitializeFromDatabase()
InitializeFromDatabase loads all Hubs from the given database prefix and adds them to the Map.
func (*Map) Optimize ¶ added in v0.3.0
FindNearestHubs searches for the nearest Hubs to the given IP address. The returned Hubs must not be modified in any way.
func (*Map) PushPinChanges ¶ added in v0.3.7
func (m *Map) PushPinChanges()
func (*Map) RegisterHubUpdateHook ¶ added in v0.3.0
RegisterHubUpdateHook registers a database pre-put hook that updates all Hubs saved at the given database prefix.
func (*Map) SetHome ¶ added in v0.3.0
func (m *Map) SetHome(id string, t *docks.CraneTerminal) (ok bool)
SetHome sets the given hub as the new home. Optionally, a terminal may be supplied to accompany the home hub.
type Options ¶ added in v0.3.0
type Options struct { // Regard holds required States. Only Hubs where all of these are present // will taken into account for the operation. If NoDefaults is not set, a // basic set of desirable states is added automatically. Regard PinState // Disregard holds disqualifying States. Only Hubs where none of these are // present will be taken into account for the operation. If NoDefaults is not // set, a basic set of undesireable states is added automatically. Disregard PinState // HubPolicy is an endpoint list that all Hubs must pass in order to be taken into account for the operation. HubPolicy endpoints.Endpoints // HomeHubPolicy is an endpoint list that Home Hubs must pass in order to be taken into account for the operation. HomeHubPolicy endpoints.Endpoints // DestinationHubPolicy is an endpoint list that Destination Hubs must pass in order to be taken into account for the operation. DestinationHubPolicy endpoints.Endpoints // FIXME CheckHubEntryPolicy bool // FIXME CheckHubExitPolicy bool // NoDefaults declares whether default and recommended Regard and Disregard states should not be used. NoDefaults bool // RequireTrustedDestinationHubs declares whether only Destination Hubs that have the Trusted state should be used. RequireTrustedDestinationHubs bool // RoutingProfile defines the algorithm to use to find a route. RoutingProfile string }
Options holds configuration options for operations with the Map.
func (*Options) Matcher ¶ added in v0.3.0
func (o *Options) Matcher(hubType HubType) PinMatcher
type Pin ¶ added in v0.3.0
type Pin struct { // Hub Information Hub *hub.Hub EntityV4 *intel.Entity EntityV6 *intel.Entity LocationV4 *geoip.Location LocationV6 *geoip.Location // Hub Status State PinState HopDistance int Load int // estimated in microseconds this port adds to latency ConnectedTo map[string]*Lane // Key is Hub ID. // FailingUntil specifies until when this Hub should be regarded as failing. // This is connected to StateFailing. FailingUntil time.Time // Connection holds a information about a connection to the Hub of this Pin. Connection *PinConnection // contains filtered or unexported fields }
Pin represents a Hub on a Map.
func (*Pin) GetActiveTerminal ¶ added in v0.3.7
func (pin *Pin) GetActiveTerminal() *docks.ExpansionTerminal
func (*Pin) HasActiveTerminal ¶ added in v0.3.0
func (*Pin) NotifyTerminalChange ¶ added in v0.3.7
func (pin *Pin) NotifyTerminalChange()
func (*Pin) SetActiveTerminal ¶ added in v0.3.7
func (pin *Pin) SetActiveTerminal(pc *PinConnection)
type PinConnection ¶ added in v0.3.0
type PinConnection struct { // Terminal holds the active terminal session. Terminal *docks.ExpansionTerminal // Route is the route built for this terminal. Route *Route }
PinConnection represents a connection to a terminal on the Hub.
type PinExport ¶ added in v0.3.7
type PinExport struct { record.Base sync.Mutex ID string Name string Map string FirstSeen time.Time EntityV4 *intel.Entity EntityV6 *intel.Entity States []string // From pin.State HopDistance int ConnectedTo map[string]*LaneExport // Key is Hub ID. Route []string // Includes Home Hub and this Pin's ID. SessionActive bool }
PinExport is the exportable version of a Pin.
type PinMatcher ¶ added in v0.3.0
type PinState ¶ added in v0.3.0
type PinState uint16
PinState holds a bit-mapped collection of Pin states, or a single state used for assigment and matching.
const ( // StateNone represents an empty state. StateNone PinState = 0 // StateInvalid signifies that there was an error while processing or // handling this Hub. StateInvalid PinState = 1 << (iota - 1) // 1 << 0 => 00000001 => 0x01 // StateSuperseded signifies that this Hub was superseded by another. This is // the case if any other Hub with a matching IP was verified after this one. // Verification timestamp equals Hub.FirstSeen. StateSuperseded // 0x02 // StateFailing signifies that a recent error was encountered while // communicating with this Hub. Pin.IgnoreUntil specifies when this state is // re-evaluated at earliest. StateFailing // 0x04 // StateHasRequiredInfo signifies that the Hub announces the minimum required // information about itself. StateHasRequiredInfo // 0x10 // StateReachable signifies that the Hub is reachable via the network from // the currently connected primary Hub. StateReachable // 0x20 // StateActive signifies that everything seems fine with the Hub and // connections to it should succeed. This is tested by checking if a valid // semi-ephemeral public key is available. StateActive // 0x40 // StateTrusted signifies the Hub has the special trusted status. StateTrusted // 0x0100 // StateUsageDiscouraged signifies that usage of the Hub is discouraged for any task. StateUsageDiscouraged // 0x0200 // StateUsageAsHomeDiscouraged signifies that usage of the Hub as a Home Hub is discouraged. StateUsageAsHomeDiscouraged // 0x0400 // StateUsageAsDestinationDiscouraged signifies that usage of the Hub as a Destination Hub is discouraged. StateUsageAsDestinationDiscouraged // 0x0800 // StateIsHomeHub signifies that the Hub is the current Home Hub. While not // negative in itself, selecting the Home Hub does not make sense in almost // all cases. StateIsHomeHub // 0x1000 // StateSummaryRegard summarizes all states that must always be set in order to take a Hub into consideration for any task. // TODO: Add StateHasRequiredInfo when we start enforcing Hub information. StateSummaryRegard = StateReachable | StateActive // StateSummaryDisregard summarizes all states that must not be set in order to take a Hub into consideration for any task. StateSummaryDisregard = StateInvalid | StateSuperseded | StateFailing | StateUsageDiscouraged | StateIsHomeHub )
type Route ¶
type Route struct { // DstCost is the calculated cost between the Destination Hub and the destination IP. DstCost int // Path is a list of Transit Hubs and the Destination Hub, including the Cost // for each Hop. Path []*Hop // TotalCost is the sum of all costs of this Route. TotalCost int // Algorithm is the ID of the algorithm used to calculate the route. Algorithm string }
type Routes ¶ added in v0.3.0
type Routes struct { All []*Route // contains filtered or unexported fields }
type RoutingProfile ¶ added in v0.3.0
type RoutingProfile struct { ID string // MinHops defines how many hops a route must have at minimum. In order to // reduce confusion, the Home Hub is also counted. MinHops int // MaxHops defines the limit on how many hops a route may have. In order to // reduce confusion, the Home Hub is also counted. MaxHops int // MaxExtraHops sets a limit on how many extra hops are allowed in addition // to the amount of Hops in the currently best route. This is an optimization // option and should not interfere with finding the best route, but might // reduce the amount of routes found. MaxExtraHops int // MaxExtraCost sets a limit on the extra cost allowed in addition to the // cost of the currently best route. This is an optimization option and // should not interfere with finding the best route, but might reduce the // amount of routes found. MaxExtraCost int }
type StorageInterface ¶ added in v0.3.7
type StorageInterface struct {
storage.InjectBase
}
StorageInterface provices a storage.Interface to the configuration manager.
type UpdateHook ¶ added in v0.3.0
func (*UpdateHook) UsesPrePut ¶ added in v0.3.0
func (hook *UpdateHook) UsesPrePut() bool
UsesPrePut implements the Hook interface.