Skip to content

Commit

Permalink
Merge pull request #337 from gravitl/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
0xdcarns authored Oct 8, 2021
2 parents a2fe77e + 4231db3 commit b06e52c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions netclient/functions/checkin.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,18 @@ func Pull(network string, manual bool) (*models.Node, error) {
return nil, err
}
servercfg := cfg.Server
var header metadata.MD

if cfg.Node.IPForwarding == "yes" && !ncutils.IsWindows() {
if err = local.SetIPForwarding(); err != nil {
return nil, err
}
}
var resNode models.Node // just need to fill this with either server calls or client calls

var header metadata.MD
var wcclient nodepb.NodeServiceClient
var ctx context.Context

if cfg.Node.IsServer != "yes" {
conn, err := grpc.Dial(cfg.Server.GRPCAddress,
ncutils.GRPCRequestOpts(cfg.Server.GRPCSSL))
Expand All @@ -176,9 +179,9 @@ func Pull(network string, manual bool) (*models.Node, error) {
return nil, err
}
defer conn.Close()
wcclient := nodepb.NewNodeServiceClient(conn)
wcclient = nodepb.NewNodeServiceClient(conn)

ctx, err := auth.SetJWT(wcclient, network)
ctx, err = auth.SetJWT(wcclient, network)
if err != nil {
ncutils.PrintLog("Failed to authenticate: "+err.Error(), 1)
return nil, err
Expand All @@ -188,6 +191,7 @@ func Pull(network string, manual bool) (*models.Node, error) {
Data: node.MacAddress + "###" + node.Network,
Type: nodepb.STRING_TYPE,
}

readres, err := wcclient.ReadNode(ctx, req, grpc.Header(&header))
if err != nil {
return nil, err
Expand Down Expand Up @@ -222,6 +226,9 @@ func Pull(network string, manual bool) (*models.Node, error) {
return &resNode, err
}
if resNode.IsServer != "yes" {
if wcclient == nil || ctx == nil {
return &cfg.Node, errors.New("issue initializing gRPC client")
}
req := &nodepb.Object{
Data: string(nodeData),
Type: nodepb.NODE_TYPE,
Expand Down

0 comments on commit b06e52c

Please sign in to comment.