Mawthuq-Software / Wireguard-Manager-and-API

A Wireguard VPN Server Manager and API to add and remove clients
GNU Affero General Public License v3.0
172 stars 24 forks source link

[BUG] No available IPs on the server #17

Open whlack opened 10 months ago

whlack commented 10 months ago

No available IPs on the server After sending a postman request to add a key, it's returning:

data: { 
  response: 'No available IPs on the server' 
}

Also, on my logs of docker container i can see UNIQUE constraint failed message:

/usr/src/wireguard-manager-and-api/src/db/db.go:108 UNIQUE constraint failed: ips.ipv6_address
[0.096ms] [rows:0] INSERT INTO `ips` (`ipv4_address`,`ipv6_address`,`in_use`,`wg_interface`) VALUES ("10.6.1.108","-","false","wg0")

My configs is: MAX_IP: 350 ADDRESS: 10.8.0.1 SUBNET: /16

whlack commented 10 months ago

okay, it looks like i got a problem. when it generates ip addresses, (IPv6 is disabled), it's trying to set ipv6_address to "-" everywhere, so it fails UNIQUE key. @RaspberryTech01

RaspberryTech01 commented 10 months ago

Interesting, how are you setting the IPv6 addresses in the config?

INSTANCE.IP.GLOBAL.ADDRESS.IPV6 what is this value in your config?

whlack commented 10 months ago

INSTANCE.IP.GLOBAL.ADDRESS.IPV6 = [ "2001:19f0:6c00:1bf2::64" ]

bug reproduces when instance.ip.local.ipv6.enabled = false; workaround is enable ipv6, anyway it's not supported in docker

RaspberryTech01 commented 10 months ago

That is correct, I never got ipv6 working in docker. Whilst its not a solution I suggest keeping it like that as it doesn't hurt.

whlack commented 10 months ago

okay, but i suggest to set ipv6 in database field to nullable (keep unique key), and set it to null if IPv6 is disabled