Universal Port (RIPD-160):

This changes the behavior and configuration specification of the listening
ports that rippled uses to accept incoming connections for the supported
protocols: peer (Peer Protocol), http (JSON-RPC over HTTP), https (JSON-RPC)
over HTTPS, ws (Websockets Clients), and wss (Secure Websockets Clients).
Each listening port is now capable of handshaking in multiple protocols
specified in the configuration file (subject to some restrictions). Each
port can be configured to provide its own SSL certificate, or to use a
self-signed certificate. Ports can be configured to share settings, this
allows multiple ports to use the same certificate or values. The list of
ports is dynamic, administrators can open as few or as many ports as they
like. Authentication settings such as user/password or admin user/admin
password (for administrative commands on RPC or Websockets interfaces) can
also be specified per-port.

As the configuration file has changed significantly, administrators will
need to update their ripple.cfg files and carefully review the documentation
and new settings.

Changes:

* rippled-example.cfg updated with documentation and new example settings:
  All obsolete websocket, rpc, and peer configuration sections have been
  removed, the documentation updated, and a new documented set of example
  settings added.

* HTTP::Writer abstraction for sending HTTP server requests and responses
* HTTP::Handler handler improvements to support Universal Port
* HTTP::Handler handler supports legacy Peer protocol handshakes
* HTTP::Port uses shared_ptr<boost::asio::ssl::context>
* HTTP::PeerImp and Overlay use ssl_bundle to support Universal Port
* New JsonWriter to stream message and body through HTTP server
* ServerHandler refactored to support Universal Port and legacy peers
* ServerHandler Setup struct updated for Universal Port
* Refactor some PeerFinder members
* WSDoor and Websocket code stores and uses the HTTP::Port configuration
* Websocket autotls class receives the current secure/plain SSL setting
* Remove PeerDoor and obsolete Overlay peer accept code
* Remove obsolete RPCDoor and synchronous RPC handling code
* Remove other obsolete classes, types, and files
* Command line tool uses ServerHandler Setup for port and authorization info
* Fix handling of admin_user, admin_password in administrative commands
* Fix adminRole to check credentials for Universal Port
* Updated Overlay README.md

* Overlay sends IP:port redirects on HTTP Upgrade peer connection requests:
  Incoming peers who handshake using the HTTP Upgrade mechanism don't get
  a slot, and always get HTTP Status 503 redirect containing a JSON
  content-body with a set of alternate IP and port addresses to try, learned
  from PeerFinder. A future commit related to the Hub and Spoke feature will
  change the response to grant the peer a slot when there are peer slots
  available.

* HTTP responses to outgoing Peer connect requests parse redirect IP:ports:
  When the [overlay] configuration section (which is experimental) has
  http_handshake = 1, HTTP redirect responses will have the JSON content-body
  parsed to obtain the redirect IP:port addresses.

* Use a single io_service for HTTP::Server and Overlay:
  This is necessary to allow HTTP::Server to pass sockets to and from Overlay
  and eventually Websockets. Unfortunately Websockets is not so easily changed
  to use an externally provided io_service. This will be addressed in a future
  commit, and is one step necessary ease the restriction on ports configured
  to offer Websocket protocols in the .cfg file.
This commit is contained in:
Vinnie Falco
2014-10-31 13:32:28 -07:00
parent e37d4043f6
commit ac0eaa912b
94 changed files with 3376 additions and 3052 deletions

View File

