# # # patch "cmd_netsync.cc" # from [13ad0b75d3476ff21841416403a97c481b530559] # to [1375806d314e6e1b9d8c0659aaba1b47acf7b8d2] # # patch "netcmd.cc" # from [fce7a074431682ce3b9ec06ab4da5e902f0dbfe7] # to [8f23b4db83aa07305b02cc0b4ca8c0ffccd39841] # # patch "netcmd.hh" # from [0fbd7278e26c2d94de3431f411bf816f1279bbea] # to [c6c88d10348672c84a61cf8e6be36c649e747aca] # # patch "netsync.cc" # from [66539579de8731054e928e25e0d7f547df9420dd] # to [2de6c24f6170532f595fa463c1751789df04b13a] # # patch "options.cc" # from [3fd2f0ffb4e8d250dc905a4461c1cdf43df0a88d] # to [0686c4f93079240ef0903c586065de4c51454430] # # patch "options_list.hh" # from [cffca0ed1884c08cf828b6f4d19138da17909736] # to [5c19f9924062e2444c604c7f5f0ed4dc15773895] # ============================================================ --- cmd_netsync.cc 13ad0b75d3476ff21841416403a97c481b530559 +++ cmd_netsync.cc 1375806d314e6e1b9d8c0659aaba1b47acf7b8d2 @@ -232,6 +232,7 @@ CMD(push, "push", "", CMD_REF(network), N_("Pushes branches to a netsync server"), N_("This will push all branches that match the pattern given in PATTERN " "to the netsync server at the address ADDRESS."), + options::opts::max_netsync_version | options::opts::min_netsync_version | options::opts::set_default | options::opts::exclude | options::opts::key_to_push) { @@ -252,6 +253,7 @@ CMD(pull, "pull", "", CMD_REF(network), N_("Pulls branches from a netsync server"), N_("This pulls all branches that match the pattern given in PATTERN " "from the netsync server at the address ADDRESS."), + options::opts::max_netsync_version | options::opts::min_netsync_version | options::opts::set_default | options::opts::exclude) { database db(app); @@ -274,6 +276,7 @@ CMD(sync, "sync", "", CMD_REF(network), N_("Synchronizes branches with a netsync server"), N_("This synchronizes branches that match the pattern given in PATTERN " "with the netsync server at the address ADDRESS."), + options::opts::max_netsync_version | options::opts::min_netsync_version | options::opts::set_default | options::opts::exclude | options::opts::key_to_push) { @@ -347,6 +350,7 @@ CMD(clone, "clone", "", CMD_REF(network) N_("If a revision is given, that's the one that will be checked out. " "Otherwise, it will be the head of the branch supplied. " "If no directory is given, the branch name will be used as directory"), + options::opts::max_netsync_version | options::opts::min_netsync_version | options::opts::revision) { if (args.size() < 2 || args.size() > 3 || app.opts.revision_selectors.size() > 1) @@ -510,6 +514,8 @@ CMD_NO_WORKSPACE(serve, "serve", "", CMD CMD_NO_WORKSPACE(serve, "serve", "", CMD_REF(network), "", N_("Serves the database to connecting clients"), "", + options::opts::max_netsync_version | + options::opts::min_netsync_version | options::opts::bind | options::opts::pidfile | options::opts::bind_stdio | options::opts::no_transport_auth ) { ============================================================ --- netcmd.cc fce7a074431682ce3b9ec06ab4da5e902f0dbfe7 +++ netcmd.cc 8f23b4db83aa07305b02cc0b4ca8c0ffccd39841 @@ -85,7 +85,8 @@ bool // note: usher_cmd does not get included in the hmac. bool -netcmd::read(string_queue & inbuf, chained_hmac & hmac) +netcmd::read(u8 min_version, u8 max_version, + string_queue & inbuf, chained_hmac & hmac) { size_t pos = 0; @@ -93,8 +94,8 @@ netcmd::read(string_queue & inbuf, chain return false; u8 extracted_ver = extract_datum_lsb(inbuf, pos, "netcmd protocol number"); - bool too_old = extracted_ver < constants::netcmd_minimum_protocol_version; - bool too_new = extracted_ver > constants::netcmd_current_protocol_version; + bool too_old = extracted_ver < min_version; + bool too_new = extracted_ver > max_version; u8 cmd_byte = extract_datum_lsb(inbuf, pos, "netcmd code"); switch (cmd_byte) @@ -127,11 +128,11 @@ netcmd::read(string_queue & inbuf, chain { throw bad_decode(F("protocol version mismatch: wanted between '%d' and '%d' got '%d' (netcmd code %d)\n" "%s") - % widen(constants::netcmd_minimum_protocol_version) - % widen(constants::netcmd_current_protocol_version) + % widen(min_version) + % widen(max_version) % widen(extracted_ver) % widen(cmd_code) - % ((constants::netcmd_current_protocol_version < extracted_ver) + % ((max_version < extracted_ver) ? _("the remote side has a newer, incompatible version of monotone") : _("the remote side has an older, incompatible version of monotone"))); } @@ -568,7 +569,7 @@ netcmd::write_usher_cmd(utf8 const & gre void netcmd::write_usher_cmd(utf8 const & greeting) { - version = constants::netcmd_current_protocol_version; + version = 0; cmd_code = usher_cmd; insert_variable_length_string(greeting(), payload); } ============================================================ --- netcmd.hh 0fbd7278e26c2d94de3431f411bf816f1279bbea +++ netcmd.hh c6c88d10348672c84a61cf8e6be36c649e747aca @@ -98,7 +98,8 @@ public: // basic cmd i/o (including checksums) void write(std::string & out, chained_hmac & hmac) const; - bool read(string_queue & inbuf, + bool read(u8 min_version, u8 max_version, + string_queue & inbuf, chained_hmac & hmac); bool read_string(std::string & inbuf, chained_hmac & hmac) { @@ -108,7 +109,8 @@ public: // can be processed efficiently string_queue tmp(inbuf.size()); tmp.append(inbuf); - bool ret = read(tmp, hmac); + // allow any version + bool ret = read(0, 255, tmp, hmac); inbuf = tmp.substr(0,tmp.size()); return ret; } ============================================================ --- netsync.cc 66539579de8731054e928e25e0d7f547df9420dd +++ netsync.cc 2de6c24f6170532f595fa463c1751789df04b13a @@ -646,6 +646,8 @@ session: public session_base { u8 version; + u8 max_version; + u8 min_version; protocol_role role; protocol_voice const voice; globish our_include_pattern; @@ -876,7 +878,9 @@ session::session(options & opts, shared_ptr sock, bool initiated_by_server) : session_base(peer, sock), - version(constants::netcmd_current_protocol_version), + version(opts.max_netsync_version), + max_version(opts.max_netsync_version), + min_version(opts.min_netsync_version), role(role), voice(voice), our_include_pattern(our_include_pattern), @@ -887,7 +891,7 @@ session::session(options & opts, lua(lua), use_transport_auth(opts.use_transport_auth), signing_key(keys.signing_key), - cmd(constants::netcmd_current_protocol_version), + cmd(opts.max_netsync_version), armed(false), received_remote_key(false), session_key(constants::netsync_key_initializer), @@ -2701,7 +2705,7 @@ session::process_usher_reply_cmd(u8 clie globish const & pattern) { // netcmd::read() has already checked that the client isn't too old - if (client_version < constants::netcmd_current_protocol_version) + if (client_version < max_version) { version = client_version; } @@ -2757,7 +2761,7 @@ session::arm() if (output_overfull()) return false; - if (cmd.read(inbuf, read_hmac)) + if (cmd.read(min_version, max_version, inbuf, read_hmac)) { armed = true; } ============================================================ --- options.cc 3fd2f0ffb4e8d250dc905a4461c1cdf43df0a88d +++ options.cc 0686c4f93079240ef0903c586065de4c51454430 @@ -11,6 +11,7 @@ #include #include "charset.hh" +#include "constants.hh" #include "options.hh" #include "platform.hh" #include "sanity.hh" ============================================================ --- options_list.hh cffca0ed1884c08cf828b6f4d19138da17909736 +++ options_list.hh 5c19f9924062e2444c604c7f5f0ed4dc15773895 @@ -119,6 +119,24 @@ OPTION(bind_opts, bind_stdio, false, "st } #endif +OPT(max_netsync_version, "max-netsync-version", + u8, constants::netcmd_current_protocol_version, + gettext_noop("")) +#ifdef option_bodies +{ + max_netsync_version = (u8)boost::lexical_cast(arg); +} +#endif + +OPT(min_netsync_version, "min-netsync-version", + u8, constants::netcmd_minimum_protocol_version, + gettext_noop("")) +#ifdef option_bodies +{ + min_netsync_version = (u8)boost::lexical_cast(arg); +} +#endif + OPT(branch, "branch,b", branch_name, , gettext_noop("select branch cert for operation")) #ifdef option_bodies