Browse Source

removing ping server function. Unnecessary

afeiszli 3 years ago
parent
commit
0531b6f78d
2 changed files with 1 additions and 23 deletions
  1. 0 18
      netclient/functions/daemon.go
  2. 1 5
      netclient/functions/mqpublish.go

+ 0 - 18
netclient/functions/daemon.go

@@ -17,7 +17,6 @@ import (
 	"time"
 
 	mqtt "github.com/eclipse/paho.mqtt.golang"
-	"github.com/go-ping/ping"
 	"github.com/gravitl/netmaker/logger"
 	"github.com/gravitl/netmaker/netclient/auth"
 	"github.com/gravitl/netmaker/netclient/config"
@@ -110,23 +109,6 @@ func UpdateKeys(nodeCfg *config.ClientConfig, client mqtt.Client) error {
 	return nil
 }
 
-// PingServer -- checks if server is reachable
-func PingServer(cfg *config.ClientConfig) error {
-	pinger, err := ping.NewPinger(cfg.Server.Server)
-	if err != nil {
-		return err
-	}
-	pinger.Timeout = 2 * time.Second
-	pinger.Count = 3
-	pinger.Run()
-	stats := pinger.Statistics()
-	if stats.PacketLoss == 100 {
-		return errors.New("ping error " + fmt.Sprintf("%f", stats.PacketLoss))
-	}
-	logger.Log(3, "ping of server", cfg.Server.Server, "was successful")
-	return nil
-}
-
 // == Private ==
 
 // sets MQ client subscriptions for a specific node config

+ 1 - 5
netclient/functions/mqpublish.go

@@ -75,11 +75,7 @@ func Checkin(ctx context.Context, wg *sync.WaitGroup) {
 						}
 					}
 				}
-				if err := PingServer(&nodeCfg); err != nil {
-					logger.Log(0, "could not ping server for", nodeCfg.Network, nodeCfg.Server.Server+"\n", err.Error())
-				} else {
-					Hello(&nodeCfg)
-				}
+				Hello(&nodeCfg)
 				checkCertExpiry(&nodeCfg)
 			}
 		}