[Widelands-dev] [Merge] lp:~widelands-dev/widelands/net-checkpwd-command into lp:widelands
The proposal to merge lp:~widelands-dev/widelands/net-checkpwd-command into lp:widelands has been updated. Status: Needs review => Merged For more details, see: https://code.launchpad.net/~widelands-dev/widelands/net-checkpwd-command/+merge/368225 -- Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/net-checkpwd-command. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands/net-checkpwd-command into lp:widelands
Review: Approve Tested and working :) @bunnybot merge force -- https://code.launchpad.net/~widelands-dev/widelands/net-checkpwd-command/+merge/368225 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/net-checkpwd-command. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands/net-checkpwd-command into lp:widelands
The related change to the metaserver has been deployed, so this branch can be tested and merged. Bunnybot fails due to transient errors. -- https://code.launchpad.net/~widelands-dev/widelands/net-checkpwd-command/+merge/368225 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/net-checkpwd-command. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
[Widelands-dev] [Merge] lp:~widelands-dev/widelands/net-checkpwd-command into lp:widelands
Continuous integration builds have changed state: Travis build 5120. State: errored. Details: https://travis-ci.org/widelands/widelands/builds/540143585. Appveyor build 4902. State: failed. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_net_checkpwd_command-4902. -- https://code.launchpad.net/~widelands-dev/widelands/net-checkpwd-command/+merge/368225 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/net-checkpwd-command. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands/net-checkpwd-command into lp:widelands
Is fixed, thanks! -- https://code.launchpad.net/~widelands-dev/widelands/net-checkpwd-command/+merge/368225 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/net-checkpwd-command. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands/net-checkpwd-command into lp:widelands
Review: Approve Code LGTM, just some small nits for the comments Diff comments: > === modified file 'src/network/internet_gaming.cc' > --- src/network/internet_gaming.cc2019-05-25 08:25:55 + > +++ src/network/internet_gaming.cc2019-06-01 12:37:21 + > @@ -405,6 +452,12 @@ > asctime(gmtime())); > return; > > + } else if (cmd == IGPCMD_PWD_OK) { > + const time_t now = time(nullptr); > + log("InternetGaming: Password check successfully at UTC > %s", asctime(gmtime())); Wither "Password checked successfully" or "Password check successful" > + state_ = LOBBY; > + return; > + > } else if (cmd == IGPCMD_ERROR) { > std::string errortype = packet.string(); > if (errortype != IGPCMD_LOGIN && errortype != > IGPCMD_PWD_CHALLENGE) { > > === modified file 'src/network/internet_gaming_protocol.h' > --- src/network/internet_gaming_protocol.h2019-02-23 11:00:49 + > +++ src/network/internet_gaming_protocol.h2019-06-01 12:37:21 + > @@ -182,7 +183,29 @@ > static const std::string IGPCMD_LOGIN = "LOGIN"; > > /** > - * This is sent by the metaserver after a IGPCMD_LOGIN by a registered > client. > + * The client tries to check the password of the user without doing a full > login. > + * Should be sent without logging in before. > + * > + * Payload: > + * \li string:protocol version (see kInternetGamingProtocolVersion) > + * \li string:client name > + * \li string:build_id of the client > + * > + * A IGPCMD_PWD_CHALLENGE exchange follows before the server replies with a > IGPCMD_PWD_OK > + * or IGPCMD_ERROR message. > + * > + * If the password is correct, the metaserver replies with a IGPCMD_PWD_OK > command > + * with the following payload: > + * \li string:client name. Will be the same as sent before. > + * \li string:clients rights (see client rights section above) > + * > + * If the password is wrong or some other error occurres, \ref IGPCMD_ERROR > is returned. occurres -> occurred > + */ > +static const std::string IGPCMD_CHECK_PWD = "CHECK_PWD"; > +static const std::string IGPCMD_PWD_OK = "PWD_OK"; > + > +/** > + * This is sent by the metaserver after a IGPCMD_LOGIN or IGPCMD_CHECK_PWD > by a registered client. > * This is the first message of the a protocol similar to the challenge > handshake authentication > * protocol (CHAP) for secure transmission of the users password. > * The server sends the nonce for hashing: -- https://code.launchpad.net/~widelands-dev/widelands/net-checkpwd-command/+merge/368225 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/net-checkpwd-command. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
[Widelands-dev] [Merge] lp:~widelands-dev/widelands/net-checkpwd-command into lp:widelands
Notabilis has proposed merging lp:~widelands-dev/widelands/net-checkpwd-command into lp:widelands. Commit message: Checking metaserver password without doing a full login. Requested reviews: Widelands Developers (widelands-dev) For more details, see: https://code.launchpad.net/~widelands-dev/widelands/net-checkpwd-command/+merge/368225 Currently, the online settings dialog does a full login to the metaserver to check the entered password. This branch avoid this by using a new CHECK_PWD command to verify whether the password is correct. Should be merged after (and can't really be tested before) https://github.com/widelands/widelands_metaserver/pull/55 is deployed. -- Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/net-checkpwd-command into lp:widelands. === modified file 'src/network/internet_gaming.cc' --- src/network/internet_gaming.cc 2019-05-25 08:25:55 + +++ src/network/internet_gaming.cc 2019-06-01 12:37:21 + @@ -235,6 +235,53 @@ reset(); } +bool InternetGaming::check_password(const std::string& nick, + const std::string& pwd, + const std::string& metaserver, + uint32_t port) { + reset(); + + meta_ = metaserver; + port_ = port; + initialize_connection(); + + // Has to be set for the password challenge later on + authenticator_ = pwd; + + log("InternetGaming: Verifying password.\n"); + { + SendPacket s; + s.string(IGPCMD_CHECK_PWD); + s.string(boost::lexical_cast(kInternetGamingProtocolVersion)); + s.string(nick); + s.string(build_id()); + net->send(s); + } + + // Now let's see, whether the metaserver is answering + uint32_t const secs = time(nullptr); + state_ = CONNECTING; + while (kInternetGamingTimeout > time(nullptr) - secs) { + handle_metaserver_communication(false); + if (state_ != CONNECTING) { + if (state_ == LOBBY) { +SendPacket s; +s.string(IGPCMD_DISCONNECT); +s.string("CONNECTION_CLOSED"); +net->send(s); +reset(); +return true; + } else if (error()) { +reset(); +return false; + } + } + } + log("InternetGaming: No answer from metaserver!\n"); + reset(); + return false; +} + /** * Handle situation when reading from socket failed. */ @@ -265,7 +312,7 @@ } /// handles all communication between the metaserver and the client -void InternetGaming::handle_metaserver_communication() { +void InternetGaming::handle_metaserver_communication(bool relogin_on_error) { if (error()) return; try { @@ -278,7 +325,7 @@ // Process all available packets std::unique_ptr packet = net->try_receive(); if (packet) { -handle_packet(*packet); +handle_packet(*packet, relogin_on_error); } else { // Nothing more to receive break; @@ -315,7 +362,7 @@ set_error(); waittimeout_ = std::numeric_limits::max(); log("InternetGaming: reached a timeout for an awaited answer of the metaserver!\n"); - if (!relogin()) { + if (relogin_on_error && !relogin()) { // Do not try to relogin again automatically. reset(); set_error(); @@ -328,7 +375,7 @@ if (time(nullptr) - lastping_ > 240) { // Try to relogin set_error(); - if (!relogin()) { + if (relogin_on_error && !relogin()) { // Do not try to relogin again automatically. reset(); set_error(); @@ -337,7 +384,7 @@ } /// Handle one packet received from the metaserver. -void InternetGaming::handle_packet(RecvPacket& packet) { +void InternetGaming::handle_packet(RecvPacket& packet, bool relogin_on_error) { std::string cmd = packet.string(); // First check if everything is fine or whether the metaserver broke up with the client. @@ -347,7 +394,7 @@ if (reason == "CLIENT_TIMEOUT") { // Try to relogin set_error(); - if (!relogin()) { + if (relogin_on_error && !relogin()) { // Do not try to relogin again automatically. reset(); set_error(); @@ -405,6 +452,12 @@ asctime(gmtime())); return; + } else if (cmd == IGPCMD_PWD_OK) { + const time_t now = time(nullptr); + log("InternetGaming: Password check successfully at UTC %s", asctime(gmtime())); + state_ = LOBBY; + return; + } else if (cmd == IGPCMD_ERROR) { std::string errortype = packet.string(); if (errortype != IGPCMD_LOGIN && errortype != IGPCMD_PWD_CHALLENGE) { === modified file 'src/network/internet_gaming.h' --- src/network/internet_gaming.h 2019-05-15 09:56:36 + +++ src/network/internet_gaming.h 2019-06-01 12:37:21 + @@ -79,6 +79,23 @@ bool relogin(); void logout(const std::string& msgcode = "CONNECTION_CLOSED"); + /** + * Connects to the metaserver and checks the password without logging in. + * + * Note that the user might be logged in with another username and as unregistered + * if the user account is already in use by another client. + * @warning Resets the curren