# # # patch "Makefile.am" # from [93991250197e0079331e14c5d65eebe34ee287ce] # to [b1bd004d62cb20c3586822bec1f57d4d9195c347] # # patch "cmd_netsync.cc" # from [de6722aba31addec6a92e6bcdbd114c171ba9daa] # to [2c43ae71a61c196e3021f919228e7ce553b05ee9] # # patch "gsync.cc" # from [29cebe236d2164c9985f9d967ca99c405e238d3c] # to [9a94a20ce0017c3c268935924fa044b2b467f6d3] # # patch "gsync.hh" # from [752324fb915ee92a4c74f8fe03d71c243f51eb5e] # to [ceb06a9cee5d328e8c087e633e63e730b96ef6cc] # # patch "http_client.cc" # from [36476ca29218bcc77fbf8a1424fdc6a706bb02fd] # to [94e78dcb07ebe12cc41a21910e011dd76376787b] # # patch "http_client.hh" # from [72ea8083efe626659072e69a49fe9f23de9ba25d] # to [aac41129c4ac4c3ca02e7b01168ce2c7ed202c27] # # patch "net_common.cc" # from [d812125cc10b1ba6f3139816959aa3713d05e870] # to [03cf2b6f449ac314d9b885abe48bf12edb4b626a] # # patch "net_common.hh" # from [31882a93b44f0c21e4a7b7d6b0a2b24d81fbae67] # to [1ca44b26b687dd7fc313f9238a59ae5c8118866e] # # patch "netsync.cc" # from [4de415f27a65e5085f12e31285ff8cb1074e158a] # to [77986be24bffcbedcf6cf60aceec3ec2361c727a] # # patch "vocab_terms.hh" # from [28341d787d1cbaba84a00ab5b176939b0a81e05e] # to [d995dbf401f1a8ab08b031a18b5ebb33f1503ec1] # ============================================================ --- Makefile.am 93991250197e0079331e14c5d65eebe34ee287ce +++ Makefile.am b1bd004d62cb20c3586822bec1f57d4d9195c347 @@ -19,6 +19,8 @@ LUAEXT_SOURCES = \ luaext_mkstemp.cc luaext_parse_basic_io.cc \ luaext_guess_binary.cc luaext_platform.cc luaext_globish.cc \ lua.cc lua.hh mkstemp.cc mkstemp.hh file_io.cc file_io.hh \ + globish.cc globish.hh basic_io.cc basic_io.hh json_io.cc \ + json_io.hh json_msgs.cc json_msgs.hh \ char_classifiers.hh MOST_SOURCES = \ ============================================================ --- cmd_netsync.cc de6722aba31addec6a92e6bcdbd114c171ba9daa +++ cmd_netsync.cc 2c43ae71a61c196e3021f919228e7ce553b05ee9 @@ -52,7 +52,7 @@ find_key(options & opts, return; rsa_keypair_id key; - + utf8 host(info.client.unparsed); if (!info.client.u.host.empty()) host = utf8(info.client.u.host); @@ -110,7 +110,7 @@ build_client_connection_info(options & o { N(!include_or_exclude_given, F("Include/exclude pattern was given both as part of the URL and as a separate argument.")); - + // Pull include/exclude from the query string char const separator = '/'; char const negate = '-'; @@ -129,7 +129,7 @@ build_client_connection_info(options & o if (begin < query.size()) end = query.find(separator, begin); } - + bool is_exclude = false; if (item.size() >= 1 && item.at(0) == negate) { @@ -145,7 +145,7 @@ build_client_connection_info(options & o is_exclude = true; item.erase(0, string("exclude=").size()); } - + if (is_exclude) excludes.push_back(arg_type(urldecode(item))); else @@ -154,7 +154,7 @@ build_client_connection_info(options & o info.client.include_pattern = globish(includes); info.client.exclude_pattern = globish(excludes); } - + // Maybe set the default values. if (!db.var_exists(default_server_key) || opts.set_default) { @@ -177,7 +177,7 @@ build_client_connection_info(options & o db.set_var(default_exclude_pattern_key, var_value(info.client.exclude_pattern())); } - + info.client.use_argv = lua.hook_get_netsync_connect_command(info.client.u, info.client.include_pattern, @@ -497,7 +497,7 @@ CMD_NO_WORKSPACE(serve, "serve", "", CMD pid_file pid(app.opts.pidfile); db.ensure_open(); - + netsync_connection_info info; info.server.addrs = app.opts.bind_uris; @@ -529,21 +529,15 @@ CMD(gsync, "gsync", "", CMD_REF(network) options::opts::set_default | options::opts::exclude | options::opts::key_to_push | options::opts::dryrun) { - utf8 addr; - database db(app); key_store keys(app); - globish include_pattern, exclude_pattern; - extract_address(app.opts, db, args, addr); - extract_patterns(app.opts, db, args, include_pattern, exclude_pattern); - find_key_if_needed(app.opts, app.lua, db, keys, addr, include_pattern, exclude_pattern); + netsync_connection_info info; + extract_client_connection_info(app.opts, app.lua, db, keys, args, info); - uri u; - parse_uri(addr(), u); - http_client h(app.opts, app.lua, u, include_pattern, exclude_pattern); + http_client h(app.opts, app.lua, info); run_gsync_protocol(app.lua, db, http_channel(h), - include_pattern, exclude_pattern, app.opts.dryrun); + app.opts.dryrun); } ============================================================ --- gsync.cc 29cebe236d2164c9985f9d967ca99c405e238d3c +++ gsync.cc 9a94a20ce0017c3c268935924fa044b2b467f6d3 @@ -390,8 +390,6 @@ run_gsync_protocol(lua_hooks & lua, data void run_gsync_protocol(lua_hooks & lua, database & db, channel const & ch, - globish const & include_pattern, // FIXME: use this pattern - globish const & exclude_pattern, // FIXME: use this pattern bool const dryrun) { bool pushing = true, pulling = true; ============================================================ --- gsync.hh 752324fb915ee92a4c74f8fe03d71c243f51eb5e +++ gsync.hh ceb06a9cee5d328e8c087e633e63e730b96ef6cc @@ -64,8 +64,6 @@ run_gsync_protocol(lua_hooks & lua, data extern void run_gsync_protocol(lua_hooks & lua, database & db, channel const & ch, - globish const & include_pattern, - globish const & exclude_pattern, bool const dryrun); void ============================================================ --- http_client.cc 36476ca29218bcc77fbf8a1424fdc6a706bb02fd +++ http_client.cc 94e78dcb07ebe12cc41a21910e011dd76376787b @@ -14,6 +14,7 @@ #include "http_client.hh" #include "json_io.hh" #include "json_msgs.hh" +#include "netcmd.hh" #include "net_common.hh" #include "sanity.hh" #include "lexical_cast.hh" @@ -48,17 +49,12 @@ http_client::http_client(options & opts, http_client::http_client(options & opts, lua_hooks & lua, - uri const & u, - globish const & include_pattern, - globish const & exclude_pattern) + netsync_connection_info const & info) : opts(opts), lua(lua), - u(u), - include_pattern(include_pattern), - exclude_pattern(exclude_pattern), - stream(build_stream_to_server(opts, lua, u, - include_pattern, exclude_pattern, - u.parse_port(constants::default_http_port), + info(info), + stream(build_stream_to_server(opts, lua, info, + info.client.u.parse_port(constants::default_http_port), Netxx::Timeout(static_cast( constants::netsync_timeout_seconds)))), nb(new Netbuf(*stream)), @@ -72,9 +68,8 @@ http_client::transact_json(json_value_t if (!open) { L(FL("reopening connection")); - stream = build_stream_to_server(opts, lua, u, - include_pattern, exclude_pattern, - u.parse_port(constants::default_http_port), + stream = build_stream_to_server(opts, lua, info, + info.client.u.parse_port(constants::default_http_port), Netxx::Timeout(static_cast( constants::netsync_timeout_seconds))); nb = shared_ptr< Netbuf >( @@ -98,13 +93,13 @@ http_client::transact_json(json_value_t "Accept-Encoding: identity\r\n" "Connection: Keep-Alive\r\n" "\r\n") - % (u.path.empty() ? "/" : u.path) - % u.host + % (info.client.u.path.empty() ? "/" : info.client.u.path) + % info.client.u.host % lexical_cast(out.buf.size())).str(); L(FL("http_client: sending request [[POST %s HTTP/1.0]]") - % (u.path.empty() ? "/" : u.path)); - L(FL("http_client: to [[Host: %s]]") % u.host); + % (info.client.u.path.empty() ? "/" : info.client.u.path)); + L(FL("http_client: to [[Host: %s]]") % info.client.u.host); L(FL("http_client: sending %d-byte body") % out.buf.size()); io->write(header.data(), header.size()); io->write(out.buf.data(), out.buf.length()); ============================================================ --- http_client.hh 72ea8083efe626659072e69a49fe9f23de9ba25d +++ http_client.hh aac41129c4ac4c3ca02e7b01168ce2c7ed202c27 @@ -22,9 +22,8 @@ #include -struct uri; -struct globish; struct options; +struct netsync_connection_info; class lua_hooks; struct @@ -32,9 +31,7 @@ http_client { options & opts; lua_hooks & lua; - uri const & u; - globish const & include_pattern; - globish const & exclude_pattern; + netsync_connection_info const & info; boost::shared_ptr stream; boost::shared_ptr< Netxx::Netbuf > nb; @@ -42,9 +39,7 @@ http_client bool open; http_client(options & opts, lua_hooks & lua, - uri const & u, - globish const & include_pattern, - globish const & exclude_pattern); + netsync_connection_info const & info); json_io::json_value_t transact_json(json_io::json_value_t v); void parse_http_status_line(); ============================================================ --- net_common.cc d812125cc10b1ba6f3139816959aa3713d05e870 +++ net_common.cc 03cf2b6f449ac314d9b885abe48bf12edb4b626a @@ -11,6 +11,7 @@ #include "globish.hh" #include "lua_hooks.hh" +#include "netcmd.hh" #include "net_common.hh" #include "options.hh" #include "uri.hh" @@ -20,6 +21,7 @@ #include #include +#include #include #include "netxx/address.h" @@ -32,9 +34,10 @@ using std::vector; using std::string; using std::list; using std::vector; +using boost::lexical_cast; using boost::shared_ptr; -void +void add_address_names(Netxx::Address & addr, std::list const & addresses, Netxx::port_type default_port) @@ -66,29 +69,20 @@ shared_ptr } shared_ptr -build_stream_to_server(options & opts, - lua_hooks & lua, - uri const & u, - globish const & include_pattern, - globish const & exclude_pattern, +build_stream_to_server(options & opts, lua_hooks & lua, + netsync_connection_info info, Netxx::port_type default_port, Netxx::Timeout timeout) { shared_ptr server; - vector argv; - if (lua.hook_get_netsync_connect_command(u, - include_pattern, - exclude_pattern, - global_sanity.debug_p(), - argv)) + if (info.client.use_argv) { - I(argv.size() > 0); - string cmd = argv[0]; - argv.erase(argv.begin()); - opts.use_transport_auth = lua.hook_use_transport_auth(u); + I(info.client.argv.size() > 0); + string cmd = info.client.argv[0]; + info.client.argv.erase(info.client.argv.begin()); return shared_ptr - (new Netxx::PipeStream(cmd, argv)); + (new Netxx::PipeStream(cmd, info.client.argv)); } else { @@ -97,8 +91,15 @@ build_stream_to_server(options & opts, #else bool use_ipv6=false; #endif - Netxx::Address addr(u.host.c_str(), default_port, use_ipv6); - return shared_ptr(new Netxx::Stream(addr, timeout)); + string host(info.client.u.host); + if (host.empty()) + host = info.client.unparsed(); + if (!info.client.u.port.empty()) + default_port = lexical_cast(info.client.u.port); + Netxx::Address addr(info.client.unparsed().c_str(), + default_port, use_ipv6); + return shared_ptr + (new Netxx::Stream(addr, timeout)); } } ============================================================ --- net_common.hh 31882a93b44f0c21e4a7b7d6b0a2b24d81fbae67 +++ net_common.hh 1ca44b26b687dd7fc313f9238a59ae5c8118866e @@ -22,10 +22,9 @@ namespace Netxx { class StreamBase; } -struct globish; struct utf8; -struct uri; struct options; +struct netsync_connection_info; class lua_hooks; @@ -33,17 +32,14 @@ class lua_hooks; // facilities (netsync and gsync). When we retire netsync, we can retire // this file and shift the code into http_client or gsync. -void +void add_address_names(Netxx::Address & addr, std::list const & addresses, Netxx::port_type default_port); boost::shared_ptr -build_stream_to_server(options & opts, - lua_hooks & lua, - uri const & u, - globish const & include_pattern, - globish const & exclude_pattern, +build_stream_to_server(options & opts, lua_hooks & lua, + netsync_connection_info info, Netxx::port_type default_port, Netxx::Timeout timeout); ============================================================ --- netsync.cc 4de415f27a65e5085f12e31285ff8cb1074e158a +++ netsync.cc 77986be24bffcbedcf6cf60aceec3ec2361c727a @@ -2348,41 +2348,6 @@ bool session::process(transaction_guard } -static shared_ptr -build_stream_to_server(options & opts, lua_hooks & lua, - netsync_connection_info info, - Netxx::port_type default_port, - Netxx::Timeout timeout) -{ - shared_ptr server; - - if (info.client.use_argv) - { - I(info.client.argv.size() > 0); - string cmd = info.client.argv[0]; - info.client.argv.erase(info.client.argv.begin()); - return shared_ptr - (new Netxx::PipeStream(cmd, info.client.argv)); - } - else - { -#ifdef USE_IPV6 - bool use_ipv6=true; -#else - bool use_ipv6=false; -#endif - string host(info.client.u.host); - if (host.empty()) - host = info.client.unparsed(); - if (!info.client.u.port.empty()) - default_port = lexical_cast(info.client.u.port); - Netxx::Address addr(info.client.unparsed().c_str(), - default_port, use_ipv6); - return shared_ptr - (new Netxx::Stream(addr, timeout)); - } -} - static void call_server(options & opts, lua_hooks & lua, @@ -2399,17 +2364,10 @@ call_server(options & opts, Netxx::Timeout timeout(static_cast(timeout_seconds)), instant(0,1); P(F("connecting to %s") % info.client.unparsed); - uri u; - parse_uri(address(), u); - P(F("connecting to %s") % address); shared_ptr server = build_stream_to_server(opts, lua, info, default_port, - u, - include_pattern, - exclude_pattern, - default_port, timeout); @@ -2841,19 +2799,13 @@ serve_connections(options & opts, info.client.exclude_pattern = globish(request.exclude); info.client.use_argv = false; parse_uri(info.client.unparsed(), info.client.u); - + try { P(F("connecting to %s") % info.client.unparsed); - uri u; - parse_uri(addr(), u); - P(F("connecting to %s") % addr()); shared_ptr server = build_stream_to_server(opts, lua, info, default_port, - = build_stream_to_server(opts, lua, u, - inc, exc, - default_port, timeout); // 'false' here means not to revert changes when @@ -2967,8 +2919,8 @@ serve_connections(options & opts, } } } - // Possibly loop around if we get exceptions from Netxx and we're - // attempting to use ipv6, or have some other reason to try again. + // Possibly loop around if we get exceptions from Netxx and we're + // attempting to use ipv6, or have some other reason to try again. catch (Netxx::NetworkException &) { if (try_again) ============================================================ --- vocab_terms.hh 28341d787d1cbaba84a00ab5b176939b0a81e05e +++ vocab_terms.hh d995dbf401f1a8ab08b031a18b5ebb33f1503ec1 @@ -96,6 +96,7 @@ EXTERN template class base64; EXTERN template class base64; EXTERN template class base64; +EXTERN template class base64; EXTERN template class base64; EXTERN template class base64; EXTERN template class base64;