subspacecommunity / subspace

A fork of the simple WireGuard VPN server GUI community maintained
MIT License
1.8k stars 131 forks source link

SUBSPACE_IPV{4,6}_POOL cannot be anything other than /24 or /112 #101

Open ledyba-z opened 4 years ago

ledyba-z commented 4 years ago

Describe the bug

Currently, both entrypoint.sh or handlers.go expects the netmask should be /24 or /112.

https://github.com/subspacecommunity/subspace/blob/master/entrypoint.sh#L45-L53

https://github.com/subspacecommunity/subspace/blob/master/handlers.go#L427

To Reproduce

Expected behavior

We use subspace in our company, so we really would like to use larger network range.

jack1902 commented 4 years ago

This is due to the way that the assignment of IP Address is currently handled. Its alot easier in Python for example to get an available ip address by doing things such as:

import ipaddress

ipnetwork = ipaddress.ip_network("192.168.0.0/24")

gateway = ipaddress.ip_address("192.168.0.1")
client_one = ipaddress.ip_address("192.168.0.2")
client_two = ipaddress.ip_address("192.168.0.10")

used = [gateway, client_one, client_two]

availabe_hosts = [host for host in ipnetwork.hosts() if host not in used]

This always ensures that the first available ip_address is given to the caller and also ensure that the ip_address is valid as the library is really smart. I might be able to achieve the same thing in Go, which will mean there can be any number of clients and it will remove the current restriction of:

https://github.com/subspacecommunity/subspace/blob/84847b5730f7c3169963035673575665eb35812b/handlers.go#L21

As the library will be far smarted in mangement of IPAddresses.

@ledyba-z Is this something you would be willing to contribute towards?

ledyba-z commented 4 years ago

Its alot easier in Python for example to get an available ip address by doing things such as:

Golang also equips a standard library to handle IP addrs, so it can be done easily as python.

Is this something you would be willing to contribute towards?

I think I can contribute them. But please wait a little... I am currently so busy and I can't spare the time soon for this issue.

alexkorotysh commented 2 years ago

Hey guys! Do we have any possibility to get fix with limits of 254 devices?