# # # patch "cmd_netsync.cc" # from [6912103a56a1e5dfa13565b592c85fc837d2fd8e] # to [47f99850e34e2c6e842ad7cc59bef6ce4f7c5162] # # patch "netsync.cc" # from [af9256a0375671de69a421969e46ce3632b639c9] # to [ccfb59a4a9f7c6ef058eb3826f5181e2d6cb6dbd] # # patch "options_list.hh" # from [dba7ef1fb761c8027484328aeb5a15abf53430a3] # to [9b2368eb9840336c6ec0d9bfc0c331e84731d96c] # ============================================================ --- cmd_netsync.cc 6912103a56a1e5dfa13565b592c85fc837d2fd8e +++ cmd_netsync.cc 47f99850e34e2c6e842ad7cc59bef6ce4f7c5162 @@ -67,7 +67,11 @@ find_key(utf8 const & addr, return; rsa_keypair_id key; - if (!app.lua.hook_get_netsync_key(app.opts.bind_address, + uri u; + utf8 host(addr); + if (parse_uri(addr(), u)) + host = utf8(u.host); + if (!app.lua.hook_get_netsync_key(host, include, exclude, key) || key() == "") @@ -426,8 +430,7 @@ CMD_NO_WORKSPACE(serve, "serve", "", CMD N_("Serves the database to connecting clients"), "", options::opts::bind | options::opts::pidfile | - options::opts::bind_stdio | options::opts::no_transport_auth | - options::opts::bind_local_socket ) + options::opts::bind_stdio | options::opts::no_transport_auth ) { if (!args.empty()) throw usage(execid); @@ -436,21 +439,18 @@ CMD_NO_WORKSPACE(serve, "serve", "", CMD if (app.opts.use_transport_auth) { - find_key(app.opts.bind_address, globish("*"), globish(""), app); + find_key(app.opts.bind_uri, globish("*"), globish(""), app); N(app.lua.hook_persist_phrase_ok(), F("need permission to store persistent passphrase (see hook persist_phrase_ok())")); require_password(app.opts.signing_key, app); } - else - { - E(app.opts.bind_stdio || app.opts.bind_local_socket, - F("The --no-transport-auth option is only permitted in combination with --stdio")); - } + else if (!app.opts.bind_stdio) + W(F("The --no-transport-auth option is usually only used in combination with --stdio")); app.db.ensure_open(); - run_netsync_protocol(server_voice, source_and_sink_role, app.opts.bind_address, + run_netsync_protocol(server_voice, source_and_sink_role, app.opts.bind_uri, globish("*"), globish(""), app); } ============================================================ --- netsync.cc af9256a0375671de69a421969e46ce3632b639c9 +++ netsync.cc ccfb59a4a9f7c6ef058eb3826f5181e2d6cb6dbd @@ -14,7 +14,6 @@ #include #include #include -#include #include @@ -2747,8 +2746,6 @@ serve_connections(protocol_role role, timeout(static_cast(timeout_seconds)), instant(0,1); - if (!app.opts.bind_port().empty()) - default_port = std::atoi(app.opts.bind_port().c_str()); #ifdef USE_IPV6 bool use_ipv6=true; #else @@ -2766,17 +2763,23 @@ serve_connections(protocol_role role, Netxx::Address addr(use_ipv6); - if (app.opts.bind_local_socket) + if (!address().empty()) { - try_again = use_ipv6 = false; - std::ostringstream local_url_ss; - local_url_ss << "local://" << app.opts.bind_path; - addr.add_address(local_url_ss.str().c_str()); + 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())); + } + else + addr.add_address(address().c_str(), default_port); } - else if (!app.opts.bind_address().empty()) - addr.add_address(app.opts.bind_address().c_str(), default_port); else - addr.add_all_addresses (default_port); + 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 ============================================================ --- options_list.hh dba7ef1fb761c8027484328aeb5a15abf53430a3 +++ options_list.hh 9b2368eb9840336c6ec0d9bfc0c331e84731d96c @@ -34,49 +34,16 @@ OPTSET(bind_opts) #endif OPTSET(bind_opts) -OPTVAR(bind_opts, utf8, bind_address, ) -OPTVAR(bind_opts, utf8, bind_port, ) +OPTVAR(bind_opts, utf8, bind_uri, ) OPTVAR(bind_opts, bool, bind_stdio, false) OPTVAR(bind_opts, bool, use_transport_auth, true) -OPTVAR(bind_opts, bool, bind_local_socket, false) -OPTVAR(bind_opts, system_path, bind_path, ) OPTION(bind_opts, bind, true, "bind", gettext_noop("address:port to listen on (default :4691)")) #ifdef option_bodies { - string addr_part, port_part; - size_t l_colon = arg.find(':'); - size_t r_colon = arg.rfind(':'); - - // not an ipv6 address, as that would have at least two colons - if (l_colon == r_colon) - { - addr_part = (r_colon == string::npos ? arg : arg.substr(0, r_colon)); - port_part = (r_colon == string::npos ? "" : arg.substr(r_colon+1, arg.size() - r_colon)); - } - else - { - // IPv6 addresses have a port specified in the style: [2001:388:0:13::]:80 - size_t squareb = arg.rfind(']'); - if ((arg.find('[') == 0) && (squareb != string::npos)) - { - if (squareb < r_colon) - port_part = (r_colon == string::npos ? "" : arg.substr(r_colon+1, arg.size() - r_colon)); - else - port_part = ""; - addr_part = (squareb == string::npos ? arg.substr(1, arg.size()) : arg.substr(1, squareb-1)); - } - else - { - addr_part = arg; - port_part = ""; - } - } + bind_uri = utf8(arg); bind_stdio = false; - bind_local_socket = false; - bind_address = utf8(addr_part); - bind_port = utf8(port_part); } #endif OPTION(bind_opts, no_transport_auth, false, "no-transport-auth", @@ -94,15 +61,6 @@ OPTION(bind_opts, bind_stdio, false, "st } #endif -OPTION(bind_opts, bind_local_socket, true, "bind-local-socket", - gettext_noop("bind to a local domain socket")) -#ifdef option_bodies -{ - bind_local_socket = true; - bind_path = system_path(arg); -} -#endif - OPTVAR(branch, branch_name, branchname, ) OPTION(branch, branch, true, "branch,b", gettext_noop("select branch cert for operation"))