Handle keep alive in signal server

This commit is contained in:
Zoltan Papp
2023-06-23 13:07:12 +02:00
parent a6431e053b
commit 551455f314
5 changed files with 25 additions and 11 deletions
+3 -6
View File
@@ -24,6 +24,7 @@ import (
"github.com/netbirdio/netbird/client/system"
"github.com/netbirdio/netbird/encryption"
appKeepAlive "github.com/netbirdio/netbird/keepalive"
"github.com/netbirdio/netbird/management/proto"
"github.com/netbirdio/netbird/version"
)
@@ -69,7 +70,7 @@ func NewClient(ctx context.Context, addr string, ourPrivateKey wgtypes.Key, tlsE
realClient := proto.NewManagementServiceClient(conn)
md := metadata.Pairs("version", version.NetbirdVersion())
md := metadata.Pairs(appKeepAlive.GrpcVersionHeaderKey, version.NetbirdVersion())
ctx = metadata.NewOutgoingContext(ctx, md)
return &GrpcClient{
@@ -252,7 +253,7 @@ func (c *GrpcClient) receiveEvents(stream proto.ManagementService_SyncClient, se
return err
}
if c.isKeepAliveMsg(update.Body) {
if appKeepAlive.IsKeepAliveMsg(update.Body) {
continue
}
@@ -396,10 +397,6 @@ func (c *GrpcClient) notifyConnected() {
c.connStateCallback.MarkManagementConnected()
}
func (c *GrpcClient) isKeepAliveMsg(body []byte) bool {
return len(body) == 0
}
func infoToMetaData(info *system.Info) *proto.PeerSystemMeta {
if info == nil {
return nil