Page 1 of 1

[0.18.6] IPv6 address in square brackets without port is claimed to be incorrect.

Posted: Tue Feb 11, 2020 10:37 pm
by movax20h

Code: Select all

2a02:348:9a:83b1::1
and

Code: Select all

[2a02:348:9a:83b1::1]:34197
work.

But this:

Code: Select all

[2a02:348:9a:83b1::1]
doesn't:
invalid-ipv6-in-squares-without-port.png
invalid-ipv6-in-squares-without-port.png (206.56 KiB) Viewed 4366 times

Code: Select all

...
 292.851 Error ClientMultiplayerManager.cpp:101: MultiplayerManager failed: "[2a02:348:9a:83b1::1] is not a valid address (Name or service not known)."
 292.851 Info ClientMultiplayerManager.cpp:589: UpdateTick(4294967295) changing state from(Ready) to(InitializationFailed)


But it should.


Both server and client are using Linux.

Connecting using DNS name that has only AAAA record (without A) record also works without issues. Didn't test CNAMEs.

Re: [0.18.6] IPv6 address in square brackets without port is claimed to be incorrect.

Posted: Fri Feb 14, 2020 12:22 pm
by Rseding91
Thanks for the report however when I try that out, it works perfectly fine for me?

Re: [0.18.6] IPv6 address in square brackets without port is claimed to be incorrect.

Posted: Fri Feb 14, 2020 6:07 pm
by movax20h
It doesn't for me. It fails with the same error message every time.

The server is running right now, it is vanilla server without password, could you try connecting right now to it using "[2a02:348:9a:83b1::1]" ?

Re: [0.18.6] IPv6 address in square brackets without port is claimed to be incorrect.

Posted: Fri Feb 14, 2020 6:45 pm
by Rseding91
I get "Couldn't establish network communication with the server" when I try to use that IP.

Re: [0.18.6] IPv6 address in square brackets without port is claimed to be incorrect.

Posted: Fri Feb 14, 2020 7:00 pm
by movax20h
Rseding91 wrote:
Fri Feb 14, 2020 6:45 pm
I get "Couldn't establish network communication with the server" when I try to use that IP.
Here is a short video example: https://www.youtube.com/watch?v=G7PzIGcSbx0

Re: [0.18.6] IPv6 address in square brackets without port is claimed to be incorrect.

Posted: Fri Feb 14, 2020 7:29 pm
by Rseding91
Are you on windows, mac, or linux? Because I'm on Windows 7 and can't reproduce that issue.

Re: [0.18.6] IPv6 address in square brackets without port is claimed to be incorrect.

Posted: Fri Feb 14, 2020 7:34 pm
by movax20h
Rseding91 wrote:
Fri Feb 14, 2020 7:29 pm
Are you on windows, mac, or linux? Because I'm on Windows 7 and can't reproduce that issue.
On Linux.

I can try running Windows version of factorio via wine. I guess to check it out.

Re: [0.18.6] IPv6 address in square brackets without port is claimed to be incorrect.

Posted: Fri Feb 14, 2020 7:42 pm
by movax20h
Can't test it via Wine. Unfortunately running Factorio 0.18.6 under Wine 5.0-rc5 doesn't work: __core__/graphics/shaders/sprites.vsh:1:53 syntax error, unexpected KW_CBUFFER, during startup / shader compilation. That is probably a bug in Wine tho, and obviously unrelated to the topic in this thread.

I don't have access to Windows to test it on real Windows installation.

Re: [0.18.6] IPv6 address in square brackets without port is claimed to be incorrect.

Posted: Fri Feb 14, 2020 9:04 pm
by orzelek
My Win 10 test shows that my mods are not correct for the server.
But it sees the server properly and communicates with it.

Re: [0.18.6] IPv6 address in square brackets without port is claimed to be incorrect.

Posted: Fri Feb 14, 2020 9:15 pm
by movax20h
orzelek wrote:
Fri Feb 14, 2020 9:04 pm
My Win 10 test shows that my mods are not correct for the server.
But it sees the server properly and communicates with it.
Yeah, I just noticed your attempt in the logs. Not sure why would it say mod mismatch, as I don't run any mods. Maybe you are not running 0.18.6?

Also, just to confirm. You did use the address WITH square brackets and NO port? As in the initial issue report.

Interesting it is OS specific tho.

Rseding91, is parsing of addresses done via some external library by any chance? I don't think glibc / libresolve is to blame, as non of the glibc resolver related functions (like `inet_pton`) ever accept both address and port in the first place as a single string. It always needs to be broken by the app first before passing to various structs. Or maybe just some bad regexp somewhere? :D

Re: [0.18.6] IPv6 address in square brackets without port is claimed to be incorrect.

Posted: Fri Feb 14, 2020 10:08 pm
by orzelek
movax20h wrote:
Fri Feb 14, 2020 9:15 pm
orzelek wrote:
Fri Feb 14, 2020 9:04 pm
My Win 10 test shows that my mods are not correct for the server.
But it sees the server properly and communicates with it.
Yeah, I just noticed your attempt in the logs. Not sure why would it say mod mismatch, as I don't run any mods. Maybe you are not running 0.18.6?

Also, just to confirm. You did use the address WITH square brackets and NO port? As in the initial issue report.

Interesting it is OS specific tho.

