Page 1 of 2

[Bug] Returning Wrong IP Address For IPv6?

Posted: 20 Mar 2017, 14:48
by hieubui149
We provided a feature to know player IP address and prevent player in the same network can't play together and it work well by call

Code: Select all

user.getIpAddress()

from Java.
This morning, we decided to support IPv6 to our customer on my server and we found the problem with players who are using IPv6.
For client Ipv4, this function returned full of ip. Eg: "115.79.219.152"
For client Ipv6, this function returned just the first part of the string: Eg: "2a01" (while there are more of it ":aaaa:bbbb:cccc"). :shock:. Because we have plenty of Ip begin with 2a01, so our server detect that they're in the same Ip and stop them from playing together.

More information: they connect to my server normally without any errors, so I think I have configured my server correctly.
I don't know what is going on. Let me know please. Thanks. :)

Re: [Bug] Returning Wrong IP Address For IPv6?

Posted: 20 Mar 2017, 15:20
by Lapo
Are you running the latest 2.12.x? Or and older version?
Before 2.12 IPv6 was not handled correctly, in terms of formatting/output.

Thanks

Re: [Bug] Returning Wrong IP Address For IPv6?

Posted: 20 Mar 2017, 15:29
by hieubui149
Hi Lapo, I'm using 2.12.3 on server - the last update.

Re: [Bug] Returning Wrong IP Address For IPv6?

Posted: 20 Mar 2017, 16:05
by Lapo
What connection is the client using?
TCP? Websocket? BlueBox?

Thanks

Re: [Bug] Returning Wrong IP Address For IPv6?

Posted: 21 Mar 2017, 00:42
by hieubui149
I supports both TCP and BlueBox. Currently they're online (from players around the world) so it's a little bit hard to know which is the one cause error. Can you guys test both of them? I don't have Ipv6 environment for testing. Thanks

Re: [Bug] Returning Wrong IP Address For IPv6?

Posted: 21 Mar 2017, 10:09
by Lapo
We don't either. It's relatively easy to setup a server with IPv6 as most providers support it, but from home/office connections it's unlikely.
In any case I've double checked the code that handles IPv6 addresses and I can't find or reproduce any issues.

Can you show me an extract of your log files where IPv6 clients have connected to the server?
They look like this:

Code: Select all

08 mar 2017 | 10:56:25,348 | INFO  | SocketReader | bitswarm.sessions.DefaultSessionManager |     | Session created: { Id: 98, Type: DEFAULT, Logged: No, IP: 127.0.0.1:54072 } on Server port: 9933 <---> 54072


Basically any "Session created" line.

Thanks

Re: [Bug] Returning Wrong IP Address For IPv6?

Posted: 21 Mar 2017, 12:21
by hieubui149
Hi Lapo,
My game is online now and I have disabled INFO on session/login. That's why I can give you that log (I don't have testing environment too). Is there another way to detect or maybe find the reason for that weird error.
My configuration for Ipv6 is [img]
Screen%20Shot%202017-03-21%20at%2019.23.58.jpg
[/img]

Re: [Bug] Returning Wrong IP Address For IPv6?

Posted: 21 Mar 2017, 14:20
by Lapo
If you need this quickly, the logs are the only way to go. Otherwise I will add your report in our bug database, without any evidence/logs and we'll have to reproduce it ourselves setting up two different IPv6 enable environments to test this out. Which will take a while.

Thanks

Re: [Bug] Returning Wrong IP Address For IPv6?

Posted: 21 Mar 2017, 15:17
by hieubui149
Ok Lapo, let's wait. By the way, I will try something to know exactly what it is. Let me know if you have more information about it. Thank you! :wink:

Re: [Bug] Returning Wrong IP Address For IPv6?

Posted: 21 Mar 2017, 18:14
by hieubui149
Hi Lapo,
I did some trick by use my servers connect to a test smartfox server to create ipv6 environment and found that log with ipv6, check it out please:

Code: Select all

18:15:01,068 INFO  [SocketReader] sessions.DefaultSessionManager     - Session created: { Id: 2, Type: DEFAULT, Logged: No, IP: 2a01 } on Server port: 9933 <---> 0
18:15:01,429 INFO  [SFSWorker:Ext:8] api.SFSApi     - User login: { Zone: Gateway }, ( User Name: 1, Id: 1, Priv: 0, Sess: 2a01 ) , Type: Android

Re: [Bug] Returning Wrong IP Address For IPv6?

Posted: 21 Mar 2017, 19:32
by Lapo
Thanks, this will probably help.

Re: [Bug] Returning Wrong IP Address For IPv6?

Posted: 23 Mar 2017, 14:23
by Lapo
We've done a few tests and fixed what we think should be the cause.
Would you please test it on your side?

You can download the patch from here.

Re: [Bug] Returning Wrong IP Address For IPv6?

Posted: 24 Mar 2017, 15:36
by hieubui149
Thank Lapo, this bug have already fixed. Here are the log from my test:

Code: Select all

15:40:09,728 INFO  [SocketReader] sessions.DefaultSessionManager     - Session created: { Id: 3, Type: DEFAULT, Logged: No, IP: 2a01:0:0:0:f03c:91ff:fee7:4e53:29930 } on Server port: 9933 <---> 29930
15:40:10,097 INFO  [SFSWorker:Ext:8] api.SFSApi     - User login: { Zone: Gateway }, ( User Name: 1, Id: 2, Priv: 0, Sess: 2a01:0:0:0:f03c:91ff:fee7:4e53:29930 ) , Type: Android

Re: [Bug] Returning Wrong IP Address For IPv6?

Posted: 24 Mar 2017, 20:23
by Lapo
Thanks for your feedback.

Re: [Bug] Returning Wrong IP Address For IPv6?

Posted: 12 Apr 2017, 18:58
by creat326
hi
it doesn't work here with latest patch, if using udp instead of tcp
it seems all udp packages bounce back as soon as it's on ipv6 network

not sure if it's the same but my server log is full of these for many of these players reporting problems
12 Apr 2017 | 19:59:59,868 | WARN | SFSWorker:Sys:2 | v2.protocol.SFSIoHandler | | Discard UDP packet from 162.250.152.155:45032, reason: Sender UDP Port doesn't match current session port: 45032 != 53727