mapper

package
v0.0.0-...-c2b3dc6 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2017 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Shuffle

func Shuffle(a []string)

Types

type Mapper

type Mapper struct {

	// graph of the network
	Graph *graph.NetworkGraph
	// map of how to send a packet on each route
	RouteMap *RouteMap
	// contains filtered or unexported fields
}

Responsible for maintaining a `NetworkGraph` by mapping the network at a configured interval

func NewMapper

func NewMapper(n string) *Mapper

func (*Mapper) AddPeer

func (m *Mapper) AddPeer(p Peer)

func (*Mapper) IterPeers

func (m *Mapper) IterPeers() chan *Peer

TODO: randomize shuffle (since this is used for mapping and pinging TODO: better, since this will be concurrent

func (*Mapper) RemovePeer

func (m *Mapper) RemovePeer(p Peer)

func (*Mapper) Start

func (m *Mapper) Start()

Start the mapping

func (*Mapper) Stop

func (m *Mapper) Stop()

TODO implement stopping

type Peer

type Peer struct {
	Name string
	Port int
}

TODO move elsewhere?

func (*Peer) String

func (p *Peer) String() string

type RouteMap

type RouteMap struct {
	// key == srcName:srcPort,dstName:dstPort
	// key -> route
	NodeRouteMap map[string]*graph.NetworkRoute
	// contains filtered or unexported fields
}

TODO: do our own route refcounting (up and down)

func NewRouteMap

func NewRouteMap() *RouteMap

func (*RouteMap) GetRoute

func (r *RouteMap) GetRoute(key string) *graph.NetworkRoute

func (*RouteMap) GetRouteOption

func (r *RouteMap) GetRouteOption(srcName string, srcPort int, dstName string, dstPort int) *graph.NetworkRoute

func (*RouteMap) IterRoutes

func (r *RouteMap) IterRoutes(dstKey string, keysChan chan string)

TODO: embed the key in the route struct, so we can return a channel of *NetworkRoute

func (*RouteMap) MarshalJSON

func (r *RouteMap) MarshalJSON() ([]byte, error)

Fancy marshal method

func (*RouteMap) RemoveDst

func (r *RouteMap) RemoveDst(dst string) []*graph.NetworkRoute

TODO: set port TODO: do our own route refcounting Remove all route options associated with dst

func (*RouteMap) ReplaceRoute

func (r *RouteMap) ReplaceRoute(o, n *graph.NetworkRoute) int

Replace old route `o` with new route `n`, and return the number of times we did that

func (*RouteMap) UpdateRouteOption

func (r *RouteMap) UpdateRouteOption(srcName string, srcPort int, dst string, newRoute *graph.NetworkRoute)

Jump to

Keyboard shortcuts

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