#
#
# add_file "net_common.cc"
# content [149d1818998cabb5f1272b7661187bf6a089fb32]
#
# add_file "net_common.hh"
# content [35e33459670654ffe1b980f0cb85058d56df2096]
#
# patch "Makefile.am"
# from [e9e3d2c42df7879640a66e21854ad11a3f8eba30]
# to [6f447accf75920caed5092841638835d59a429d9]
#
# patch "cmd_scgi.cc"
# from [0ba8a300f548e224ba3c7f716de24fa4aac2279b]
# to [18ff8d191dfc47514b90fd910d811a25284b0266]
#
# patch "constants.hh"
# from [26ea1fa80b9236854f37ac0fbdeaccf6236a5c90]
# to [543fe816b29fe333a10afbc71e64e63164d8c9c3]
#
# patch "http_client.cc"
# from [52d1fd430adb95bae1d814a2bebbdb99128fa0f4]
# to [04067dcf693ff4f61072c778668e58c69d728fe6]
#
# patch "netsync.cc"
# from [1e875fe8ba23a5c956819d1d81b7322feff2682f]
# to [6ccf9f2ca21fcc1865ac22d243eb381519a3d37e]
#
============================================================
--- net_common.cc 149d1818998cabb5f1272b7661187bf6a089fb32
+++ net_common.cc 149d1818998cabb5f1272b7661187bf6a089fb32
@@ -0,0 +1,110 @@
+// Copyright (C) 2008 Graydon Hoare
+//
+// This program is made available under the GNU GPL version 2.0 or
+// greater. See the accompanying file COPYING for details.
+//
+// This program is distributed WITHOUT ANY WARRANTY; without even the
+// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+// PURPOSE.
+
+#include "base.hh"
+
+#include "app_state.hh"
+#include "globish.hh"
+#include "net_common.hh"
+#include "uri.hh"
+#include "vocab.hh"
+
+#include
+#include
+#include
+
+#include
+
+#include "netxx/address.h"
+#include "netxx/stream.h"
+#include "netxx/streambase.h"
+#include "netxx/timeout.h"
+#include "netxx_pipe.hh"
+
+
+using std::string;
+using std::list;
+using std::vector;
+using boost::shared_ptr;
+
+void
+add_address_names(Netxx::Address & addr,
+ std::list 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);
+ }
+ }
+ }
+}
+
+shared_ptr
+build_stream_to_server(app_state & app,
+ uri const & u,
+ globish const & include_pattern,
+ globish const & exclude_pattern,
+ Netxx::port_type default_port,
+ Netxx::Timeout timeout)
+{
+ shared_ptr server;
+ vector argv;
+
+ if (app.lua.hook_get_netsync_connect_command(u,
+ include_pattern,
+ exclude_pattern,
+ global_sanity.debug_p(),
+ argv))
+ {
+ I(argv.size() > 0);
+ string cmd = argv[0];
+ argv.erase(argv.begin());
+ app.opts.use_transport_auth = app.lua.hook_use_transport_auth(u);
+ return shared_ptr
+ (new Netxx::PipeStream(cmd, argv));
+ }
+ else
+ {
+#ifdef USE_IPV6
+ bool use_ipv6=true;
+#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));
+ }
+}
+
+
+// Local Variables:
+// mode: C++
+// fill-column: 76
+// c-file-style: "gnu"
+// indent-tabs-mode: nil
+// End:
+// vim: et:sw=2:sts=2:ts=2:cino=>2s,{s,\:s,+s,t0,g0,^-2,e-2,n-2,p2s,(0,=s:
============================================================
--- net_common.hh 35e33459670654ffe1b980f0cb85058d56df2096
+++ net_common.hh 35e33459670654ffe1b980f0cb85058d56df2096
@@ -0,0 +1,57 @@
+#ifndef __NET_COMMON_HH__
+#define __NET_COMMON_HH__
+
+// Copyright (C) 2008 Graydon Hoare
+//
+// This program is made available under the GNU GPL version 2.0 or
+// greater. See the accompanying file COPYING for details.
+//
+// This program is distributed WITHOUT ANY WARRANTY; without even the
+// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+// PURPOSE.
+
+#include "base.hh"
+
+#include
+
+#include "netxx/types.h"
+
+namespace Netxx {
+ class Address;
+ class Timeout;
+ class StreamBase;
+}
+
+struct globish;
+struct utf8;
+struct uri;
+struct app_state;
+
+
+// This just covers helper routines that are shared across networking
+// facilities (netsync and gsync). When we retire netsync, we can retire
+// this file and shift the code into http_client or gsync.
+
+void
+add_address_names(Netxx::Address & addr,
+ std::list const & addresses,
+ Netxx::port_type default_port);
+
+boost::shared_ptr
+build_stream_to_server(app_state & app,
+ uri const & u,
+ globish const & include_pattern,
+ globish const & exclude_pattern,
+ Netxx::port_type default_port,
+ Netxx::Timeout timeout);
+
+
+// Local Variables:
+// mode: C++
+// fill-column: 76
+// c-file-style: "gnu"
+// indent-tabs-mode: nil
+// End:
+// vim: et:sw=2:sts=2:ts=2:cino=>2s,{s,\:s,+s,t0,g0,^-2,e-2,n-2,p2s,(0,=s:
+
+#endif // __NET_COMMON_HH__
============================================================
--- Makefile.am e9e3d2c42df7879640a66e21854ad11a3f8eba30
+++ Makefile.am 6f447accf75920caed5092841638835d59a429d9
@@ -45,6 +45,7 @@ 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 \
netxx_pipe.cc netxx_pipe.hh \
============================================================
--- cmd_scgi.cc 0ba8a300f548e224ba3c7f716de24fa4aac2279b
+++ cmd_scgi.cc 18ff8d191dfc47514b90fd910d811a25284b0266
@@ -12,14 +12,25 @@
#include
#include