Documentation ¶
Index ¶
- Constants
- Variables
- func CalculateExpectedFrameSize(addr net.Addr) int
- func CleanDomain(domain string) (cleaned string, valid bool)
- type Config
- func (c *Config) CheckInboundTrafficPolicy(protocol uint8, dstPort uint16, src netip.Addr) (allowed bool)
- func (c *Config) DevMode() bool
- func (c *Config) GetRouterInfo() *m.RouterInfo
- func (c *Config) OverlayFrameSize() int
- func (c *Config) SaveTo(filename string) error
- func (c *Config) SetDevMode(mode bool)
- func (c *Config) SetOverlayFrameSize(mtu int)
- func (c *Config) SetTunMTU(mtu int)
- func (c *Config) Started() time.Time
- func (c *Config) TunMTU() int
- func (c *Config) Uptime() time.Duration
- type Friend
- type FriendConfig
- type Router
- type Service
- type ServiceConfig
- type Store
- type System
Constants ¶
const ( // DefaultTunMTU is used for tun devices. DefaultTunMTU = 9000 // DefaultFrameSize is the default expected frame size based on the default tun mtu. DefaultFrameSize = DefaultTunMTU - IPv6HeaderMTUSize - TCPHeaderMTUSize - LinkFrameSize - FrameSizeEncrypted )
const ( BaseMTU = 1480 // 1500 with 20 bytes a little extra space for special cases. IPv4HeaderMTUSize = 20 // Without options, as not common. IPv6HeaderMTUSize = 40 // Without options, as not common. TCPHeaderMTUSize = 20 // Base size with no options. UDPHeaderMTUSize = 8 // Has no options. FrameSizeEncrypted = 80 // With 12 byte switch block. TODO: Source better. LinkFrameSize = 32 // TODO: Source better. )
MTU Calculation Configuration.
const DefaultPortNumber = 47369 // M(1+3), Y(2+5), C(3), O(1+5), R(1+8); 0xB909
DefaultPortNumber is the default port number used by Mycoria.
Variables ¶
var DefaultAPIAddress = netip.MustParseAddr("fd00::b909")
DefaultAPIAddress is the default local API address used by Mycoria.
var DefaultDotTLD = ".myco"
DefaultDotTLD is the default TLD that Mycoria uses, but with a dot prefix.
var DefaultTLD = "myco"
DefaultTLD is the default TLD that Mycoria uses.
var DefaultTLDBetweenDots = ".myco."
DefaultTLDBetweenDots is the default TLD that Mycoria uses, but between dots.
Functions ¶
func CalculateExpectedFrameSize ¶
CalculateExpectedFrameSize calculates the overlay MTU based on the given address.
func CleanDomain ¶ added in v0.1.0
CleanDomain cleans the given domain and also returns if it is valid.
Types ¶
type Config ¶
type Config struct { Store APIListen netip.AddrPort Friends []Friend FriendsByName map[string]Friend FriendsByIP map[netip.Addr]Friend Services []Service Resolve map[string]netip.Addr // contains filtered or unexported fields }
Config holds initialized configuration.
func LoadConfig ¶
LoadConfig loads the config from the given file.
func MakeTestConfig ¶
MakeTestConfig parses and returns the given config store with loosened checks. If anything fails, it panics.
func (*Config) CheckInboundTrafficPolicy ¶
func (c *Config) CheckInboundTrafficPolicy(protocol uint8, dstPort uint16, src netip.Addr) (allowed bool)
CheckInboundTrafficPolicy checks if the given inbound traffic is allowed.
func (*Config) GetRouterInfo ¶
func (c *Config) GetRouterInfo() *m.RouterInfo
GetRouterInfo retruns a new router info derived from config.
func (*Config) OverlayFrameSize ¶
OverlayFrameSize returns the expected maximum frame size for overlay network links.
func (*Config) SetDevMode ¶ added in v0.1.0
SetDevMode sets the development mode.
func (*Config) SetOverlayFrameSize ¶
SetOverlayFrameSize sets the expected maximum frame size for overlay network links.
func (*Config) Started ¶ added in v0.1.0
Started returns the time when the router was started. Measured by when the config was created.
type FriendConfig ¶
type FriendConfig struct { Name string `json:"name,omitempty" yaml:"name,omitempty"` IP string `json:"ip,omitempty" yaml:"ip,omitempty"` }
FriendConfig is a trusted router in the network.
type Router ¶
type Router struct { // Address it the identity of the router. Address m.AddressStorage `json:"address,omitempty" yaml:"address,omitempty"` // Universe holds the "universe" the router is in. Universe string `json:"universe,omitempty" yaml:"universe,omitempty"` UniverseSecret string `json:"universeSecret,omitempty" yaml:"universeSecret,omitempty"` // Isolate constrains outgoing traffic to friends. Isolate bool `json:"isolate,omitempty" yaml:"isolate,omitempty"` // Listen holds the peering URLs to listen on. // URLs must have an IP address as host. Listen []string `json:"listen,omitempty" yaml:"listen,omitempty"` // IANA holds a list of domains or IPs assigne by IANA through which the router can be reached. IANA []string `json:"iana,omitempty" yaml:"iana,omitempty"` // Connect holds the peering URLs the router // tries to always hold a connection to. Connect []string `json:"connect,omitempty" yaml:"connect,omitempty"` // AutoConnect specifies whether the router should automatically peer with // other routers (based on live usage data) to improve network flow. AutoConnect bool `json:"autoConnect,omitempty" yaml:"autoConnect,omitempty"` // Bootstrap holds peering URLs that the router uses to bootstrap to the network. Bootstrap []string `json:"bootstrap,omitempty" yaml:"bootstrap,omitempty"` // Stub runs the router in stub mode. It will not relay router announcements // and will appear as a dead end to other routers. Stub bool `json:"stub,omitempty" yaml:"stub,omitempty"` // Lite runs the router in lite mode. It will attempt to reduce any // non-essential activity and traffic. // Behavior will slightly change over time and also depends on other routers // playing along - do not use for workarounds. Lite bool `json:"lite,omitempty" yaml:"lite,omitempty"` }
Router defines all configuration regarding the overlay network itself.
type Service ¶
type Service struct { Name string Description string Domain string URL string Public bool Friends bool For []netip.Addr Advertise bool }
Service defines an endpoint other routers can send traffic to.
type ServiceConfig ¶
type ServiceConfig struct { Name string `json:"name,omitempty" yaml:"name,omitempty"` Description string `json:"description,omitempty" yaml:"description,omitempty"` Domain string `json:"domain,omitempty" yaml:"domain,omitempty"` URL string `json:"url,omitempty" yaml:"url,omitempty"` // Access Control Public bool `json:"public,omitempty" yaml:"public,omitempty"` Friends bool `json:"friends,omitempty" yaml:"friends,omitempty"` For []string `json:"for,omitempty" yaml:"for,omitempty"` Advertise bool `json:"advertise,omitempty" yaml:"advertise,omitempty"` }
ServiceConfig defines an endpoint other routers can send traffic to.
type Store ¶
type Store struct { Router Router `json:"router,omitempty" yaml:"router,omitempty"` System System `json:"system,omitempty" yaml:"system,omitempty"` ServiceConfigs []ServiceConfig `json:"services,omitempty" yaml:"services,omitempty"` FriendConfigs []FriendConfig `json:"friends,omitempty" yaml:"friends,omitempty"` ResolveConfig map[string]string `json:"resolve,omitempty" yaml:"resolve,omitempty"` }
Store holds all configuration in a storable format.
type System ¶
type System struct { TunName string `json:"tunName,omitempty" yaml:"tunName,omitempty"` DisableTun bool `json:"disableTun,omitempty" yaml:"disableTun,omitempty"` APIListen string `json:"apiListen,omitempty" yaml:"apiListen,omitempty"` StatePath string `json:"statePath,omitempty" yaml:"statePath,omitempty"` DisableChromiumWorkaround bool `json:"disableChromiumWorkaround,omitempty" yaml:"disableChromiumWorkaround,omitempty"` }
System defines all configuration regarding the system.