mirror of
https://github.com/gravitl/netmaker.git
synced 2025-02-25 16:44:01 +08:00
added conn closes
This commit is contained in:
parent
0551e54dd6
commit
5cf69ebe5b
4 changed files with 10 additions and 4 deletions
|
@ -171,6 +171,7 @@ func Pull(network string, manual bool) (*models.Node, error) {
|
|||
ncutils.PrintLog("Cant dial GRPC server: "+err.Error(), 1)
|
||||
return nil, err
|
||||
}
|
||||
defer conn.Close()
|
||||
wcclient := nodepb.NewNodeServiceClient(conn)
|
||||
|
||||
ctx, err := auth.SetJWT(wcclient, network)
|
||||
|
@ -253,6 +254,7 @@ func Push(network string) error {
|
|||
ncutils.PrintLog("Cant dial GRPC server: "+err.Error(), 1)
|
||||
return err
|
||||
}
|
||||
defer conn.Close()
|
||||
wcclient = nodepb.NewNodeServiceClient(conn)
|
||||
|
||||
ctx, err := auth.SetJWT(wcclient, network)
|
||||
|
|
|
@ -156,7 +156,7 @@ func Uninstall() error {
|
|||
} else if ncutils.IsMac() {
|
||||
daemon.CleanupMac()
|
||||
} else if !ncutils.IsKernel() {
|
||||
ncutils.PrintLog("manual cleanup required",1)
|
||||
ncutils.PrintLog("manual cleanup required", 1)
|
||||
}
|
||||
|
||||
return err
|
||||
|
@ -177,6 +177,7 @@ func LeaveNetwork(network string) error {
|
|||
if err != nil {
|
||||
log.Printf("Unable to establish client connection to "+servercfg.GRPCAddress+": %v", err)
|
||||
} else {
|
||||
defer conn.Close()
|
||||
wcclient = nodepb.NewNodeServiceClient(conn)
|
||||
|
||||
ctx, err := auth.SetJWT(wcclient, network)
|
||||
|
|
|
@ -90,7 +90,7 @@ func JoinNetwork(cfg config.ClientConfig, privateKey string) error {
|
|||
if err != nil {
|
||||
log.Fatalf("Unable to establish client connection to "+cfg.Server.GRPCAddress+": %v", err)
|
||||
}
|
||||
|
||||
defer conn.Close()
|
||||
wcclient = nodepb.NewNodeServiceClient(conn)
|
||||
|
||||
postnode := &models.Node{
|
||||
|
|
|
@ -29,6 +29,7 @@ func getGrpcClient(cfg *config.ClientConfig) (nodepb.NodeServiceClient, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer conn.Close()
|
||||
wcclient = nodepb.NewNodeServiceClient(conn)
|
||||
return wcclient, nil
|
||||
}
|
||||
|
@ -138,6 +139,7 @@ func GetPeers(macaddress string, network string, server string, dualstack bool,
|
|||
if err != nil {
|
||||
log.Fatalf("Unable to establish client connection to localhost:50051: %v", err)
|
||||
}
|
||||
defer conn.Close()
|
||||
// Instantiate the BlogServiceClient with our client connection to the server
|
||||
wcclient = nodepb.NewNodeServiceClient(conn)
|
||||
|
||||
|
@ -215,11 +217,11 @@ func GetPeers(macaddress string, network string, server string, dualstack bool,
|
|||
continue // if can't parse CIDR
|
||||
}
|
||||
nodeEndpointArr := strings.Split(node.Endpoint, ":") // getting the public ip of node
|
||||
if ipnet.Contains(net.ParseIP(nodeEndpointArr[0])) { // ensuring egress gateway range does not contain public ip of node
|
||||
if ipnet.Contains(net.ParseIP(nodeEndpointArr[0])) { // ensuring egress gateway range does not contain public ip of node
|
||||
ncutils.PrintLog("egress IP range of "+iprange+" overlaps with "+node.Endpoint+", omitting", 2)
|
||||
continue // skip adding egress range if overlaps with node's ip
|
||||
}
|
||||
if ipnet.Contains(net.ParseIP(nodecfg.LocalAddress)) { // ensuring egress gateway range does not contain public ip of node
|
||||
if ipnet.Contains(net.ParseIP(nodecfg.LocalAddress)) { // ensuring egress gateway range does not contain public ip of node
|
||||
ncutils.PrintLog("egress IP range of "+iprange+" overlaps with "+nodecfg.LocalAddress+", omitting", 2)
|
||||
continue // skip adding egress range if overlaps with node's local ip
|
||||
}
|
||||
|
@ -293,6 +295,7 @@ func GetExtPeers(macaddress string, network string, server string, dualstack boo
|
|||
if err != nil {
|
||||
log.Fatalf("Unable to establish client connection to localhost:50051: %v", err)
|
||||
}
|
||||
defer conn.Close()
|
||||
// Instantiate the BlogServiceClient with our client connection to the server
|
||||
wcclient = nodepb.NewNodeServiceClient(conn)
|
||||
|
||||
|
|
Loading…
Reference in a new issue