mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2025-10-04 00:06:18 +00:00
Added Pydantic for configurations info
This commit is contained in:
@@ -12,6 +12,7 @@ from .Peer import Peer
|
||||
from .PeerJobs import PeerJobs
|
||||
from .PeerShareLinks import PeerShareLinks
|
||||
from .Utilities import StringToBoolean, GenerateWireguardPublicKey, RegexMatch
|
||||
from .WireguardConfigurationInfo import WireguardConfigurationInfo
|
||||
|
||||
|
||||
class WireguardConfiguration:
|
||||
@@ -122,6 +123,8 @@ class WireguardConfiguration:
|
||||
if self.getAutostartStatus() and not self.getStatus() and startup:
|
||||
self.toggleConfiguration()
|
||||
print(f"[WGDashboard] Autostart Configuration: {name}")
|
||||
|
||||
self.configurationInfo: WireguardConfigurationInfo | None = None
|
||||
|
||||
def __getProtocolPath(self):
|
||||
return self.DashboardConfig.GetConfig("Server", "wg_conf_path")[1] if self.Protocol == "wg" \
|
||||
@@ -296,6 +299,12 @@ class WireguardConfiguration:
|
||||
sqlalchemy.Column('preshared_key', sqlalchemy.String(255)),
|
||||
extend_existing=True
|
||||
)
|
||||
self.infoTable = sqlalchemy.Table(
|
||||
'ConfigurationsInfo', self.metadata,
|
||||
sqlalchemy.Column('ID', sqlalchemy.String(255), primary_key=True),
|
||||
sqlalchemy.Column('Info', sqlalchemy.Text),
|
||||
extend_existing=True
|
||||
)
|
||||
|
||||
self.metadata.create_all(self.engine)
|
||||
|
||||
@@ -1048,4 +1057,13 @@ class WireguardConfiguration:
|
||||
else:
|
||||
return { "sent": 0, "recv": 0 }
|
||||
else:
|
||||
return { "sent": 0, "recv": 0 }
|
||||
return { "sent": 0, "recv": 0 }
|
||||
|
||||
def readConfigurationInfo(self):
|
||||
with self.engine.connect() as conn:
|
||||
result = conn.execute(
|
||||
self.infoTable.select().where(
|
||||
self.infoTable.c.ID == self.Name
|
||||
)
|
||||
).mappings().fetchone()
|
||||
return result
|
Reference in New Issue
Block a user