mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-23 17:03:17 +08:00
adjusting client join
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"log"
|
||||
|
||||
"github.com/gravitl/netmaker/database"
|
||||
"github.com/gravitl/netmaker/functions"
|
||||
@@ -118,6 +119,8 @@ func (s *NodeServiceServer) Login(ctx context.Context, req *nodepb.Object) (*nod
|
||||
password := reqNode.Password
|
||||
macaddress := reqNode.MacAddress
|
||||
|
||||
log.Printf("authing node: %v \n", reqNode)
|
||||
|
||||
var result models.NodeAuth
|
||||
var err error
|
||||
// err := errors.New("generic server error")
|
||||
|
@@ -8,6 +8,7 @@ import (
|
||||
"log"
|
||||
"os/exec"
|
||||
|
||||
"github.com/google/uuid"
|
||||
nodepb "github.com/gravitl/netmaker/grpc"
|
||||
"github.com/gravitl/netmaker/models"
|
||||
"github.com/gravitl/netmaker/netclient/auth"
|
||||
@@ -76,12 +77,15 @@ func JoinNetwork(cfg config.ClientConfig, privateKey string) error {
|
||||
macs, err := ncutils.GetMacAddr()
|
||||
if err != nil {
|
||||
return err
|
||||
} else if len(macs) == 0 {
|
||||
log.Fatal("could not retrieve mac address")
|
||||
} else {
|
||||
cfg.Node.MacAddress = macs[0]
|
||||
}
|
||||
}
|
||||
|
||||
if cfg.Node.ID == "" {
|
||||
cfg.Node.ID = uuid.NewString()
|
||||
}
|
||||
|
||||
if ncutils.IsLinux() {
|
||||
_, err := exec.LookPath("resolvconf")
|
||||
if err != nil {
|
||||
@@ -100,6 +104,7 @@ func JoinNetwork(cfg config.ClientConfig, privateKey string) error {
|
||||
var node models.Node // fill this node with appropriate calls
|
||||
postnode := &models.Node{
|
||||
Password: cfg.Node.Password,
|
||||
ID: cfg.Node.ID,
|
||||
MacAddress: cfg.Node.MacAddress,
|
||||
AccessKey: cfg.Server.AccessKey,
|
||||
IsStatic: cfg.Node.IsStatic,
|
||||
@@ -122,6 +127,7 @@ func JoinNetwork(cfg config.ClientConfig, privateKey string) error {
|
||||
if cfg.Node.IsServer != "yes" {
|
||||
ncutils.Log("joining " + cfg.Network + " at " + cfg.Server.GRPCAddress)
|
||||
var wcclient nodepb.NodeServiceClient
|
||||
log.Printf("used: %v\n", postnode)
|
||||
|
||||
conn, err := grpc.Dial(cfg.Server.GRPCAddress,
|
||||
ncutils.GRPCRequestOpts(cfg.Server.GRPCSSL))
|
||||
|
Reference in New Issue
Block a user