Merge pull request #710 from reloadlife/feat/route-table

feat: Supporting "table" directive in the configuration
This commit is contained in:
Donald Zou 2025-04-27 16:17:17 +08:00 committed by GitHub
commit 2bcf24bd84
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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))),
"TotalPeers": len(self.Peers),
"Protocol": self.Protocol
"Protocol": self.Protocol,
"Table": self.Table,
}
def backupConfigurationFile(self) -> tuple[bool, dict[str, str]]:
@ -1047,7 +1048,7 @@ class WireguardConfiguration:
dataChanged = False
with open(self.configPath, 'r') as f:
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':
allowEdit += ["Jc", "Jmin", "Jmax", "S1", "S2", "H1", "H2", "H3", "H4"]
start = original.index("[Interface]")

View File

@ -171,6 +171,17 @@ const deleteConfigurationModal = ref(false)
id="configuration_listen_port">
</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']">
<label :for="'configuration_' + key" class="form-label">
<small class="text-muted">

View File

@ -34,6 +34,7 @@ export default {
PreDown: "",
PostUp: "",
PostDown: "",
Table: "",
Protocol: "wg",
Jc: 5,
Jmin: 49,
@ -342,6 +343,19 @@ export default {
</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>
<div class="accordion" id="newConfigurationOptionalAccordion">
<div class="accordion-item">

View File

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