Documentation ¶
Overview ¶
Package p2plocate is a peer to peer discovery tool that uses UDP broadcasts on the local network to discover services running on other computers within that network and to determine what functions those services support.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetBroadcastAddress ¶
GetBroadcastAddress returns the broadcast address for the specified IP address's network.
func GetClientID ¶
func GetClientID() string
GetClientID returns the unique client id (UUID) for this application.
func GetLocalBroadcastAddress ¶
func GetLocalBroadcastAddress() string
GetLocalBroadcastAddress returns the broadcast address for the local network
func GetLocalIPAddresses ¶
GetLocalIPAddresses gets a list of valid IPv4 addresses for the local machine
Types ¶
type Device ¶
Device ... Holds data about a discovered device
func (*Device) HasFunction ¶
HasFunction ... Returns whether or not the device offers the specified function
type Msg ¶
Msg ... The structure containing the data that is sent with a broadcast message
type P2PServer ¶
type P2PServer struct { PortNo int ClientID string BroadcastAddr string IsRunning bool LastDiscoverOK bool LastDiscover time.Time LastError error Functions []string Devices []Device // contains filtered or unexported fields }
P2PServer is used to locate services running on other devices and determine their functions.
func (*P2PServer) Discover ¶
Discover broadcasts a discovery message and rebuilds the list of devices from the replies received from the other devices on the local network
func (*P2PServer) GetDevicesForFunction ¶
GetDevicesForFunction returns a list of devices that offer the specified function.
func (*P2PServer) OnDiscover ¶
func (s *P2PServer) OnDiscover(f func())
OnDiscover allows a func to be set that will be called when a device is discovered or updated