mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2024-11-21 23:01:39 +01:00
Reduced the time to open the config file
This commit is contained in:
parent
252c147dcf
commit
fec20ed381
@ -598,6 +598,7 @@ class WireguardConfiguration:
|
|||||||
return changed
|
return changed
|
||||||
|
|
||||||
def __getPeers(self):
|
def __getPeers(self):
|
||||||
|
|
||||||
if self.configurationFileChanged():
|
if self.configurationFileChanged():
|
||||||
self.Peers = []
|
self.Peers = []
|
||||||
with open(os.path.join(WG_CONF_PATH, f'{self.Name}.conf'), 'r') as configFile:
|
with open(os.path.join(WG_CONF_PATH, f'{self.Name}.conf'), 'r') as configFile:
|
||||||
@ -670,6 +671,11 @@ class WireguardConfiguration:
|
|||||||
self.Peers.append(Peer(checkIfExist, self))
|
self.Peers.append(Peer(checkIfExist, self))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"[WGDashboard] {self.Name} Error: {str(e)}")
|
print(f"[WGDashboard] {self.Name} Error: {str(e)}")
|
||||||
|
else:
|
||||||
|
self.Peers.clear()
|
||||||
|
checkIfExist = sqlSelect("SELECT * FROM '%s'" % self.Name).fetchall()
|
||||||
|
for i in checkIfExist:
|
||||||
|
self.Peers.append(Peer(i, self))
|
||||||
|
|
||||||
|
|
||||||
def addPeers(self, peers: list):
|
def addPeers(self, peers: list):
|
||||||
@ -809,12 +815,11 @@ class WireguardConfiguration:
|
|||||||
else:
|
else:
|
||||||
status = "stopped"
|
status = "stopped"
|
||||||
if int(latestHandshake[count + 1]) > 0:
|
if int(latestHandshake[count + 1]) > 0:
|
||||||
sqldb.execute("UPDATE '%s' SET latest_handshake = ?, status = ? WHERE id= ?" % self.Name
|
sqlUpdate("UPDATE '%s' SET latest_handshake = ?, status = ? WHERE id= ?" % self.Name
|
||||||
, (str(minus).split(".", maxsplit=1)[0], status, latestHandshake[count],))
|
, (str(minus).split(".", maxsplit=1)[0], status, latestHandshake[count],))
|
||||||
else:
|
else:
|
||||||
sqldb.execute("UPDATE '%s' SET latest_handshake = 'No Handshake', status = ? WHERE id= ?" % self.Name
|
sqlUpdate("UPDATE '%s' SET latest_handshake = 'No Handshake', status = ? WHERE id= ?" % self.Name
|
||||||
, (status, latestHandshake[count],))
|
, (status, latestHandshake[count],))
|
||||||
sqldb.commit()
|
|
||||||
count += 2
|
count += 2
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user