Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // Address used for link local discovery. // Multicast on port 5227 MulticastDiscoveryIP6 = net.ParseIP("FF02::5227") MulticastDiscoveryIP4 = net.ParseIP("224.0.0.250") )
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 {
UDPMsgConn *net.UDPConn `json:"-"`
ActiveInterfaces map[string]*ActiveInterface `json:"-"`
Name string `json:"name,omitempty"`
ActiveP2P string `json:"-"`
VIP64 uint64 `json:"-"`
Nodes map[string]*Node `json:"-"`
// contains filtered or unexported fields
}
func (*LLDiscovery) AnnounceMulticast ¶
func (gw *LLDiscovery) AnnounceMulticast()
Sends a packet to dmesh routers, using local multicast.
func (*LLDiscovery) FixIp6ForHTTP ¶
func (gw *LLDiscovery) FixIp6ForHTTP(addr *net.UDPAddr) string
// Format an address + zone + port for use in HTTP request
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
func (*LLDiscovery) Start ¶
func (gw *LLDiscovery) Start() error
Starts create a UDP listener for local UDP messages, used for direct reply and ACK.
Also starts a periodic task to find the interfaces and send multicast messages on each network. Each interface will get a listener for that interface.
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.