Documentation ¶
Index ¶
Constants ¶
const ( DefaultDeviceName = "tun0" IATunDevicePrefix = "s." )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Dummy ¶
type Dummy struct { }
Dummy is a route management backend that does nothing. It is useful to use instead of nil pointer. It saves the user the pain of checking whether interface is nil which happens to be non-trivial in Go.
func (*Dummy) DeleteRoute ¶
func (*Dummy) NewConsumer ¶
func (*Dummy) NewPublisher ¶
func (*Dummy) Updates ¶
func (d *Dummy) Updates() <-chan control.RouteUpdate
type Linux ¶
type Linux struct { // DeviceManager is used to export routes to external routing tables (e.g., Linux). DeviceManager control.DeviceManager // contains filtered or unexported fields }
Linux is a one-way exporter of routes to Linux kernel.
func (*Linux) Diagnostics ¶
func (l *Linux) Diagnostics() control.Diagnostics
func (*Linux) NewPublisher ¶
type MultiDeviceManager ¶
type MultiDeviceManager struct { // DeviceOpener is used to create new resources for handles returned by Get. DeviceOpener control.DeviceOpener // contains filtered or unexported fields }
MultiDeviceManager opens one device for each ISD-AS.
func (*MultiDeviceManager) Get ¶
func (m *MultiDeviceManager) Get(ctx context.Context, ia addr.IA) (control.DeviceHandle, error)
Get returns a handle to the device for the ISD-AS. If no device exists, one will be created. If a device already exists, a handle to the existing device is returned. The caller must Close the handle to guarantee that resources will be cleaned up.
Devices are created with a name composed of the default tunnel device prefix and an unpadded base32 representation of the ISD-AS.
func (*MultiDeviceManager) Size ¶
func (m *MultiDeviceManager) Size() int
Size returns the number of existing devices.
type RouteConsumer ¶
type RouteConsumer struct {
// contains filtered or unexported fields
}
func (*RouteConsumer) Close ¶
func (c *RouteConsumer) Close()
Close closes the consumer. This will also close the update channel.
func (*RouteConsumer) Updates ¶
func (c *RouteConsumer) Updates() <-chan control.RouteUpdate
Updates returns a channel for route updates. When the database is closed this channel will be closed as well.
type RouteDB ¶
type RouteDB struct { // RouteExpiration specifies how long it takes for an unreferenced route to // expire. Zero means expire immediately. Default 0. RouteExpiration time.Duration // CleanupInterval specifies how often should the cleanup be done. // Default 1 second. Set this to a small value in tests to make them run faster. CleanupInterval time.Duration // Metrics are metrics related to this route database. Metrics RouteDBMetrics // contains filtered or unexported fields }
RouteDB is a one-way channel between route publisher(s) and route consumer(s). Routes in the database are reference counted. When the last reference is deleted, the route will remain in the database for some time before in expires.
func (*RouteDB) Close ¶
func (db *RouteDB) Close()
Close shuts down worker goroutines. It also closes update channels for all associated consumers.
func (*RouteDB) Diagnostics ¶
func (db *RouteDB) Diagnostics() control.Diagnostics
Diagnostics takes a diagnostic snapshot of the RouteDB.
func (*RouteDB) NewConsumer ¶
NewConsumer creates a new consumer that can be used to get route updates from the database. Calling the function after Close results in undefined behavior.
func (*RouteDB) NewPublisher ¶
NewPublisher creates a new publisher that can be used to insert routes to the database. Calling the function after Close results in undefined behavior.
type RouteDBMetrics ¶
type RoutePublisher ¶
type RoutePublisher struct {
// contains filtered or unexported fields
}
func (*RoutePublisher) AddRoute ¶
func (p *RoutePublisher) AddRoute(route control.Route)
AddRoute adds a route to the database. Inserting the same route multiple times is OK. The routes are reference counted. Calling the function after Close results in undefined behavior.
func (*RoutePublisher) Close ¶
func (p *RoutePublisher) Close()
Close closes the publisher, deleting all the routes that have been added through it.
func (*RoutePublisher) DeleteRoute ¶
func (p *RoutePublisher) DeleteRoute(route control.Route)
DeleteRoute removes a route from the database. If the route in question hasn't been added via this publisher the function will panic. Calling the function after Close results in undefined behavior.
type SingleDeviceManager ¶
type SingleDeviceManager struct { // DeviceOpener is the object used to create new handles. DeviceOpener control.DeviceOpener // contains filtered or unexported fields }
SingleDeviceManager opens a single device for all ISD-ASes.
func (*SingleDeviceManager) Get ¶
func (m *SingleDeviceManager) Get( ctx context.Context, ia addr.IA, ) (control.DeviceHandle, error)
Get returns a handle to the device for the ISD-AS. If no device exists, one will be created. If a device already exists, a handle to the existing device is returned. The caller must Close the handle to guarantee that resources will be cleaned up.