mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2025-10-04 08:16:17 +00:00
Updated AWG
This commit is contained in:
@@ -13,85 +13,6 @@ class AmneziaWGPeer(Peer):
|
||||
self.advanced_security = tableData["advanced_security"]
|
||||
super().__init__(tableData, configuration)
|
||||
|
||||
def downloadPeer(self) -> dict[str, str]:
|
||||
filename = self.name
|
||||
if len(filename) == 0:
|
||||
filename = "UntitledPeer"
|
||||
filename = "".join(filename.split(' '))
|
||||
filename = f"{filename}_{self.configuration.Name}"
|
||||
illegal_filename = [".", ",", "/", "?", "<", ">", "\\", ":", "*", '|' '\"', "com1", "com2", "com3",
|
||||
"com4", "com5", "com6", "com7", "com8", "com9", "lpt1", "lpt2", "lpt3", "lpt4",
|
||||
"lpt5", "lpt6", "lpt7", "lpt8", "lpt9", "con", "nul", "prn"]
|
||||
for i in illegal_filename:
|
||||
filename = filename.replace(i, "")
|
||||
|
||||
finalFilename = ""
|
||||
for i in filename:
|
||||
if re.match("^[a-zA-Z0-9_=+.-]$", i):
|
||||
finalFilename += i
|
||||
|
||||
interfaceSection = {
|
||||
"PrivateKey": self.private_key,
|
||||
"Address": self.allowed_ip,
|
||||
"MTU": self.mtu,
|
||||
"DNS": self.DNS,
|
||||
"Jc": self.configuration.Jc,
|
||||
"Jmin": self.configuration.Jmin,
|
||||
"Jmax": self.configuration.Jmax,
|
||||
"S1": self.configuration.S1,
|
||||
"S2": self.configuration.S2,
|
||||
"H1": self.configuration.H1,
|
||||
"H2": self.configuration.H2,
|
||||
"H3": self.configuration.H3,
|
||||
"H4": self.configuration.H4
|
||||
}
|
||||
peerSection = {
|
||||
"PublicKey": self.configuration.PublicKey,
|
||||
"AllowedIPs": self.endpoint_allowed_ip,
|
||||
"Endpoint": f'{self.configuration.DashboardConfig.GetConfig("Peers", "remote_endpoint")[1]}:{self.configuration.ListenPort}',
|
||||
"PersistentKeepalive": self.keepalive,
|
||||
"PresharedKey": self.preshared_key
|
||||
}
|
||||
combine = [interfaceSection.items(), peerSection.items()]
|
||||
peerConfiguration = ""
|
||||
for s in range(len(combine)):
|
||||
if s == 0:
|
||||
peerConfiguration += "[Interface]\n"
|
||||
else:
|
||||
peerConfiguration += "\n[Peer]\n"
|
||||
for (key, val) in combine[s]:
|
||||
if val is not None and ((type(val) is str and len(val) > 0) or (type(val) is int and val > 0)):
|
||||
peerConfiguration += f"{key} = {val}\n"
|
||||
|
||||
# peerConfiguration = f'''[Interface]
|
||||
# PrivateKey = {self.private_key}
|
||||
# Address = {self.allowed_ip}
|
||||
# MTU = {str(self.mtu)}
|
||||
# Jc = {self.configuration.Jc}
|
||||
# Jmin = {self.configuration.Jmin}
|
||||
# Jmax = {self.configuration.Jmax}
|
||||
# S1 = {self.configuration.S1}
|
||||
# S2 = {self.configuration.S2}
|
||||
# H1 = {self.configuration.H1}
|
||||
# H2 = {self.configuration.H2}
|
||||
# H3 = {self.configuration.H3}
|
||||
# H4 = {self.configuration.H4}
|
||||
# '''
|
||||
# if len(self.DNS) > 0:
|
||||
# peerConfiguration += f"DNS = {self.DNS}\n"
|
||||
# peerConfiguration += f'''
|
||||
# [Peer]
|
||||
# PublicKey = {self.configuration.PublicKey}
|
||||
# AllowedIPs = {self.endpoint_allowed_ip}
|
||||
# Endpoint = {self.configuration.DashboardConfig.GetConfig("Peers", "remote_endpoint")[1]}:{self.configuration.ListenPort}
|
||||
# PersistentKeepalive = {str(self.keepalive)}
|
||||
# '''
|
||||
# if len(self.preshared_key) > 0:
|
||||
# peerConfiguration += f"PresharedKey = {self.preshared_key}\n"
|
||||
return {
|
||||
"fileName": finalFilename,
|
||||
"file": peerConfiguration
|
||||
}
|
||||
|
||||
def updatePeer(self, name: str, private_key: str,
|
||||
preshared_key: str,
|
||||
|
@@ -150,6 +150,20 @@ class Peer:
|
||||
if self.configuration.configurationInfo.OverridePeerSettings.DNS else self.DNS
|
||||
)
|
||||
}
|
||||
|
||||
if self.configuration.Protocol == "awg":
|
||||
interfaceSection.update({
|
||||
"Jc": self.configuration.Jc,
|
||||
"Jmin": self.configuration.Jmin,
|
||||
"Jmax": self.configuration.Jmax,
|
||||
"S1": self.configuration.S1,
|
||||
"S2": self.configuration.S2,
|
||||
"H1": self.configuration.H1,
|
||||
"H2": self.configuration.H2,
|
||||
"H3": self.configuration.H3,
|
||||
"H4": self.configuration.H4
|
||||
})
|
||||
|
||||
peerSection = {
|
||||
"PublicKey": self.configuration.PublicKey,
|
||||
"AllowedIPs": (
|
||||
|
Reference in New Issue
Block a user