@@ -62,8 +62,6 @@ parseKeyValueSection (IniFileSections& secSource, std::string const& strSection)
//------------------------------------------------------------------------------
const int SYSTEM_PEER_PORT = 6561;
enum SizedItemName
{
siSweepInterval,
@@ -151,69 +149,9 @@ public:
// DEPRECATED
boost::filesystem::path VALIDATORS_FILE; // As specifed in rippled.cfg.
//--------------------------------------------------------------------------
// Settings related to RPC
/** Get the client or server RPC IP address.
@note The string may not always be in a valid parsable state.
@return A string representing the address.
*/
std::string getRpcIP () const { return m_rpcIP; }
/** Get the client or server RPC port number.
@note The port number may be invalid (out of range or zero)
@return The RPC port number.
*/
int getRpcPort () const { return m_rpcPort; }
/** Set the client or server RPC IP and optional port.
@note The string is not syntax checked.
@param newAddress A string in the format <ip-address>[':'<port-number>]
*/
void setRpcIpAndOptionalPort (std::string const& newAddress);
/** Set the client or server RPC IP.
@note The string is not syntax-checked.
@param newIP A string representing the IP address to use.
*/
void setRpcIP (std::string const& newIP) { m_rpcIP = newIP; }
/** Set the client or server RPC port number.
@note The port number is not range checked.
@param newPort The RPC port number to use.
*/
void setRpcPort (int newPort) { m_rpcPort = newPort; }
/** Convert the RPC/port combination to a readable string.
*/
std::string const getRpcAddress ()
{
return m_rpcIP + ":" + std::to_string (m_rpcPort);
}
/** Determine the level of administrative permission to grant.
*/
// VFALCO TODO Get this out of here
enum Role
{
GUEST,
USER,
ADMIN,
FORBID
};
Role getAdminRole (Json::Value const& params, beast::IP::Endpoint const& remoteIp) const;
/** Listening port number for peer connections. */
int peerListeningPort;
/** List of Validators entries from rippled.cfg */
std::vector <std::string> validators;
private:
std::string m_rpcIP;
int m_rpcPort; // VFALCO TODO This should be a short.
private:
/** The folder where new module databases should be located */
beast::File m_moduleDbPath;
@@ -318,39 +256,15 @@ public:
int VALIDATION_QUORUM; // Minimum validations to consider ledger authoritative
// Peer networking parameters
std::string PEER_IP;
bool PEER_PRIVATE; // True to ask peers not to relay current IP.
unsigned int PEERS_MAX;
// Websocket networking parameters
std::string WEBSOCKET_PUBLIC_IP; // XXX Going away. Merge with the inbound peer connction.
int WEBSOCKET_PUBLIC_PORT;
int WEBSOCKET_PUBLIC_SECURE;
std::string WEBSOCKET_IP;
int WEBSOCKET_PORT;
int WEBSOCKET_SECURE;
int WEBSOCKET_PING_FREQ;
std::string WEBSOCKET_SSL_CERT;
std::string WEBSOCKET_SSL_CHAIN;
std::string WEBSOCKET_SSL_KEY;
// RPC parameters
std::vector<beast::IP::Endpoint> RPC_ADMIN_ALLOW;
std::string RPC_ADMIN_PASSWORD;
std::string RPC_ADMIN_USER;
std::string RPC_PASSWORD;
std::string RPC_USER;
bool RPC_ALLOW_REMOTE;
Json::Value RPC_STARTUP;
int RPC_SECURE;
std::string RPC_SSL_CERT;
std::string RPC_SSL_CHAIN;
std::string RPC_SSL_KEY;
// Path searching
int PATH_SEARCH_OLD;
int PATH_SEARCH;
@@ -399,36 +313,10 @@ public:
int getSize (SizedItemName);
void setup (std::string const& strConf, bool bQuiet);
void load ();
private:
void build_legacy();
};
extern Config& getConfig ();
//------------------------------------------------------------------------------
namespace RPC {
struct Setup
{
bool allow_remote = false;
std::string admin_user;
std::string admin_password;
std::string ip;
int port = 5001;
std::string user;
std::string password;
int secure = 0;
std::string ssl_cert;
std::string ssl_chain;
std::string ssl_key;
};
}
RPC::Setup
setup_RPC (Section const& s);
// VFALCO DEPRECATED
extern Config& getConfig();
} // ripple