mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2025-07-06 13:16:58 +00:00
All AWG support work is done ;)
This commit is contained in:
parent
57583b6747
commit
c5f9387b92
@ -505,6 +505,18 @@ class WireguardConfiguration:
|
||||
"SaveConfig": "true"
|
||||
}
|
||||
|
||||
if self.Protocol == 'awg':
|
||||
self.__parser["Interface"]["Jc"] = self.Jc
|
||||
self.__parser["Interface"]["Jc"] = self.Jc
|
||||
self.__parser["Interface"]["Jmin"] = self.Jmin
|
||||
self.__parser["Interface"]["Jmax"] = self.Jmax
|
||||
self.__parser["Interface"]["S1"] = self.S1
|
||||
self.__parser["Interface"]["S2"] = self.S2
|
||||
self.__parser["Interface"]["H1"] = self.H1
|
||||
self.__parser["Interface"]["H2"] = self.H2
|
||||
self.__parser["Interface"]["H3"] = self.H3
|
||||
self.__parser["Interface"]["H4"] = self.H4
|
||||
|
||||
if "Backup" not in data.keys():
|
||||
self.createDatabase()
|
||||
with open(self.configPath, "w+") as configFile:
|
||||
@ -1118,6 +1130,8 @@ class WireguardConfiguration:
|
||||
with open(self.configPath, 'r') as f:
|
||||
original = [l.rstrip("\n") for l in f.readlines()]
|
||||
allowEdit = ["Address", "PreUp", "PostUp", "PreDown", "PostDown", "ListenPort"]
|
||||
if self.Protocol == 'awg':
|
||||
allowEdit += ["Jc", "Jmin", "Jmax", "S1", "S2", "H1", "H2", "H3", "H4"]
|
||||
start = original.index("[Interface]")
|
||||
try:
|
||||
end = original.index("[Peer]")
|
||||
@ -1131,7 +1145,7 @@ class WireguardConfiguration:
|
||||
if split[0] not in allowEdit:
|
||||
new.append(original[line])
|
||||
for key in allowEdit:
|
||||
new.insert(1, f"{key} = {newData[key].strip()}")
|
||||
new.insert(1, f"{key} = {str(newData[key]).strip()}")
|
||||
new.append("")
|
||||
for line in range(end, len(original)):
|
||||
new.append(original[line])
|
||||
|
@ -145,49 +145,61 @@ watch(data, () => {
|
||||
id="configuration_listen_port">
|
||||
|
||||
</div>
|
||||
<div>
|
||||
<label for="configuration_preup" class="form-label">
|
||||
<div v-for="key in ['PreUp', 'PreDown', 'PostUp', 'PostDown']">
|
||||
<label :for="'configuration_' + key" class="form-label">
|
||||
<small class="text-muted">
|
||||
<LocaleText t="PreUp"></LocaleText>
|
||||
<LocaleText :t="key"></LocaleText>
|
||||
</small>
|
||||
</label>
|
||||
<input type="text" class="form-control form-control-sm rounded-3"
|
||||
:disabled="saving"
|
||||
v-model="data.PreUp"
|
||||
id="configuration_preup">
|
||||
v-model="data[key]"
|
||||
:id="'configuration_' + key">
|
||||
</div>
|
||||
<div>
|
||||
<label for="configuration_predown" class="form-label">
|
||||
<!-- <div>-->
|
||||
<!-- <label for="configuration_predown" class="form-label">-->
|
||||
<!-- <small class="text-muted">-->
|
||||
<!-- <LocaleText t="PreDown"></LocaleText>-->
|
||||
<!-- </small>-->
|
||||
<!-- </label>-->
|
||||
<!-- <input type="text" class="form-control form-control-sm rounded-3"-->
|
||||
<!-- :disabled="saving"-->
|
||||
<!-- v-model="data.PreDown"-->
|
||||
<!-- id="configuration_predown">-->
|
||||
<!-- </div>-->
|
||||
<!-- <div>-->
|
||||
<!-- <label for="configuration_postup" class="form-label">-->
|
||||
<!-- <small class="text-muted">-->
|
||||
<!-- <LocaleText t="PostUp"></LocaleText>-->
|
||||
<!-- </small>-->
|
||||
<!-- </label>-->
|
||||
<!-- <input type="text" class="form-control form-control-sm rounded-3"-->
|
||||
<!-- :disabled="saving"-->
|
||||
<!-- v-model="data.PostUp"-->
|
||||
<!-- id="configuration_postup">-->
|
||||
<!-- </div>-->
|
||||
<!-- <div>-->
|
||||
<!-- <label for="configuration_postdown" class="form-label">-->
|
||||
<!-- <small class="text-muted">-->
|
||||
<!-- <LocaleText t="PostDown"></LocaleText>-->
|
||||
<!-- </small>-->
|
||||
<!-- </label>-->
|
||||
<!-- <input type="text" class="form-control form-control-sm rounded-3"-->
|
||||
<!-- :disabled="saving"-->
|
||||
<!-- v-model="data.PostDown"-->
|
||||
<!-- id="configuration_postdown">-->
|
||||
<!-- </div>-->
|
||||
<div v-for="key in ['Jc', 'Jmin', 'Jmax', 'S1', 'S2', 'H1', 'H2', 'H3', 'H4']"
|
||||
v-if="configurationInfo.Protocol === 'awg'">
|
||||
<label :for="'configuration_' + key" class="form-label">
|
||||
<small class="text-muted">
|
||||
<LocaleText t="PreDown"></LocaleText>
|
||||
<LocaleText :t="key"></LocaleText>
|
||||
</small>
|
||||
</label>
|
||||
<input type="text" class="form-control form-control-sm rounded-3"
|
||||
<input type="number" class="form-control form-control-sm rounded-3"
|
||||
:disabled="saving"
|
||||
v-model="data.PreDown"
|
||||
id="configuration_predown">
|
||||
</div>
|
||||
<div>
|
||||
<label for="configuration_postup" class="form-label">
|
||||
<small class="text-muted">
|
||||
<LocaleText t="PostUp"></LocaleText>
|
||||
</small>
|
||||
</label>
|
||||
<input type="text" class="form-control form-control-sm rounded-3"
|
||||
:disabled="saving"
|
||||
v-model="data.PostUp"
|
||||
id="configuration_postup">
|
||||
</div>
|
||||
<div>
|
||||
<label for="configuration_postdown" class="form-label">
|
||||
<small class="text-muted">
|
||||
<LocaleText t="PostDown"></LocaleText>
|
||||
</small>
|
||||
</label>
|
||||
<input type="text" class="form-control form-control-sm rounded-3"
|
||||
:disabled="saving"
|
||||
v-model="data.PostDown"
|
||||
id="configuration_postdown">
|
||||
v-model="data[key]"
|
||||
:id="'configuration_' + key">
|
||||
</div>
|
||||
<div class="d-flex align-items-center gap-2 mt-4">
|
||||
<button class="btn bg-secondary-subtle border-secondary-subtle text-secondary-emphasis rounded-3 shadow ms-auto"
|
||||
|
@ -32,7 +32,16 @@ export default {
|
||||
PreDown: "",
|
||||
PostUp: "",
|
||||
PostDown: "",
|
||||
Protocol: "wg"
|
||||
Protocol: "wg",
|
||||
Jc: 5,
|
||||
Jmin: 49,
|
||||
Jmax: 998,
|
||||
S1: 17,
|
||||
S2: 110,
|
||||
H1: 0,
|
||||
H2: 0,
|
||||
H3: 0,
|
||||
H4: 0
|
||||
},
|
||||
numberOfAvailableIPs: "0",
|
||||
error: false,
|
||||
@ -42,9 +51,20 @@ export default {
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.wireguardGenerateKeypair();
|
||||
this.wireguardGenerateKeypair();
|
||||
let hValue = []
|
||||
while ([...new Set(hValue)].length !== 4){
|
||||
hValue = [this.rand(1, (2**31) - 1), this.rand(1, (2**31) - 1), this.rand(1, (2**31) - 1), this.rand(1, (2**31) - 1)]
|
||||
}
|
||||
this.newConfiguration.H1 = hValue[0]
|
||||
this.newConfiguration.H2 = hValue[1]
|
||||
this.newConfiguration.H3 = hValue[2]
|
||||
this.newConfiguration.H4 = hValue[3]
|
||||
},
|
||||
methods: {
|
||||
rand(min, max){
|
||||
return Math.floor(Math.random() * (max - min) + min);
|
||||
},
|
||||
wireguardGenerateKeypair(){
|
||||
const wg = window.wireguard.generateKeypair();
|
||||
this.newConfiguration.PrivateKey = wg.privateKey;
|
||||
@ -293,24 +313,16 @@ export default {
|
||||
class="form-control font-monospace" :id="key" v-model="this.newConfiguration[key]">
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="card rounded-3">-->
|
||||
<!-- <div class="card-header">PreDown</div>-->
|
||||
<!-- <div class="card-body">-->
|
||||
<!-- <input type="text" class="form-control" id="preDown" v-model="this.newConfiguration.PreDown">-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
<!-- <div class="card rounded-3">-->
|
||||
<!-- <div class="card-header">PostUp</div>-->
|
||||
<!-- <div class="card-body">-->
|
||||
<!-- <input type="text" class="form-control" id="postUp" v-model="this.newConfiguration.PostUp">-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
<!-- <div class="card rounded-3">-->
|
||||
<!-- <div class="card-header">PostDown</div>-->
|
||||
<!-- <div class="card-body">-->
|
||||
<!-- <input type="text" class="form-control" id="postDown" v-model="this.newConfiguration.PostDown">-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
|
||||
<div class="card rounded-3"
|
||||
v-if="this.newConfiguration.Protocol === 'awg'"
|
||||
v-for="key in ['Jc', 'Jmin', 'Jmax', 'S1', 'S2', 'H1', 'H2', 'H3', 'H4']">
|
||||
<div class="card-header">{{ key }}</div>
|
||||
<div class="card-body">
|
||||
<input type="text"
|
||||
class="form-control font-monospace" :id="key" v-model="this.newConfiguration[key]">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user