@@ -106,8 +106,8 @@ type agent_t struct {
106106func new_agent () (agent * agent_t ) {
107107
108108 // push output from udp into zmq socket
109- bcast := & net.UDPAddr {Port : PING_PORT_NUMBER , IP : net .IPv4bcast }
110- conn , e := net .ListenUDP ("udp" , bcast )
109+ addr := & net.UDPAddr {Port : PING_PORT_NUMBER , IP : net .IPv4allsys }
110+ conn , e := net .ListenMulticastUDP ("udp" , nil , addr )
111111 if e != nil {
112112 panic (e )
113113 }
@@ -139,6 +139,8 @@ func new_agent() (agent *agent_t) {
139139 peers : make (map [string ]* peer_t ),
140140 }
141141
142+ pipe .SendMessage ("AGENT " , uuID .String ())
143+
142144 return
143145}
144146
@@ -177,7 +179,7 @@ func (agent *agent_t) handle_beacon() (err error) {
177179 uuid_bytes := []byte (msg [0 ])
178180 if bytes .Compare (uuid_bytes , agent .uuid_bytes ) != 0 {
179181 // Find or create peer via its UUID string
180- uuID , _ := uuid .ParseBytes (uuid_bytes )
182+ uuID , _ := uuid .FromBytes (uuid_bytes )
181183 uuid_string := uuID .String ()
182184 peer , ok := agent .peers [uuid_string ]
183185 if ! ok {
@@ -199,7 +201,7 @@ func (agent *agent_t) handle_beacon() (err error) {
199201func (agent * agent_t ) reap_peer (peer * peer_t ) {
200202 if time .Now ().After (peer .expires_at ) {
201203 // Report peer left the network
202- agent .pipe .SendMessage ("LEFT" , peer .uuid_string )
204+ agent .pipe .SendMessage ("LEFT " , peer .uuid_string )
203205 delete (agent .peers , peer .uuid_string )
204206 }
205207}
0 commit comments