mirror of
https://github.com/ngoduykhanh/wireguard-ui.git
synced 2025-06-06 00:37:24 +03:00
Edit wireguard client (#19)
* Add the ability to modify an existing client * Update client page using Ajax
This commit is contained in:
parent
9169e75e88
commit
cd7f6e500a
9 changed files with 445 additions and 76 deletions
14
util/util.go
14
util/util.go
|
@ -173,7 +173,7 @@ func GetIPFromCIDR(cidr string) (string, error) {
|
|||
}
|
||||
|
||||
// GetAllocatedIPs to get all ip addresses allocated to clients and server
|
||||
func GetAllocatedIPs() ([]string, error) {
|
||||
func GetAllocatedIPs(ignoreClientID string) ([]string, error) {
|
||||
allocatedIPs := make([]string, 0)
|
||||
|
||||
// initialize database directory
|
||||
|
@ -211,12 +211,14 @@ func GetAllocatedIPs() ([]string, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
for _, cidr := range client.AllocatedIPs {
|
||||
ip, err := GetIPFromCIDR(cidr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
if client.ID != ignoreClientID {
|
||||
for _, cidr := range client.AllocatedIPs {
|
||||
ip, err := GetIPFromCIDR(cidr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
allocatedIPs = append(allocatedIPs, ip)
|
||||
}
|
||||
allocatedIPs = append(allocatedIPs, ip)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue