void ServerHandlerImp::setup (beast::Journal journal) { if (! setup_.ip.empty() && setup_.port != 0) { auto ep = beast::IP::Endpoint::from_string (setup_.ip); // VFALCO TODO IP address should not have an "unspecified" state //if (! is_unspecified (ep)) { HTTP::Port port; if (setup_.secure == 0) port.security = HTTP::Port::Security::no_ssl; else if (setup_.secure == 1) port.security = HTTP::Port::Security::allow_ssl; else port.security = HTTP::Port::Security::require_ssl; port.addr = ep.at_port(0); if (setup_.port != 0) port.port = setup_.port; else port.port = ep.port(); port.context = m_context.get (); HTTP::Ports ports; ports.push_back (port); m_server.setPorts (ports); } } else { journal.info << "RPC interface: disabled"; } }
// { // ip: <string>, // port: <number> // } // XXX Might allow domain for manual connections. Json::Value doConnect (RPC::Context& context) { auto lock = beast::make_lock(getApp().getMasterMutex()); if (getConfig ().RUN_STANDALONE) return "cannot connect in standalone mode"; if (!context.params.isMember (jss::ip)) return RPC::missing_field_error (jss::ip); if (context.params.isMember (jss::port) && !context.params[jss::port].isConvertibleTo (Json::intValue)) { return rpcError (rpcINVALID_PARAMS); } int iPort; if(context.params.isMember (jss::port)) iPort = context.params[jss::port].asInt (); else iPort = 6561; auto ip = beast::IP::Endpoint::from_string( context.params[jss::ip].asString ()); if (! is_unspecified (ip)) getApp().overlay ().connect (ip.at_port(iPort)); return RPC::makeObjectValue ("connecting"); }