mirror of
https://github.com/h44z/wg-portal.git
synced 2026-12-05 19:56:06 +01:00
feat: add support for AmneziaWG (#649)
This commit is contained in:
@@ -50,6 +50,8 @@ const currentTags = ref({
|
||||
PeerDefDnsSearch: ""
|
||||
})
|
||||
const formData = ref(freshInterface())
|
||||
const amneziaWGText = ref("")
|
||||
const isAmneziaWG = computed(() => formData.value.Backend === 'amneziawg')
|
||||
const isSaving = ref(false)
|
||||
const isDeleting = ref(false)
|
||||
const isApplyingDefaults = ref(false)
|
||||
@@ -77,7 +79,7 @@ const isHookSupported = computed(() => {
|
||||
let availableBackends = settings.Setting('AvailableBackends') || [];
|
||||
let backend = availableBackends.find(b => b.Id === formData.value.Backend);
|
||||
if (!backend) return false;
|
||||
return backend.Type === 'local' || backend.Type === 'mikrotik';
|
||||
return backend.Type === 'local' || backend.Type === 'amneziawg' || backend.Type === 'mikrotik';
|
||||
})
|
||||
|
||||
// functions
|
||||
@@ -169,6 +171,8 @@ watch(() => props.visible, async (newValue, oldValue) => {
|
||||
formData.value.PeerDefPostDown = selectedInterface.value.PeerDefPostDown
|
||||
|
||||
}
|
||||
const options = (selectedInterface.value ? selectedInterface.value.AmneziaWG : interfaces.Prepared?.AmneziaWG) || {}
|
||||
amneziaWGText.value = Object.entries(options).map(([key, value]) => `${key} = ${value}`).join('\n')
|
||||
}
|
||||
}
|
||||
)
|
||||
@@ -275,6 +279,18 @@ async function save() {
|
||||
if (isSaving.value) return
|
||||
isSaving.value = true
|
||||
try {
|
||||
const options = {}
|
||||
if (isAmneziaWG.value) {
|
||||
for (const line of amneziaWGText.value.split('\n')) {
|
||||
if (!line.trim() || line.trim().startsWith('#')) continue
|
||||
const match = line.match(/^\s*([A-Za-z][A-Za-z0-9]*)\s*=\s*(.*?)\s*$/)
|
||||
if (!match || Object.hasOwn(options, match[1])) {
|
||||
throw new Error(t('modals.interface-edit.amneziawg.invalid'))
|
||||
}
|
||||
options[match[1]] = match[2]
|
||||
}
|
||||
}
|
||||
formData.value.AmneziaWG = options
|
||||
if (props.interfaceId!=='#NEW#') {
|
||||
await interfaces.UpdateInterface(selectedInterface.value.Identifier, formData.value)
|
||||
} else {
|
||||
@@ -427,6 +443,12 @@ async function del() {
|
||||
<input v-model="formData.DisplayName" class="form-control" :placeholder="$t('modals.interface-edit.display-name.placeholder')" type="text">
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset v-if="isAmneziaWG">
|
||||
<legend class="mt-4">AmneziaWG</legend>
|
||||
<label class="form-label" for="amneziaWGOptions">{{ $t('modals.interface-edit.amneziawg.label') }}</label>
|
||||
<textarea id="amneziaWGOptions" v-model="amneziaWGText" class="form-control font-monospace" rows="8" placeholder="Jc = 4 Jmin = 40 Jmax = 70 S1 = 86 S2 = 94 H1 = 123456789 H2 = 234567890 H3 = 345678901 H4 = 456789012"></textarea>
|
||||
<small class="form-text">{{ $t('modals.interface-edit.amneziawg.help') }}</small>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend class="mt-4">{{ $t('modals.interface-edit.header-crypto') }}</legend>
|
||||
<div class="form-group">
|
||||
|
||||
@@ -7,6 +7,7 @@ export function freshInterface() {
|
||||
CreateDefaultPeer: false,
|
||||
Mode: "server",
|
||||
Backend: "local",
|
||||
AmneziaWG: {},
|
||||
|
||||
PublicKey: "",
|
||||
PrivateKey: "",
|
||||
@@ -175,4 +176,4 @@ export function freshStats() {
|
||||
BytesReceived: 0,
|
||||
EndpointAddress: ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -425,6 +425,7 @@
|
||||
"tab-peerdef": "Peer-Standardeinstellungen",
|
||||
"header-general": "Allgemein",
|
||||
"header-network": "Netzwerk",
|
||||
"amneziawg": {"label": "Verschleierungsoptionen", "help": "Eine Option pro Zeile (zum Beispiel H1 = 123456789). Ausgelassene Optionen behalten ihren aktuellen Kernelwert. Zum Zurücksetzen explizite Werte angeben. Diese Einstellungen werden in Client-Konfigurationen übernommen; Clients benötigen AmneziaWG-Unterstützung.", "invalid": "Eine AmneziaWG-Option pro Zeile als Name = Wert angeben, ohne doppelte Namen."},
|
||||
"header-crypto": "Kryptografie",
|
||||
"header-hooks": "Schnittstellen-Hooks",
|
||||
"header-peer-hooks": "Hooks",
|
||||
|
||||
@@ -425,6 +425,7 @@
|
||||
"tab-peerdef": "Peer Defaults",
|
||||
"header-general": "General",
|
||||
"header-network": "Network",
|
||||
"amneziawg": {"label": "Obfuscation options", "help": "One option per line (for example H1 = 123456789). Omitted options keep their current kernel values. Use explicit values to reset options. These settings are included in client configurations; clients need AmneziaWG support.", "invalid": "Use one AmneziaWG option per line as Name = Value, without duplicate names."},
|
||||
"header-crypto": "Cryptography",
|
||||
"header-hooks": "Interface Hooks",
|
||||
"header-peer-hooks": "Hooks",
|
||||
|
||||
Reference in New Issue
Block a user