mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2025-07-06 21:26: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"
|
"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():
|
if "Backup" not in data.keys():
|
||||||
self.createDatabase()
|
self.createDatabase()
|
||||||
with open(self.configPath, "w+") as configFile:
|
with open(self.configPath, "w+") as configFile:
|
||||||
@ -1118,6 +1130,8 @@ class WireguardConfiguration:
|
|||||||
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"]
|
||||||
|
if self.Protocol == 'awg':
|
||||||
|
allowEdit += ["Jc", "Jmin", "Jmax", "S1", "S2", "H1", "H2", "H3", "H4"]
|
||||||
start = original.index("[Interface]")
|
start = original.index("[Interface]")
|
||||||
try:
|
try:
|
||||||
end = original.index("[Peer]")
|
end = original.index("[Peer]")
|
||||||
@ -1131,7 +1145,7 @@ class WireguardConfiguration:
|
|||||||
if split[0] not in allowEdit:
|
if split[0] not in allowEdit:
|
||||||
new.append(original[line])
|
new.append(original[line])
|
||||||
for key in allowEdit:
|
for key in allowEdit:
|
||||||
new.insert(1, f"{key} = {newData[key].strip()}")
|
new.insert(1, f"{key} = {str(newData[key]).strip()}")
|
||||||
new.append("")
|
new.append("")
|
||||||
for line in range(end, len(original)):
|
for line in range(end, len(original)):
|
||||||
new.append(original[line])
|
new.append(original[line])
|
||||||
|
@ -145,49 +145,61 @@ watch(data, () => {
|
|||||||
id="configuration_listen_port">
|
id="configuration_listen_port">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div v-for="key in ['PreUp', 'PreDown', 'PostUp', 'PostDown']">
|
||||||
<label for="configuration_preup" class="form-label">
|
<label :for="'configuration_' + key" class="form-label">
|
||||||
<small class="text-muted">
|
<small class="text-muted">
|
||||||
<LocaleText t="PreUp"></LocaleText>
|
<LocaleText :t="key"></LocaleText>
|
||||||
</small>
|
</small>
|
||||||
</label>
|
</label>
|
||||||
<input type="text" class="form-control form-control-sm rounded-3"
|
<input type="text" class="form-control form-control-sm rounded-3"
|
||||||
:disabled="saving"
|
:disabled="saving"
|
||||||
v-model="data.PreUp"
|
v-model="data[key]"
|
||||||
id="configuration_preup">
|
:id="'configuration_' + key">
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<!-- <div>-->
|
||||||
<label for="configuration_predown" class="form-label">
|
<!-- <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">
|
<small class="text-muted">
|
||||||
<LocaleText t="PreDown"></LocaleText>
|
<LocaleText :t="key"></LocaleText>
|
||||||
</small>
|
</small>
|
||||||
</label>
|
</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"
|
:disabled="saving"
|
||||||
v-model="data.PreDown"
|
v-model="data[key]"
|
||||||
id="configuration_predown">
|
:id="'configuration_' + key">
|
||||||
</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>
|
||||||
<div class="d-flex align-items-center gap-2 mt-4">
|
<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"
|
<button class="btn bg-secondary-subtle border-secondary-subtle text-secondary-emphasis rounded-3 shadow ms-auto"
|
||||||
|
@ -32,7 +32,16 @@ export default {
|
|||||||
PreDown: "",
|
PreDown: "",
|
||||||
PostUp: "",
|
PostUp: "",
|
||||||
PostDown: "",
|
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",
|
numberOfAvailableIPs: "0",
|
||||||
error: false,
|
error: false,
|
||||||
@ -43,8 +52,19 @@ export default {
|
|||||||
},
|
},
|
||||||
created() {
|
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: {
|
methods: {
|
||||||
|
rand(min, max){
|
||||||
|
return Math.floor(Math.random() * (max - min) + min);
|
||||||
|
},
|
||||||
wireguardGenerateKeypair(){
|
wireguardGenerateKeypair(){
|
||||||
const wg = window.wireguard.generateKeypair();
|
const wg = window.wireguard.generateKeypair();
|
||||||
this.newConfiguration.PrivateKey = wg.privateKey;
|
this.newConfiguration.PrivateKey = wg.privateKey;
|
||||||
@ -293,24 +313,16 @@ export default {
|
|||||||
class="form-control font-monospace" :id="key" v-model="this.newConfiguration[key]">
|
class="form-control font-monospace" :id="key" v-model="this.newConfiguration[key]">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- <div class="card rounded-3">-->
|
|
||||||
<!-- <div class="card-header">PreDown</div>-->
|
<div class="card rounded-3"
|
||||||
<!-- <div class="card-body">-->
|
v-if="this.newConfiguration.Protocol === 'awg'"
|
||||||
<!-- <input type="text" class="form-control" id="preDown" v-model="this.newConfiguration.PreDown">-->
|
v-for="key in ['Jc', 'Jmin', 'Jmax', 'S1', 'S2', 'H1', 'H2', 'H3', 'H4']">
|
||||||
<!-- </div>-->
|
<div class="card-header">{{ key }}</div>
|
||||||
<!-- </div>-->
|
<div class="card-body">
|
||||||
<!-- <div class="card rounded-3">-->
|
<input type="text"
|
||||||
<!-- <div class="card-header">PostUp</div>-->
|
class="form-control font-monospace" :id="key" v-model="this.newConfiguration[key]">
|
||||||
<!-- <div class="card-body">-->
|
</div>
|
||||||
<!-- <input type="text" class="form-control" id="postUp" v-model="this.newConfiguration.PostUp">-->
|
</div>
|
||||||
<!-- </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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user