diff --git a/Builds/VisualStudio2012/RippleD.vcxproj b/Builds/VisualStudio2012/RippleD.vcxproj
index 75f330249b..b4fe0f11ba 100644
--- a/Builds/VisualStudio2012/RippleD.vcxproj
+++ b/Builds/VisualStudio2012/RippleD.vcxproj
@@ -809,7 +809,7 @@
true
true
-
+
true
true
true
@@ -1532,7 +1532,7 @@
-
+
diff --git a/Builds/VisualStudio2012/RippleD.vcxproj.filters b/Builds/VisualStudio2012/RippleD.vcxproj.filters
index 96eb688949..395ecf8e69 100644
--- a/Builds/VisualStudio2012/RippleD.vcxproj.filters
+++ b/Builds/VisualStudio2012/RippleD.vcxproj.filters
@@ -843,9 +843,6 @@
[1] Ripple\ripple_core\validator
-
- [1] Ripple\ripple_core\validator
-
[1] Ripple
@@ -880,6 +877,9 @@
[1] Ripple\ripple_core\functional
+
+ [1] Ripple\ripple_core\validator
+
@@ -1725,9 +1725,6 @@
[1] Ripple\ripple_core\validator
-
- [1] Ripple\ripple_core\validator
-
[1] Ripple\ripple_core\peerfinder
@@ -1735,6 +1732,9 @@
[1] Ripple\ripple_core\functional
+
+ [1] Ripple\ripple_core\validator
+
diff --git a/src/beast/modules/beast_asio/http/HTTPHeaders.cpp b/src/beast/modules/beast_asio/http/HTTPHeaders.cpp
index f28f5113f2..48c460026d 100644
--- a/src/beast/modules/beast_asio/http/HTTPHeaders.cpp
+++ b/src/beast/modules/beast_asio/http/HTTPHeaders.cpp
@@ -72,3 +72,15 @@ String HTTPHeaders::operator[] (String const& field) const
{
return get (field);
}
+
+String HTTPHeaders::toString () const
+{
+ String s;
+ for (int i = 0; i < m_fields.size (); ++i)
+ {
+ HTTPField const field (at(i));
+ s << field.name() << ": " << field.value() << newLine;
+ }
+ return s;
+}
+
diff --git a/src/beast/modules/beast_asio/http/HTTPHeaders.h b/src/beast/modules/beast_asio/http/HTTPHeaders.h
index d2a1a4cad1..6cf7e7e2aa 100644
--- a/src/beast/modules/beast_asio/http/HTTPHeaders.h
+++ b/src/beast/modules/beast_asio/http/HTTPHeaders.h
@@ -61,6 +61,9 @@ public:
String operator[] (String const& field) const;
/** @} */
+ /** Outputs all the headers into one string. */
+ String toString () const;
+
private:
StringPairArray m_fields;
};
diff --git a/src/beast/modules/beast_asio/http/HTTPMessage.cpp b/src/beast/modules/beast_asio/http/HTTPMessage.cpp
index aeb743843e..c08c549bf1 100644
--- a/src/beast/modules/beast_asio/http/HTTPMessage.cpp
+++ b/src/beast/modules/beast_asio/http/HTTPMessage.cpp
@@ -40,3 +40,11 @@ ContentBodyBuffer const& HTTPMessage::body () const
{
return m_body;
}
+
+String HTTPMessage::toString () const
+{
+ String s;
+ s << "HTTP " << version().toString() << newLine;
+ s << m_headers.toString ();
+ return s;
+}
diff --git a/src/beast/modules/beast_asio/http/HTTPMessage.h b/src/beast/modules/beast_asio/http/HTTPMessage.h
index 549d7d43c1..0280b0fb3a 100644
--- a/src/beast/modules/beast_asio/http/HTTPMessage.h
+++ b/src/beast/modules/beast_asio/http/HTTPMessage.h
@@ -51,6 +51,9 @@ public:
/** Returns the content-body. */
ContentBodyBuffer const& body () const;
+ /** Outputs all the HTTPMessage data excluding the body into a string. */
+ String toString () const;
+
private:
HTTPVersion m_version;
HTTPHeaders m_headers;
diff --git a/src/beast/modules/beast_asio/http/HTTPResponse.cpp b/src/beast/modules/beast_asio/http/HTTPResponse.cpp
index 7396127b5c..a4cd89a302 100644
--- a/src/beast/modules/beast_asio/http/HTTPResponse.cpp
+++ b/src/beast/modules/beast_asio/http/HTTPResponse.cpp
@@ -31,3 +31,12 @@ unsigned short HTTPResponse::status () const
{
return m_status;
}
+
+String HTTPResponse::toString () const
+{
+ String s;
+ s << "Status: " << String::fromNumber (status ()) << newLine;
+ s << this->HTTPMessage::toString ();
+ return s;
+}
+
diff --git a/src/beast/modules/beast_asio/http/HTTPResponse.h b/src/beast/modules/beast_asio/http/HTTPResponse.h
index bb3f89cb11..7c7d80ff43 100644
--- a/src/beast/modules/beast_asio/http/HTTPResponse.h
+++ b/src/beast/modules/beast_asio/http/HTTPResponse.h
@@ -35,6 +35,9 @@ public:
unsigned short status () const;
+ /** Convert the response into a string, excluding the body. */
+ String toString () const;
+
private:
unsigned short m_status;
};
diff --git a/src/ripple_app/main/ripple_Application.cpp b/src/ripple_app/main/ripple_Application.cpp
index f5b22fce5d..5fd2e3c796 100644
--- a/src/ripple_app/main/ripple_Application.cpp
+++ b/src/ripple_app/main/ripple_Application.cpp
@@ -223,17 +223,23 @@ public:
// Initialize the Validators object with Config information.
void initValidatorsConfig ()
{
+#if RIPPLE_USE_NEW_VALIDATORS
{
std::vector const& strings (getConfig().validators);
if (! strings.empty ())
m_validators->addStrings (strings);
}
-#if 0
+ /*
+ if (getConfig().getValidatorsFile() != File::nonexistent())
{
- String const& localValidatorsPath (getConfig().localValidatorsPath);
- if (localValidatorsPath != String::empty)
- m_validators->addFile (localValidatorsPath);
+ m_validators->addFile (getConfig().getValidatorsFile());
+ }
+ */
+
+ if (! getConfig().getValidatorsURL().empty())
+ {
+ m_validators->addURL (getConfig().getValidatorsURL());
}
#endif
}
diff --git a/src/ripple_core/functional/Config.cpp b/src/ripple_core/functional/Config.cpp
index 9945af769c..cd3f21b18a 100644
--- a/src/ripple_core/functional/Config.cpp
+++ b/src/ripple_core/functional/Config.cpp
@@ -87,7 +87,7 @@ Config::Config ()
ACCOUNT_PROBE_MAX = 10;
- VALIDATORS_SITE = DEFAULT_VALIDATORS_SITE;
+ VALIDATORS_SITE = "";
SSL_VERIFY = true;
@@ -722,6 +722,17 @@ File Config::getDatabaseDir () const
return File (String (DATA_DIR.native ().c_str ()));
}
+File Config::getValidatorsFile () const
+{
+ return getConfigDir().getChildFile (String (VALIDATORS_FILE.native().c_str()));
+}
+
+UniformResourceLocator Config::getValidatorsURL () const
+{
+ String s = "https://" + VALIDATORS_SITE + VALIDATORS_URI;
+ return ParsedURL (s).url ();
+}
+
//------------------------------------------------------------------------------
void Config::setRpcIpAndOptionalPort (std::string const& newAddress)
diff --git a/src/ripple_core/functional/Config.h b/src/ripple_core/functional/Config.h
index 0c8ead96cc..39cd91a69c 100644
--- a/src/ripple_core/functional/Config.h
+++ b/src/ripple_core/functional/Config.h
@@ -19,8 +19,6 @@
// VFALCO NOTE Set this to 1 to enable code which is unnecessary
#define ENABLE_INSECURE 0
-#define DEFAULT_VALIDATORS_SITE ""
-
const int DOMAIN_BYTES_MAX = 256;
const int PUBLIC_BYTES_MAX = 33; // Maximum bytes for an account public key.
@@ -197,6 +195,12 @@ public:
// Settings related to validators
+ /** Return the path to the separate, optional validators file. */
+ File getValidatorsFile () const;
+
+ /** Returns the optional URL to a trusted network source of validators. */
+ UniformResourceLocator getValidatorsURL () const;
+
boost::filesystem::path VALIDATORS_FILE; // As specifed in rippled.cfg.
//--------------------------------------------------------------------------
diff --git a/src/ripple_core/ripple_core.cpp b/src/ripple_core/ripple_core.cpp
index 40fc22519b..e45dd73642 100644
--- a/src/ripple_core/ripple_core.cpp
+++ b/src/ripple_core/ripple_core.cpp
@@ -67,11 +67,11 @@ namespace ripple
#include "validator/ValidatorsUtilities.cpp"
# include "validator/ValidatorSourceFile.h"
# include "validator/ValidatorSourceStrings.h"
-# include "validator/ValidatorSourceTrustedURL.h"
+# include "validator/ValidatorSourceURL.h"
# include "validator/ValidatorsImp.h"
#include "validator/ValidatorSourceFile.cpp"
#include "validator/ValidatorSourceStrings.cpp"
-#include "validator/ValidatorSourceTrustedURL.cpp"
+#include "validator/ValidatorSourceURL.cpp"
#include "validator/Validators.cpp"
#include "peerfinder/ripple_PeerFinder.h" // private (for now)
diff --git a/src/ripple_core/validator/ValidatorSourceStrings.cpp b/src/ripple_core/validator/ValidatorSourceStrings.cpp
index bc3c5360ee..2ab8d2cc78 100644
--- a/src/ripple_core/validator/ValidatorSourceStrings.cpp
+++ b/src/ripple_core/validator/ValidatorSourceStrings.cpp
@@ -8,6 +8,7 @@ class ValidatorSourceStringsImp : public ValidatorSourceStrings
{
public:
ValidatorSourceStringsImp (StringArray const& strings)
+ : m_strings (strings)
{
}
@@ -18,11 +19,21 @@ public:
Result fetch (CancelCallback&)
{
Result result;
-
+
+ result.list.ensureStorageAllocated (m_strings.size ());
+
+ for (int i = 0; i < m_strings.size (); ++i)
+ {
+ ValidatorsUtilities::parseResultLine (result, m_strings [i]);
+ }
+
+ result.success = result.list.size () > 0;
+ result.expirationTime = Time::getCurrentTime () + RelativeTime::hours (24);
return result;
}
private:
+ StringArray m_strings;
};
//------------------------------------------------------------------------------
diff --git a/src/ripple_core/validator/ValidatorSourceTrustedURL.cpp b/src/ripple_core/validator/ValidatorSourceURL.cpp
similarity index 68%
rename from src/ripple_core/validator/ValidatorSourceTrustedURL.cpp
rename to src/ripple_core/validator/ValidatorSourceURL.cpp
index 98bca1a63b..039c3ac838 100644
--- a/src/ripple_core/validator/ValidatorSourceTrustedURL.cpp
+++ b/src/ripple_core/validator/ValidatorSourceURL.cpp
@@ -4,15 +4,15 @@
*/
//==============================================================================
-class ValidatorSourceTrustedURLImp : public ValidatorSourceTrustedURL
+class ValidatorSourceURLImp : public ValidatorSourceURL
{
public:
- explicit ValidatorSourceTrustedURLImp (UniformResourceLocator const& url)
+ explicit ValidatorSourceURLImp (UniformResourceLocator const& url)
: m_url (url)
{
}
- ~ValidatorSourceTrustedURLImp ()
+ ~ValidatorSourceURLImp ()
{
}
@@ -37,11 +37,11 @@ private:
//------------------------------------------------------------------------------
-ValidatorSourceTrustedURL* ValidatorSourceTrustedURL::New (
+ValidatorSourceURL* ValidatorSourceURL::New (
UniformResourceLocator const& url)
{
- ScopedPointer object (
- new ValidatorSourceTrustedURLImp (url));
+ ScopedPointer object (
+ new ValidatorSourceURLImp (url));
return object.release ();
}
diff --git a/src/ripple_core/validator/ValidatorSourceTrustedURL.h b/src/ripple_core/validator/ValidatorSourceURL.h
similarity index 75%
rename from src/ripple_core/validator/ValidatorSourceTrustedURL.h
rename to src/ripple_core/validator/ValidatorSourceURL.h
index b7fe122d17..df3c55fa64 100644
--- a/src/ripple_core/validator/ValidatorSourceTrustedURL.h
+++ b/src/ripple_core/validator/ValidatorSourceURL.h
@@ -9,10 +9,10 @@
/** Provides validators from a trusted URI (e.g. HTTPS)
*/
-class ValidatorSourceTrustedURL : public Validators::Source
+class ValidatorSourceURL : public Validators::Source
{
public:
- static ValidatorSourceTrustedURL* New (UniformResourceLocator const& url);
+ static ValidatorSourceURL* New (UniformResourceLocator const& url);
};
#endif
diff --git a/src/ripple_core/validator/Validators.h b/src/ripple_core/validator/Validators.h
index 9a9e356a91..3e29049ee4 100644
--- a/src/ripple_core/validator/Validators.h
+++ b/src/ripple_core/validator/Validators.h
@@ -57,6 +57,7 @@ public:
bool success;
String message;
+ Time expirationTime;
Array list;
};
virtual Result fetch (CancelCallback& callback) = 0;
@@ -99,7 +100,7 @@ public:
/** Add a live source of validators from a trusted URL.
The URL will be contacted periodically to update the list.
*/
- virtual void addTrustedURL (UniformResourceLocator const& url) = 0;
+ virtual void addURL (UniformResourceLocator const& url) = 0;
/** Add a live source of validators.
The caller loses ownership of the object.
diff --git a/src/ripple_core/validator/ValidatorsImp.h b/src/ripple_core/validator/ValidatorsImp.h
index 57217c4672..880897ecb5 100644
--- a/src/ripple_core/validator/ValidatorsImp.h
+++ b/src/ripple_core/validator/ValidatorsImp.h
@@ -406,9 +406,9 @@ public:
addStaticSource (ValidatorSourceFile::New (path));
}
- void addTrustedURL (UniformResourceLocator const& url)
+ void addURL (UniformResourceLocator const& url)
{
- addSource (ValidatorSourceTrustedURL::New (url));
+ addSource (ValidatorSourceURL::New (url));
}
void addSource (Source* source)
diff --git a/src/ripple_core/validator/ValidatorsUtilities.cpp b/src/ripple_core/validator/ValidatorsUtilities.cpp
index 121e1743be..38a02a17ca 100644
--- a/src/ripple_core/validator/ValidatorsUtilities.cpp
+++ b/src/ripple_core/validator/ValidatorsUtilities.cpp
@@ -4,3 +4,27 @@
*/
//==============================================================================
+bool ValidatorsUtilities::parseInfoLine (Validators::Source::Info& info, String line)
+{
+ bool success (false);
+
+ return success;
+}
+
+void ValidatorsUtilities::parseResultLine (
+ Validators::Source::Result& result,
+ String line)
+{
+ bool success = false;
+
+ if (! success)
+ {
+ Validators::Source::Info info;
+
+ success = parseInfoLine (info, line);
+ if (success)
+ result.list.add (info);
+ }
+
+
+}
diff --git a/src/ripple_core/validator/ValidatorsUtilities.h b/src/ripple_core/validator/ValidatorsUtilities.h
index 6559a2bdae..e4af592068 100644
--- a/src/ripple_core/validator/ValidatorsUtilities.h
+++ b/src/ripple_core/validator/ValidatorsUtilities.h
@@ -14,12 +14,7 @@ class ValidatorsUtilities
public:
typedef std::vector Strings;
- /** Turn a linear buffer of newline delimited text into strings.
- This can be called incrementally, i.e. successive calls with
- multiple buffer segments.
- */
- static void parseLines (Strings& lines, char const* buf, std::size_t bytes);
-
+#if 0
/** Parse a ConstBufferSequence of newline delimited text into strings.
This works incrementally.
*/
@@ -30,6 +25,28 @@ public:
iter != buffers.end (); ++iter)
parserLines (lines, *iter);
}
+
+ /** Turn a linear buffer of newline delimited text into strings.
+ This can be called incrementally, i.e. successive calls with
+ multiple buffer segments.
+ */
+ static void parseLines (Strings& lines, char const* buf, std::size_t bytes);
+#endif
+
+ /** Parse a string into the Source::Result.
+ Invalid or comment lines will be skipped.
+ Lines containing validator info will be added to the Result object.
+ Metadata lines will update the corresponding Result fields.
+ */
+ static void parseResultLine (
+ Validators::Source::Result& result,
+ String line);
+
+private:
+ /** Parse a string into a Source::Info.
+ @return `true` on success.
+ */
+ static bool parseInfoLine (Validators::Source::Info& info, String line);
};
#endif