@cryptotaxi247 / kubo / commits / 4ce6358bd

pnet: add warning when we are in PNet and have no peers

License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>

Jakub Sztandera committed Feb 17, 2017 at 13:58 UTC 4ce6358bd7ce88caa68981c8d7d776b608e80de7
1 file changed +18
core/core.go
+18
@@ -190,6 +190,24 @@ func (n *IpfsNode) startOnlineServices(ctx context.Context, routingOption Routin
190 return err
191 }
192 n.PNetFingerpint = protec.Fingerprint()
193 + go func() {
194 + t := time.NewTicker(30 * time.Second)
195 + <-t.C // swallow one tick
196 + for {
197 + select {
198 + case <-t.C:
199 + if ph := n.PeerHost; ph != nil {
200 + if len(ph.Network().Peers()) == 0 {
201 + log.Warning("We are in private network and have no peers.")
202 + log.Warning("This might be configuration mistake.")
203 + }
204 + }
205 + case <-n.Process().Closing():
206 + t.Stop()
207 + return
208 + }
209 + }
210 + }()
211 }
212
213 peerhost, err := hostOption(ctx, n.Identity, n.Peerstore, n.Reporter,