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

This subforum contains all the issues which we already resolved.
Post Reply
movax20h
Fast Inserter
Fast Inserter
Posts: 164
Joined: Fri Mar 08, 2019 7:07 pm
Contact:

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

Post 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 4057 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.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13198
Joined: Wed Jun 11, 2014 5:23 am
Contact:

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

Post by Rseding91 »

Thanks for the report however when I try that out, it works perfectly fine for me?
If you want to get ahold of me I'm almost always on Discord.

movax20h
Fast Inserter
Fast Inserter
Posts: 164
Joined: Fri Mar 08, 2019 7:07 pm
Contact:

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

Post 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]" ?

Rseding91
Factorio Staff
Factorio Staff
Posts: 13198
Joined: Wed Jun 11, 2014 5:23 am
Contact:

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

Post by Rseding91 »

I get "Couldn't establish network communication with the server" when I try to use that IP.
If you want to get ahold of me I'm almost always on Discord.

movax20h
Fast Inserter
Fast Inserter
Posts: 164
Joined: Fri Mar 08, 2019 7:07 pm
Contact:

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

Post 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

Rseding91
Factorio Staff
Factorio Staff
Posts: 13198
Joined: Wed Jun 11, 2014 5:23 am
Contact:

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

Post by Rseding91 »

Are you on windows, mac, or linux? Because I'm on Windows 7 and can't reproduce that issue.
If you want to get ahold of me I'm almost always on Discord.

movax20h
Fast Inserter
Fast Inserter
Posts: 164
Joined: Fri Mar 08, 2019 7:07 pm
Contact:

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

Post 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.

movax20h
Fast Inserter
Fast Inserter
Posts: 164
Joined: Fri Mar 08, 2019 7:07 pm
Contact:

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

Post 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.

orzelek
Smart Inserter
Smart Inserter
Posts: 3911
Joined: Fri Apr 03, 2015 10:20 am
Contact:

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

Post 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.

movax20h
Fast Inserter
Fast Inserter
Posts: 164
Joined: Fri Mar 08, 2019 7:07 pm
Contact:

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

Post 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

orzelek
Smart Inserter
Smart Inserter
Posts: 3911
Joined: Fri Apr 03, 2015 10:20 am
Contact:

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

Post 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.

movax20h
Fast Inserter
Fast Inserter
Posts: 164
Joined: Fri Mar 08, 2019 7:07 pm
Contact:

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

Post 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.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13198
Joined: Wed Jun 11, 2014 5:23 am
Contact:

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

Post by Rseding91 »

The parsing is done by calling getaddrinfo() which is a function outside of our control.
If you want to get ahold of me I'm almost always on Discord.

movax20h
Fast Inserter
Fast Inserter
Posts: 164
Joined: Fri Mar 08, 2019 7:07 pm
Contact:

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

Post 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.

quyxkh
Smart Inserter
Smart Inserter
Posts: 1028
Joined: Sun May 08, 2016 9:01 am
Contact:

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

Post 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.

posila
Factorio Staff
Factorio Staff
Posts: 5201
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

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

Post 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.

movax20h
Fast Inserter
Fast Inserter
Posts: 164
Joined: Fri Mar 08, 2019 7:07 pm
Contact:

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

Post 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. :)

Post Reply

Return to “Resolved Problems and Bugs”