Documentation
¶
Index ¶
- Constants
- Variables
- func AddMetric(a, b uint32) uint32
- func AwaitAll[T any](ctx context.Context, futures []Future[T]) ([]T, error)
- func Bootstrap(centralPath, nodePath, logPath string, verbose bool, opts state.NylonOptions)
- func CleanupWireGuardDevice(n *Nylon) error
- func ComputeRoutes(s *state.RouterState, r Router)
- func ConfigureAlias(logger *slog.Logger, ifName string, addr netip.Addr) error
- func ConfigureRoute(logger *slog.Logger, dev tun.Device, itfName string, route netip.Prefix) error
- func Exec(logger *slog.Logger, name string, arg ...string) error
- func ExecSplit(logger *slog.Logger, command string) error
- func FetchConfig(repoStr string, key state.NyPublicKey, maxSize int64) (*state.CentralCfg, error)
- func FullTableUpdate(s *state.RouterState, r Router)
- func HandleAckRetract(s *state.RouterState, r Router, neighId state.NodeId, prefix netip.Prefix)
- func HandleNeighbourUpdate(s *state.RouterState, r Router, neighId state.NodeId, adv state.PubRoute)
- func HandleNylonIPC(n *Nylon, rw *bufio.ReadWriter) error
- func HandleSeqnoRequest(s *state.RouterState, r Router, fromNeigh state.NodeId, src state.Source, ...)
- func InitInterface(logger *slog.Logger, ifName string) error
- func InitUAPI(logger *slog.Logger, itfName string) (net.Listener, error)
- func IsStrictlyBetter(curRoute state.SelRoute, newRoute state.SelRoute) bool
- func NeighContainsFunc(s *state.RouterState, f func(neigh state.NodeId, route state.NeighRoute) bool) bool
- func NewWireGuardDevice(n *Nylon) (dev *device.Device, tunDevice tun.Device, realItf string, err error)
- func PushFullTable(s *state.RouterState, r Router, neigh state.NodeId)
- func RemoveAlias(logger *slog.Logger, ifName string, addr netip.Addr) error
- func RemoveRoute(logger *slog.Logger, dev tun.Device, itfName string, route netip.Prefix) error
- func RunGC(s *state.RouterState, r Router)
- func SendIPCRequest(itf string, req *protocol.IpcRequest) (*protocol.IpcResponse, error)
- func SendIPCStream(itf string, req *protocol.IpcRequest, ...) error
- func SeqnoGe(a, b uint16) bool
- func SeqnoGt(a, b uint16) bool
- func SeqnoLe(a, b uint16) bool
- func SeqnoLt(a, b uint16) bool
- func ShouldSwitch(curRoute state.SelRoute, newRoute state.SelRoute, ...) bool
- func SolveStarvation(router *state.RouterState, r Router)
- type AppliedSystemState
- type ApplyResult
- type EpPing
- type ForwardingTables
- type Future
- type IOPending
- type Nylon
- func (n *Nylon) ApplyCentralConfig(cfg *state.CentralCfg) (ApplyResult, error)
- func (n *Nylon) BroadcastRequestSeqno(src state.Source, seqno uint16, hopCnt uint8)
- func (n *Nylon) BroadcastSendRouteUpdate(advRoute state.PubRoute)
- func (n *Nylon) Cleanup() error
- func (n *Nylon) CleanupRouter() error
- func (n *Nylon) ComputeSysRouteTable() []netip.Prefix
- func (n *Nylon) Dispatch(fun func() error)
- func (n *Nylon) GcRouter() error
- func (n *Nylon) GetNeighIO(neigh state.NodeId) *IOPending
- func (n *Nylon) Init() error
- func (n *Nylon) InitRouter() error
- func (n *Nylon) InstallTC()
- func (n *Nylon) Probe(node state.NodeId, ep *state.NylonEndpoint) error
- func (n *Nylon) RepeatTask(fun func() error, delay time.Duration)
- func (n *Nylon) RequestSeqno(neigh state.NodeId, src state.Source, seqno uint16, hopCnt uint8)
- func (n *Nylon) RouterEvent(event string, desc string, args ...any)
- func (n *Nylon) ScheduleTask(fun func() error, delay time.Duration)
- func (n *Nylon) SendAckRetract(neigh state.NodeId, prefix netip.Prefix)
- func (n *Nylon) SendNylon(pkt *protocol.Ny, endpoint conn.Endpoint, peer *device.Peer) error
- func (n *Nylon) SendNylonBundle(pkt *protocol.TransportBundle, endpoint conn.Endpoint, peer *device.Peer) error
- func (n *Nylon) SendRouteUpdate(neigh state.NodeId, advRoute state.PubRoute)
- func (n *Nylon) Start() error
- func (n *Nylon) Stop()
- func (n *Nylon) SyncApplicationState() error
- func (n *Nylon) SyncSystemState() error
- func (n *Nylon) SyncWireGuard() error
- func (n *Nylon) TableDeleteRoute(prefix netip.Prefix)
- func (n *Nylon) TableInsertRoute(prefix netip.Prefix, route state.SelRoute)
- func (n *Nylon) UpdateNeighbour(neigh state.NodeId)
- type NylonTrace
- type RouteTableEntry
- type Router
Constants ¶
const (
NyProtoId = 8
)
Variables ¶
var ErrFutureAlreadyAwaited = errors.New("future already awaited")
Functions ¶
func AwaitAll ¶ added in v0.4.4
AwaitAll blocks until every input future completes or ctx is canceled. Values are returned in the same order as the input slice. AwaitAll awaits and consumes every completed input future in order.
func Bootstrap ¶ added in v0.3.3
func Bootstrap(centralPath, nodePath, logPath string, verbose bool, opts state.NylonOptions)
Bootstrap provides startup logic in a real environment
func CleanupWireGuardDevice ¶
func ComputeRoutes ¶
func ComputeRoutes(s *state.RouterState, r Router)
func ConfigureAlias ¶
func ConfigureRoute ¶
func FetchConfig ¶ added in v0.3.3
func FetchConfig(repoStr string, key state.NyPublicKey, maxSize int64) (*state.CentralCfg, error)
fetches and unbundles central config from url
func FullTableUpdate ¶
func FullTableUpdate(s *state.RouterState, r Router)
func HandleAckRetract ¶
func HandleNeighbourUpdate ¶
func HandleNeighbourUpdate(s *state.RouterState, r Router, neighId state.NodeId, adv state.PubRoute)
this function should also be called on every probe
func HandleNylonIPC ¶ added in v0.4.0
func HandleNylonIPC(n *Nylon, rw *bufio.ReadWriter) error
func HandleSeqnoRequest ¶
func IsStrictlyBetter ¶ added in v0.4.0
func NeighContainsFunc ¶
func NeighContainsFunc(s *state.RouterState, f func(neigh state.NodeId, route state.NeighRoute) bool) bool
func NewWireGuardDevice ¶
func PushFullTable ¶
func PushFullTable(s *state.RouterState, r Router, neigh state.NodeId)
func RemoveAlias ¶ added in v0.4.0
func RemoveRoute ¶ added in v0.4.0
func RunGC ¶
func RunGC(s *state.RouterState, r Router)
func SendIPCRequest ¶ added in v0.4.0
func SendIPCRequest(itf string, req *protocol.IpcRequest) (*protocol.IpcResponse, error)
func SendIPCStream ¶ added in v0.4.0
func SendIPCStream(itf string, req *protocol.IpcRequest, handler func(*protocol.IpcResponse) error) error
func ShouldSwitch ¶
func SolveStarvation ¶
func SolveStarvation(router *state.RouterState, r Router)
Types ¶
type AppliedSystemState ¶ added in v0.4.0
type ApplyResult ¶ added in v0.4.0
type ApplyResult string
const ( ApplyNoop ApplyResult = "noop" ApplyApplied ApplyResult = "applied" ApplyRejected ApplyResult = "rejected" ApplyRestartRequired ApplyResult = "restart_required" )
type ForwardingTables ¶ added in v0.4.5
type ForwardingTables struct {
// Forward contains the full routing table.
Forward *bart.Table[RouteTableEntry]
// Exit contains only routes to services hosted on this node.
Exit *bart.Table[RouteTableEntry]
}
type Future ¶ added in v0.4.4
type Future[T any] struct { // contains filtered or unexported fields }
Future is a single-assignment async result.
func NewDispatchFuture ¶ added in v0.4.4
func NewFuture ¶ added in v0.4.4
NewFuture returns a Future and its completion function. Only the first completion call is used; later calls are ignored.
type Nylon ¶
type Nylon struct {
Trace *NylonTrace
// tunables and options
state.RouterTunables
state.NylonOptions
// state
state.ConfigState
RouterState *state.RouterState
AppliedSystem AppliedSystemState
PingBuf *ttlcache.Cache[uint64, EpPing]
PeerMap atomic.Pointer[map[state.NyPublicKey]state.NodeId]
DNSResolver *state.DNSResolver
EndpointResolver *state.EndpointResolver
// runtime/application
DispatchChannel chan func() error
Log *slog.Logger
ConfigPath string
// resources
Tun tun.Device
Interface string
Device *device.Device
// only used for debugging & tests
AuxConfig map[string]any
// lifecycle
Context context.Context
Cancel context.CancelCauseFunc
// contains filtered or unexported fields
}
func NewNylon ¶ added in v0.4.0
func NewNylon(ccfg state.CentralCfg, ncfg state.LocalCfg, logLevel slog.Level, configPath string, aux map[string]any, opts state.NylonOptions, tunables *state.RouterTunables) (*Nylon, error)
func (*Nylon) ApplyCentralConfig ¶ added in v0.4.0
func (n *Nylon) ApplyCentralConfig(cfg *state.CentralCfg) (ApplyResult, error)
func (*Nylon) BroadcastRequestSeqno ¶ added in v0.4.0
func (*Nylon) BroadcastSendRouteUpdate ¶ added in v0.4.0
func (*Nylon) CleanupRouter ¶ added in v0.4.0
func (*Nylon) ComputeSysRouteTable ¶ added in v0.4.0
ComputeSysRouteTable computes: computed = prefixes - (((n.CentralCfg.ExcludeIPs U selected self prefixes) - n.LocalCfg.UnexcludeIPs) U n.LocalCfg.ExcludeIPs)
func (*Nylon) Dispatch ¶ added in v0.4.0
Dispatch Dispatches the function to run on the main thread without waiting for it to complete
func (*Nylon) GetNeighIO ¶ added in v0.4.0
func (*Nylon) InitRouter ¶ added in v0.4.0
func (*Nylon) RepeatTask ¶ added in v0.4.0
func (*Nylon) RequestSeqno ¶ added in v0.4.0
func (*Nylon) RouterEvent ¶ added in v0.4.0
func (*Nylon) ScheduleTask ¶ added in v0.4.0
func (*Nylon) SendAckRetract ¶ added in v0.4.0
func (*Nylon) SendNylonBundle ¶
func (*Nylon) SendRouteUpdate ¶ added in v0.4.0
func (*Nylon) SyncApplicationState ¶ added in v0.4.5
func (*Nylon) SyncSystemState ¶ added in v0.4.0
func (*Nylon) SyncWireGuard ¶ added in v0.4.0
func (*Nylon) TableDeleteRoute ¶ added in v0.4.0
func (*Nylon) TableInsertRoute ¶ added in v0.4.0
func (*Nylon) UpdateNeighbour ¶ added in v0.4.0
type NylonTrace ¶ added in v0.4.0
type NylonTrace struct {
broadcast.Broadcaster
}
func (*NylonTrace) Cleanup ¶ added in v0.4.0
func (n *NylonTrace) Cleanup() error
func (*NylonTrace) Init ¶ added in v0.4.0
func (n *NylonTrace) Init(core *Nylon) error
type RouteTableEntry ¶
type Router ¶
type Router interface {
SendRouteUpdate(neigh state.NodeId, advRoute state.PubRoute)
SendAckRetract(neigh state.NodeId, prefix netip.Prefix)
BroadcastSendRouteUpdate(advRoute state.PubRoute)
RequestSeqno(neigh state.NodeId, src state.Source, seqno uint16, hopCnt uint8)
BroadcastRequestSeqno(src state.Source, seqno uint16, hopCnt uint8)
TableInsertRoute(prefix netip.Prefix, route state.SelRoute)
TableDeleteRoute(prefix netip.Prefix)
RouterEvent(event string, desc string, args ...any)
}
Router is an interface that defines the underlying router operations
Source Files
¶
- entrypoint.go
- future.go
- ipc_client.go
- ipc_handler.go
- nylon.go
- nylon_apply.go
- nylon_distribution.go
- nylon_endpoints.go
- nylon_gc.go
- nylon_passive.go
- nylon_prefix_health.go
- nylon_scheduler.go
- nylon_tc.go
- nylon_trace.go
- nylon_wireguard.go
- observability.go
- router.go
- router_algo.go
- router_utils.go
- sys.go
- sys_linux.go
- sys_physical.go
- sys_utils.go
- utils.go