Skip to content

Commit

Permalink
add allowed ips
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Fournet committed May 11, 2021
1 parent 534673d commit 57d4a41
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
1 change: 1 addition & 0 deletions model/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ type GlobalSetting struct {
PersistentKeepalive int `json:"persistent_keepalive,string"`
ConfigFilePath string `json:"config_file_path"`
UpdatedAt time.Time `json:"updated_at"`
AllowedIPs []string `json:"allowed_ips"`
}
24 changes: 12 additions & 12 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ <h4 class="modal-title">New Wireguard Client</h4>
</div>
<div class="form-group">
<label for="client_allowed_ips" class="control-label">Allowed IPs</label>
<input type="text" data-role="tagsinput" class="form-control" id="client_allowed_ips"
<input disabled type="text" data-role="tagsinput" class="form-control" id="client_allowed_ips"
value="0.0.0.0/0">
</div>
<div class="form-group">
Expand Down Expand Up @@ -345,16 +345,16 @@ <h1>{{template "page_title" .}}</h1>
});

// AllowedIPs tag input
$("#client_allowed_ips").tagsInput({
'width': '100%',
'height': '75%',
'interactive': true,
'defaultText': 'Add More',
'removeWithBackspace': true,
'minChars': 0,
'maxChars': 18,
'placeholderColor': '#666666'
});
// $("#client_allowed_ips").tagsInput({
// 'width': '100%',
// 'height': '75%',
// 'interactive': true,
// 'defaultText': 'Add More',
// 'removeWithBackspace': true,
// 'minChars': 0,
// 'maxChars': 18,
// 'placeholderColor': '#666666'
// });

// New client form validation
$(document).ready(function () {
Expand Down Expand Up @@ -434,4 +434,4 @@ <h1>{{template "page_title" .}}</h1>
</body>

</html>
{{end}}
{{end}}
2 changes: 1 addition & 1 deletion util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func BuildClientConfig(client model.Client, server model.Server, setting model.G
// Peer section
peerPublicKey := fmt.Sprintf("PublicKey = %s", server.KeyPair.PublicKey)
peerPresharedKey := fmt.Sprintf("PresharedKey = %s", client.PresharedKey)
peerAllowedIPs := fmt.Sprintf("AllowedIPs = %s", strings.Join(client.AllowedIPs, ","))
peerAllowedIPs := fmt.Sprintf("AllowedIPs = %s", strings.Join(setting.AllowedIPs, ","))
peerEndpoint := fmt.Sprintf("Endpoint = %s:%d", setting.EndpointAddress, server.Interface.ListenPort)
peerPersistentKeepalive := fmt.Sprintf("PersistentKeepalive = %d", setting.PersistentKeepalive)

Expand Down

0 comments on commit 57d4a41

Please sign in to comment.