mirror of
https://github.com/donaldzou/WGDashboard
synced 2025-02-26 05:58:47 +00:00
Merge pull request #584 from donaldzou/fix-#581
Fixed Job Logger Bug, Restrict Peers with Configuration include special characters
This commit is contained in:
commit
57db4df618
@ -351,15 +351,13 @@ class PeerJobs:
|
|||||||
f"Peer {fp.id} from {c.Name} failed {job.Action}ed."
|
f"Peer {fp.id} from {c.Name} failed {job.Action}ed."
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
JobLogger.log(job.JobID, s["status"],
|
JobLogger.log(job.JobID,False,
|
||||||
f"Somehow can't find this peer {job.Peer} from {c.Name} failed {job.Action}ed."
|
f"Somehow can't find this peer {job.Peer} from {c.Name} failed {job.Action}ed."
|
||||||
)
|
)
|
||||||
# needToDelete.append(job)
|
|
||||||
else:
|
else:
|
||||||
JobLogger.log(job.JobID, s["status"],
|
JobLogger.log(job.JobID, False,
|
||||||
f"Somehow can't find this peer {job.Peer} from {job.Configuration} failed {job.Action}ed."
|
f"Somehow can't find this peer {job.Peer} from {job.Configuration} failed {job.Action}ed."
|
||||||
)
|
)
|
||||||
# needToDelete.append(job)
|
|
||||||
for j in needToDelete:
|
for j in needToDelete:
|
||||||
self.deleteJob(j)
|
self.deleteJob(j)
|
||||||
|
|
||||||
@ -796,7 +794,7 @@ class WireguardConfiguration:
|
|||||||
for i in listOfPublicKeys:
|
for i in listOfPublicKeys:
|
||||||
p = sqlSelect("SELECT * FROM '%s_restrict_access' WHERE id = ?" % self.Name, (i,)).fetchone()
|
p = sqlSelect("SELECT * FROM '%s_restrict_access' WHERE id = ?" % self.Name, (i,)).fetchone()
|
||||||
if p is not None:
|
if p is not None:
|
||||||
sqlUpdate("INSERT INTO '%s' SELECT * FROM %s_restrict_access WHERE id = ?"
|
sqlUpdate("INSERT INTO '%s' SELECT * FROM '%s_restrict_access' WHERE id = ?"
|
||||||
% (self.Name, self.Name,), (p['id'],))
|
% (self.Name, self.Name,), (p['id'],))
|
||||||
sqlUpdate("DELETE FROM '%s_restrict_access' WHERE id = ?"
|
sqlUpdate("DELETE FROM '%s_restrict_access' WHERE id = ?"
|
||||||
% self.Name, (p['id'],))
|
% self.Name, (p['id'],))
|
||||||
@ -830,7 +828,7 @@ class WireguardConfiguration:
|
|||||||
try:
|
try:
|
||||||
subprocess.check_output(f"wg set {self.Name} peer {pf.id} remove",
|
subprocess.check_output(f"wg set {self.Name} peer {pf.id} remove",
|
||||||
shell=True, stderr=subprocess.STDOUT)
|
shell=True, stderr=subprocess.STDOUT)
|
||||||
sqlUpdate("INSERT INTO '%s_restrict_access' SELECT * FROM %s WHERE id = ?" %
|
sqlUpdate("INSERT INTO '%s_restrict_access' SELECT * FROM '%s' WHERE id = ?" %
|
||||||
(self.Name, self.Name,), (pf.id,))
|
(self.Name, self.Name,), (pf.id,))
|
||||||
sqlUpdate("UPDATE '%s_restrict_access' SET status = 'stopped' WHERE id = ?" %
|
sqlUpdate("UPDATE '%s_restrict_access' SET status = 'stopped' WHERE id = ?" %
|
||||||
(self.Name,), (pf.id,))
|
(self.Name,), (pf.id,))
|
||||||
@ -1647,7 +1645,7 @@ def sqlSelect(statement: str, paramters: tuple = ()) -> sqlite3.Cursor:
|
|||||||
try:
|
try:
|
||||||
cursor = sqldb.cursor()
|
cursor = sqldb.cursor()
|
||||||
return cursor.execute(statement, paramters)
|
return cursor.execute(statement, paramters)
|
||||||
except Exception as e:
|
except Exception as error:
|
||||||
print("[WGDashboard] SQLite Error:" + str(error) + " | Statement: " + statement)
|
print("[WGDashboard] SQLite Error:" + str(error) + " | Statement: " + statement)
|
||||||
return []
|
return []
|
||||||
|
|
||||||
@ -1661,7 +1659,7 @@ def sqlUpdate(statement: str, paramters: tuple = ()) -> sqlite3.Cursor:
|
|||||||
s = f'BEGIN TRANSACTION;{statement};END TRANSACTION;'
|
s = f'BEGIN TRANSACTION;{statement};END TRANSACTION;'
|
||||||
cursor.execute(statement, paramters)
|
cursor.execute(statement, paramters)
|
||||||
sqldb.commit()
|
sqldb.commit()
|
||||||
except Exception as e:
|
except Exception as error:
|
||||||
print("[WGDashboard] SQLite Error:" + str(error) + " | Statement: " + statement)
|
print("[WGDashboard] SQLite Error:" + str(error) + " | Statement: " + statement)
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user