Documentation ¶
Index ¶
- Variables
- type Host
- type Intermediate
- type NamedRoute
- type Routable
- type Router
- func (r *Router) AddName(n *NamedRoute) error
- func (r *Router) DialContext(ctx context.Context, network, address string) (net.Conn, error)
- func (r *Router) Exists(_ context.Context, s string) error
- func (r *Router) Find(n string) (Routable, bool)
- func (r *Router) Names(rtbl Routable) ([]NamedRoute, error)
- func (r *Router) Offline(d Routable)
- func (r *Router) Online(rtbl Routable) (bool, error)
- func (r *Router) RemoveName(s string, from Routable) error
- func (r *Router) RemoveNames(from Routable) ([]*NamedRoute, error)
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("not found")
ErrNotFound errors are returned when searching for something that does not exist
var ErrOffline = errors.New("peer offline")
ErrOffline used to indicate an offline host
Functions ¶
This section is empty.
Types ¶
type Host ¶
type Host struct { Routable `json:"-"` Name string `json:"name"` // LastSeen is used when garbage collecting LastSeen time.Time `json:"lastseen"` Created time.Time `json:"created"` }
Host represents a host that can be offline
func (*Host) DialContext ¶
DialContext dials this host
type Intermediate ¶
type Intermediate struct { Host *Host `json:"host,omitempty"` NamedRoute *NamedRoute `json:"namedroute,omitempty"` }
Intermediate is able to json parse either Hosts or NamedRoutes from json files
type NamedRoute ¶
type NamedRoute struct { // Name, the FQDN Name string // Owner's pubkey fingerprint Owner string // contains filtered or unexported fields }
NamedRoute implements Routable and is used when people want to create more human friendly hostnames for their tunnels
func NewName ¶
func NewName(s string, r Routable) *NamedRoute
NewName sets up and returns a *NamedRoute which can be added the router
func (*NamedRoute) DialContext ¶
DialContext on a NamedRoute looks up the correct tunnel in the router and uses its DialContext
func (*NamedRoute) FQDN ¶
func (n *NamedRoute) FQDN() string
FQDN returns the fully qualified domain name for this route
func (*NamedRoute) Replaced ¶
func (n *NamedRoute) Replaced()
Replaced for NamedRoutes means deleting the NamedRoute for good and really should not happen - only in the case that a user tries to steal another users pubkey.hostname name - an when the guy with the actural key comes online - this Replaced is called which will remove it from the database
type Routable ¶
type Routable interface { DialContext(ctx context.Context, network, address string) (net.Conn, error) // A routable should be able to identify it self FQDN() string // Replaced is used to indicate to a ssh session that it's routes // have been replaced with another ssh session Replaced() }
Routable describes requirements to be routable
type Router ¶
Router - takes care of Routable and Namedroutes
func (*Router) AddName ¶
func (r *Router) AddName(n *NamedRoute) error
AddName adds a *NamedRoute to the router
func (*Router) DialContext ¶
DialContext is used by stuff that what to dial something up
func (*Router) Names ¶
func (r *Router) Names(rtbl Routable) ([]NamedRoute, error)
Names returns a list of NamedRoutes
func (*Router) Online ¶
Online should only be used by peers, e.g. ssh clients which proved by authentication that they do infact have the private key for their FQDN
func (*Router) RemoveName ¶
RemoveName removes a named router if * The route exists * The route is a *NamedRoute * The *NamedRoute's owner, is the one trying to remove it
func (*Router) RemoveNames ¶
func (r *Router) RemoveNames(from Routable) ([]*NamedRoute, error)
RemoveNames removes all names from a Routable