Page MenuHomeWildfire Games

Add a lobby server port config option
Needs ReviewPublic

Authored by mmoanis on May 26 2018, 11:29 AM.

Details

Reviewers
user1
elexis
Trac Tickets
#5122
Summary

This patch enable the server port to be configurable using the "default.cfg" config file.

The gloox XMPP client allow for connecting to a specific port which is updated in the gloox wrapper.

Test Plan
  • Connecting to the current lobby server [done]
  • Create another server using another port [done]

Diff Detail

Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

mmoanis created this revision.May 26 2018, 11:29 AM
Vulcan added a subscriber: Vulcan.May 26 2018, 11:33 AM

Successful build - Chance fights ever on the side of the prudent.

Link to build: https://jenkins.wildfiregames.com/job/differential/574/display/redirect

vladislavbelov added inline comments.
source/lobby/XmppClient.cpp
78

Standard type members are not initialised, so the m_port should be initialised here. Else it's UB.

mmoanis updated this revision to Diff 6674.May 28 2018, 9:48 PM

Initialize member variable to default value to avoid UB

mmoanis marked an inline comment as done.May 28 2018, 9:49 PM
mmoanis added inline comments.
source/lobby/XmppClient.cpp
78

Yes, you are right. Initialized it to -1 which is gloox default value.

Imarok added a subscriber: Imarok.May 29 2018, 11:14 AM
Imarok added inline comments.
source/lobby/XmppClient.cpp
96

Why not just make the port the first or second argument of the ctor?
Then you wouldn't need the new function

vladislavbelov added inline comments.May 29 2018, 1:00 PM
source/lobby/XmppClient.cpp
96

It seems because glooxwrapper::Client is the gloox class wrapped in the glooxwrapper namespace with the same interface.

mmoanis marked an inline comment as done.May 30 2018, 10:29 PM
mmoanis added inline comments.
source/lobby/XmppClient.cpp
96

Yes, the wrapper is exposing the same interface so I didn't change that.

Imarok added inline comments.May 31 2018, 8:35 PM
source/lobby/XmppClient.cpp
96

You are changing the wrapper anyway, so that's no argument.
That gloox itself only provides Client (const std::string &server) and Client (const JID &jid, const std::string &password, int port=-1) however is an argument for your code.

vladislavbelov added inline comments.May 31 2018, 8:57 PM
source/lobby/XmppClient.cpp
96

You are changing the wrapper anyway.

He doesn't change the wrapper, the Client has the setPort method too. So his version is more near to the gloox class, than the original version.

ejabberd Ubunut package for Xenial turned to be version 16.01-2

I will need to build/install from sources to complete testing of the patch, will continue by next week.

mmoanis added inline comments.May 31 2018, 9:38 PM
source/lobby/XmppClient.cpp
96

My understanding is that the wrapper is the same gloox interface but only used to build the library once for all game builds with different compilers.

mmoanis edited the test plan for this revision. (Show Details)Jun 9 2018, 10:41 PM
mmoanis added a comment.EditedJun 9 2018, 10:53 PM

Sorry for the delay. Testing on a custom server (ejabberd 18.04) is done and working as expected, patch should be ready to go.

Switch port to 5111 instead of 5222

python3 XpartaMuPP.py --domain localhost --login admin --password admin
2018-06-09 22:39:54        ERROR    Could not connect to [::1]:5222. Socket Error #111: Connection refused
2018-06-09 22:39:56        ERROR    Could not connect to 127.0.0.1:5222. Socket Error #111: Connection refused
2018-06-09 22:39:56        ERROR    Unable to connect
python3 XpartaMuPP.py --domain localhost --login admin --password admin -P 5111
2018-06-09 22:40:04        INFO     Negotiating TLS
2018-06-09 22:40:04        INFO     Using SSL version: TLSv1
2018-06-09 22:40:04        WARNING  Could not find pyasn1 and pyasn1_modules. SSL certificate COULD NOT BE VERIFIED.
2018-06-09 22:40:06        INFO     JID set to: admin@localhost/CC
2018-06-09 22:40:06        WARNING  Could not find pyasn1 and pyasn1_modules. SSL certificate expiration COULD NOT BE VERIFIED.
2018-06-09 22:40:06        INFO     XpartaMuPP started
2018-06-09 22:40:12        INFO     Waiting for </stream:stream> from server

