Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow duplicate ports when using multiple IP addresses #77

Open
brianmay opened this issue Jun 28, 2024 · 3 comments
Open

Allow duplicate ports when using multiple IP addresses #77

brianmay opened this issue Jun 28, 2024 · 3 comments
Labels
bug Something isn't working enhancement New feature or request module Topic: The minecraft-servers module

Comments

@brianmay
Copy link

I see the code:

        {
          assertion =
            let
              serverPorts = mapAttrsToList
                (name: conf: conf.serverProperties.server-port or 25565)
                (filterAttrs (_: cfg: cfg.openFirewall) servers);

              counts = map (port: count (x: x == port) serverPorts) (unique serverPorts);
            in
            lib.all (x: x == 1) counts;
          message = "Multiple servers are set to use the same port. Change one to use a different port.";
        }

I haven't tested it, but this looks very much like you can't have multiple servers using the same server-port even if they have different server-ip values.

Or Maybe it just means you can't use openFirewall with such configs. Still trying to understand this logic.

@Infinidoge
Copy link
Owner

Infinidoge commented Jun 28, 2024

This is indeed an oversight. The general logic is that it catches trivial mistakes for the general case of non-differentiated IPs, which prevents starting servers in a situation that would cause them to conflict. Shouldn't be too difficult to make it check both server ip and port to make sure those combinations are unique. openFirewall isn't much of an issue since it should(?, not actually sure) have it open for all IP addresses, so just filtering out duplicate ports would be fine.

@Infinidoge Infinidoge changed the title false duplicate port when using multiple IP addresses Allow duplicate ports when using multiple IP addresses Jun 28, 2024
@Infinidoge Infinidoge added bug Something isn't working enhancement New feature or request module Topic: The minecraft-servers module labels Jun 28, 2024
@Vixeliz
Copy link

Vixeliz commented Jul 19, 2024

Just adding my input. Even when on the same ip, i personally use this to just easily setup up multiple mc servers for playing with different people on my laptop. I think the check should be able to be opted out entirely possibly. I have autostart off for all my servers and just start them up when needed. Obviously I could also just port forward a port range instead but it'd be nice for convenience to just have them all be the same one since I only ever have one up at a time.

@brianmay
Copy link
Author

I think if you set cfg.openFirewall=false it disables this check. Seems to work for me anyway.

But then of course you will have to open the firewall ports yourself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request module Topic: The minecraft-servers module
Projects
None yet
Development

No branches or pull requests

3 participants