mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2025-12-16 08:26:17 +00:00
Manage Tracking Feature Done
This commit is contained in:
@@ -1216,7 +1216,7 @@ class WireguardConfiguration:
|
||||
self.configurationInfo.PeerGroups = peerGroups
|
||||
elif key == "PeerTrafficTracking":
|
||||
self.configurationInfo.PeerTrafficTracking = value
|
||||
elif key == "PeerHistoricalTrafficTracking":
|
||||
elif key == "PeerHistoricalEndpointTracking":
|
||||
self.configurationInfo.PeerHistoricalEndpointTracking = value
|
||||
else:
|
||||
return False, "Key does not exist", None
|
||||
@@ -1236,4 +1236,51 @@ class WireguardConfiguration:
|
||||
status = False
|
||||
msg = "Listen Port must be >= 1 and <= 65535"
|
||||
return status, msg
|
||||
|
||||
|
||||
def getTransferTableSize(self):
|
||||
with self.engine.connect() as db:
|
||||
row_count = db.execute(
|
||||
sqlalchemy.select(sqlalchemy.func.count()).select_from(self.peersTransferTable)
|
||||
).scalar()
|
||||
return int(row_count)
|
||||
|
||||
def getHistoricalEndpointTableSize(self):
|
||||
with self.engine.connect() as db:
|
||||
row_count = db.execute(
|
||||
sqlalchemy.select(sqlalchemy.func.count()).select_from(self.peersHistoryEndpointTable)
|
||||
).scalar()
|
||||
return int(row_count)
|
||||
|
||||
def downloadTransferTable(self):
|
||||
with self.engine.connect() as db:
|
||||
data = db.execute(
|
||||
self.peersTransferTable.select()
|
||||
).mappings().fetchall()
|
||||
return data
|
||||
|
||||
def downloadHistoricalEndpointTable(self):
|
||||
with self.engine.connect() as db:
|
||||
data = db.execute(
|
||||
self.peersHistoryEndpointTable.select()
|
||||
).mappings().fetchall()
|
||||
return data
|
||||
|
||||
def deleteTransferTable(self):
|
||||
try:
|
||||
with self.engine.begin() as db:
|
||||
db.execute(
|
||||
self.peersTransferTable.delete()
|
||||
)
|
||||
except Exception as e:
|
||||
return False
|
||||
return True
|
||||
|
||||
def deleteHistoryEndpointTable(self):
|
||||
try:
|
||||
with self.engine.begin() as db:
|
||||
db.execute(
|
||||
self.peersHistoryEndpointTable.delete()
|
||||
)
|
||||
except Exception as e:
|
||||
return False
|
||||
return True
|
||||
Reference in New Issue
Block a user