Registering a user account and logging in:

tail ../logs/ejabberd.log 
2018-06-09 22:48:49.156 [info] <0.369.0>@ejabberd_listener:accept:302 (<0.512.0>) Accepted connection ::ffff:127.0.0.1:33640 -> ::ffff:127.0.1.1:5111
2018-06-09 22:48:49.470 [info] <0.512.0>@mod_register:try_register:326 The account player1@localhost was registered from IP address ::ffff:127.0.0.1
2018-06-09 22:48:58.666 [info] <0.369.0>@ejabberd_listener:accept:302 (<0.518.0>) Accepted connection ::ffff:127.0.0.1:33642 -> ::ffff:127.0.1.1:5111
2018-06-09 22:48:58.750 [info] <0.518.0>@ejabberd_c2s:handle_auth_success:434 (tcp|<0.518.0>) Accepted c2s SCRAM-SHA-1 authentication for player1@localhost by mnesia backend from ::ffff:127.0.0.1
2018-06-09 22:48:59.078 [info] <0.518.0>@ejabberd_c2s:bind:403 (tcp|<0.518.0>) Opened c2s session for player1@localhost/0ad
2018-06-09 22:49:20.859 [info] <0.518.0>@ejabberd_c2s:process_terminated:271 (tcp|<0.518.0>) Closing c2s session for player1@localhost/0ad: Connection failed: connection closed

screenshot from the lobby

Dunedan added inline comments.Jul 8 2018, 2:20 PM
source/tools/XpartaMuPP/XpartaMuPP.py
660

Instead of adding a port option to the bots, I suggest to remove the`--server` option as well and to call xmpp.connect() without any arguments. Without providing an address tuple to xmpp.connect() SleekXMPP tries to figure out the server and port using DNS SRV records to figure out the responsible XMPP server for the given JID (see https://wiki.xmpp.org/web/SRV_Records#XMPP_SRV_records) and falls back to using the domain from the JID as server and the default port 5222 in case no SRV record can be found (https://github.com/fritzy/SleekXMPP/blob/7075a3b7fa857fc8f9db60da9d01fa1a11806659/sleekxmpp/clientxmpp.py#L154-L156),

So removing the --server option instead of adding a --port option would keep the bots functioning as they are, remove the need for 2 additional options to provide to them and would be more standard compliant, as it'd honor DNS SRV records. For XMPP server operators that'd mean that they'd have to add a SRV-DNS-record if they want to use a non-default port, something they should do anyway.

Itms edited reviewers, added: user1, elexis; removed: Itms.Dec 27 2018, 10:44 PM
Itms added a subscriber: user1.

Hello @mmoanis, and thank you very much for the patch! As you may know we had a large period without accepting patches, because we were preparing a re-release of the game.

Now it's finally over, and we also have an upgraded server and a new lobby administrator since August (@user1). So I will pass this over to him. I have only a generic knowledge of the lobby, so your patch looks good to me, but I might miss some issues, and it would be better to test your code on the server.

Please let us know if you are still around in case a change is requested, and sorry for the inconvenience!

mmoanis added a subscriber: Itms.Jan 3 2019, 12:02 PM

Hi @Itms I am available for any further modification needed.

Stan added a subscriber: Stan.Jan 3 2019, 12:05 PM

@mmoanis @Dunedan's comment seems legit

@Stan @Dunedan I will work on it, Currently I am about to start my exams so I will be delayed for a bit of time.

@Stan @Dunedan I will work on it, Currently I am about to start my exams so I will be delayed for a bit of time.

Hi @mmoanis are you able to continue with this patch?