# # # delete "net_common.cc" # # delete "net_common.hh" # # add_file "README.nuskool" # content [04f87d1a7666644cd6847bb50f0a2c3da584585d] # # patch "Makefile.am" # from [b1bd004d62cb20c3586822bec1f57d4d9195c347] # to [457135e25b2c2165a6adffd4670527276752bed6] # # patch "cmd_scgi.cc" # from [5af4065b772cd457d94270d6c2b5cd54f3b0bdc8] # to [c7ae55b8a9c2d302285d1bbb01db6ef1c39b4b49] # # patch "http_client.cc" # from [94e78dcb07ebe12cc41a21910e011dd76376787b] # to [c5ace715abae7d5332b3e0e7d25ac77aae090040] # # patch "netcmd.hh" # from [10527907b0ef2b48afc16182cc998211ba879d08] # to [ff54375f7898011057457f203bd306910437fdaf] # # patch "netsync.cc" # from [95c3b13dab0491dece3d426cd8c399b8da89c801] # to [62d0be6030d7c5e95cff1e959dfd62de6544a855] # ============================================================ --- README.nuskool 04f87d1a7666644cd6847bb50f0a2c3da584585d +++ README.nuskool 04f87d1a7666644cd6847bb50f0a2c3da584585d @@ -0,0 +1,27 @@ +Here's what you need to do to try out the nuskool sync protocol + +1. install lighttpd (apache should work too but the config below is for lighty) + +2. add something like the following to /etc/lighttpd/lighttpd.conf + +scgi.server = ( + "/monotone" => (( + "host" => "127.0.0.1", + "port" => 3000, + "max-procs" => 1, + "idle-timeout" => 30, + "check-local" => "disable" + )) +) + +3. start lighttpd + + $ /etc/init.d/lighttpd start + +4. start a gserve server for lighttpd to proxy to + + $ mtn gserve --db server.db + +5. run the gsync client + + $ mtn --db client.db gsync http://localhost/monotone '*' --debug ============================================================ --- Makefile.am b1bd004d62cb20c3586822bec1f57d4d9195c347 +++ Makefile.am 457135e25b2c2165a6adffd4670527276752bed6 @@ -47,7 +47,6 @@ MOST_SOURCES = \ schema_migration.cc schema_migration.hh \ refiner.cc refiner.hh \ enumerator.cc enumerator.hh \ - net_common.cc net_common.hh \ netsync.cc \ gsync.cc gsync.hh \ netxx_pipe.cc netxx_pipe.hh \ ============================================================ --- cmd_scgi.cc 5af4065b772cd457d94270d6c2b5cd54f3b0bdc8 +++ cmd_scgi.cc c7ae55b8a9c2d302285d1bbb01db6ef1c39b4b49 @@ -26,7 +26,7 @@ #include "lexical_cast.hh" #include "lua.hh" #include "lua_hooks.hh" -#include "net_common.hh" +#include "netcmd.hh" #include "transforms.hh" #include "ui.hh" ============================================================ --- http_client.cc 94e78dcb07ebe12cc41a21910e011dd76376787b +++ http_client.cc c5ace715abae7d5332b3e0e7d25ac77aae090040 @@ -15,7 +15,6 @@ #include "json_io.hh" #include "json_msgs.hh" #include "netcmd.hh" -#include "net_common.hh" #include "sanity.hh" #include "lexical_cast.hh" #include "constants.hh" ============================================================ --- netcmd.hh 10527907b0ef2b48afc16182cc998211ba879d08 +++ netcmd.hh ff54375f7898011057457f203bd306910437fdaf @@ -22,6 +22,8 @@ #include "hmac.hh" #include "string_queue.hh" +#include "netxx/types.h" + struct globish; class database; class project_t; @@ -201,6 +203,27 @@ void run_netsync_protocol(options & opts protocol_role role, netsync_connection_info const & info); +// stuff added for nuskool - this was originally in net_common.{cc,hh} but +// that causes merge problems so it has been moved back here for now + +namespace Netxx { + class Address; + class Timeout; + class StreamBase; +} + +boost::shared_ptr +build_stream_to_server(options & opts, lua_hooks & lua, + netsync_connection_info info, + Netxx::port_type default_port, + Netxx::Timeout timeout); + +void +add_address_names(Netxx::Address & addr, + std::list const & addresses, + Netxx::port_type default_port); + + // Local Variables: // mode: C++ // fill-column: 76 ============================================================ --- netsync.cc 95c3b13dab0491dece3d426cd8c399b8da89c801 +++ netsync.cc 62d0be6030d7c5e95cff1e959dfd62de6544a855 @@ -32,7 +32,6 @@ #include "lua.hh" #include "merkle_tree.hh" #include "netcmd.hh" -#include "net_common.hh" #include "netio.hh" #include "numeric_vocab.hh" #include "refiner.hh" @@ -2368,6 +2367,41 @@ bool session::process(transaction_guard } +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, @@ -2730,6 +2764,37 @@ reap_dead_sessions(map const & addresses, + Netxx::port_type default_port) +{ + if (addresses.empty()) + addr.add_all_addresses(default_port); + else + { + 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())); + } + else + addr.add_address(address().c_str(), default_port); + } + } + } +} + static void serve_connections(options & opts, lua_hooks & lua,