logs, unused funcs, cleanup

This commit is contained in:
0xdcarns
2022-01-02 10:30:07 -05:00
parent 314fc3057e
commit 5448042b9a
9 changed files with 50 additions and 79 deletions

View File

@@ -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 {