# # # patch "network/session.cc" # from [40cad838dd7bd8417b4bb7464f2f35a578eb1dc5] # to [30e79173fce3cd35666e1f52393fa1736cc9b01e] # # patch "options_list.hh" # from [b549313cdd98c32cb903c9ec47b12d4dafbd0045] # to [0d16e20cef1cca3e40f7f39c7a8cec68aaaa0c88] # ============================================================ --- network/session.cc 40cad838dd7bd8417b4bb7464f2f35a578eb1dc5 +++ network/session.cc 30e79173fce3cd35666e1f52393fa1736cc9b01e @@ -62,6 +62,13 @@ session::session(app_state & app, projec unnoted_bytes_in(0), unnoted_bytes_out(0) { + if (!app.opts.max_netsync_version_given) + { + max_version = constants::netcmd_current_protocol_version; + version = max_version; + } + if (!app.opts.min_netsync_version_given) + min_version = constants::netcmd_minimum_protocol_version; } session::~session() ============================================================ --- options_list.hh b549313cdd98c32cb903c9ec47b12d4dafbd0045 +++ options_list.hh 0d16e20cef1cca3e40f7f39c7a8cec68aaaa0c88 @@ -110,6 +110,14 @@ void set_simple_option(bool & t, std::st template<> void set_simple_option(bool & t, std::string const & arg) { t = true; } +void set_simple_option(u8 & t, std::string const & arg) +{ + long l = boost::lexical_cast(arg); + if (l < 0 || l > 255) + throw bad_arg_internal(F("must be between 0 and 255").str()); + else + t = (u8)l; +} template<> void set_simple_option(std::string & t, std::string const & arg) { t = arg; } @@ -198,27 +206,14 @@ GROUPED_SIMPLE_OPTION(bind_opts, bind_st GROUPED_SIMPLE_OPTION(bind_opts, bind_stdio, "stdio", bool, gettext_noop("serve netsync on stdio")) -OPT(max_netsync_version, "max-netsync-version", - u8, constants::netcmd_current_protocol_version, - gettext_noop("cause monotone to lie about the maximum netsync " - "protocol version that it supports, mostly for debugging")) -#ifdef option_bodies -{ - max_netsync_version = (u8)boost::lexical_cast(arg); -} -#endif +SIMPLE_OPTION(max_netsync_version, "max-netsync-version", u8, + gettext_noop("cause monotone to lie about the maximum netsync " + "protocol version that it supports, mostly for debugging")) +SIMPLE_OPTION(min_netsync_version, "min-netsync-version", u8, + gettext_noop("cause monotone to lie about the minimum netsync " + "protocol version it supports, useful for debugging or " + "if you want to prevent use of older protocol versions")) -OPT(min_netsync_version, "min-netsync-version", - u8, constants::netcmd_minimum_protocol_version, - gettext_noop("cause monotone to lie about the minimum netsync " - "protocol version it supports, useful for debugging or " - "if you want to prevent use of older protocol versions")) -#ifdef option_bodies -{ - min_netsync_version = (u8)boost::lexical_cast(arg); -} -#endif - SIMPLE_OPTION(remote_stdio_host, "remote-stdio-host", arg_type, gettext_noop("sets the host (and optionally the port) for a " "remote netsync action"))