Fix peer tracking disabled by default; include endpoint history in backup/restore

peer_tracking defaulted to "false", silently disabling all tracking for new
installs and upgrades. Change default to "true" to restore prior behaviour.

Add extend_existing=True to peersHistoryEndpointTable so createDatabase() can
be called more than once on the same metadata instance without raising
InvalidRequestError (triggered on every restoreBackup() call).

Include _history_endpoint in __dropDatabase and __dumpDatabase so endpoint
history is cleared on restore and preserved in backup files, consistent with
the other tracking tables.

Remove debug print that fired every 10 seconds per active configuration.

Fixes #1275

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
pull/1288/head
Viper Network 2026-05-29 01:13:35 +03:00
parent fedf7db8a4
commit fac4f19b37
3 changed files with 5 additions and 5 deletions

View File

@ -96,7 +96,6 @@ def peerInformationBackgroundThread():
c.getPeersEndpoint()
c.getPeers()
if DashboardConfig.GetConfig('WireGuardConfiguration', 'peer_tracking')[1] is True:
print("[WGDashboard] Tracking Peers")
if delay == 6:
if c.configurationInfo.PeerTrafficTracking:
c.logPeersTraffic()

View File

@ -83,7 +83,7 @@ class DashboardConfig:
},
"WireGuardConfiguration": {
"autostart": "",
"peer_tracking": "false"
"peer_tracking": "true"
}
}

View File

@ -232,7 +232,7 @@ class WireguardConfiguration:
self.Status = self.getStatus()
def __dropDatabase(self):
existingTables = [self.Name, f'{self.Name}_restrict_access', f'{self.Name}_transfer', f'{self.Name}_deleted']
existingTables = [self.Name, f'{self.Name}_restrict_access', f'{self.Name}_transfer', f'{self.Name}_deleted', f'{self.Name}_history_endpoint']
try:
with self.engine.begin() as conn:
for t in existingTables:
@ -308,7 +308,8 @@ class WireguardConfiguration:
f'{dbName}_history_endpoint', self.metadata,
sqlalchemy.Column('id', sqlalchemy.String(255), nullable=False),
sqlalchemy.Column('endpoint', sqlalchemy.String(255), nullable=False),
sqlalchemy.Column('time', time_col_type)
sqlalchemy.Column('time', time_col_type),
extend_existing=True
)
self.infoTable = sqlalchemy.Table(
@ -322,7 +323,7 @@ class WireguardConfiguration:
def __dumpDatabase(self):
with self.engine.connect() as conn:
tables = [self.peersTable, self.peersRestrictedTable, self.peersTransferTable, self.peersDeletedTable]
tables = [self.peersTable, self.peersRestrictedTable, self.peersTransferTable, self.peersDeletedTable, self.peersHistoryEndpointTable]
for i in tables:
rows = conn.execute(i.select()).mappings().fetchall()
for row in rows: