GUI: auto-fill split AllowedIPs in New Peer form
This commit is contained in:
@@ -6,17 +6,41 @@
|
|||||||
<input name="name" required placeholder="astra" />
|
<input name="name" required placeholder="astra" />
|
||||||
</label>
|
</label>
|
||||||
<label>Режим
|
<label>Режим
|
||||||
<select name="mode">
|
<select name="mode" id="mode">
|
||||||
<option value="full">full (весь трафик через VPN)</option>
|
<option value="full">full (весь трафик через VPN)</option>
|
||||||
<option value="split">split (только выбранные сети)</option>
|
<option value="split">split (только выбранные сети)</option>
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
<label>AllowedIPs (для split)
|
<label>AllowedIPs (для split)
|
||||||
<input name="allowed_ips" placeholder="{{ meta.get('WG_NETWORK','10.66.66.0/24') }}" />
|
<input
|
||||||
|
id="allowed_ips"
|
||||||
|
name="allowed_ips"
|
||||||
|
placeholder="{{ meta.get('WG_NETWORK','10.66.66.0/24') }}"
|
||||||
|
data-default="{{ meta.get('WG_NETWORK','10.66.66.0/24') }}"
|
||||||
|
/>
|
||||||
</label>
|
</label>
|
||||||
<label>Сети за клиентом (роуты)
|
<label>Сети за клиентом (роуты)
|
||||||
<input name="routes" placeholder="192.168.33.0/24,10.10.0.0/16" />
|
<input name="routes" placeholder="192.168.33.0/24,10.10.0.0/16" />
|
||||||
</label>
|
</label>
|
||||||
<button type="submit">Создать</button>
|
<button type="submit">Создать</button>
|
||||||
</form>
|
</form>
|
||||||
|
<script>
|
||||||
|
(() => {
|
||||||
|
const mode = document.getElementById("mode");
|
||||||
|
const allowed = document.getElementById("allowed_ips");
|
||||||
|
const def = allowed.dataset.default || "10.66.66.0/24";
|
||||||
|
|
||||||
|
function syncAllowed() {
|
||||||
|
if (mode.value === "split") {
|
||||||
|
if (!allowed.value.trim()) allowed.value = def;
|
||||||
|
allowed.readOnly = false;
|
||||||
|
} else {
|
||||||
|
allowed.readOnly = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mode.addEventListener("change", syncAllowed);
|
||||||
|
syncAllowed();
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
Reference in New Issue
Block a user