routing

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseConnector

type BaseConnector struct {
	// contains filtered or unexported fields
}

wire connector

func (*BaseConnector) Dial

func (c *BaseConnector) Dial(endpoint string)

connect to endpoint

type Connector

type Connector interface {
	Dial(string)
}

Connector interface

func NewBaseConnector

func NewBaseConnector(r *Router) (Connector, error)

type Option

type Option func(r *Router) error

router option

func WithConnector

func WithConnector() Option

func WithDiscovery

func WithDiscovery(namespace string) Option

discovery

func WithFakeIP

func WithFakeIP(network, script, db string) Option

dns fake ip

func WithForward

func WithForward(forwardCIDRs ...string) Option

forward cidrs

func WithMaxMetric

func WithMaxMetric(metric int) Option

max metric allowd for this rouer

func WithName added in v0.1.14

func WithName(name string) Option

name

type Port

type Port struct {
	// contains filtered or unexported fields
}

port is a connect session with a node

func (*Port) Address

func (p *Port) Address() net.IP

func (*Port) AnnouceRouting

func (p *Port) AnnouceRouting(routings *message.Routing) error

send routing info to peers

func (*Port) BeginRttTiming

func (p *Port) BeginRttTiming()

func (*Port) Close

func (p *Port) Close() error

close port

func (*Port) EndRttTiming

func (p *Port) EndRttTiming()

func (*Port) Faster

func (p *Port) Faster(base int) bool

return true, if port has smaller rtt. law of large number

func (*Port) IsTunnel

func (p *Port) IsTunnel() bool

func (*Port) PeerID

func (p *Port) PeerID() string

func (*Port) ReadPacket

func (p *Port) ReadPacket(packet *message.Packet) error

func (*Port) Rtt

func (p *Port) Rtt() int

func (*Port) String

func (p *Port) String() string

func (*Port) WritePacket

func (p *Port) WritePacket(packet *message.Packet) error

send packet to target wire

type Router

type Router struct {
	// connector
	Connector
	// contains filtered or unexported fields
}

router

func NewRouter

func NewRouter(localcidr string, opts ...Option) *Router

func (*Router) Close

func (r *Router) Close()

Close the router

func (*Router) Done

func (r *Router) Done() <-chan struct{}

func (*Router) FindDestPort

func (r *Router) FindDestPort(dst net.IP) (*Port, error)

find dest port

func (*Router) RegisterPort

func (r *Router) RegisterPort(p *Port) error

func (*Router) UpdateRouting

func (r *Router) UpdateRouting(p *Port, routing message.Routing) error

update routing tables for this port

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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