Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions shared/management/client/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ type GrpcClient struct {
conn *grpc.ClientConn
connStateCallback ConnStateNotifier
connStateCallbackLock sync.RWMutex

srvKey *wgtypes.Key
}

// NewClient creates a new client to Management service
Expand Down Expand Up @@ -270,6 +272,10 @@ func (c *GrpcClient) GetServerPublicKey() (*wgtypes.Key, error) {
return nil, errors.New(errMsgNoMgmtConnection)
}

if c.srvKey != nil {
return c.srvKey, nil
}

mgmCtx, cancel := context.WithTimeout(c.ctx, 5*time.Second)
defer cancel()
resp, err := c.realClient.GetServerKey(mgmCtx, &proto.Empty{})
Expand All @@ -282,6 +288,7 @@ func (c *GrpcClient) GetServerPublicKey() (*wgtypes.Key, error) {
if err != nil {
return nil, err
}
c.srvKey = &serverKey

return &serverKey, nil
}
Expand Down
Loading