Py-KMS-Organization/py-kms

Issue with server listening on IPv6

Closed this issue · 6 comments

Here is the issue i can run on specific IPv4 & IPv6 and it will work (for example: ./pykms_Server.py ::1 1688 - will listen on loopback interface ip v6 ::1 and ./pykms_Server.py 127.0.0.1 1688 - will listen on loopback interface ip v4 127.0.0.1), but as it stands right now there is no way to use both at the same time (dual stack), because for IP it only takes only 1 argument. Also default option (0.0.0.0), only listens on all interfaces IPv4 only and skips IPv6 listening... sure i could run 2 pykms_Server instances both listening on different ips, but it shouldnt be that hard, also since i run py-kms in docker, i would need to run 2 py-kms docker containers or write my own...

Would be nice to have ability, to set server to listen on multiple ips in the same instance and have default option to listen on all ipv4 and ipv6 addresses on all interfaces.

Actually its possible to specify more ips... something along this lines:

./pykms_Server.py 84.xxx.xxx.xxx 1688 -l 1033 -c 26 -a 120 -r 10080 -w RANDOM -V INFO -F STDOUT connect -n 10.0.0.1,1688 -n 2a01:xxx:xxxx:xxxx::1,1688,

bit clumsy :) now need to figure out how to add this in to docker without rebuilding it...

Tried to "extend" docker LOGFILE env variable with -e LOGFILE="STDOUT connect -n 10.0.0.1,1688 -n 2a01:xxx:xxxx:xxxx::1,1688", but it errors out with: argument -F/--logfile: invalid directory: 'STDOUT connect -n 10.0.0.1,1688 -n 2a01:xxx:xxxx:xxxx::1,1688'. Exiting...

hm... dont think its possible how docker container is set right now, i think we would need another env variable for example "CUSTOM_OPTIONS" that would append whatever you put in to it at the end of pykms_Server.py command...

I dont understand, i created new env variable for docker, changed start.py to add connect that enviroment variable at the end (like i had it working outside docker container) and now im getting this error:

Sun, 03 Apr 2022 17:03:39 INFO     Log level: DEBUG
Sun, 03 Apr 2022 17:03:39 INFO     Setting gid to '65534'.
Sun, 03 Apr 2022 17:03:39 INFO     Setting uid to '65534'.
Sun, 03 Apr 2022 17:03:39 DEBUG    server_cmd: /usr/bin/python3 -u pykms_Server.py 84.xxx.xxx.xxx 1688 -l 1033 -c 26 -a 120 -r 10080 -w RANDOM -V DEBUG -F STDOUT connect -n 10.0.0.1,1688 -n 2a01:xxx:xxxx:xxxx::1,1688
unrecognized optional connect arguments: `-n 10.0.0.1,1688 -n 2a01:xxx:xxxx:xxxx::1,1688`. Exiting...

obviously server_cmd seems fine, i dont undestand why its working outside docker container in my python enviroment, but inside it errors out...

This is outside docker in my own python env:

mih ~/py-kms/py-kms # ./pykms_Server.py 84.xxx.xxx.xxx 1688 -l 1033 -c 26 -a 120 -r 10080 -w RANDOM -V INFO -F STDOUT connect -n 10.0.0.1,1688 -n 2a01:xxx:xxxx:xxxx::1,1688
Sun, 03 Apr 2022 17:09:54 INFO     TCP server listening at 84.xxx.xxx.xxx on port 1688
                                                        at 10.0.0.1 on port 1688
                                                        at 2a01:xxx:xxxx:xxxx::1 on port 1688
Sun, 03 Apr 2022 17:09:54 INFO     HWID: 86C01601ECD24FE

someone smarter then mee needs to figure this out :)

Hi,

  1. Docker creates an isolated network namespace for every container. Please take a look into that (tip: network_mode: host).
  2. Linux allows an IPv4 to connect to any IPv6 port thanks to address mapping / translation. Go ahead and test it! -> Meaning listening to :: should be enough.
  3. For specific network restrictions please utilize the firewall capabilities of your setup (e.g. iptables for Linux).

Greetings...

Hey,

  1. I know, im using host
  2. yes if you set as IP :: server listens for traffic on all ipv6 interfaces, but not on ipv4 again problem is you would need to set 0.0.0.0 and ::

anyway i had some time, so i lerned some basic python, didnt go that far to change pykms_Server code, but i fixed start.py to allow multiple IPs in docker eviroment variable: #238af40

check if everything is fine (it should be), anyway it works for me, you can now put multiple IPs (IPv4 and IPv6 - seperated by spaces) in to IP variable, first one it takes as "main" one and others it throws in to connect -n option.