@@ -11,6 +11,8 @@ import (
11
11
"golang.org/x/xerrors"
12
12
"gvisor.dev/gvisor/pkg/tcpip/adapters/gonet"
13
13
"inet.af/netaddr"
14
+ "tailscale.com/hostinfo"
15
+ "tailscale.com/ipn/ipnstate"
14
16
"tailscale.com/net/dns"
15
17
"tailscale.com/net/netns"
16
18
"tailscale.com/net/tsdial"
@@ -239,11 +241,11 @@ func (s *Server) SetNodeCallback(callback func(node *Node)) {
239
241
fmt .Printf ("\n \n \n \n Network status: %+v %s\n \n \n \n " , s , err )
240
242
})
241
243
242
- s .wireguardEngine .AddNetworkMapCallback (func (nm * netmap.NetworkMap ) {
243
- fmt .Printf ("\n \n \n \n Network map: %+v\n \n \n \n " , nm )
244
- })
244
+ // s.wireguardEngine.AddNetworkMapCallback(func(nm *netmap.NetworkMap) {
245
+ // fmt.Printf("\n\n\n\nNetwork map: %+v\n\n\n\n", nm)
246
+ // })
245
247
s .magicConn .SetNetInfoCallback (func (ni * tailcfg.NetInfo ) {
246
- fmt .Printf ("\n \n \n \n \n Updating network information: %+v\n \n \n \n \n " , ni )
248
+ // fmt.Printf("\n\n\n\n\nUpdating network information: %+v\n\n\n\n\n", ni)
247
249
callback (& Node {
248
250
ID : s .netMap .SelfNode .ID ,
249
251
Key : s .netMap .SelfNode .Key ,
@@ -256,16 +258,6 @@ func (s *Server) SetNodeCallback(callback func(node *Node)) {
256
258
})
257
259
}
258
260
259
- // Once the client disconnects, why not just reset the connection?
260
- // When the agent reconnects it will update itself, in which case
261
- // we should do a `SetNetInfoCallback` to get the personal node info
262
- // again to send on the wire.
263
- //
264
- // On disconnect, we should continually poll the workspace agent to
265
- // update the node to reestablish a connection.
266
- //
267
- // How do we know if we're disconnected?
268
-
269
261
// UpdateNodes connects with a set of peers. This can be constantly updated,
270
262
// and peers will continually be reconnected as necessary.
271
263
func (s * Server ) UpdateNodes (nodes []* Node ) error {
@@ -283,6 +275,7 @@ func (s *Server) UpdateNodes(nodes []*Node) error {
283
275
Addresses : node .Addresses ,
284
276
AllowedIPs : node .AllowedIPs ,
285
277
DERP : fmt .Sprintf ("%s:%d" , magicsock .DerpMagicIP , node .PreferredDERP ),
278
+ Hostinfo : hostinfo .New ().View (),
286
279
}
287
280
}
288
281
s .netMap .Peers = make ([]* tailcfg.Node , 0 , len (peerMap ))
@@ -302,6 +295,10 @@ func (s *Server) UpdateNodes(nodes []*Node) error {
302
295
return nil
303
296
}
304
297
298
+ func (s * Server ) Ping (ip netaddr.IP , pingType tailcfg.PingType , cb func (* ipnstate.PingResult )) {
299
+ s .wireguardEngine .Ping (ip , pingType , cb )
300
+ }
301
+
305
302
// Close shuts down the Wireguard connection.
306
303
func (s * Server ) Close () error {
307
304
s .mutex .Lock ()
0 commit comments