From 2427cce2c8b2ddb7da9d48325e711f581dd8e74b Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Fri, 18 Oct 2013 15:30:13 -0700 Subject: [PATCH] Rename to IPAddress and remove unused files --- doc/todo/VFALCO_TODO.txt | 2 +- .../Builds/VisualStudio2012/beast.vcxproj | 11 +- .../VisualStudio2012/beast.vcxproj.filters | 18 +- src/beast/beast/Net.h | 2 +- .../beast/net/{IPEndpoint.h => IPAddress.h} | 97 ++-- src/beast/beast/net/Net.cpp | 2 +- .../impl/{IPEndpoint.cpp => IPAddress.cpp} | 191 ++++--- src/beast/modules/beast_core/beast_core.cpp | 1 - src/beast/modules/beast_core/beast_core.h | 1 - .../beast_core/native/win32_Network.cpp | 18 - .../modules/beast_core/network/IPAddress.cpp | 144 ------ .../modules/beast_core/network/IPAddress.h | 77 --- src/beast/modules/beast_core/network/URL.cpp | 468 ------------------ src/beast/modules/beast_core/network/URL.h | 342 ------------- src/ripple/http/api/Port.h | 4 +- src/ripple/http/api/Session.h | 2 +- src/ripple/http/impl/Peer.h | 2 +- src/ripple/http/impl/Port.cpp | 2 +- src/ripple/http/impl/Types.h | 8 +- src/ripple/peerfinder/api/Callback.h | 2 +- src/ripple/peerfinder/api/Endpoint.h | 2 +- src/ripple/peerfinder/api/Manager.h | 8 +- src/ripple/peerfinder/impl/Cache.h | 2 +- src/ripple/peerfinder/impl/Checker.cpp | 12 +- src/ripple/peerfinder/impl/Checker.h | 6 +- src/ripple/peerfinder/impl/CheckerAdapter.h | 2 +- src/ripple/peerfinder/impl/LegacyEndpoint.h | 4 +- .../peerfinder/impl/LegacyEndpointCache.h | 14 +- src/ripple/peerfinder/impl/Logic.h | 32 +- src/ripple/peerfinder/impl/Manager.cpp | 4 +- src/ripple/peerfinder/impl/PeerInfo.h | 12 +- src/ripple/peerfinder/impl/Source.h | 2 +- src/ripple/peerfinder/impl/SourceStrings.cpp | 4 +- src/ripple/peerfinder/impl/Store.h | 2 +- src/ripple/peerfinder/impl/StoreSqdb.h | 6 +- src/ripple/resource/api/Gossip.h | 2 +- src/ripple/resource/api/Manager.h | 4 +- src/ripple/resource/impl/Key.h | 4 +- src/ripple/resource/impl/Logic.h | 6 +- src/ripple/resource/impl/Manager.cpp | 4 +- src/ripple/resource/impl/Tests.cpp | 8 +- src/ripple_app/main/RPCHTTPServer.cpp | 2 +- src/ripple_app/peers/Peer.cpp | 19 +- src/ripple_app/peers/Peer.h | 2 +- src/ripple_app/peers/Peers.cpp | 4 +- src/ripple_app/websocket/WSConnection.h | 4 +- 46 files changed, 250 insertions(+), 1315 deletions(-) rename src/beast/beast/net/{IPEndpoint.h => IPAddress.h} (75%) rename src/beast/beast/net/impl/{IPEndpoint.cpp => IPAddress.cpp} (69%) delete mode 100644 src/beast/modules/beast_core/network/IPAddress.cpp delete mode 100644 src/beast/modules/beast_core/network/IPAddress.h delete mode 100644 src/beast/modules/beast_core/network/URL.cpp delete mode 100644 src/beast/modules/beast_core/network/URL.h diff --git a/doc/todo/VFALCO_TODO.txt b/doc/todo/VFALCO_TODO.txt index a304fc0521..2bf36d707b 100644 --- a/doc/todo/VFALCO_TODO.txt +++ b/doc/todo/VFALCO_TODO.txt @@ -29,7 +29,7 @@ David Features: - Look into using CMake -- IPv6 support in IPEndpoint +- IPv6 support in IPAddress - Configuration list for Jenkins diff --git a/src/beast/Builds/VisualStudio2012/beast.vcxproj b/src/beast/Builds/VisualStudio2012/beast.vcxproj index 455746b304..cdaea28a8d 100644 --- a/src/beast/Builds/VisualStudio2012/beast.vcxproj +++ b/src/beast/Builds/VisualStudio2012/beast.vcxproj @@ -137,7 +137,7 @@ - + @@ -303,7 +303,6 @@ - @@ -490,7 +489,7 @@ true true - + true true true @@ -1033,12 +1032,6 @@ true true - - true - true - true - true - true true diff --git a/src/beast/Builds/VisualStudio2012/beast.vcxproj.filters b/src/beast/Builds/VisualStudio2012/beast.vcxproj.filters index 077df7635a..1f927cb513 100644 --- a/src/beast/Builds/VisualStudio2012/beast.vcxproj.filters +++ b/src/beast/Builds/VisualStudio2012/beast.vcxproj.filters @@ -416,9 +416,6 @@ beast_core\native - - beast_core\network - beast_core\network @@ -932,9 +929,6 @@ beast_core\memory - - beast\net - beast @@ -1254,6 +1248,9 @@ beast\utility + + beast\net + @@ -1361,9 +1358,6 @@ beast_core\native - - beast_core\network - beast_core\network @@ -1682,9 +1676,6 @@ beast_extras - - beast\net\impl - beast\net @@ -1805,6 +1796,9 @@ beast\utility\impl + + beast\net\impl + diff --git a/src/beast/beast/Net.h b/src/beast/beast/Net.h index 091c940f05..79515845ad 100644 --- a/src/beast/beast/Net.h +++ b/src/beast/beast/Net.h @@ -23,6 +23,6 @@ #include "net/BufferType.h" #include "net/DynamicBuffer.h" -#include "net/IPEndpoint.h" +#include "net/IPAddress.h" #endif diff --git a/src/beast/beast/net/IPEndpoint.h b/src/beast/beast/net/IPAddress.h similarity index 75% rename from src/beast/beast/net/IPEndpoint.h rename to src/beast/beast/net/IPAddress.h index 1852297179..1903f89f45 100644 --- a/src/beast/beast/net/IPEndpoint.h +++ b/src/beast/beast/net/IPAddress.h @@ -17,8 +17,8 @@ */ //============================================================================== -#ifndef BEAST_NET_IPENDPOINT_H_INCLUDED -#define BEAST_NET_IPENDPOINT_H_INCLUDED +#ifndef BEAST_NET_IPADDRESS_H_INCLUDED +#define BEAST_NET_IPADDRESS_H_INCLUDED #include #include @@ -27,11 +27,10 @@ #include "../CStdInt.h" #include "../mpl/IfCond.h" -namespace beast -{ +namespace beast { /** Represents an IP address (v4 or v6) and port combination. */ -class IPEndpoint +class IPAddress { public: enum Type @@ -216,62 +215,62 @@ public: //-------------------------------------------------------------------------- /** Create an empty address. */ - IPEndpoint (); + IPAddress (); /** Create an IPv4 address with optional port. */ - IPEndpoint (V4 const& v4, uint16 port = 0); + IPAddress (V4 const& v4, uint16 port = 0); /** Create an IPv6 address with optional port. */ - IPEndpoint (V6 const& v6, uint16 port = 0); + IPAddress (V6 const& v6, uint16 port = 0); - /** Create a copy of another IPEndpoint. */ - IPEndpoint (IPEndpoint const& other); + /** Create a copy of another IPAddress. */ + IPAddress (IPAddress const& other); - /** Copy assign another IPEndpoint. */ - IPEndpoint& operator= (IPEndpoint const& other); + /** Copy assign another IPAddress. */ + IPAddress& operator= (IPAddress const& other); - /** Create an IPEndpoint from a string. + /** Create an IPAddress from a string. If a parsing error occurs, the endpoint will be empty. */ - static IPEndpoint from_string (std::string const& s); + static IPAddress from_string (std::string const& s); - /** Create an IPEndpoint from a string. + /** Create an IPAddress from a string. If a parsing error occurs, the endpoint will be empty. This recognizes an alternate form of the text. Instead of a colon separating the optional port specification, any amount of whitespace is allowed. */ - static IPEndpoint from_string_altform (std::string const& s); + static IPAddress from_string_altform (std::string const& s); /** Copy assign an IPv4 address. The port is set to zero. */ - IPEndpoint& operator= (V4 const& address); + IPAddress& operator= (V4 const& address); /** Copy assign an IPv6 address. The port is set to zero. */ - IPEndpoint& operator= (V6 const& address); + IPAddress& operator= (V6 const& address); - /** Returns a new IPEndpoint with this address, and the given port. */ - IPEndpoint withPort (uint16 port) const; + /** Returns a new IPAddress with this address, and the given port. */ + IPAddress withPort (uint16 port) const; - /** Returns `true` if this IPEndpoint refers to nothing. */ + /** Returns `true` if this IPAddress refers to nothing. */ bool empty () const; - /** Returns `true` if this IPEndpoint refers to nothing. */ + /** Returns `true` if this IPAddress refers to nothing. */ bool isNull () const; - /** Returns `true` if this IPEndpoint refers to something. */ + /** Returns `true` if this IPAddress refers to something. */ bool isNotNull () const; - /** Returns the type of this IPEndpoint. */ + /** Returns the type of this IPAddress. */ Type type () const; - /** Returns `true` if this IPEndpoint represents an IPv4 address. */ + /** Returns `true` if this IPAddress represents an IPv4 address. */ bool isV4 () const; - /** Returns `true` if this IPEndpoint represents an IPv6 address. */ + /** Returns `true` if this IPAddress represents an IPv6 address. */ bool isV6 () const; /** Returns the IPv4 address. @@ -312,7 +311,7 @@ public: struct hasher { - std::size_t operator() (IPEndpoint const& value) const + std::size_t operator() (IPAddress const& value) const { std::size_t hash (0); if (value.isV4()) @@ -335,39 +334,39 @@ private: /** Comparison. */ /** @{ */ -int compare (IPEndpoint::V4 const& lhs, IPEndpoint::V4 const& rhs); -bool operator== (IPEndpoint::V4 const& lhs, IPEndpoint::V4 const& rhs); -bool operator!= (IPEndpoint::V4 const& lhs, IPEndpoint::V4 const& rhs); -bool operator< (IPEndpoint::V4 const& lhs, IPEndpoint::V4 const& rhs); -bool operator<= (IPEndpoint::V4 const& lhs, IPEndpoint::V4 const& rhs); -bool operator> (IPEndpoint::V4 const& lhs, IPEndpoint::V4 const& rhs); -bool operator>= (IPEndpoint::V4 const& lhs, IPEndpoint::V4 const& rhs); +int compare (IPAddress::V4 const& lhs, IPAddress::V4 const& rhs); +bool operator== (IPAddress::V4 const& lhs, IPAddress::V4 const& rhs); +bool operator!= (IPAddress::V4 const& lhs, IPAddress::V4 const& rhs); +bool operator< (IPAddress::V4 const& lhs, IPAddress::V4 const& rhs); +bool operator<= (IPAddress::V4 const& lhs, IPAddress::V4 const& rhs); +bool operator> (IPAddress::V4 const& lhs, IPAddress::V4 const& rhs); +bool operator>= (IPAddress::V4 const& lhs, IPAddress::V4 const& rhs); -int compare (IPEndpoint const& lhs, IPEndpoint const& rhs); -bool operator== (IPEndpoint const& lhs, IPEndpoint const& rhs); -bool operator!= (IPEndpoint const& lhs, IPEndpoint const& rhs); -bool operator< (IPEndpoint const& lhs, IPEndpoint const& rhs); -bool operator<= (IPEndpoint const& lhs, IPEndpoint const& rhs); -bool operator> (IPEndpoint const& lhs, IPEndpoint const& rhs); -bool operator>= (IPEndpoint const& lhs, IPEndpoint const& rhs); +int compare (IPAddress const& lhs, IPAddress const& rhs); +bool operator== (IPAddress const& lhs, IPAddress const& rhs); +bool operator!= (IPAddress const& lhs, IPAddress const& rhs); +bool operator< (IPAddress const& lhs, IPAddress const& rhs); +bool operator<= (IPAddress const& lhs, IPAddress const& rhs); +bool operator> (IPAddress const& lhs, IPAddress const& rhs); +bool operator>= (IPAddress const& lhs, IPAddress const& rhs); /** Output stream conversions. */ /** @{ */ -std::ostream& operator<< (std::ostream& os, IPEndpoint::V4 const& addr); -std::ostream& operator<< (std::ostream& os, IPEndpoint::V6 const& addr); -std::ostream& operator<< (std::ostream& os, IPEndpoint const& ep); +std::ostream& operator<< (std::ostream& os, IPAddress::V4 const& addr); +std::ostream& operator<< (std::ostream& os, IPAddress::V6 const& addr); +std::ostream& operator<< (std::ostream& os, IPAddress const& ep); /** @} */ /** Input stream conversions. */ /** @{ */ -std::istream& operator>> (std::istream& is, IPEndpoint::V4& addr); -std::istream& operator>> (std::istream& is, IPEndpoint& ep); -//std::istream& operator>> (std::istream &is, IPEndpoint::V6&); +std::istream& operator>> (std::istream& is, IPAddress::V4& addr); +std::istream& operator>> (std::istream& is, IPAddress& ep); +//std::istream& operator>> (std::istream &is, IPAddress::V6&); /** @} */ -struct IPEndpoint::key_equal +struct IPAddress::key_equal { - bool operator() (IPEndpoint const& lhs, IPEndpoint const& rhs) const + bool operator() (IPAddress const& lhs, IPAddress const& rhs) const { return lhs == rhs; } diff --git a/src/beast/beast/net/Net.cpp b/src/beast/beast/net/Net.cpp index 6a84e21858..a176d962f5 100644 --- a/src/beast/beast/net/Net.cpp +++ b/src/beast/beast/net/Net.cpp @@ -24,4 +24,4 @@ #include "../../modules/beast_core/beast_core.h" // for UnitTest #include "impl/DynamicBuffer.cpp" -#include "impl/IPEndpoint.cpp" +#include "impl/IPAddress.cpp" diff --git a/src/beast/beast/net/impl/IPEndpoint.cpp b/src/beast/beast/net/impl/IPAddress.cpp similarity index 69% rename from src/beast/beast/net/impl/IPEndpoint.cpp rename to src/beast/beast/net/impl/IPAddress.cpp index ffa2bf77bf..fb6855233d 100644 --- a/src/beast/beast/net/impl/IPEndpoint.cpp +++ b/src/beast/beast/net/impl/IPAddress.cpp @@ -17,43 +17,42 @@ */ //============================================================================== -#include "../IPEndpoint.h" +#include "../IPAddress.h" -namespace beast -{ +namespace beast { -IPEndpoint::V4::V4 () +IPAddress::V4::V4 () : value (0) { } -IPEndpoint::V4::V4 (uint32 value_) +IPAddress::V4::V4 (uint32 value_) : value (value_) { } -IPEndpoint::V4::V4 (uint8 a, uint8 b, uint8 c, uint8 d) +IPAddress::V4::V4 (uint8 a, uint8 b, uint8 c, uint8 d) : value ((a<<24)|(b<<16)|(c<<8)|d) { } -IPEndpoint::V4::V4 (V4 const& other) +IPAddress::V4::V4 (V4 const& other) : value (other.value) { } -IPEndpoint::V4& IPEndpoint::V4::operator= (V4 const& other) +IPAddress::V4& IPAddress::V4::operator= (V4 const& other) { value = other.value; return *this; } -IPEndpoint::V4 IPEndpoint::V4::localBroadcastAddress () +IPAddress::V4 IPAddress::V4::localBroadcastAddress () { return V4 (0xffffffff); } -IPEndpoint::V4 IPEndpoint::V4::broadcastAddress () const +IPAddress::V4 IPAddress::V4::broadcastAddress () const { switch (getClass()) { @@ -68,18 +67,18 @@ IPEndpoint::V4 IPEndpoint::V4::broadcastAddress () const return V4(); } -char IPEndpoint::V4::getClass () const +char IPAddress::V4::getClass () const { static char const* table = "AAAABBCD"; return table[(value&0xE0000000)>>29]; } -bool IPEndpoint::V4::isPublic () const +bool IPAddress::V4::isPublic () const { return !isPrivate() && !isBroadcast() && !isMulticast(); } -bool IPEndpoint::V4::isPrivate () const +bool IPAddress::V4::isPrivate () const { return ((value&0xff000000)==0x0a000000) || // Prefix /8, 10.##.#.# @@ -88,22 +87,22 @@ bool IPEndpoint::V4::isPrivate () const isLoopback(); } -bool IPEndpoint::V4::isBroadcast () const +bool IPAddress::V4::isBroadcast () const { return (value == broadcastAddress().value); } -bool IPEndpoint::V4::isMulticast () const +bool IPAddress::V4::isMulticast () const { return getClass() == 'D'; } -bool IPEndpoint::V4::isLoopback () const +bool IPAddress::V4::isLoopback () const { return (value&0xff000000)==0x7f000000; } -IPEndpoint::V4::Proxy IPEndpoint::V4::operator[] (std::size_t index) const +IPAddress::V4::Proxy IPAddress::V4::operator[] (std::size_t index) const { switch (index) { @@ -116,7 +115,7 @@ IPEndpoint::V4::Proxy IPEndpoint::V4::operator[] (std::size_t index) cons }; }; -IPEndpoint::V4::Proxy IPEndpoint::V4::operator[] (std::size_t index) +IPAddress::V4::Proxy IPAddress::V4::operator[] (std::size_t index) { switch (index) { @@ -129,7 +128,7 @@ IPEndpoint::V4::Proxy IPEndpoint::V4::operator[] (std::size_t index) }; }; -std::string IPEndpoint::V4::to_string () const +std::string IPAddress::V4::to_string () const { std::string s; s.reserve (15); @@ -140,33 +139,33 @@ std::string IPEndpoint::V4::to_string () const return s; } -IPEndpoint::V4::operator std::string () const +IPAddress::V4::operator std::string () const { return to_string(); } //------------------------------------------------------------------------------ -IPEndpoint::IPEndpoint () +IPAddress::IPAddress () : m_type (none) { } -IPEndpoint::IPEndpoint (V4 const& v4, uint16 port) +IPAddress::IPAddress (V4 const& v4, uint16 port) : m_type (ipv4) , m_port (port) , m_v4 (v4) { } -IPEndpoint::IPEndpoint (V6 const& v6, uint16 port) +IPAddress::IPAddress (V6 const& v6, uint16 port) : m_type (ipv6) , m_port (port) , m_v6 (v6) { } -IPEndpoint::IPEndpoint (IPEndpoint const& other) +IPAddress::IPAddress (IPAddress const& other) : m_type (other.m_type) , m_port (other.m_port) { @@ -180,7 +179,7 @@ IPEndpoint::IPEndpoint (IPEndpoint const& other) }; } -IPEndpoint& IPEndpoint::operator= (IPEndpoint const& other) +IPAddress& IPAddress::operator= (IPAddress const& other) { m_type = other.m_type; m_port = other.m_port; @@ -195,17 +194,17 @@ IPEndpoint& IPEndpoint::operator= (IPEndpoint const& other) return *this; } -IPEndpoint IPEndpoint::from_string (std::string const& s) +IPAddress IPAddress::from_string (std::string const& s) { std::stringstream is (s); - IPEndpoint ep; + IPAddress ep; is >> ep; if (! is.fail() && is.rdbuf()->in_avail() == 0) return ep; - return IPEndpoint(); + return IPAddress(); } -IPEndpoint& IPEndpoint::operator= (V4 const& address) +IPAddress& IPAddress::operator= (V4 const& address) { m_type = ipv4; m_port = 0; @@ -213,7 +212,7 @@ IPEndpoint& IPEndpoint::operator= (V4 const& address) return *this; } -IPEndpoint& IPEndpoint::operator= (V6 const& address) +IPAddress& IPAddress::operator= (V6 const& address) { m_type = ipv6; m_port = 0; @@ -221,66 +220,66 @@ IPEndpoint& IPEndpoint::operator= (V6 const& address) return *this; } -IPEndpoint IPEndpoint::withPort (uint16 port) const +IPAddress IPAddress::withPort (uint16 port) const { switch (m_type) { - case ipv4: return IPEndpoint (m_v4, port); - case ipv6: return IPEndpoint (m_v6, port); + case ipv4: return IPAddress (m_v4, port); + case ipv6: return IPAddress (m_v6, port); default: case none: bassertfalse; break; }; - return IPEndpoint(); + return IPAddress(); } -bool IPEndpoint::empty () const +bool IPAddress::empty () const { return m_type == none; } -bool IPEndpoint::isNull () const +bool IPAddress::isNull () const { return empty (); } -bool IPEndpoint::isNotNull () const +bool IPAddress::isNotNull () const { return ! empty (); } -IPEndpoint::Type IPEndpoint::type () const +IPAddress::Type IPAddress::type () const { return m_type; } -bool IPEndpoint::isV4 () const +bool IPAddress::isV4 () const { return m_type == ipv4; } -bool IPEndpoint::isV6 () const +bool IPAddress::isV6 () const { return m_type == ipv6; } -IPEndpoint::V4 const& IPEndpoint::v4 () const +IPAddress::V4 const& IPAddress::v4 () const { return m_v4; } -IPEndpoint::V6 const& IPEndpoint::v6 () const +IPAddress::V6 const& IPAddress::v6 () const { return m_v6; } -uint16 IPEndpoint::port () const +uint16 IPAddress::port () const { return m_port; } -bool IPEndpoint::isPublic () const +bool IPAddress::isPublic () const { switch (m_type) { @@ -294,7 +293,7 @@ bool IPEndpoint::isPublic () const return false; } -bool IPEndpoint::isPrivate () const +bool IPAddress::isPrivate () const { switch (m_type) { @@ -308,7 +307,7 @@ bool IPEndpoint::isPrivate () const return false; } -bool IPEndpoint::isBroadcast () const +bool IPAddress::isBroadcast () const { switch (m_type) { @@ -322,7 +321,7 @@ bool IPEndpoint::isBroadcast () const return false; } -bool IPEndpoint::isMulticast () const +bool IPAddress::isMulticast () const { switch (m_type) { @@ -336,7 +335,7 @@ bool IPEndpoint::isMulticast () const return false; } -bool IPEndpoint::isLoopback () const +bool IPAddress::isLoopback () const { switch (m_type) { @@ -350,7 +349,7 @@ bool IPEndpoint::isLoopback () const return false; } -std::string IPEndpoint::to_string () const +std::string IPAddress::to_string () const { switch (m_type) { @@ -376,7 +375,7 @@ std::string IPEndpoint::to_string () const return std::string(); } -IPEndpoint::operator std::string () const +IPAddress::operator std::string () const { return to_string(); } @@ -446,7 +445,7 @@ detail::integer_holder integer (IntType& i) } /** Parse IPv4 address. */ -std::istream& operator>> (std::istream &is, IPEndpoint::V4& addr) +std::istream& operator>> (std::istream &is, IPAddress::V4& addr) { uint8 octets [4]; is >> parse::integer (octets [0]); @@ -458,16 +457,16 @@ std::istream& operator>> (std::istream &is, IPEndpoint::V4& addr) if (!is) return is; } - addr = IPEndpoint::V4 (octets[0], octets[1], octets[2], octets[3]); + addr = IPAddress::V4 (octets[0], octets[1], octets[2], octets[3]); return is; } -/** Parse an IPEndpoint. +/** Parse an IPAddress. @note Currently only IPv4 addresses are supported. */ -std::istream& operator>> (std::istream &is, IPEndpoint& ep) +std::istream& operator>> (std::istream &is, IPAddress& ep) { - IPEndpoint::V4 v4; + IPAddress::V4 v4; is >> v4; if (is.fail()) return is; @@ -479,7 +478,7 @@ std::istream& operator>> (std::istream &is, IPEndpoint& ep) if (c != ':') { is.unget(); - ep = IPEndpoint (v4); + ep = IPAddress (v4); return is; } @@ -488,11 +487,11 @@ std::istream& operator>> (std::istream &is, IPEndpoint& ep) if (is.fail()) return is; - ep = IPEndpoint (v4, port); + ep = IPAddress (v4, port); } else { - ep = IPEndpoint (v4); + ep = IPAddress (v4); } return is; @@ -500,11 +499,11 @@ std::istream& operator>> (std::istream &is, IPEndpoint& ep) //------------------------------------------------------------------------------ -IPEndpoint IPEndpoint::from_string_altform (std::string const& s) +IPAddress IPAddress::from_string_altform (std::string const& s) { // Accept the regular form if it parses { - IPEndpoint ep (IPEndpoint::from_string (s)); + IPAddress ep (IPAddress::from_string (s)); if (! ep.empty()) return ep; } @@ -512,16 +511,16 @@ IPEndpoint IPEndpoint::from_string_altform (std::string const& s) // Now try the alt form std::stringstream is (s); - IPEndpoint::V4 v4; + IPAddress::V4 v4; is >> v4; if (! is.fail()) { - IPEndpoint ep (v4); + IPAddress ep (v4); if (is.rdbuf()->in_avail()>0) { if (! parse::expect (is, ' ')) - return IPEndpoint(); + return IPAddress(); while (is.rdbuf()->in_avail()>0) { @@ -537,7 +536,7 @@ IPEndpoint IPEndpoint::from_string_altform (std::string const& s) uint16 port; is >> port; if (is.fail()) - return IPEndpoint(); + return IPAddress(); return ep.withPort (port); } @@ -550,12 +549,12 @@ IPEndpoint IPEndpoint::from_string_altform (std::string const& s) // Could be V6 here... - return IPEndpoint(); + return IPAddress(); } //------------------------------------------------------------------------------ -int compare (IPEndpoint::V4 const& lhs, IPEndpoint::V4 const& rhs) +int compare (IPAddress::V4 const& lhs, IPAddress::V4 const& rhs) { if (lhs.value < rhs.value) return -1; @@ -564,14 +563,14 @@ int compare (IPEndpoint::V4 const& lhs, IPEndpoint::V4 const& rhs) return 0; } -bool operator== (IPEndpoint::V4 const& lhs, IPEndpoint::V4 const& rhs) { return compare (lhs, rhs) == 0; } -bool operator!= (IPEndpoint::V4 const& lhs, IPEndpoint::V4 const& rhs) { return compare (lhs, rhs) != 0; } -bool operator< (IPEndpoint::V4 const& lhs, IPEndpoint::V4 const& rhs) { return compare (lhs, rhs) < 0; } -bool operator<= (IPEndpoint::V4 const& lhs, IPEndpoint::V4 const& rhs) { return compare (lhs, rhs) <= 0; } -bool operator> (IPEndpoint::V4 const& lhs, IPEndpoint::V4 const& rhs) { return compare (lhs, rhs) > 0; } -bool operator>= (IPEndpoint::V4 const& lhs, IPEndpoint::V4 const& rhs) { return compare (lhs, rhs) >= 0; } +bool operator== (IPAddress::V4 const& lhs, IPAddress::V4 const& rhs) { return compare (lhs, rhs) == 0; } +bool operator!= (IPAddress::V4 const& lhs, IPAddress::V4 const& rhs) { return compare (lhs, rhs) != 0; } +bool operator< (IPAddress::V4 const& lhs, IPAddress::V4 const& rhs) { return compare (lhs, rhs) < 0; } +bool operator<= (IPAddress::V4 const& lhs, IPAddress::V4 const& rhs) { return compare (lhs, rhs) <= 0; } +bool operator> (IPAddress::V4 const& lhs, IPAddress::V4 const& rhs) { return compare (lhs, rhs) > 0; } +bool operator>= (IPAddress::V4 const& lhs, IPAddress::V4 const& rhs) { return compare (lhs, rhs) >= 0; } -static int type_compare (IPEndpoint const& lhs, IPEndpoint const& rhs) +static int type_compare (IPAddress const& lhs, IPAddress const& rhs) { if (lhs.type() < rhs.type()) return -1; @@ -580,7 +579,7 @@ static int type_compare (IPEndpoint const& lhs, IPEndpoint const& rhs) return 0; } -int compare (IPEndpoint const& lhs, IPEndpoint const& rhs) +int compare (IPAddress const& lhs, IPAddress const& rhs) { int const tc (type_compare (lhs, rhs)); @@ -591,36 +590,36 @@ int compare (IPEndpoint const& lhs, IPEndpoint const& rhs) switch (lhs.type()) { - case IPEndpoint::none: return 0; - case IPEndpoint::ipv4: return compare (lhs.v4(), rhs.v4()); + case IPAddress::none: return 0; + case IPAddress::ipv4: return compare (lhs.v4(), rhs.v4()); default: - case IPEndpoint::ipv6: + case IPAddress::ipv6: break; }; bassertfalse; return 0; } -bool operator== (IPEndpoint const& lhs, IPEndpoint const& rhs) { return compare (lhs, rhs) == 0; } -bool operator!= (IPEndpoint const& lhs, IPEndpoint const& rhs) { return compare (lhs, rhs) != 0; } -bool operator< (IPEndpoint const& lhs, IPEndpoint const& rhs) { return compare (lhs, rhs) < 0; } -bool operator<= (IPEndpoint const& lhs, IPEndpoint const& rhs) { return compare (lhs, rhs) <= 0; } -bool operator> (IPEndpoint const& lhs, IPEndpoint const& rhs) { return compare (lhs, rhs) > 0; } -bool operator>= (IPEndpoint const& lhs, IPEndpoint const& rhs) { return compare (lhs, rhs) >= 0; } +bool operator== (IPAddress const& lhs, IPAddress const& rhs) { return compare (lhs, rhs) == 0; } +bool operator!= (IPAddress const& lhs, IPAddress const& rhs) { return compare (lhs, rhs) != 0; } +bool operator< (IPAddress const& lhs, IPAddress const& rhs) { return compare (lhs, rhs) < 0; } +bool operator<= (IPAddress const& lhs, IPAddress const& rhs) { return compare (lhs, rhs) <= 0; } +bool operator> (IPAddress const& lhs, IPAddress const& rhs) { return compare (lhs, rhs) > 0; } +bool operator>= (IPAddress const& lhs, IPAddress const& rhs) { return compare (lhs, rhs) >= 0; } -std::ostream& operator<< (std::ostream &os, IPEndpoint::V4 const& addr) +std::ostream& operator<< (std::ostream &os, IPAddress::V4 const& addr) { os << addr.to_string(); return os; } -std::ostream& operator<< (std::ostream &os, IPEndpoint::V6 const& addr) +std::ostream& operator<< (std::ostream &os, IPAddress::V6 const& addr) { os << addr.to_string(); return os; } -std::ostream& operator<< (std::ostream &os, IPEndpoint const& ep) +std::ostream& operator<< (std::ostream &os, IPAddress const& ep) { os << ep.to_string(); return os; @@ -628,10 +627,10 @@ std::ostream& operator<< (std::ostream &os, IPEndpoint const& ep) //------------------------------------------------------------------------------ -class IPEndpointTests : public UnitTest +class IPAddressTests : public UnitTest { public: - bool parse (char const* text, IPEndpoint& ep) + bool parse (char const* text, IPAddress& ep) { std::string input (text); std::istringstream stream (input); @@ -641,14 +640,14 @@ public: void shouldPass (char const* text) { - IPEndpoint ep; + IPAddress ep; expect (parse (text, ep)); expect (ep.to_string() == std::string(text)); } void shouldFail (char const* text) { - IPEndpoint ep; + IPAddress ep; unexpected (parse (text, ep)); } @@ -673,9 +672,9 @@ public: { beginTestCase ("addresses"); - IPEndpoint ep; + IPAddress ep; - ep = IPEndpoint(IPEndpoint::V4(127,0,0,1)).withPort (80); + ep = IPAddress(IPAddress::V4(127,0,0,1)).withPort (80); expect (!ep.isPublic()); expect ( ep.isPrivate()); expect (!ep.isBroadcast()); @@ -683,7 +682,7 @@ public: expect ( ep.isLoopback()); expect (ep.to_string() == "127.0.0.1:80"); - ep = IPEndpoint::V4(10,0,0,1); + ep = IPAddress::V4(10,0,0,1); expect ( ep.v4().getClass() == 'A'); expect (!ep.isPublic()); expect ( ep.isPrivate()); @@ -692,7 +691,7 @@ public: expect (!ep.isLoopback()); expect (ep.to_string() == "10.0.0.1"); - ep = IPEndpoint::V4(166,78,151,147); + ep = IPAddress::V4(166,78,151,147); expect ( ep.isPublic()); expect (!ep.isPrivate()); expect (!ep.isBroadcast()); @@ -707,11 +706,11 @@ public: testParse(); } - IPEndpointTests () : UnitTest ("IPEndpoint", "beast") + IPAddressTests () : UnitTest ("IPAddress", "beast") { } }; -static IPEndpointTests ipEndpointTests; +static IPAddressTests ipEndpointTests; } diff --git a/src/beast/modules/beast_core/beast_core.cpp b/src/beast/modules/beast_core/beast_core.cpp index 8608e180d1..92abf6fb42 100644 --- a/src/beast/modules/beast_core/beast_core.cpp +++ b/src/beast/modules/beast_core/beast_core.cpp @@ -168,7 +168,6 @@ namespace beast #include "network/MACAddress.cpp" #include "network/NamedPipe.cpp" #include "network/Socket.cpp" -#include "network/IPAddress.cpp" #include "streams/BufferedInputStream.cpp" #include "streams/FileInputSource.cpp" diff --git a/src/beast/modules/beast_core/beast_core.h b/src/beast/modules/beast_core/beast_core.h index fff039ba9f..e095d1d27c 100644 --- a/src/beast/modules/beast_core/beast_core.h +++ b/src/beast/modules/beast_core/beast_core.h @@ -195,7 +195,6 @@ class FileOutputStream; #include "misc/Main.h" #include "misc/Uuid.h" #include "misc/WindowsRegistry.h" -#include "network/IPAddress.h" #include "network/MACAddress.h" #include "threads/ReadWriteLock.h" #include "network/NamedPipe.h" diff --git a/src/beast/modules/beast_core/native/win32_Network.cpp b/src/beast/modules/beast_core/native/win32_Network.cpp index d85cc01de2..231b897ab5 100644 --- a/src/beast/modules/beast_core/native/win32_Network.cpp +++ b/src/beast/modules/beast_core/native/win32_Network.cpp @@ -112,24 +112,6 @@ void MACAddress::findAllAddresses (Array& result) MACAddressHelpers::getViaNetBios (result); } -void IPAddress::findAllAddresses (Array& result) -{ - result.addIfNotAlreadyThere (IPAddress::local()); - - GetAdaptersInfoHelper gah; - - if (gah.callGetAdaptersInfo()) - { - for (PIP_ADAPTER_INFO adapter = gah.adapterInfo; adapter != nullptr; adapter = adapter->Next) - { - IPAddress ip (adapter->IpAddressList.IpAddress.String); - - if (ip != IPAddress::any()) - result.addIfNotAlreadyThere (ip); - } - } -} - //============================================================================== bool Process::openEmailWithAttachments (const String& targetEmailAddress, const String& emailSubject, diff --git a/src/beast/modules/beast_core/network/IPAddress.cpp b/src/beast/modules/beast_core/network/IPAddress.cpp deleted file mode 100644 index 08e69bee33..0000000000 --- a/src/beast/modules/beast_core/network/IPAddress.cpp +++ /dev/null @@ -1,144 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Portions of this file are from JUCE. - Copyright (c) 2013 - Raw Material Software Ltd. - Please visit http://www.juce.com - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -IPAddress::IPAddress() noexcept -{ - address[0] = 0; address[1] = 0; - address[2] = 0; address[3] = 0; -} - -IPAddress::IPAddress (const uint8 bytes[4]) noexcept -{ - address[0] = bytes[0]; address[1] = bytes[1]; - address[2] = bytes[2]; address[3] = bytes[3]; -} - -IPAddress::IPAddress (uint8 a0, uint8 a1, uint8 a2, uint8 a3) noexcept -{ - address[0] = a0; address[1] = a1; - address[2] = a2; address[3] = a3; -} - -IPAddress::IPAddress (uint32 n) noexcept -{ - address[0] = (n >> 24); - address[1] = (n >> 16) & 255; - address[2] = (n >> 8) & 255; - address[3] = (n & 255); -} - -IPAddress::IPAddress (const String& adr) -{ - StringArray tokens; - tokens.addTokens (adr, ".", String::empty); - - for (int i = 0; i < 4; ++i) - address[i] = (uint8) tokens[i].getIntValue(); -} - -String IPAddress::toString() const -{ - String s ((int) address[0]); - - for (int i = 1; i < 4; ++i) - s << '.' << (int) address[i]; - - return s; -} - -IPAddress IPAddress::any() noexcept { return IPAddress(); } -IPAddress IPAddress::broadcast() noexcept { return IPAddress (255, 255, 255, 255); } -IPAddress IPAddress::local() noexcept { return IPAddress (127, 0, 0, 1); } - -bool IPAddress::operator== (const IPAddress& other) const noexcept -{ - return address[0] == other.address[0] - && address[1] == other.address[1] - && address[2] == other.address[2] - && address[3] == other.address[3]; -} - -bool IPAddress::operator!= (const IPAddress& other) const noexcept -{ - return ! operator== (other); -} - -#if ! BEAST_WINDOWS -static void addAddress (const sockaddr_in* addr_in, Array& result) -{ - in_addr_t addr = addr_in->sin_addr.s_addr; - - if (addr != INADDR_NONE) - result.addIfNotAlreadyThere (IPAddress (ntohl (addr))); -} - -static void findIPAddresses (int sock, Array& result) -{ - ifconf cfg; - HeapBlock buffer; - int bufferSize = 1024; - - do - { - bufferSize *= 2; - buffer.calloc ((size_t)bufferSize); - - cfg.ifc_len = bufferSize; - cfg.ifc_buf = buffer; - - if (ioctl (sock, SIOCGIFCONF, &cfg) < 0 && errno != EINVAL) - return; - - } while (bufferSize < cfg.ifc_len + 2 * (int) (IFNAMSIZ + sizeof (struct sockaddr_in6))); - - #if BEAST_MAC || BEAST_IOS - while (cfg.ifc_len >= (int) (IFNAMSIZ + sizeof (struct sockaddr_in))) - { - if (cfg.ifc_req->ifr_addr.sa_family == AF_INET) // Skip non-internet addresses - addAddress ((const sockaddr_in*) &cfg.ifc_req->ifr_addr, result); - - cfg.ifc_len -= IFNAMSIZ + cfg.ifc_req->ifr_addr.sa_len; - cfg.ifc_buf += IFNAMSIZ + cfg.ifc_req->ifr_addr.sa_len; - } - #else - for (size_t i = 0; i < cfg.ifc_len / sizeof (struct ifreq); ++i) - { - const ifreq& item = cfg.ifc_req[i]; - - if (item.ifr_addr.sa_family == AF_INET) - addAddress ((const sockaddr_in*) &item.ifr_addr, result); - } - #endif -} - -void IPAddress::findAllAddresses (Array& result) -{ - const int sock = socket (AF_INET, SOCK_DGRAM, 0); // a dummy socket to execute the IO control - - if (sock >= 0) - { - findIPAddresses (sock, result); - ::close (sock); - } -} -#endif diff --git a/src/beast/modules/beast_core/network/IPAddress.h b/src/beast/modules/beast_core/network/IPAddress.h deleted file mode 100644 index 6847d7aefe..0000000000 --- a/src/beast/modules/beast_core/network/IPAddress.h +++ /dev/null @@ -1,77 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Portions of this file are from JUCE. - Copyright (c) 2013 - Raw Material Software Ltd. - Please visit http://www.juce.com - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_IPADDRESS_H_INCLUDED -#define BEAST_IPADDRESS_H_INCLUDED - - -//============================================================================== -/** - An IPV4 address. -*/ -class BEAST_API IPAddress -{ -public: - //============================================================================== - /** Populates a list of all the IP addresses that this machine is using. */ - static void findAllAddresses (Array& results); - - //============================================================================== - /** Creates a null address (0.0.0.0). */ - IPAddress() noexcept; - - /** Creates an address from 4 bytes. */ - explicit IPAddress (const uint8 bytes[4]) noexcept; - - /** Creates an address from 4 bytes. */ - IPAddress (uint8 address1, uint8 address2, uint8 address3, uint8 address4) noexcept; - - /** Creates an address from a packed 32-bit integer, where the MSB is - the first number in the address, and the LSB is the last. - */ - explicit IPAddress (uint32 asNativeEndian32Bit) noexcept; - - /** Parses a string IP address of the form "a.b.c.d". */ - explicit IPAddress (const String& address); - - /** Returns a dot-separated string in the form "1.2.3.4" */ - String toString() const; - - /** Returns an address meaning "any" (0.0.0.0) */ - static IPAddress any() noexcept; - - /** Returns an address meaning "broadcast" (255.255.255.255) */ - static IPAddress broadcast() noexcept; - - /** Returns an address meaning "localhost" (127.0.0.1) */ - static IPAddress local() noexcept; - - bool operator== (const IPAddress& other) const noexcept; - bool operator!= (const IPAddress& other) const noexcept; - - /** The elements of the IP address. */ - uint8 address[4]; -}; - - -#endif // BEAST_IPADDRESS_H_INCLUDED diff --git a/src/beast/modules/beast_core/network/URL.cpp b/src/beast/modules/beast_core/network/URL.cpp deleted file mode 100644 index 8e71c6db9e..0000000000 --- a/src/beast/modules/beast_core/network/URL.cpp +++ /dev/null @@ -1,468 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Portions of this file are from JUCE. - Copyright (c) 2013 - Raw Material Software Ltd. - Please visit http://www.juce.com - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -URL::URL() -{ -} - -URL::URL (const String& url_) - : url (url_) -{ - int i = url.indexOfChar ('?'); - - if (i >= 0) - { - do - { - const int nextAmp = url.indexOfChar (i + 1, '&'); - const int equalsPos = url.indexOfChar (i + 1, '='); - - if (equalsPos > i + 1) - { - if (nextAmp < 0) - { - addParameter (removeEscapeChars (url.substring (i + 1, equalsPos)), - removeEscapeChars (url.substring (equalsPos + 1))); - } - else if (nextAmp > 0 && equalsPos < nextAmp) - { - addParameter (removeEscapeChars (url.substring (i + 1, equalsPos)), - removeEscapeChars (url.substring (equalsPos + 1, nextAmp))); - } - } - - i = nextAmp; - } - while (i >= 0); - - url = url.upToFirstOccurrenceOf ("?", false, false); - } -} - -URL::URL (const URL& other) - : url (other.url), - postData (other.postData), - parameterNames (other.parameterNames), - parameterValues (other.parameterValues), - filesToUpload (other.filesToUpload), - mimeTypes (other.mimeTypes) -{ -} - -URL& URL::operator= (const URL& other) -{ - url = other.url; - postData = other.postData; - parameterNames = other.parameterNames; - parameterValues = other.parameterValues; - filesToUpload = other.filesToUpload; - mimeTypes = other.mimeTypes; - - return *this; -} - -bool URL::operator== (const URL& other) const -{ - return url == other.url - && postData == other.postData - && parameterNames == other.parameterNames - && parameterValues == other.parameterValues - && filesToUpload == other.filesToUpload - && mimeTypes == other.mimeTypes; -} - -bool URL::operator!= (const URL& other) const -{ - return ! operator== (other); -} - -URL::~URL() -{ -} - -namespace URLHelpers -{ - static String getMangledParameters (const URL& url) - { - bassert (url.getParameterNames().size() == url.getParameterValues().size()); - String p; - - for (int i = 0; i < url.getParameterNames().size(); ++i) - { - if (i > 0) - p << '&'; - - p << URL::addEscapeChars (url.getParameterNames()[i], true) - << '=' - << URL::addEscapeChars (url.getParameterValues()[i], true); - } - - return p; - } - - static int findEndOfScheme (const String& url) - { - int i = 0; - - while (CharacterFunctions::isLetterOrDigit (url[i]) - || url[i] == '+' || url[i] == '-' || url[i] == '.') - ++i; - - return url[i] == ':' ? i + 1 : 0; - } - - static int findStartOfNetLocation (const String& url) - { - int start = findEndOfScheme (url); - while (url[start] == '/') - ++start; - - return start; - } - - static int findStartOfPath (const String& url) - { - return url.indexOfChar (findStartOfNetLocation (url), '/') + 1; - } - - static void createHeadersAndPostData (const URL& url, String& headers, MemoryBlock& postData) - { - MemoryOutputStream data (postData, false); - - if (url.getFilesToUpload().size() > 0) - { - // need to upload some files, so do it as multi-part... - const String boundary (String::toHexString (Random::getSystemRandom().nextInt64())); - - headers << "Content-Type: multipart/form-data; boundary=" << boundary << "\r\n"; - - data << "--" << boundary; - - for (int i = 0; i < url.getParameterNames().size(); ++i) - { - data << "\r\nContent-Disposition: form-data; name=\"" - << url.getParameterNames() [i] - << "\"\r\n\r\n" - << url.getParameterValues() [i] - << "\r\n--" - << boundary; - } - - for (int i = 0; i < url.getFilesToUpload().size(); ++i) - { - const File file (url.getFilesToUpload().getAllValues() [i]); - const String paramName (url.getFilesToUpload().getAllKeys() [i]); - - data << "\r\nContent-Disposition: form-data; name=\"" << paramName - << "\"; filename=\"" << file.getFileName() << "\"\r\n"; - - const String mimeType (url.getMimeTypesOfUploadFiles() - .getValue (paramName, String::empty)); - - if (mimeType.isNotEmpty()) - data << "Content-Type: " << mimeType << "\r\n"; - - data << "Content-Transfer-Encoding: binary\r\n\r\n" - << file << "\r\n--" << boundary; - } - - data << "--\r\n"; - } - else - { - data << getMangledParameters (url) - << url.getPostData(); - - // just a short text attachment, so use simple url encoding.. - headers << "Content-Type: application/x-www-form-urlencoded\r\nContent-length: " - << (int) data.getDataSize() << "\r\n"; - } - } - - static void concatenatePaths (String& path, const String& suffix) - { - if (! path.endsWithChar ('/')) - path << '/'; - - if (suffix.startsWithChar ('/')) - path += suffix.substring (1); - else - path += suffix; - } -} - -void URL::addParameter (const String& name, const String& value) -{ - parameterNames.add (name); - parameterValues.add (value); -} - -String URL::toString (const bool includeGetParameters) const -{ - if (includeGetParameters && parameterNames.size() > 0) - return url + "?" + URLHelpers::getMangledParameters (*this); - - return url; -} - -bool URL::isWellFormed() const -{ - //xxx TODO - return url.isNotEmpty(); -} - -String URL::getDomain() const -{ - const int start = URLHelpers::findStartOfNetLocation (url); - const int end1 = url.indexOfChar (start, '/'); - const int end2 = url.indexOfChar (start, ':'); - - const int end = (end1 < 0 && end2 < 0) ? std::numeric_limits::max() - : ((end1 < 0 || end2 < 0) ? bmax (end1, end2) - : bmin (end1, end2)); - return url.substring (start, end); -} - -String URL::getSubPath() const -{ - const int startOfPath = URLHelpers::findStartOfPath (url); - - return startOfPath <= 0 ? String::empty - : url.substring (startOfPath); -} - -String URL::getScheme() const -{ - return url.substring (0, URLHelpers::findEndOfScheme (url) - 1); -} - -int URL::getPort() const -{ - const int colonPos = url.indexOfChar (URLHelpers::findStartOfNetLocation (url), ':'); - - return colonPos > 0 ? url.substring (colonPos + 1).getIntValue() : 0; -} - -URL URL::withNewSubPath (const String& newPath) const -{ - const int startOfPath = URLHelpers::findStartOfPath (url); - - URL u (*this); - - if (startOfPath > 0) - u.url = url.substring (0, startOfPath); - - URLHelpers::concatenatePaths (u.url, newPath); - return u; -} - -URL URL::getChildURL (const String& subPath) const -{ - URL u (*this); - URLHelpers::concatenatePaths (u.url, subPath); - return u; -} - -//============================================================================== -bool URL::isProbablyAWebsiteURL (const String& possibleURL) -{ - const char* validProtocols[] = { "http:", "ftp:", "https:" }; - - for (int i = 0; i < numElementsInArray (validProtocols); ++i) - if (possibleURL.startsWithIgnoreCase (validProtocols[i])) - return true; - - if (possibleURL.containsChar ('@') - || possibleURL.containsChar (' ')) - return false; - - const String topLevelDomain (possibleURL.upToFirstOccurrenceOf ("/", false, false) - .fromLastOccurrenceOf (".", false, false)); - - return topLevelDomain.isNotEmpty() && topLevelDomain.length() <= 3; -} - -bool URL::isProbablyAnEmailAddress (const String& possibleEmailAddress) -{ - const int atSign = possibleEmailAddress.indexOfChar ('@'); - - return atSign > 0 - && possibleEmailAddress.lastIndexOfChar ('.') > (atSign + 1) - && (! possibleEmailAddress.endsWithChar ('.')); -} - -//============================================================================== -InputStream* URL::createInputStream (const bool usePostCommand, - OpenStreamProgressCallback* const progressCallback, - void* const progressCallbackContext, - const String& extraHeaders, - const int timeOutMs, - StringPairArray* const responseHeaders) const -{ - String headers; - MemoryBlock headersAndPostData; - - if (usePostCommand) - URLHelpers::createHeadersAndPostData (*this, headers, headersAndPostData); - - headers += extraHeaders; - - if (! headers.endsWithChar ('\n')) - headers << "\r\n"; - - return createNativeStream (toString (! usePostCommand), usePostCommand, headersAndPostData, - progressCallback, progressCallbackContext, - headers, timeOutMs, responseHeaders); -} - -//============================================================================== -bool URL::readEntireBinaryStream (MemoryBlock& destData, - const bool usePostCommand) const -{ - const ScopedPointer in (createInputStream (usePostCommand)); - - if (in != nullptr) - { - in->readIntoMemoryBlock (destData); - return true; - } - - return false; -} - -String URL::readEntireTextStream (const bool usePostCommand) const -{ - const ScopedPointer in (createInputStream (usePostCommand)); - - if (in != nullptr) - return in->readEntireStreamAsString(); - - return String::empty; -} - -XmlElement* URL::readEntireXmlStream (const bool usePostCommand) const -{ - return XmlDocument::parse (readEntireTextStream (usePostCommand)); -} - -//============================================================================== -URL URL::withParameter (const String& parameterName, - const String& parameterValue) const -{ - URL u (*this); - u.addParameter (parameterName, parameterValue); - return u; -} - -URL URL::withFileToUpload (const String& parameterName, - const File& fileToUpload, - const String& mimeType) const -{ - bassert (mimeType.isNotEmpty()); // You need to supply a mime type! - - URL u (*this); - u.filesToUpload.set (parameterName, fileToUpload.getFullPathName()); - u.mimeTypes.set (parameterName, mimeType); - return u; -} - -URL URL::withPOSTData (const String& postData_) const -{ - URL u (*this); - u.postData = postData_; - return u; -} - -const StringPairArray& URL::getFilesToUpload() const -{ - return filesToUpload; -} - -const StringPairArray& URL::getMimeTypesOfUploadFiles() const -{ - return mimeTypes; -} - -//============================================================================== -String URL::removeEscapeChars (const String& s) -{ - String result (s.replaceCharacter ('+', ' ')); - - if (! result.containsChar ('%')) - return result; - - // We need to operate on the string as raw UTF8 chars, and then recombine them into unicode - // after all the replacements have been made, so that multi-byte chars are handled. - Array utf8 (result.toRawUTF8(), (int) result.getNumBytesAsUTF8()); - - for (int i = 0; i < utf8.size(); ++i) - { - if (utf8.getUnchecked(i) == '%') - { - const int hexDigit1 = CharacterFunctions::getHexDigitValue ((beast_wchar) (uint8) utf8 [i + 1]); - const int hexDigit2 = CharacterFunctions::getHexDigitValue ((beast_wchar) (uint8) utf8 [i + 2]); - - if (hexDigit1 >= 0 && hexDigit2 >= 0) - { - utf8.set (i, (char) ((hexDigit1 << 4) + hexDigit2)); - utf8.removeRange (i + 1, 2); - } - } - } - - return String::fromUTF8 (utf8.getRawDataPointer(), utf8.size()); -} - -String URL::addEscapeChars (const String& s, const bool isParameter) -{ - const CharPointer_UTF8 legalChars (isParameter ? "_-.*!'()" - : ",$_-.*!'()"); - - Array utf8 (s.toRawUTF8(), (int) s.getNumBytesAsUTF8()); - - for (int i = 0; i < utf8.size(); ++i) - { - const char c = utf8.getUnchecked(i); - - if (! (CharacterFunctions::isLetterOrDigit (c) - || legalChars.indexOf ((beast_wchar) c) >= 0)) - { - utf8.set (i, '%'); - utf8.insert (++i, "0123456789abcdef" [((uint8) c) >> 4]); - utf8.insert (++i, "0123456789abcdef" [c & 15]); - } - } - - return String::fromUTF8 (utf8.getRawDataPointer(), utf8.size()); -} - -//============================================================================== -bool URL::launchInDefaultBrowser() const -{ - String u (toString (true)); - - if (u.containsChar ('@') && ! u.containsChar (':')) - u = "mailto:" + u; - - return Process::openDocument (u, String::empty); -} diff --git a/src/beast/modules/beast_core/network/URL.h b/src/beast/modules/beast_core/network/URL.h deleted file mode 100644 index 589f974f00..0000000000 --- a/src/beast/modules/beast_core/network/URL.h +++ /dev/null @@ -1,342 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Portions of this file are from JUCE. - Copyright (c) 2013 - Raw Material Software Ltd. - Please visit http://www.juce.com - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_URL_H_INCLUDED -#define BEAST_URL_H_INCLUDED - -class InputStream; -class XmlElement; - - -//============================================================================== -/** - Represents a URL and has a bunch of useful functions to manipulate it. - - This class can be used to launch URLs in browsers, and also to create - InputStreams that can read from remote http or ftp sources. -*/ -class BEAST_API URL : LeakChecked -{ -public: - //============================================================================== - /** Creates an empty URL. */ - URL(); - - /** Creates a URL from a string. */ - URL (const String& url); - - /** Creates a copy of another URL. */ - URL (const URL& other); - - /** Destructor. */ - ~URL(); - - /** Copies this URL from another one. */ - URL& operator= (const URL& other); - - /** Compares two URLs. - All aspects of the URLs must be identical for them to match, including any parameters, - upload files, etc. - */ - bool operator== (const URL&) const; - bool operator!= (const URL&) const; - - //============================================================================== - /** Returns a string version of the URL. - - If includeGetParameters is true and any parameters have been set with the - withParameter() method, then the string will have these appended on the - end and url-encoded. - */ - String toString (bool includeGetParameters) const; - - /** True if it seems to be valid. */ - bool isWellFormed() const; - - /** Returns just the domain part of the URL. - - E.g. for "http://www.xyz.com/foobar", this will return "www.xyz.com". - */ - String getDomain() const; - - /** Returns the path part of the URL. - - E.g. for "http://www.xyz.com/foo/bar?x=1", this will return "foo/bar". - */ - String getSubPath() const; - - /** Returns the scheme of the URL. - - E.g. for "http://www.xyz.com/foobar", this will return "http". (It won't - include the colon). - */ - String getScheme() const; - - /** Attempts to read a port number from the URL. - @returns the port number, or 0 if none is explicitly specified. - */ - int getPort() const; - - /** Returns a new version of this URL that uses a different sub-path. - - E.g. if the URL is "http://www.xyz.com/foo?x=1" and you call this with - "bar", it'll return "http://www.xyz.com/bar?x=1". - */ - URL withNewSubPath (const String& newPath) const; - - /** Returns a new URL that refers to a sub-path relative to this one. - - E.g. if the URL is "http://www.xyz.com/foo" and you call this with - "bar", it'll return "http://www.xyz.com/foo/bar". Note that there's no way for - this method to know whether the original URL is a file or directory, so it's - up to you to make sure it's a directory. It also won't attempt to be smart about - the content of the childPath string, so if this string is an absolute URL, it'll - still just get bolted onto the end of the path. - - @see File::getChildFile - */ - URL getChildURL (const String& subPath) const; - - //============================================================================== - /** Returns a copy of this URL, with a GET or POST parameter added to the end. - - Any control characters in the value will be encoded. - - e.g. calling "withParameter ("amount", "some fish") for the url "www.fish.com" - would produce a new url whose toString(true) method would return - "www.fish.com?amount=some+fish". - - @see getParameterNames, getParameterValues - */ - URL withParameter (const String& parameterName, - const String& parameterValue) const; - - /** Returns a copy of this URl, with a file-upload type parameter added to it. - - When performing a POST where one of your parameters is a binary file, this - lets you specify the file. - - Note that the filename is stored, but the file itself won't actually be read - until this URL is later used to create a network input stream. - */ - URL withFileToUpload (const String& parameterName, - const File& fileToUpload, - const String& mimeType) const; - - /** Returns an array of the names of all the URL's parameters. - - E.g. for the url "www.fish.com?type=haddock&amount=some+fish", this array would - contain two items: "type" and "amount". - - You can call getParameterValues() to get the corresponding value of each - parameter. Note that the list can contain multiple parameters with the same name. - - @see getParameterValues, withParameter - */ - const StringArray& getParameterNames() const noexcept { return parameterNames; } - - /** Returns an array of the values of all the URL's parameters. - - E.g. for the url "www.fish.com?type=haddock&amount=some+fish", this array would - contain two items: "haddock" and "some fish". - - The values returned will have been cleaned up to remove any escape characters. - - You can call getParameterNames() to get the corresponding name of each - parameter. Note that the list can contain multiple parameters with the same name. - - @see getParameterNames, withParameter - */ - const StringArray& getParameterValues() const noexcept { return parameterValues; } - - /** Returns the set of files that should be uploaded as part of a POST operation. - - This is the set of files that were added to the URL with the withFileToUpload() - method. - */ - const StringPairArray& getFilesToUpload() const; - - /** Returns the set of mime types associated with each of the upload files. - */ - const StringPairArray& getMimeTypesOfUploadFiles() const; - - /** Returns a copy of this URL, with a block of data to send as the POST data. - - If you're setting the POST data, be careful not to have any parameters set - as well, otherwise it'll all get thrown in together, and might not have the - desired effect. - - If the URL already contains some POST data, this will replace it, rather - than being appended to it. - - This data will only be used if you specify a post operation when you call - createInputStream(). - */ - URL withPOSTData (const String& postData) const; - - /** Returns the data that was set using withPOSTData(). */ - const String& getPostData() const noexcept { return postData; } - - //============================================================================== - /** Tries to launch the system's default browser to open the URL. - - Returns true if this seems to have worked. - */ - bool launchInDefaultBrowser() const; - - //============================================================================== - /** Takes a guess as to whether a string might be a valid website address. - - This isn't foolproof! - */ - static bool isProbablyAWebsiteURL (const String& possibleURL); - - /** Takes a guess as to whether a string might be a valid email address. - - This isn't foolproof! - */ - static bool isProbablyAnEmailAddress (const String& possibleEmailAddress); - - //============================================================================== - /** This callback function can be used by the createInputStream() method. - - It allows your app to receive progress updates during a lengthy POST operation. If you - want to continue the operation, this should return true, or false to abort. - */ - typedef bool (OpenStreamProgressCallback) (void* context, int bytesSent, int totalBytes); - - /** Attempts to open a stream that can read from this URL. - - @param usePostCommand if true, it will try to do use a http 'POST' to pass - the paramters, otherwise it'll encode them into the - URL and do a 'GET'. - @param progressCallback if this is non-zero, it lets you supply a callback function - to keep track of the operation's progress. This can be useful - for lengthy POST operations, so that you can provide user feedback. - @param progressCallbackContext if a callback is specified, this value will be passed to - the function - @param extraHeaders if not empty, this string is appended onto the headers that - are used for the request. It must therefore be a valid set of HTML - header directives, separated by newlines. - @param connectionTimeOutMs if 0, this will use whatever default setting the OS chooses. If - a negative number, it will be infinite. Otherwise it specifies a - time in milliseconds. - @param responseHeaders if this is non-zero, all the (key, value) pairs received as headers - in the response will be stored in this array - @returns an input stream that the caller must delete, or a null pointer if there was an - error trying to open it. - */ - InputStream* createInputStream (bool usePostCommand, - OpenStreamProgressCallback* progressCallback = nullptr, - void* progressCallbackContext = nullptr, - const String& extraHeaders = String::empty, - int connectionTimeOutMs = 0, - StringPairArray* responseHeaders = nullptr) const; - - - //============================================================================== - /** Tries to download the entire contents of this URL into a binary data block. - - If it succeeds, this will return true and append the data it read onto the end - of the memory block. - - @param destData the memory block to append the new data to - @param usePostCommand whether to use a POST command to get the data (uses - a GET command if this is false) - @see readEntireTextStream, readEntireXmlStream - */ - bool readEntireBinaryStream (MemoryBlock& destData, - bool usePostCommand = false) const; - - /** Tries to download the entire contents of this URL as a string. - - If it fails, this will return an empty string, otherwise it will return the - contents of the downloaded file. If you need to distinguish between a read - operation that fails and one that returns an empty string, you'll need to use - a different method, such as readEntireBinaryStream(). - - @param usePostCommand whether to use a POST command to get the data (uses - a GET command if this is false) - @see readEntireBinaryStream, readEntireXmlStream - */ - String readEntireTextStream (bool usePostCommand = false) const; - - /** Tries to download the entire contents of this URL and parse it as XML. - - If it fails, or if the text that it reads can't be parsed as XML, this will - return 0. - - When it returns a valid XmlElement object, the caller is responsibile for deleting - this object when no longer needed. - - @param usePostCommand whether to use a POST command to get the data (uses - a GET command if this is false) - - @see readEntireBinaryStream, readEntireTextStream - */ - XmlElement* readEntireXmlStream (bool usePostCommand = false) const; - - //============================================================================== - /** Adds escape sequences to a string to encode any characters that aren't - legal in a URL. - - E.g. any spaces will be replaced with "%20". - - This is the opposite of removeEscapeChars(). - - If isParameter is true, it means that the string is going to be used - as a parameter, so it also encodes '$' and ',' (which would otherwise - be legal in a URL. - - @see removeEscapeChars - */ - static String addEscapeChars (const String& stringToAddEscapeCharsTo, - bool isParameter); - - /** Replaces any escape character sequences in a string with their original - character codes. - - E.g. any instances of "%20" will be replaced by a space. - - This is the opposite of addEscapeChars(). - - @see addEscapeChars - */ - static String removeEscapeChars (const String& stringToRemoveEscapeCharsFrom); - -private: - //============================================================================== - String url, postData; - StringArray parameterNames, parameterValues; - StringPairArray filesToUpload, mimeTypes; - - void addParameter (const String&, const String&); - - static InputStream* createNativeStream (const String& address, bool isPost, const MemoryBlock& postData, - OpenStreamProgressCallback* progressCallback, - void* progressCallbackContext, const String& headers, - const int timeOutMs, StringPairArray* responseHeaders); -}; - - -#endif // BEAST_URL_H_INCLUDED diff --git a/src/ripple/http/api/Port.h b/src/ripple/http/api/Port.h index f593058001..675c5d5450 100644 --- a/src/ripple/http/api/Port.h +++ b/src/ripple/http/api/Port.h @@ -39,11 +39,11 @@ struct Port Port (); Port (Port const& other); Port& operator= (Port const& other); - Port (uint16 port_, IPEndpoint const& addr_, + Port (uint16 port_, IPAddress const& addr_, Security security_, SSLContext* context_); uint16 port; - IPEndpoint addr; + IPAddress addr; Security security; SSLContext* context; }; diff --git a/src/ripple/http/api/Session.h b/src/ripple/http/api/Session.h index 43ce84bd79..848a52c0cc 100644 --- a/src/ripple/http/api/Session.h +++ b/src/ripple/http/api/Session.h @@ -46,7 +46,7 @@ public: virtual Journal journal() = 0; /** Returns the remote address of the connection. */ - virtual IPEndpoint remoteAddress() = 0; + virtual IPAddress remoteAddress() = 0; /** Returns `true` if the full HTTP headers have been received. */ virtual bool headersComplete() = 0; diff --git a/src/ripple/http/impl/Peer.h b/src/ripple/http/impl/Peer.h index 36f73e090f..0866a2f5e7 100644 --- a/src/ripple/http/impl/Peer.h +++ b/src/ripple/http/impl/Peer.h @@ -117,7 +117,7 @@ public: return m_impl.journal(); } - IPEndpoint remoteAddress() + IPAddress remoteAddress() { return from_asio (get_socket().remote_endpoint()); } diff --git a/src/ripple/http/impl/Port.cpp b/src/ripple/http/impl/Port.cpp index ce2986a9bf..177803b992 100644 --- a/src/ripple/http/impl/Port.cpp +++ b/src/ripple/http/impl/Port.cpp @@ -47,7 +47,7 @@ Port& Port::operator= (Port const& other) Port::Port ( uint16 port_, - IPEndpoint const& addr_, + IPAddress const& addr_, Security security_, SSLContext* context_) : port (port_) diff --git a/src/ripple/http/impl/Types.h b/src/ripple/http/impl/Types.h index 03cd012f1e..b206977873 100644 --- a/src/ripple/http/impl/Types.h +++ b/src/ripple/http/impl/Types.h @@ -49,19 +49,19 @@ inline endpoint_t to_asio (Port const& port) { if (port.addr.isV4()) { - IPEndpoint::V4 v4 (port.addr.v4()); + IPAddress::V4 v4 (port.addr.v4()); std::string const& s (v4.to_string()); return endpoint_t (address().from_string (s), port.port); } - //IPEndpoint::V6 v6 (ep.v6()); + //IPAddress::V6 v6 (ep.v6()); return endpoint_t (); } -inline IPEndpoint from_asio (endpoint_t const& endpoint) +inline IPAddress from_asio (endpoint_t const& endpoint) { std::stringstream ss (to_string (endpoint)); - IPEndpoint ep; + IPAddress ep; ss >> ep; return ep; } diff --git a/src/ripple/peerfinder/api/Callback.h b/src/ripple/peerfinder/api/Callback.h index 8cfdb7d94d..90017f17d5 100644 --- a/src/ripple/peerfinder/api/Callback.h +++ b/src/ripple/peerfinder/api/Callback.h @@ -35,7 +35,7 @@ struct Callback std::vector const& endpoints) = 0; /** Initiate outgoing Peer connections to the specified set of endpoints. */ - virtual void connectPeerEndpoints (std::vector const& list) = 0; + virtual void connectPeerEndpoints (std::vector const& list) = 0; /** Impose a load charge on the specified peer. */ virtual void chargePeerLoadPenalty (PeerID const& id) = 0; diff --git a/src/ripple/peerfinder/api/Endpoint.h b/src/ripple/peerfinder/api/Endpoint.h index 7a7b2f311c..ed7d6ef86c 100644 --- a/src/ripple/peerfinder/api/Endpoint.h +++ b/src/ripple/peerfinder/api/Endpoint.h @@ -28,7 +28,7 @@ struct Endpoint { Endpoint (); - IPEndpoint address; + IPAddress address; int hops; uint32 incomingSlotsAvailable; uint32 incomingSlotsMax; diff --git a/src/ripple/peerfinder/api/Manager.h b/src/ripple/peerfinder/api/Manager.h index 9b86e0c8d6..7beb3b8df1 100644 --- a/src/ripple/peerfinder/api/Manager.h +++ b/src/ripple/peerfinder/api/Manager.h @@ -58,13 +58,13 @@ public: virtual void addFixedPeers ( std::vector const& strings) = 0; - /** Add a set of strings as fallback IPEndpoint sources. + /** Add a set of strings as fallback IPAddress sources. @param name A label used for diagnostics. */ virtual void addFallbackStrings (std::string const& name, std::vector const& strings) = 0; - /** Add a URL as a fallback location to obtain IPEndpoint sources. + /** Add a URL as a fallback location to obtain IPAddress sources. @param name A label used for diagnostics. */ virtual void addFallbackURL (std::string const& name, @@ -76,7 +76,7 @@ public: we are sure that its connection is stable. */ virtual void onPeerConnected (PeerID const& id, - IPEndpoint const& address, + IPAddress const& address, bool inbound) = 0; /** Called when an existing peer connection drops for whatever reason. @@ -91,7 +91,7 @@ public: std::vector const& endpoints) = 0; /** Called when a legacy IP/port address is received (from mtPEER). */ - virtual void onPeerLegacyEndpoint (IPEndpoint const& ep) = 0; + virtual void onPeerLegacyEndpoint (IPAddress const& ep) = 0; }; } diff --git a/src/ripple/peerfinder/impl/Cache.h b/src/ripple/peerfinder/impl/Cache.h index 68fd4700e8..e5f6564085 100644 --- a/src/ripple/peerfinder/impl/Cache.h +++ b/src/ripple/peerfinder/impl/Cache.h @@ -29,7 +29,7 @@ class Cache { private: typedef boost::unordered_map < - IPEndpoint, CachedEndpoint, IPEndpoint::hasher> Table; + IPAddress, CachedEndpoint, IPAddress::hasher> Table; Journal m_journal; diff --git a/src/ripple/peerfinder/impl/Checker.cpp b/src/ripple/peerfinder/impl/Checker.cpp index f791cf1bdb..593933c50f 100644 --- a/src/ripple/peerfinder/impl/Checker.cpp +++ b/src/ripple/peerfinder/impl/Checker.cpp @@ -41,8 +41,8 @@ private: //-------------------------------------------------------------------------- - static boost::asio::ip::tcp::endpoint fromIPEndpoint ( - IPEndpoint const& ipEndpoint) + static boost::asio::ip::tcp::endpoint fromIPAddress ( + IPAddress const& ipEndpoint) { if (ipEndpoint.isV4 ()) { @@ -71,14 +71,14 @@ private: CheckerImp& m_owner; boost::asio::io_service& m_io_service; - IPEndpoint m_address; + IPAddress m_address; AbstractHandler m_handler; socket_type m_socket; boost::system::error_code m_error; bool m_canAccept; Request (CheckerImp& owner, boost::asio::io_service& io_service, - IPEndpoint const& address, AbstractHandler handler) + IPAddress const& address, AbstractHandler handler) : m_owner (owner) , m_io_service (io_service) , m_address (address) @@ -88,7 +88,7 @@ private: { m_owner.add (*this); - m_socket.async_connect (fromIPEndpoint (m_address), + m_socket.async_connect (fromIPAddress (m_address), wrapHandler (boost::bind (&Request::handle_connect, Ptr(this), boost::asio::placeholders::error), m_handler)); } @@ -165,7 +165,7 @@ public: iter->cancel(); } - void async_test (IPEndpoint const& endpoint, + void async_test (IPAddress const& endpoint, AbstractHandler handler) { new Request (*this, m_io_service, endpoint, handler); diff --git a/src/ripple/peerfinder/impl/Checker.h b/src/ripple/peerfinder/impl/Checker.h index cf85ea825c..f4028a13ce 100644 --- a/src/ripple/peerfinder/impl/Checker.h +++ b/src/ripple/peerfinder/impl/Checker.h @@ -54,7 +54,7 @@ public: { } /** The original address. */ - IPEndpoint address; + IPAddress address; /** The error code from the operation. */ boost::system::error_code error; @@ -71,7 +71,7 @@ public: void (Result const& result); */ template - void async_test (IPEndpoint const& endpoint, + void async_test (IPAddress const& endpoint, BEAST_MOVE_ARG(Handler) handler) { async_test (endpoint, @@ -79,7 +79,7 @@ public: BEAST_MOVE_CAST(Handler)(handler))); } - virtual void async_test (IPEndpoint const& endpoint, + virtual void async_test (IPAddress const& endpoint, AbstractHandler handler) = 0; }; diff --git a/src/ripple/peerfinder/impl/CheckerAdapter.h b/src/ripple/peerfinder/impl/CheckerAdapter.h index f4258b2a6f..3972ff6b31 100644 --- a/src/ripple/peerfinder/impl/CheckerAdapter.h +++ b/src/ripple/peerfinder/impl/CheckerAdapter.h @@ -86,7 +86,7 @@ public: m_checker->cancel(); } - void async_test (IPEndpoint const& endpoint, + void async_test (IPAddress const& endpoint, AbstractHandler handler) { m_checker->async_test (endpoint, Handler ( diff --git a/src/ripple/peerfinder/impl/LegacyEndpoint.h b/src/ripple/peerfinder/impl/LegacyEndpoint.h index 36668c4abd..b749005ec6 100644 --- a/src/ripple/peerfinder/impl/LegacyEndpoint.h +++ b/src/ripple/peerfinder/impl/LegacyEndpoint.h @@ -32,13 +32,13 @@ struct LegacyEndpoint , canAccept (false) { } - LegacyEndpoint (IPEndpoint const& address_, DiscreteTime now) + LegacyEndpoint (IPAddress const& address_, DiscreteTime now) : address (address_) , whenInserted (now) , lastGet(0) { } - IPEndpoint address; + IPAddress address; // When we inserted the endpoint into the cache DiscreteTime mutable whenInserted; diff --git a/src/ripple/peerfinder/impl/LegacyEndpointCache.h b/src/ripple/peerfinder/impl/LegacyEndpointCache.h index a9311f5b6d..1f44d2527d 100644 --- a/src/ripple/peerfinder/impl/LegacyEndpointCache.h +++ b/src/ripple/peerfinder/impl/LegacyEndpointCache.h @@ -33,8 +33,8 @@ private: typedef boost::multi_index_container < LegacyEndpoint, boost::multi_index::indexed_by < boost::multi_index::hashed_unique < - BOOST_MULTI_INDEX_MEMBER(PeerFinder::LegacyEndpoint,IPEndpoint,address), - IPEndpoint::hasher> + BOOST_MULTI_INDEX_MEMBER(PeerFinder::LegacyEndpoint,IPAddress,address), + IPAddress::hasher> > > MapType; @@ -166,7 +166,7 @@ public: /** Load the legacy endpoints cache from the database. */ void load (DiscreteTime now) { - typedef std::vector List; + typedef std::vector List; List list; m_store.loadLegacyEndpoints (list); std::size_t n (0); @@ -186,7 +186,7 @@ public: The return value provides a reference to the new or existing endpoint. The bool indicates whether or not the insertion took place. */ - std::pair insert (IPEndpoint const& address, DiscreteTime now) + std::pair insert (IPAddress const& address, DiscreteTime now) { std::pair result ( m_map.insert (LegacyEndpoint (address, now))); @@ -198,7 +198,7 @@ public: } /** Returns a pointer to the legacy endpoint if it exists, else nullptr. */ - LegacyEndpoint const* find (IPEndpoint const& address) + LegacyEndpoint const* find (IPAddress const& address) { MapType::iterator iter (m_map.find (address)); if (iter != m_map.end()) @@ -209,7 +209,7 @@ public: /** Updates the metadata following a connection attempt. @param canAccept A flag indicating if the connection succeeded. */ - void checked (IPEndpoint const& address, bool canAccept) + void checked (IPAddress const& address, bool canAccept) { LegacyEndpoint const* endpoint (find (address)); if (endpoint != nullptr) @@ -224,7 +224,7 @@ public: Also updates the lastGet field of the LegacyEndpoint so we will avoid re-using the address until we have tried all the others. */ - void get (std::size_t n, std::vector & result, DiscreteTime now) const + void get (std::size_t n, std::vector & result, DiscreteTime now) const { FlattenedList list (flatten()); std::random_shuffle (list.begin(), list.end()); diff --git a/src/ripple/peerfinder/impl/Logic.h b/src/ripple/peerfinder/impl/Logic.h index bf2ab5b575..9a505b0aa7 100644 --- a/src/ripple/peerfinder/impl/Logic.h +++ b/src/ripple/peerfinder/impl/Logic.h @@ -42,8 +42,8 @@ typedef boost::multi_index_container < BOOST_MULTI_INDEX_MEMBER(PeerFinder::PeerInfo,PeerID,id), PeerID::hasher>, boost::multi_index::hashed_non_unique < - BOOST_MULTI_INDEX_MEMBER(PeerFinder::PeerInfo,IPEndpoint,address), - IPEndpoint::hasher> + BOOST_MULTI_INDEX_MEMBER(PeerFinder::PeerInfo,IPAddress,address), + IPAddress::hasher> > > Peers; @@ -87,7 +87,7 @@ public: int m_fixedPeersConnected; // A list of peers that should always be connected - typedef std::set FixedPeers; + typedef std::set FixedPeers; FixedPeers m_fixedPeers; // A list of dynamic sources to consult as a fallback @@ -151,8 +151,8 @@ public: bassert (m_config.wantIncoming); Endpoint ep; - ep.address = IPEndpoint ( - IPEndpoint::V4 ()).withPort (m_config.listeningPort); + ep.address = IPAddress ( + IPAddress::V4 ()).withPort (m_config.listeningPort); ep.hops = 0; ep.incomingSlotsAvailable = m_slots.inboundSlots; ep.incomingSlotsMax = m_slots.inboundSlotsMaximum; @@ -161,9 +161,9 @@ public: return ep; } - // Returns true if the IPEndpoint contains no invalid data. + // Returns true if the IPAddress contains no invalid data. // - bool validIPEndpoint (IPEndpoint const& address) + bool validIPAddress (IPAddress const& address) { if (! address.isPublic()) return false; @@ -180,7 +180,7 @@ public: if (m_config.connectAutomatically) return; - std::vector list; + std::vector list; if (m_slots.outDesired > m_slots.outboundCount) { @@ -233,7 +233,7 @@ public: for (std::vector ::const_iterator iter (strings.begin()); iter != strings.end(); ++iter) { - IPEndpoint ep (IPEndpoint::from_string (*iter)); + IPAddress ep (IPAddress::from_string (*iter)); if (! ep.empty ()) { m_fixedPeers.insert (ep); @@ -275,7 +275,7 @@ public: // but we are *NOT* guaranteed that the IP isn't. So we need // to be careful. void onPeerConnected (PeerID const& id, - IPEndpoint const& address, bool inbound) + IPAddress const& address, bool inbound) { m_journal.debug << "Peer connected: " << address; // If this is outgoing, record the success @@ -316,7 +316,7 @@ public: // This function is here in case we add more stuff // we want to validate to the Endpoint struct. // - return validIPEndpoint (endpoint.address); + return validIPAddress (endpoint.address); } // Prunes invalid endpoints from a list. @@ -385,7 +385,7 @@ public: // Called when the Checker completes a connectivity test // void onCheckEndpoint (PeerID const& id, - IPEndpoint address, Checker::Result const& result) + IPAddress address, Checker::Result const& result) { if (result.error == boost::asio::error::operation_aborted) return; @@ -562,7 +562,7 @@ public: std::size_t newEntries (0); DiscreteTime now (get_now()); - for (std::vector ::const_iterator iter (results.list.begin()); + for (std::vector ::const_iterator iter (results.list.begin()); iter != results.list.end(); ++iter) { std::pair result ( @@ -586,7 +586,7 @@ public: // Completion handler for a LegacyEndpoint listening test. // - void onCheckLegacyEndpoint (IPEndpoint const& endpoint, + void onCheckLegacyEndpoint (IPAddress const& endpoint, Checker::Result const& result) { if (result.error == boost::asio::error::operation_aborted) @@ -608,9 +608,9 @@ public: } } - void onPeerLegacyEndpoint (IPEndpoint const& address) + void onPeerLegacyEndpoint (IPAddress const& address) { - if (! validIPEndpoint (address)) + if (! validIPAddress (address)) return; std::pair result ( m_legacyCache.insert (address, get_now())); diff --git a/src/ripple/peerfinder/impl/Manager.cpp b/src/ripple/peerfinder/impl/Manager.cpp index b013ec000f..86a1f31209 100644 --- a/src/ripple/peerfinder/impl/Manager.cpp +++ b/src/ripple/peerfinder/impl/Manager.cpp @@ -268,7 +268,7 @@ public: } void onPeerConnected (PeerID const& id, - IPEndpoint const& address, bool incoming) + IPAddress const& address, bool incoming) { m_queue.dispatch ( m_context.wrap ( @@ -284,7 +284,7 @@ public: id))); } - void onPeerLegacyEndpoint (IPEndpoint const& ep) + void onPeerLegacyEndpoint (IPAddress const& ep) { m_queue.dispatch ( m_context.wrap ( diff --git a/src/ripple/peerfinder/impl/PeerInfo.h b/src/ripple/peerfinder/impl/PeerInfo.h index 70086d3400..14bf02983f 100644 --- a/src/ripple/peerfinder/impl/PeerInfo.h +++ b/src/ripple/peerfinder/impl/PeerInfo.h @@ -31,7 +31,7 @@ namespace PeerFinder { struct PeerInfo { PeerInfo (PeerID const& id_, - IPEndpoint const& address_, + IPAddress const& address_, bool inbound_, DiscreteTime now) : id (id_) @@ -46,7 +46,7 @@ struct PeerInfo } PeerID id; - IPEndpoint address; + IPAddress address; bool inbound; // Tells us if we checked the connection. Outbound connections @@ -70,12 +70,12 @@ struct PeerInfo // DiscreteTime mutable whenAcceptEndpoints; - // The set of all recent IPEndpoint that we have seen from this peer. + // The set of all recent IPAddress that we have seen from this peer. // We try to avoid sending a peer the same addresses they gave us. // - CycledSet mutable received; + CycledSet mutable received; }; } diff --git a/src/ripple/peerfinder/impl/Source.h b/src/ripple/peerfinder/impl/Source.h index 3ef81fef2c..07074f21a1 100644 --- a/src/ripple/peerfinder/impl/Source.h +++ b/src/ripple/peerfinder/impl/Source.h @@ -41,7 +41,7 @@ public: ErrorCode error; // list of fetched endpoints - std::vector list; + std::vector list; }; virtual ~Source () { } diff --git a/src/ripple/peerfinder/impl/SourceStrings.cpp b/src/ripple/peerfinder/impl/SourceStrings.cpp index 8532cc5f68..7d3e1d81bf 100644 --- a/src/ripple/peerfinder/impl/SourceStrings.cpp +++ b/src/ripple/peerfinder/impl/SourceStrings.cpp @@ -44,8 +44,8 @@ public: results.list.reserve (m_strings.size()); for (int i = 0; i < m_strings.size (); ++i) { - IPEndpoint ep ( - IPEndpoint::from_string_altform ( + IPAddress ep ( + IPAddress::from_string_altform ( m_strings [i])); if (! ep.empty()) results.list.push_back (ep); diff --git a/src/ripple/peerfinder/impl/Store.h b/src/ripple/peerfinder/impl/Store.h index 042ec13f75..cc676305f2 100644 --- a/src/ripple/peerfinder/impl/Store.h +++ b/src/ripple/peerfinder/impl/Store.h @@ -30,7 +30,7 @@ public: virtual ~Store () { } virtual void loadLegacyEndpoints ( - std::vector & list) = 0; + std::vector & list) = 0; virtual void updateLegacyEndpoints ( std::vector const& list) = 0; diff --git a/src/ripple/peerfinder/impl/StoreSqdb.h b/src/ripple/peerfinder/impl/StoreSqdb.h index afaae37178..2ad17dc895 100644 --- a/src/ripple/peerfinder/impl/StoreSqdb.h +++ b/src/ripple/peerfinder/impl/StoreSqdb.h @@ -64,7 +64,7 @@ public: } void loadLegacyEndpoints ( - std::vector & list) + std::vector & list) { list.clear (); @@ -99,7 +99,7 @@ public: { do { - IPEndpoint ep (IPEndpoint::from_string (s)); + IPAddress ep (IPAddress::from_string (s)); if (! ep.empty()) list.push_back (ep); } @@ -140,7 +140,7 @@ public: for (List::const_iterator iter (list.begin()); !error && iter != list.end(); ++iter) { - IPEndpoint const& ep ((*iter)->address); + IPAddress const& ep ((*iter)->address); s = ep.to_string(); st.execute_and_fetch (error); } diff --git a/src/ripple/resource/api/Gossip.h b/src/ripple/resource/api/Gossip.h index a3ee1ea19b..60076c8040 100644 --- a/src/ripple/resource/api/Gossip.h +++ b/src/ripple/resource/api/Gossip.h @@ -30,7 +30,7 @@ struct Gossip struct Item { int balance; - IPEndpoint address; + IPAddress address; }; std::vector items; diff --git a/src/ripple/resource/api/Manager.h b/src/ripple/resource/api/Manager.h index cee8ce62bf..afdcf771dc 100644 --- a/src/ripple/resource/api/Manager.h +++ b/src/ripple/resource/api/Manager.h @@ -35,10 +35,10 @@ public: virtual ~Manager() { } /** Create a new endpoint keyed by inbound IP address. */ - virtual Consumer newInboundEndpoint (IPEndpoint const& address) = 0; + virtual Consumer newInboundEndpoint (IPAddress const& address) = 0; /** Create a new endpoint keyed by outbound IP address and port. */ - virtual Consumer newOutboundEndpoint (IPEndpoint const& address) = 0; + virtual Consumer newOutboundEndpoint (IPAddress const& address) = 0; /** Create a new endpoint keyed by name. */ virtual Consumer newAdminEndpoint (std::string const& name) = 0; diff --git a/src/ripple/resource/impl/Key.h b/src/ripple/resource/impl/Key.h index 69cb60c830..889909b788 100644 --- a/src/ripple/resource/impl/Key.h +++ b/src/ripple/resource/impl/Key.h @@ -27,7 +27,7 @@ namespace Resource { struct Key { Kind kind; - IPEndpoint address; + IPAddress address; std::string name; struct hasher @@ -51,7 +51,7 @@ struct Key } private: - IPEndpoint::hasher m_addr_hash; + IPAddress::hasher m_addr_hash; boost::hash m_name_hash; }; diff --git a/src/ripple/resource/impl/Logic.h b/src/ripple/resource/impl/Logic.h index 791a3b861a..5cd8d5db1c 100644 --- a/src/ripple/resource/impl/Logic.h +++ b/src/ripple/resource/impl/Logic.h @@ -85,7 +85,7 @@ public: state->table.clear(); } - Consumer newInboundEndpoint (IPEndpoint const& address) + Consumer newInboundEndpoint (IPAddress const& address) { if (isWhitelisted (address)) return newAdminEndpoint (address.to_string()); @@ -117,7 +117,7 @@ public: return Consumer (*this, *entry); } - Consumer newOutboundEndpoint (IPEndpoint const& address) + Consumer newOutboundEndpoint (IPAddress const& address) { if (isWhitelisted (address)) return newAdminEndpoint (address.to_string()); @@ -294,7 +294,7 @@ public: //-------------------------------------------------------------------------- - bool isWhitelisted (IPEndpoint const& address) + bool isWhitelisted (IPAddress const& address) { if (! address.isPublic()) return true; diff --git a/src/ripple/resource/impl/Manager.cpp b/src/ripple/resource/impl/Manager.cpp index bd8a6f8548..5c3261622f 100644 --- a/src/ripple/resource/impl/Manager.cpp +++ b/src/ripple/resource/impl/Manager.cpp @@ -41,12 +41,12 @@ public: stopThread (); } - Consumer newInboundEndpoint (IPEndpoint const& address) + Consumer newInboundEndpoint (IPAddress const& address) { return m_logic.newInboundEndpoint (address); } - Consumer newOutboundEndpoint (IPEndpoint const& address) + Consumer newOutboundEndpoint (IPAddress const& address) { return m_logic.newOutboundEndpoint (address); } diff --git a/src/ripple/resource/impl/Tests.cpp b/src/ripple/resource/impl/Tests.cpp index d4bcac90d3..47ac660271 100644 --- a/src/ripple/resource/impl/Tests.cpp +++ b/src/ripple/resource/impl/Tests.cpp @@ -32,7 +32,7 @@ public: { Gossip::Item item; item.balance = 100 + random().nextInt (500); - item.address = IPEndpoint (IPEndpoint::V4 ( + item.address = IPAddress (IPAddress::V4 ( 207, 127, 82, v + i)); gossip.items.push_back (item); } @@ -64,7 +64,7 @@ public: Gossip g; Gossip::Item item; item.balance = 100; - item.address = IPEndpoint (IPEndpoint::V4 (207, 127, 82, 1)); + item.address = IPAddress (IPAddress::V4 (207, 127, 82, 1)); g.items.push_back (item); logic.importConsumers ("g", g); @@ -79,7 +79,7 @@ public: LogicType logic (journal()); { - IPEndpoint address (IPEndpoint::from_string ("207.127.82.1")); + IPAddress address (IPAddress::from_string ("207.127.82.1")); Consumer c (logic.newInboundEndpoint (address)); logMessage ("Charging " + c.label() + " 10,000 units"); c.charge (10000); @@ -93,7 +93,7 @@ public: } { - IPEndpoint address (IPEndpoint::from_string ("207.127.82.2")); + IPAddress address (IPAddress::from_string ("207.127.82.2")); Consumer c (logic.newInboundEndpoint (address)); logMessage ("Charging " + c.label() + " 1000 units per second"); for (int i = 0; i < 128; ++i) diff --git a/src/ripple_app/main/RPCHTTPServer.cpp b/src/ripple_app/main/RPCHTTPServer.cpp index 626852a3cc..af3a749cf0 100644 --- a/src/ripple_app/main/RPCHTTPServer.cpp +++ b/src/ripple_app/main/RPCHTTPServer.cpp @@ -65,7 +65,7 @@ public: if (! getConfig ().getRpcIP().empty () && getConfig ().getRpcPort() != 0) { - IPEndpoint ep (IPEndpoint::from_string (getConfig().getRpcIP())); + IPAddress ep (IPAddress::from_string (getConfig().getRpcIP())); if (! ep.empty()) { HTTP::Port port; diff --git a/src/ripple_app/peers/Peer.cpp b/src/ripple_app/peers/Peer.cpp index b732e62b9a..8e5de9466f 100644 --- a/src/ripple_app/peers/Peer.cpp +++ b/src/ripple_app/peers/Peer.cpp @@ -119,9 +119,9 @@ private: protocol::TMHello mHello; bool m_remoteAddressSet; - IPEndpoint m_remoteAddress; + IPAddress m_remoteAddress; Resource::Consumer m_usage; - + public: static char const* getCountedObjectName () { return "Peer"; } @@ -215,7 +215,7 @@ public: return (uMin >= mMinLedger) && (uMax <= mMaxLedger); } - IPEndpoint getPeerEndpoint() const + IPAddress getPeerEndpoint() const { return m_remoteAddress; } @@ -308,6 +308,7 @@ private: } else { + if (m_socket->getFlags ().set (MultiSocket::Flag::proxy) && m_isInbound) { MultiSocket::ProxyInfo const proxyInfo (m_socket->getProxyInfo ()); @@ -315,7 +316,7 @@ private: if (proxyInfo.protocol == "TCP4") { m_remoteAddressSet = true; - m_remoteAddress = IPEndpoint (IPEndpoint::V4 ( + m_remoteAddress = IPAddress (IPAddress::V4 ( proxyInfo.sourceAddress.value [0], proxyInfo.sourceAddress.value [1], proxyInfo.sourceAddress.value [2], @@ -359,7 +360,7 @@ private: if (addr.is_v4()) { boost::asio::ip::address_v4::bytes_type bytes (addr.to_v4().to_bytes()); - m_remoteAddress = IPEndpoint (IPEndpoint::V4 ( + m_remoteAddress = IPAddress (IPAddress::V4 ( bytes[0], bytes[1], bytes[2], bytes[3]), 0); if (! m_isInbound) m_remoteAddress = m_remoteAddress.withPort ( @@ -1693,8 +1694,8 @@ void PeerImp::recvPeers (protocol::TMPeers& packet) addr.s_addr = packet.nodes (i).ipv4 (); { - IPEndpoint::V4 v4 (ntohl (addr.s_addr)); - IPEndpoint ep (v4, packet.nodes (i).ipv4port ()); + IPAddress::V4 v4 (ntohl (addr.s_addr)); + IPAddress ep (v4, packet.nodes (i).ipv4port ()); getApp().getPeers().getPeerFinder().onPeerLegacyEndpoint (ep); } @@ -1729,8 +1730,8 @@ void PeerImp::recvEndpoints (protocol::TMEndpoints& packet) { in_addr addr; addr.s_addr = tm.ipv4().ipv4(); - IPEndpoint::V4 v4 (ntohl (addr.s_addr)); - endpoint.address = IPEndpoint (v4, tm.ipv4().ipv4port ()); + IPAddress::V4 v4 (ntohl (addr.s_addr)); + endpoint.address = IPAddress (v4, tm.ipv4().ipv4port ()); } else { diff --git a/src/ripple_app/peers/Peer.h b/src/ripple_app/peers/Peer.h index 386ec801bd..f494b9624b 100644 --- a/src/ripple_app/peers/Peer.h +++ b/src/ripple_app/peers/Peer.h @@ -109,7 +109,7 @@ public: virtual bool hasRange (uint32 uMin, uint32 uMax) = 0; - virtual IPEndpoint getPeerEndpoint() const = 0; + virtual IPAddress getPeerEndpoint() const = 0; //-------------------------------------------------------------------------- diff --git a/src/ripple_app/peers/Peers.cpp b/src/ripple_app/peers/Peers.cpp index 183919857a..27ecfa098f 100644 --- a/src/ripple_app/peers/Peers.cpp +++ b/src/ripple_app/peers/Peers.cpp @@ -189,9 +189,9 @@ public: } } - void connectPeerEndpoints (std::vector const& list) + void connectPeerEndpoints (std::vector const& list) { - typedef std::vector List; + typedef std::vector List; for (List::const_iterator iter (list.begin()); iter != list.end(); ++iter) diff --git a/src/ripple_app/websocket/WSConnection.h b/src/ripple_app/websocket/WSConnection.h index c8d58edba9..4e3acc8cce 100644 --- a/src/ripple_app/websocket/WSConnection.h +++ b/src/ripple_app/websocket/WSConnection.h @@ -92,10 +92,10 @@ public: typedef WSServerHandler server_type; public: - static IPEndpoint from_address (boost::asio::ip::address const& addr) + static IPAddress from_address (boost::asio::ip::address const& addr) { boost::asio::ip::address_v4::bytes_type bytes (addr.to_v4().to_bytes()); - IPEndpoint ep (IPEndpoint::V4 (bytes[0], bytes[1], bytes[2], bytes[3]), 0); + IPAddress ep (IPAddress::V4 (bytes[0], bytes[1], bytes[2], bytes[3]), 0); return ep; }