mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-06 01:07:41 +08:00
logs, unused funcs, cleanup
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
package functions
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
@@ -21,10 +19,6 @@ import (
|
||||
"google.golang.org/grpc/metadata"
|
||||
)
|
||||
|
||||
var (
|
||||
wcclient nodepb.NodeServiceClient
|
||||
)
|
||||
|
||||
// ListPorts - lists ports of WireGuard devices
|
||||
func ListPorts() error {
|
||||
wgclient, err := wgctrl.New()
|
||||
@@ -101,30 +95,31 @@ func getPrivateAddrBackup() (string, error) {
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
err := errors.New("Local Address Not Found.")
|
||||
err := errors.New("local ip address not found")
|
||||
return "", err
|
||||
}
|
||||
return local, err
|
||||
}
|
||||
|
||||
func needInterfaceUpdate(ctx context.Context, mac string, network string, iface string) (bool, string, error) {
|
||||
var header metadata.MD
|
||||
req := &nodepb.Object{
|
||||
Data: mac + "###" + network,
|
||||
Type: nodepb.STRING_TYPE,
|
||||
}
|
||||
readres, err := wcclient.ReadNode(ctx, req, grpc.Header(&header))
|
||||
if err != nil {
|
||||
return false, "", err
|
||||
}
|
||||
var resNode models.Node
|
||||
if err := json.Unmarshal([]byte(readres.Data), &resNode); err != nil {
|
||||
return false, iface, err
|
||||
}
|
||||
oldiface := resNode.Interface
|
||||
// DEPRECATED
|
||||
// func needInterfaceUpdate(ctx context.Context, mac string, network string, iface string) (bool, string, error) {
|
||||
// var header metadata.MD
|
||||
// req := &nodepb.Object{
|
||||
// Data: mac + "###" + network,
|
||||
// Type: nodepb.STRING_TYPE,
|
||||
// }
|
||||
// readres, err := wcclient.ReadNode(ctx, req, grpc.Header(&header))
|
||||
// if err != nil {
|
||||
// return false, "", err
|
||||
// }
|
||||
// var resNode models.Node
|
||||
// if err := json.Unmarshal([]byte(readres.Data), &resNode); err != nil {
|
||||
// return false, iface, err
|
||||
// }
|
||||
// oldiface := resNode.Interface
|
||||
|
||||
return iface != oldiface, oldiface, err
|
||||
}
|
||||
// return iface != oldiface, oldiface, err
|
||||
// }
|
||||
|
||||
// GetNode - gets node locally
|
||||
func GetNode(network string) models.Node {
|
||||
|
Reference in New Issue
Block a user