# # # patch "cmd_netsync.cc" # from [47f99850e34e2c6e842ad7cc59bef6ce4f7c5162] # to [ec1d1888558e6ae358ade3ab83605091c7ecc86a] # # patch "netcmd.hh" # from [91da5034baab3bc9dec528c24ca5b8b2ff484d5c] # to [d69da40e724fba3645cc1150c7848c6d7e398681] # # patch "netsync.cc" # from [ccfb59a4a9f7c6ef058eb3826f5181e2d6cb6dbd] # to [c526e90209938009dd2df7766cfd6650e50842d9] # # patch "options_list.hh" # from [9b2368eb9840336c6ec0d9bfc0c331e84731d96c] # to [4cacf72a9eef98b563cfc3a2ee88a544fba2def5] # ============================================================ --- cmd_netsync.cc 47f99850e34e2c6e842ad7cc59bef6ce4f7c5162 +++ cmd_netsync.cc ec1d1888558e6ae358ade3ab83605091c7ecc86a @@ -33,7 +33,7 @@ extract_address(args_vector const & args static void extract_address(args_vector const & args, - arg_type & addr, + utf8 & addr, app_state & app) { if (args.size() >= 1) @@ -51,7 +51,7 @@ extract_address(args_vector const & args F("no server given and no default server set")); var_value addr_value; app.db.get_var(default_server_key, addr_value); - addr = arg_type(addr_value()); + addr = utf8(addr_value()); L(FL("using default server address: %s") % addr()); } } @@ -160,13 +160,16 @@ CMD(push, "push", "", CMD_REF(network), options::opts::set_default | options::opts::exclude | options::opts::key_to_push) { - arg_type addr; + utf8 addr; globish include_pattern, exclude_pattern; extract_address(args, addr, app); extract_patterns(args, include_pattern, exclude_pattern, app); find_key_if_needed(addr, include_pattern, exclude_pattern, app); - run_netsync_protocol(client_voice, source_role, addr, + std::list uris; + uris.push_back(addr); + + run_netsync_protocol(client_voice, source_role, uris, include_pattern, exclude_pattern, app); } @@ -177,7 +180,7 @@ CMD(pull, "pull", "", CMD_REF(network), "from the netsync server at the address ADDRESS."), options::opts::set_default | options::opts::exclude) { - arg_type addr; + utf8 addr; globish include_pattern, exclude_pattern; extract_address(args, addr, app); extract_patterns(args, include_pattern, exclude_pattern, app); @@ -186,7 +189,10 @@ CMD(pull, "pull", "", CMD_REF(network), if (app.opts.signing_key() == "") P(F("doing anonymous pull; use -kKEYNAME if you need authentication")); - run_netsync_protocol(client_voice, sink_role, addr, + std::list uris; + uris.push_back(addr); + + run_netsync_protocol(client_voice, sink_role, uris, include_pattern, exclude_pattern, app); } @@ -198,13 +204,16 @@ CMD(sync, "sync", "", CMD_REF(network), options::opts::set_default | options::opts::exclude | options::opts::key_to_push) { - arg_type addr; + utf8 addr; globish include_pattern, exclude_pattern; extract_address(args, addr, app); extract_patterns(args, include_pattern, exclude_pattern, app); find_key_if_needed(addr, include_pattern, exclude_pattern, app); - run_netsync_protocol(client_voice, source_and_sink_role, addr, + std::list uris; + uris.push_back(addr); + + run_netsync_protocol(client_voice, source_and_sink_role, uris, include_pattern, exclude_pattern, app); } @@ -326,7 +335,10 @@ CMD(clone, "clone", "", CMD_REF(network) // make sure we're back in the original dir so that file: URIs work change_current_working_dir(start_dir); - run_netsync_protocol(client_voice, sink_role, addr, + std::list uris; + uris.push_back(addr); + + run_netsync_protocol(client_voice, sink_role, uris, include_pattern, exclude_pattern, app); change_current_working_dir(workspace_dir); @@ -439,7 +451,10 @@ CMD_NO_WORKSPACE(serve, "serve", "", CMD if (app.opts.use_transport_auth) { - find_key(app.opts.bind_uri, globish("*"), globish(""), app); + if (!app.opts.bind_uris.empty()) + find_key(*app.opts.bind_uris.begin(), globish("*"), globish(""), app); + else + find_key(utf8(), globish("*"), globish(""), app); N(app.lua.hook_persist_phrase_ok(), F("need permission to store persistent passphrase (see hook persist_phrase_ok())")); @@ -450,7 +465,7 @@ CMD_NO_WORKSPACE(serve, "serve", "", CMD app.db.ensure_open(); - run_netsync_protocol(server_voice, source_and_sink_role, app.opts.bind_uri, + run_netsync_protocol(server_voice, source_and_sink_role, app.opts.bind_uris, globish("*"), globish(""), app); } ============================================================ --- netcmd.hh 91da5034baab3bc9dec528c24ca5b8b2ff484d5c +++ netcmd.hh d69da40e724fba3645cc1150c7848c6d7e398681 @@ -11,6 +11,7 @@ // PURPOSE. #include +#include #include #include "merkle_tree.hh" @@ -171,7 +172,7 @@ void run_netsync_protocol(protocol_voice class app_state; void run_netsync_protocol(protocol_voice voice, protocol_role role, - utf8 const & addr, + std::list const & addrs, globish const & include_pattern, globish const & exclude_pattern, app_state & app); ============================================================ --- netsync.cc ccfb59a4a9f7c6ef058eb3826f5181e2d6cb6dbd +++ netsync.cc c526e90209938009dd2df7766cfd6650e50842d9 @@ -2371,12 +2371,14 @@ call_server(protocol_role role, globish const & include_pattern, globish const & exclude_pattern, app_state & app, - utf8 const & address, + std::list const & addresses, Netxx::port_type default_port, unsigned long timeout_seconds) { Netxx::PipeCompatibleProbe probe; transaction_guard guard(app.db); + I(addresses.size() == 1); + utf8 address(*addresses.begin()); Netxx::Timeout timeout(static_cast(timeout_seconds)), instant(0,1); @@ -2734,7 +2736,7 @@ serve_connections(protocol_role role, globish const & include_pattern, globish const & exclude_pattern, app_state & app, - utf8 const & address, + std::list const & addresses, Netxx::port_type default_port, unsigned long timeout_seconds, unsigned long session_limit) @@ -2763,23 +2765,30 @@ serve_connections(protocol_role role, Netxx::Address addr(use_ipv6); - if (!address().empty()) + if (addresses.empty()) + addr.add_all_addresses(default_port); + else { - size_t l_colon = address().find(':'); - size_t r_colon = address().rfind(':'); + for (std::list::const_iterator it = addresses.begin(); it != addresses.end(); ++it) + { + const utf8 & address = *it; + if (!address().empty()) + { + size_t l_colon = address().find(':'); + size_t r_colon = address().rfind(':'); - if (l_colon == r_colon && l_colon == 0) - { - // can't be an IPv6 address as there is only one colon - // must be a : followed by a port - string port_str = address().substr(1); - addr.add_all_addresses(std::atoi(port_str.c_str())); + if (l_colon == r_colon && l_colon == 0) + { + // can't be an IPv6 address as there is only one colon + // must be a : followed by a port + string port_str = address().substr(1); + addr.add_all_addresses(std::atoi(port_str.c_str())); + } + else + addr.add_address(address().c_str(), default_port); + } } - else - addr.add_address(address().c_str(), default_port); } - else - addr.add_all_addresses(default_port); // If se use IPv6 and the initialisation of server fails, we want // to try again with IPv4. The reason is that someone may have @@ -3249,7 +3258,7 @@ run_netsync_protocol(protocol_voice voic void run_netsync_protocol(protocol_voice voice, protocol_role role, - utf8 const & addr, + std::list const & addrs, globish const & include_pattern, globish const & exclude_pattern, app_state & app) @@ -3283,7 +3292,7 @@ run_netsync_protocol(protocol_voice voic } else serve_connections(role, include_pattern, exclude_pattern, app, - addr, static_cast(constants::netsync_default_port), + addrs, static_cast(constants::netsync_default_port), static_cast(constants::netsync_timeout_seconds), static_cast(constants::netsync_connection_limit)); } @@ -3291,7 +3300,7 @@ run_netsync_protocol(protocol_voice voic { I(voice == client_voice); call_server(role, include_pattern, exclude_pattern, app, - addr, static_cast(constants::netsync_default_port), + addrs, static_cast(constants::netsync_default_port), static_cast(constants::netsync_timeout_seconds)); } } ============================================================ --- options_list.hh 9b2368eb9840336c6ec0d9bfc0c331e84731d96c +++ options_list.hh 4cacf72a9eef98b563cfc3a2ee88a544fba2def5 @@ -34,7 +34,7 @@ OPTSET(bind_opts) #endif OPTSET(bind_opts) -OPTVAR(bind_opts, utf8, bind_uri, ) +OPTVAR(bind_opts, std::list, bind_uris, ) OPTVAR(bind_opts, bool, bind_stdio, false) OPTVAR(bind_opts, bool, use_transport_auth, true) @@ -42,7 +42,7 @@ OPTION(bind_opts, bind, true, "bind", gettext_noop("address:port to listen on (default :4691)")) #ifdef option_bodies { - bind_uri = utf8(arg); + bind_uris.push_back(utf8(arg)); bind_stdio = false; } #endif