mirror of
https://github.com/netbirdio/netbird.git
synced 2026-10-25 05:49:06 +01:00
return SyncMessageVersion in sql_store.getPeers()
Signed-off-by: Dmitri Dolguikh <dmitri.external@netbird.io>
This commit is contained in:
@@ -46,7 +46,6 @@ import (
|
|||||||
"github.com/netbirdio/netbird/management/server/settings"
|
"github.com/netbirdio/netbird/management/server/settings"
|
||||||
"github.com/netbirdio/netbird/management/server/telemetry"
|
"github.com/netbirdio/netbird/management/server/telemetry"
|
||||||
"github.com/netbirdio/netbird/management/server/types"
|
"github.com/netbirdio/netbird/management/server/types"
|
||||||
sharedgrpc "github.com/netbirdio/netbird/shared/management/grpc"
|
|
||||||
"github.com/netbirdio/netbird/shared/management/proto"
|
"github.com/netbirdio/netbird/shared/management/proto"
|
||||||
internalStatus "github.com/netbirdio/netbird/shared/management/status"
|
internalStatus "github.com/netbirdio/netbird/shared/management/status"
|
||||||
)
|
)
|
||||||
@@ -1024,9 +1023,9 @@ func (s *Server) sendInitialSync(ctx context.Context, peerKey wgtypes.Key, peer
|
|||||||
|
|
||||||
var plainResp *proto.SyncResponse
|
var plainResp *proto.SyncResponse
|
||||||
|
|
||||||
commonSyncMessageVersion := sharedgrpc.HighestCommonSyncMessageVersion(
|
commonSyncMessageVersion := grpc.HighestCommonSyncMessageVersion(
|
||||||
s.perAccountOrGlobalSyncMessageVersions(peer.AccountID),
|
s.perAccountOrGlobalSyncMessageVersions(peer.AccountID),
|
||||||
sharedgrpc.SyncMessageVersionFromConfig(&peer.Meta.SyncMessageVersion))
|
grpc.SyncMessageVersionFromConfig(&peer.Meta.SyncMessageVersion))
|
||||||
|
|
||||||
log.WithContext(ctx).
|
log.WithContext(ctx).
|
||||||
WithFields(log.Fields{
|
WithFields(log.Fields{
|
||||||
@@ -1035,7 +1034,7 @@ func (s *Server) sendInitialSync(ctx context.Context, peerKey wgtypes.Key, peer
|
|||||||
"peer_sync_message_version": grpc.SyncMessageVersionFromConfig(&peer.Meta.SyncMessageVersion),
|
"peer_sync_message_version": grpc.SyncMessageVersionFromConfig(&peer.Meta.SyncMessageVersion),
|
||||||
}).Debug("common highest sync message version")
|
}).Debug("common highest sync message version")
|
||||||
|
|
||||||
if commonSyncMessageVersion == sharedgrpc.ComponentNetworkMap {
|
if commonSyncMessageVersion == grpc.ComponentNetworkMap {
|
||||||
// Capable peer: discard the legacy NetworkMap that SyncAndMarkPeer
|
// Capable peer: discard the legacy NetworkMap that SyncAndMarkPeer
|
||||||
// computed and recompute the raw components instead. This wastes one
|
// computed and recompute the raw components instead. This wastes one
|
||||||
// Calculate() call per initial-sync — the component-based wire
|
// Calculate() call per initial-sync — the component-based wire
|
||||||
@@ -1081,11 +1080,11 @@ func (s *Server) sendInitialSync(ctx context.Context, peerKey wgtypes.Key, peer
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) perAccountOrGlobalSyncMessageVersions(accountId string) sharedgrpc.SyncMessageVersion {
|
func (s *Server) perAccountOrGlobalSyncMessageVersions(accountId string) grpc.SyncMessageVersion {
|
||||||
if version, ok := s.config.PerAccountHighestSupportedSyncMessageVersion[accountId]; ok {
|
if version, ok := s.config.PerAccountHighestSupportedSyncMessageVersion[accountId]; ok {
|
||||||
return sharedgrpc.SyncMessageVersionFromConfig(&version)
|
return grpc.SyncMessageVersionFromConfig(&version)
|
||||||
}
|
}
|
||||||
return sharedgrpc.SyncMessageVersionFromConfig(s.config.HighestSupportedSyncMessageVersion)
|
return grpc.SyncMessageVersionFromConfig(s.config.HighestSupportedSyncMessageVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDeviceAuthorizationFlow returns a device authorization flow information
|
// GetDeviceAuthorizationFlow returns a device authorization flow information
|
||||||
|
|||||||
@@ -1869,7 +1869,7 @@ func (s *SqlStore) getPeers(ctx context.Context, accountID string) ([]nbpeer.Pee
|
|||||||
meta_kernel_version, meta_network_addresses, meta_system_serial_number, meta_system_product_name, meta_system_manufacturer,
|
meta_kernel_version, meta_network_addresses, meta_system_serial_number, meta_system_product_name, meta_system_manufacturer,
|
||||||
meta_environment, meta_flags, meta_files, meta_capabilities, peer_status_last_seen, peer_status_session_started_at,
|
meta_environment, meta_flags, meta_files, meta_capabilities, peer_status_last_seen, peer_status_session_started_at,
|
||||||
peer_status_connected, peer_status_login_expired, peer_status_requires_approval, location_connection_ip,
|
peer_status_connected, peer_status_login_expired, peer_status_requires_approval, location_connection_ip,
|
||||||
location_country_code, location_city_name, location_geo_name_id, proxy_meta_embedded, proxy_meta_cluster, ipv6
|
location_country_code, location_city_name, location_geo_name_id, proxy_meta_embedded, proxy_meta_cluster, ipv6, meta_sync_message_version
|
||||||
FROM peers WHERE account_id = $1`
|
FROM peers WHERE account_id = $1`
|
||||||
rows, err := s.pool.Query(ctx, query, accountID)
|
rows, err := s.pool.Query(ctx, query, accountID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -1891,6 +1891,7 @@ func (s *SqlStore) getPeers(ctx context.Context, accountID string) ([]nbpeer.Pee
|
|||||||
metaSystemSerialNumber, metaSystemProductName, metaSystemManufacturer sql.NullString
|
metaSystemSerialNumber, metaSystemProductName, metaSystemManufacturer sql.NullString
|
||||||
locationCountryCode, locationCityName, proxyCluster sql.NullString
|
locationCountryCode, locationCityName, proxyCluster sql.NullString
|
||||||
locationGeoNameID sql.NullInt64
|
locationGeoNameID sql.NullInt64
|
||||||
|
metaSyncMessageVersion sql.NullInt
|
||||||
)
|
)
|
||||||
|
|
||||||
err := row.Scan(&p.ID, &p.AccountID, &p.Key, &ip, &p.Name, &p.DNSLabel, &p.UserID, &p.SSHKey, &sshEnabled,
|
err := row.Scan(&p.ID, &p.AccountID, &p.Key, &ip, &p.Name, &p.DNSLabel, &p.UserID, &p.SSHKey, &sshEnabled,
|
||||||
@@ -1900,7 +1901,7 @@ func (s *SqlStore) getPeers(ctx context.Context, accountID string) ([]nbpeer.Pee
|
|||||||
&metaSystemSerialNumber, &metaSystemProductName, &metaSystemManufacturer, &env, &flags, &files, &capabilities,
|
&metaSystemSerialNumber, &metaSystemProductName, &metaSystemManufacturer, &env, &flags, &files, &capabilities,
|
||||||
&peerStatusLastSeen, &peerStatusSessionStartedAt, &peerStatusConnected, &peerStatusLoginExpired,
|
&peerStatusLastSeen, &peerStatusSessionStartedAt, &peerStatusConnected, &peerStatusLoginExpired,
|
||||||
&peerStatusRequiresApproval, &connIP, &locationCountryCode, &locationCityName, &locationGeoNameID,
|
&peerStatusRequiresApproval, &connIP, &locationCountryCode, &locationCityName, &locationGeoNameID,
|
||||||
&proxyEmbedded, &proxyCluster, &ipv6)
|
&proxyEmbedded, &proxyCluster, &ipv6, &metaSyncMessageVersion)
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if lastLogin.Valid {
|
if lastLogin.Valid {
|
||||||
@@ -2020,6 +2021,9 @@ func (s *SqlStore) getPeers(ctx context.Context, accountID string) ([]nbpeer.Pee
|
|||||||
if connIP != nil {
|
if connIP != nil {
|
||||||
_ = json.Unmarshal(connIP, &p.Location.ConnectionIP)
|
_ = json.Unmarshal(connIP, &p.Location.ConnectionIP)
|
||||||
}
|
}
|
||||||
|
if metaSyncMessageVersion.Valid {
|
||||||
|
p.Meta.SyncMessageVersion = metaSyncMessageVersion.Int
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return p, err
|
return p, err
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user