mirror of
https://github.com/ngoduykhanh/wireguard-ui.git
synced 2025-06-07 00:46:58 +03:00
re-implementation of optional extraAllowedIPs in client entry
This commit is contained in:
parent
655375258e
commit
a61c4fa65f
5 changed files with 66 additions and 14 deletions
|
@ -163,6 +163,11 @@
|
|||
<input type="text" data-role="tagsinput" class="form-control" id="client_allowed_ips"
|
||||
value="0.0.0.0/0">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="client_extra_allowed_ips" class="control-label">Extra Allowed IPs</label>
|
||||
<input type="text" data-role="tagsinput" class="form-control"
|
||||
id="client_extra_allowed_ips">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="icheck-primary d-inline">
|
||||
<input type="checkbox" id="use_server_dns" checked>
|
||||
|
@ -376,6 +381,16 @@
|
|||
'placeholderColor': '#666666'
|
||||
});
|
||||
|
||||
$("#client_extra_allowed_ips").tagsInput({
|
||||
'width': '100%',
|
||||
'height': '75%',
|
||||
'interactive': true,
|
||||
'defaultText': 'Add More',
|
||||
'removeWithBackspace': true,
|
||||
'minChars': 0,
|
||||
'placeholderColor': '#666666'
|
||||
});
|
||||
|
||||
// New client form validation
|
||||
$(document).ready(function () {
|
||||
$.validator.setDefaults({
|
||||
|
@ -414,6 +429,7 @@
|
|||
$("#client_name").val("");
|
||||
$("#client_email").val("");
|
||||
$("#client_allocated_ips").importTags('');
|
||||
$("#client_extra_allowed_ips").importTags('');
|
||||
updateIPAllocationSuggestion();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -86,6 +86,11 @@ Wireguard Clients
|
|||
<label for="_client_allowed_ips" class="control-label">Allowed IPs</label>
|
||||
<input type="text" data-role="tagsinput" class="form-control" id="_client_allowed_ips">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="_client_extra_allowed_ips" class="control-label">Extra Allowed IPs</label>
|
||||
<input type="text" data-role="tagsinput" class="form-control"
|
||||
id="_client_extra_allowed_ips">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="icheck-primary d-inline">
|
||||
<input type="checkbox" id="_use_server_dns">
|
||||
|
@ -302,6 +307,16 @@ Wireguard Clients
|
|||
'placeholderColor': '#666666'
|
||||
});
|
||||
|
||||
modal.find("#_client_extra_allowed_ips").tagsInput({
|
||||
'width': '100%',
|
||||
'height': '75%',
|
||||
'interactive': true,
|
||||
'defaultText': 'Add More',
|
||||
'removeWithBackspace' : true,
|
||||
'minChars': 0,
|
||||
'placeholderColor': '#666666'
|
||||
})
|
||||
|
||||
// update client modal data
|
||||
$.ajax({
|
||||
cache: false,
|
||||
|
@ -327,6 +342,11 @@ Wireguard Clients
|
|||
modal.find("#_client_allowed_ips").addTag(obj);
|
||||
});
|
||||
|
||||
modal.find("#_client_extra_allowed_ips").importTags('');
|
||||
client.extra_allowed_ips.forEach(function (obj) {
|
||||
modal.find("#_client_extra_allowed_ips").addTag(obj);
|
||||
});
|
||||
|
||||
modal.find("#_use_server_dns").prop("checked", client.use_server_dns);
|
||||
modal.find("#_enabled").prop("checked", client.enabled);
|
||||
},
|
||||
|
@ -370,6 +390,7 @@ Wireguard Clients
|
|||
const email = $("#_client_email").val();
|
||||
const allocated_ips = $("#_client_allocated_ips").val().split(",");
|
||||
const allowed_ips = $("#_client_allowed_ips").val().split(",");
|
||||
const extra_allowed_ips = $("#_client_extra_allowed_ips").val().split(",");
|
||||
let use_server_dns = false;
|
||||
|
||||
if ($("#_use_server_dns").is(':checked')){
|
||||
|
@ -383,7 +404,7 @@ Wireguard Clients
|
|||
}
|
||||
|
||||
const data = {"id": client_id, "name": name, "email": email, "allocated_ips": allocated_ips,
|
||||
"allowed_ips": allowed_ips, "use_server_dns": use_server_dns, "enabled": enabled};
|
||||
"allowed_ips": allowed_ips, "extra_allowed_ips": extra_allowed_ips, "use_server_dns": use_server_dns, "enabled": enabled};
|
||||
|
||||
$.ajax({
|
||||
cache: false,
|
||||
|
|
|
@ -20,5 +20,5 @@ PostDown = {{ .serverConfig.Interface.PostDown }}
|
|||
[Peer]
|
||||
PublicKey = {{ .Client.PublicKey }}
|
||||
PresharedKey = {{ .Client.PresharedKey }}
|
||||
AllowedIPs = {{$first :=true}}{{range .Client.AllocatedIPs }}{{if $first}}{{$first = false}}{{else}},{{end}}{{.}}{{end}}{{$first :=true}}{{range .Client.AllowedIPs }}{{if ne . "0.0.0.0/0" }},{{.}}{{end}}{{end}}
|
||||
AllowedIPs = {{$first :=true}}{{range .Client.AllocatedIPs }}{{if $first}}{{$first = false}}{{else}},{{end}}{{.}}{{end}}{{$first :=true}}{{range .Client.ExtraAllowedIPs }},{{.}}{{end}}
|
||||
{{end}}{{end}}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue