feat: Supporting "table" directive in the configuration

This commit is contained in:
Mohammad Mahdi Afshar 2025-04-24 18:51:26 +03:30
parent cd11c4beb6
commit 30fe827253
4 changed files with 30 additions and 3 deletions

View File

@ -945,7 +945,8 @@ class WireguardConfiguration:
}, },
"ConnectedPeers": len(list(filter(lambda x: x.status == "running", self.Peers))), "ConnectedPeers": len(list(filter(lambda x: x.status == "running", self.Peers))),
"TotalPeers": len(self.Peers), "TotalPeers": len(self.Peers),
"Protocol": self.Protocol "Protocol": self.Protocol,
"Table": self.Table,
} }
def backupConfigurationFile(self) -> tuple[bool, dict[str, str]]: def backupConfigurationFile(self) -> tuple[bool, dict[str, str]]:
@ -1047,7 +1048,7 @@ class WireguardConfiguration:
dataChanged = False dataChanged = False
with open(self.configPath, 'r') as f: with open(self.configPath, 'r') as f:
original = [l.rstrip("\n") for l in f.readlines()] original = [l.rstrip("\n") for l in f.readlines()]
allowEdit = ["Address", "PreUp", "PostUp", "PreDown", "PostDown", "ListenPort"] allowEdit = ["Address", "PreUp", "PostUp", "PreDown", "PostDown", "ListenPort", "Table"]
if self.Protocol == 'awg': if self.Protocol == 'awg':
allowEdit += ["Jc", "Jmin", "Jmax", "S1", "S2", "H1", "H2", "H3", "H4"] allowEdit += ["Jc", "Jmin", "Jmax", "S1", "S2", "H1", "H2", "H3", "H4"]
start = original.index("[Interface]") start = original.index("[Interface]")

View File

@ -171,6 +171,17 @@ const deleteConfigurationModal = ref(false)
id="configuration_listen_port"> id="configuration_listen_port">
</div> </div>
<div>
<label for="configuration_table" class="form-label">
<small class="text-muted">
<LocaleText t="Table"></LocaleText>
</small>
</label>
<input type="text" class="form-control form-control-sm rounded-3"
:disabled="saving"
v-model="data.Table"
id="configuration_table">
</div>
<div v-for="key in ['PreUp', 'PreDown', 'PostUp', 'PostDown']"> <div v-for="key in ['PreUp', 'PreDown', 'PostUp', 'PostDown']">
<label :for="'configuration_' + key" class="form-label"> <label :for="'configuration_' + key" class="form-label">
<small class="text-muted"> <small class="text-muted">

View File

@ -34,6 +34,7 @@ export default {
PreDown: "", PreDown: "",
PostUp: "", PostUp: "",
PostDown: "", PostDown: "",
Table: "",
Protocol: "wg", Protocol: "wg",
Jc: 5, Jc: 5,
Jmin: 49, Jmin: 49,
@ -342,6 +343,19 @@ export default {
</div> </div>
</div> </div>
</div> </div>
<div class="card rounded-3 shadow">
<div class="card-header">
<LocaleText t="Table"></LocaleText>
</div>
<div class="card-body">
<input type="text" class="form-control" placeholder="Ex: off" id="Table"
v-model="this.newConfiguration.Table"
:disabled="this.loading">
<div class="invalid-feedback">
<div v-if="this.error">{{this.errorMessage}}</div>
</div>
</div>
</div>
<hr> <hr>
<div class="accordion" id="newConfigurationOptionalAccordion"> <div class="accordion" id="newConfigurationOptionalAccordion">
<div class="accordion-item"> <div class="accordion-item">

View File

@ -59,6 +59,7 @@
"Turning Off\\.\\.\\.": "", "Turning Off\\.\\.\\.": "",
"Address": "", "Address": "",
"Listen Port": "", "Listen Port": "",
"Table": "",
"Public Key": "", "Public Key": "",
"Connected Peers": "", "Connected Peers": "",
"Total Usage": "", "Total Usage": "",