Documentation ¶
Index ¶
- Variables
- func ActiveNetworks(gw *LLDiscovery) (map[string]*ActiveInterface, error)
- func IPs() []net.IP
- func IsRFC1918(ip net.IP) bool
- func ListenUDP(gw *LLDiscovery)
- type ActiveInterface
- type LLDiscovery
- func (gw *LLDiscovery) AnnounceMulticast()
- func (gw *LLDiscovery) FixIp6ForHTTP(addr *net.UDPAddr) string
- func (gw *LLDiscovery) HttpGetLLIf(w http.ResponseWriter, r *http.Request)
- func (gw *LLDiscovery) OnLocalNetworkFunc(node *Node, addr *net.UDPAddr, fromMySTA bool)
- func (gw *LLDiscovery) PeriodicThread() error
- func (gw *LLDiscovery) RefreshNetworks()
- type Node
- type NodeAnnounce
Constants ¶
This section is empty.
Variables ¶
var ( MetricActiveNetworks = expvar.NewInt("net_active_interfaces") MetricChangedNetworks = expvar.NewInt("net_changed_interfaces_total") MetricLLReceived = expvar.NewInt("ll_receive_total") MetricLLReceivedAck = expvar.NewInt("ll_receive_ack_total") MetricLLReceiveErr = expvar.NewInt("ll_receive_err_total") MetricLLTotal = expvar.NewInt("ll_peers") )
var ( // Address used for link local discovery. // Multicast on port 5227 MulticastDiscoveryIP6 = net.ParseIP("FF02::5227") MulticastDiscoveryIP4 = net.ParseIP("224.0.0.250") )
var (
VerboseAnnounce = true
)
Functions ¶
func ActiveNetworks ¶
func ActiveNetworks(gw *LLDiscovery) (map[string]*ActiveInterface, error)
ActiveNetworks lists the networks that have IP6 link local, and detects if they are android special or AP. (ap, p2pClient)
Types ¶
type ActiveInterface ¶
type ActiveInterface struct { // Interface name. Name containing 'p2p' results in specific behavior. Name string // IP6 link local address. May be nil if IPPub is set. // One or the other must be set. IP6LL net.IP // IP4 address - may be a routable address, nil or private address. // If public address - may be included in the register, but typically not // useful. IP4 net.IP // Public addresses. IP6 address may be used for direct connections (in some // cases) IPPub []net.IP // Port for the UDP unicast link-local listener. Port int // Port for the UDP unicast link-local listener. Port4 int // True if this interface is an Android AP AndroidAP bool // True if this interface is connected to an Android DM node. AndroidAPClient bool // contains filtered or unexported fields }
ActiveInterface tracks one 'up' interface. Used for IPv6 multicast, which requires 'zone', and to find the local addresses. On recent Android - it is blocked by privacy and not used.
type LLDiscovery ¶
type LLDiscovery struct { Nodes map[string]*Node // Will be updated with the list of active interfaces // by Refresh() calls or provided by Android. // Key is the string representation of the address. ActiveInterfaces map[string]*ActiveInterface // If set, the p2p- interface name of the current active AP // The name may change - used to adjust the address/zone of nodes. // All nodes have LL addresses including the old zone - might be better to remove any known node, // and wait for it to reannounce or respond to our announce. It'll take some time to reconnect as well. ActiveP2P string // SSID and password of the AP AP string APFreq string PSK string // Set to the SSID of the main connection. 'w' param in the net status message. ConnectedWifi string WifiFreq string WifiLevel string // Listening on * for signed messages // Source for sent messages and multicasts UDPMsgConn *net.UDPConn // contains filtered or unexported fields }
link local announcements,discovery and messaging
func (*LLDiscovery) AnnounceMulticast ¶
func (gw *LLDiscovery) AnnounceMulticast()
Sends a packet to dmesh routers, using local multicast. Called when refreshNetworks is called, 15 min or on change
func (*LLDiscovery) FixIp6ForHTTP ¶
func (gw *LLDiscovery) FixIp6ForHTTP(addr *net.UDPAddr) string
Format an address + zone + port for use in HTTP request
func (*LLDiscovery) HttpGetLLIf ¶
func (gw *LLDiscovery) HttpGetLLIf(w http.ResponseWriter, r *http.Request)
func (*LLDiscovery) OnLocalNetworkFunc ¶
func (gw *LLDiscovery) OnLocalNetworkFunc(node *Node, addr *net.UDPAddr, fromMySTA bool)
Called after connection to the VPN has been created.
Currently used only for Mesh AP chains.
func (*LLDiscovery) PeriodicThread ¶
func (gw *LLDiscovery) PeriodicThread() error
Periodic refresh and registration.
func (*LLDiscovery) RefreshNetworks ¶
func (gw *LLDiscovery) RefreshNetworks()
RefreshNetworks will update the list of ActiveInterface networks, and ensure each has a listener. Local communication uses the link-local address. If the interface is connected to an Android AP, it uses a link-local multicast address instead.
- Called from android using "r" message, on connectivity changes - Also called from android at startup and property changes ( "P" - properties ). - 15-min thread on link local
type Node ¶
type Node struct { ID string LastSeen time.Time // In seconds since first seen, last 100 Seen []int `json:"-"` // Information from the node - from an announce or message. // Not trusted, self-signed. NodeAnnounce *NodeAnnounce `json:"info,omitempty"` LastSeen4 time.Time Last4 *net.UDPAddr LastSeen6 time.Time Last6 *net.UDPAddr }
type NodeAnnounce ¶
type NodeAnnounce struct { UA string `json:"UA,omitempty"` // Non-link local IPs from all interfaces. Includes public internet addresses // and Wifi IP4 address. Used to determine if a node is directly connected. IPs []*net.UDPAddr `json:"addrs,omitempty"` // Set if the node is an active Android AP. SSID string `json:"ssid,omitempty"` // True if the node is an active Android AP on the interface sending the message. // Will trigger special handling in link-local - if the receiving interface is also // an android client. AP bool `json:"AP,omitempty"` Ack bool `json:"ACK,omitempty"` // VIP of the direct parent, if this node is connected. // Used to determine the mesh topology. Vpn string `json:"Vpn,omitempty"` }
Information about a node. Sent periodically, signed by the origin - for example as a JWT, or UDP proto. TODO: map it to Pod, IPFS announce TODO: move Wifi discovery to separate package.