mirror of
https://github.com/netbirdio/netbird.git
synced 2026-10-21 21:09:07 +02:00
pass sync message version in SyncResponse
Signed-off-by: Dmitri Dolguikh <dmitri.external@netbird.io>
This commit is contained in:
@@ -995,12 +995,17 @@ func (e *Engine) handleSync(update *mgmProto.SyncResponse) error {
|
|||||||
nm *mgmProto.NetworkMap
|
nm *mgmProto.NetworkMap
|
||||||
components *types.NetworkMapComponents
|
components *types.NetworkMapComponents
|
||||||
)
|
)
|
||||||
if envelope := update.GetNetworkMapEnvelope(); envelope != nil {
|
if version := update.GetVersion(); version == mgmProto.SyncResponseVersion_VersionComponentNetworkMap {
|
||||||
// Components-format peer: decode the envelope back to typed
|
// Components-format peer: decode the envelope back to typed
|
||||||
// components, run Calculate() locally, and convert to the wire
|
// components, run Calculate() locally, and convert to the wire
|
||||||
// NetworkMap shape the rest of the engine consumes. Components are
|
// NetworkMap shape the rest of the engine consumes. Components are
|
||||||
// retained so future incremental updates can apply deltas instead
|
// retained so future incremental updates can apply deltas instead
|
||||||
// of doing a full reconstruction.
|
// of doing a full reconstruction.
|
||||||
|
envelope := update.GetNetworkMapEnvelope()
|
||||||
|
if envelope == nil {
|
||||||
|
return fmt.Errorf("received a SyncReponse indicating use of components network map, but components are missing")
|
||||||
|
}
|
||||||
|
|
||||||
localKey := e.config.WgPrivateKey.PublicKey().String()
|
localKey := e.config.WgPrivateKey.PublicKey().String()
|
||||||
dnsName := ""
|
dnsName := ""
|
||||||
if pc := update.GetPeerConfig(); pc != nil {
|
if pc := update.GetPeerConfig(); pc != nil {
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ func ToComponentSyncResponse(
|
|||||||
PeerConfig: peerConfig,
|
PeerConfig: peerConfig,
|
||||||
NetworkMapEnvelope: envelope,
|
NetworkMapEnvelope: envelope,
|
||||||
Checks: toProtocolChecks(ctx, checks),
|
Checks: toProtocolChecks(ctx, checks),
|
||||||
|
Version: proto.SyncResponseVersion_VersionComponentNetworkMap,
|
||||||
}
|
}
|
||||||
|
|
||||||
nbConfig := toNetbirdConfig(config, turnCredentials, relayCredentials, extraSettings, settings)
|
nbConfig := toNetbirdConfig(config, turnCredentials, relayCredentials, extraSettings, settings)
|
||||||
|
|||||||
@@ -28,9 +28,6 @@ import (
|
|||||||
//
|
//
|
||||||
// Peers base64(wg_pub_key) // stable across snapshots
|
// Peers base64(wg_pub_key) // stable across snapshots
|
||||||
func DecodeEnvelope(env *proto.NetworkMapEnvelope) (*types.NetworkMapComponents, error) {
|
func DecodeEnvelope(env *proto.NetworkMapEnvelope) (*types.NetworkMapComponents, error) {
|
||||||
if env == nil {
|
|
||||||
return nil, fmt.Errorf("nil envelope")
|
|
||||||
}
|
|
||||||
full := env.GetFull()
|
full := env.GetFull()
|
||||||
if full == nil {
|
if full == nil {
|
||||||
return nil, fmt.Errorf("envelope has no Full payload")
|
return nil, fmt.Errorf("envelope has no Full payload")
|
||||||
|
|||||||
+1344
-1280
File diff suppressed because it is too large
Load Diff
@@ -121,6 +121,11 @@ message SyncRequest {
|
|||||||
PeerSystemMeta meta = 1;
|
PeerSystemMeta meta = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum SyncResponseVersion {
|
||||||
|
VersionUnknown = 0;
|
||||||
|
VersionComponentNetworkMap = 1;
|
||||||
|
}
|
||||||
|
|
||||||
// SyncResponse represents a state that should be applied to the local peer (e.g. Netbird servers config as well as local peer and remote peers configs)
|
// SyncResponse represents a state that should be applied to the local peer (e.g. Netbird servers config as well as local peer and remote peers configs)
|
||||||
message SyncResponse {
|
message SyncResponse {
|
||||||
|
|
||||||
@@ -156,6 +161,8 @@ message SyncResponse {
|
|||||||
// is left empty: management ships components and the client runs Calculate()
|
// is left empty: management ships components and the client runs Calculate()
|
||||||
// locally instead of receiving an expanded NetworkMap.
|
// locally instead of receiving an expanded NetworkMap.
|
||||||
NetworkMapEnvelope NetworkMapEnvelope = 8;
|
NetworkMapEnvelope NetworkMapEnvelope = 8;
|
||||||
|
|
||||||
|
SyncResponseVersion Version = 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
message SyncMetaRequest {
|
message SyncMetaRequest {
|
||||||
|
|||||||
Reference in New Issue
Block a user