mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2025-11-16 18:36:19 +00:00
Fixed duplicated data
This commit is contained in:
@@ -501,15 +501,24 @@ class WireguardConfiguration:
|
||||
with self.engine.begin() as conn:
|
||||
for tempPeer in self.Peers:
|
||||
if tempPeer.status == "running":
|
||||
endpoint = tempPeer.endpoint.rsplit(":", 1)
|
||||
endpoint = tempPeer.endpoint.rsplit(":", 1)
|
||||
if len(endpoint) == 2 and len(endpoint[0]) > 0:
|
||||
conn.execute(
|
||||
self.peersHistoryEndpointTable.insert().values({
|
||||
"id": tempPeer.id,
|
||||
"endpoint": endpoint[0],
|
||||
"time": datetime.now()
|
||||
})
|
||||
)
|
||||
exist = conn.execute(
|
||||
self.peersHistoryEndpointTable.select().where(
|
||||
sqlalchemy.and_(
|
||||
self.peersHistoryEndpointTable.c.id == tempPeer.id,
|
||||
self.peersHistoryEndpointTable.c.endpoint == endpoint[0]
|
||||
)
|
||||
)
|
||||
).mappings().fetchone()
|
||||
if not exist:
|
||||
conn.execute(
|
||||
self.peersHistoryEndpointTable.insert().values({
|
||||
"id": tempPeer.id,
|
||||
"endpoint": endpoint[0],
|
||||
"time": datetime.now()
|
||||
})
|
||||
)
|
||||
|
||||
def addPeers(self, peers: list) -> tuple[bool, list, str]:
|
||||
result = {
|
||||
|
||||
Reference in New Issue
Block a user