Rseding91, is parsing of addresses done via some external library by any chance? I don't think glibc / libresolve is to blame, as non of the glibc resolver related functions (like `inet_pton`) ever accept both address and port in the first place as a single string. It always needs to be broken by the app first before passing to various structs. Or maybe just some bad regexp somewhere? :D
I did use [2a02:348:9a:83b1::1] directly in address field and nothing more.
And mod mismatch is correct - I do have mods active.

Re: [0.18.6] IPv6 address in square brackets without port is claimed to be incorrect.

Posted: Fri Feb 14, 2020 11:06 pm
by movax20h
orzelek wrote:
Fri Feb 14, 2020 10:08 pm
movax20h wrote:
Fri Feb 14, 2020 9:15 pm
orzelek wrote:
Fri Feb 14, 2020 9:04 pm
My Win 10 test shows that my mods are not correct for the server.
But it sees the server properly and communicates with it.
Yeah, I just noticed your attempt in the logs. Not sure why would it say mod mismatch, as I don't run any mods. Maybe you are not running 0.18.6?

Also, just to confirm. You did use the address WITH square brackets and NO port? As in the initial issue report.

Interesting it is OS specific tho.

Rseding91, is parsing of addresses done via some external library by any chance? I don't think glibc / libresolve is to blame, as non of the glibc resolver related functions (like `inet_pton`) ever accept both address and port in the first place as a single string. It always needs to be broken by the app first before passing to various structs. Or maybe just some bad regexp somewhere? :D
I did use [2a02:348:9a:83b1::1] directly in address field and nothing more.
And mod mismatch is correct - I do have mods active.
Thanks for testing this.

Re: [0.18.6] IPv6 address in square brackets without port is claimed to be incorrect.

Posted: Fri Feb 14, 2020 11:16 pm
by Rseding91
The parsing is done by calling getaddrinfo() which is a function outside of our control.

Re: [0.18.6] IPv6 address in square brackets without port is claimed to be incorrect.

Posted: Fri Feb 14, 2020 11:34 pm
by movax20h
Rseding91 wrote:
Fri Feb 14, 2020 11:16 pm
The parsing is done by calling getaddrinfo() which is a function outside of our control.
That is not true. getaddrinfo and getaddrinfo_a DOES NOT receive a single string containing both address and service. They are separate arguments, thus you must parse them to separate them out.

My guess is you are passing possibly empty string to 'service' argument, but it should be NULL instead, with service port pre-initalized to a default value by factorio.

Please read a manpage on getaddrinfo(3).

Or are you trying to tell me that this works:

Code: Select all

int ret = getaddrinfo("[2a02:348:9a:83b1::1]:34197", NULL, NULL, &res);
? Because that is incorrect use of the getaddrinfo. http://man7.org/linux/man-pages/man3/getaddrinfo.3.html

This can be verified in RFC2553:

Code: Select all

   The nodename and servname arguments are pointers to null-terminated
   strings or NULL.  One or both of these two arguments must be a non-
   NULL pointer.  In the normal client scenario, both the nodename and
   servname are specified.  In the normal server scenario, only the
   servname is specified.  A non-NULL nodename string can be either a
   node name or a numeric host address string (i.e., a dotted-decimal
   IPv4 address or an IPv6 hex address).  A non-NULL servname string can
   be either a service name or a decimal port number.
And can be also found in POSIX.1-2008 specification for this function.

EDIT: I just tested this, and getaddrinfo on Linux / glibc correctly rejects such constructs. It doesn't accept address in square bracket either. Also correctly. It only accepts IPv4, IPv6 or DNS / host name. No square brackets or ports or service names. The service name / port must go into service argument.

Ergo factorio does parse the address to obtain it.

Re: [0.18.6] IPv6 address in square brackets without port is claimed to be incorrect.

Posted: Sat Feb 15, 2020 1:20 am
by quyxkh
movax20h wrote:
Fri Feb 14, 2020 11:34 pm
Ergo factorio does parse the address to obtain it.
The RFC that actually specifies other-than-uri text forms for IPv6 addresses with ports is 5952, which notably includes the paragraph
Other styles are acceptable when there is exactly one style for the given context and cross-platform portability does not become an issue.
and this isn't a uri and there are multiple address families possible here.

The only listed format that includes a bracketed IPv6 address is followed by a colon and a port. Giving a bracketed IPv6 address with no following colon and port is not listed as acceptable in any technical context I can find outside a URI, and you're not giving a URI.

Specifying the bare IPv6 address correctly works.

Re: [0.18.6] IPv6 address in square brackets without port is claimed to be incorrect.

Posted: Sat Feb 15, 2020 3:03 pm
by posila
I agree with what quyxkh wrote, but since getaddrinfo() accepts brackets on Windows, for consistency between plaforms I'll just trim the brackets if ipv6 parsing regex fails. It is also easier for me to just do that and finally not see this thread in "new posts", than to start arguing about it.

Re: [0.18.6] IPv6 address in square brackets without port is claimed to be incorrect.

Posted: Fri Jun 26, 2020 10:37 pm
by movax20h
posila wrote:
Sat Feb 15, 2020 3:03 pm
I agree with what quyxkh wrote, but since getaddrinfo() accepts brackets on Windows, for consistency between plaforms I'll just trim the brackets if ipv6 parsing regex fails. It is also easier for me to just do that and finally not see this thread in "new posts", than to start arguing about it.


Thank you! I can confirm this is fixed and works correctly on Linux too. :)