|
|
@ -35,6 +35,7 @@ |
|
|
|
#include <fstream> |
|
|
|
#include <fstream> |
|
|
|
#include <streambuf> |
|
|
|
#include <streambuf> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef ENABLE_WS |
|
|
|
#include <websocketpp/config/asio_no_tls_client.hpp> |
|
|
|
#include <websocketpp/config/asio_no_tls_client.hpp> |
|
|
|
#include <websocketpp/client.hpp> |
|
|
|
#include <websocketpp/client.hpp> |
|
|
|
#include <websocketpp/config/asio_no_tls.hpp> |
|
|
|
#include <websocketpp/config/asio_no_tls.hpp> |
|
|
@ -57,6 +58,7 @@ typedef websocketpp::lib::shared_ptr<websocketpp::lib::asio::ssl::context> conte |
|
|
|
wsserver wss; |
|
|
|
wsserver wss; |
|
|
|
swsserver swss; |
|
|
|
swsserver swss; |
|
|
|
vector<websocketpp::connection_hdl> wsconnections; |
|
|
|
vector<websocketpp::connection_hdl> wsconnections; |
|
|
|
|
|
|
|
#endif // ENABLE_WS
|
|
|
|
|
|
|
|
|
|
|
|
using namespace std; |
|
|
|
using namespace std; |
|
|
|
using namespace boost; |
|
|
|
using namespace boost; |
|
|
@ -313,7 +315,6 @@ static const CRPCCommand vRPCCommands[] = |
|
|
|
{ "uidtousername", &uidtousername, false, true, true }, |
|
|
|
{ "uidtousername", &uidtousername, false, true, true }, |
|
|
|
{ "newshorturl", &newshorturl, false, true, false }, |
|
|
|
{ "newshorturl", &newshorturl, false, true, false }, |
|
|
|
{ "decodeshorturl", &decodeshorturl, false, true, true }, |
|
|
|
{ "decodeshorturl", &decodeshorturl, false, true, true }, |
|
|
|
// { "openwebsocket", &openwebsocket, false, true, true },
|
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
CRPCTable::CRPCTable() |
|
|
|
CRPCTable::CRPCTable() |
|
|
@ -783,6 +784,7 @@ static void RPCAcceptHandler(boost::shared_ptr< basic_socket_acceptor<Protocol> |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef ENABLE_WS |
|
|
|
template <class WST> |
|
|
|
template <class WST> |
|
|
|
void on_message_server(WST *s, websocketpp::connection_hdl hdl, message_ptr msg); |
|
|
|
void on_message_server(WST *s, websocketpp::connection_hdl hdl, message_ptr msg); |
|
|
|
template <class WST> |
|
|
|
template <class WST> |
|
|
@ -890,10 +892,12 @@ void StartWSServer(WST &ws) |
|
|
|
std::cout << "other exception" << std::endl; |
|
|
|
std::cout << "other exception" << std::endl; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endif // ENABLE_WS
|
|
|
|
|
|
|
|
|
|
|
|
void StartRPCThreads() |
|
|
|
void StartRPCThreads() |
|
|
|
{ |
|
|
|
{ |
|
|
|
const bool fUseSSL = GetBoolArg("-rpcssl", false); |
|
|
|
const bool fUseSSL = GetBoolArg("-rpcssl", false); |
|
|
|
|
|
|
|
#ifdef ENABLE_WS |
|
|
|
if (GetBoolArg("-websocket", false)) |
|
|
|
if (GetBoolArg("-websocket", false)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (fUseSSL) |
|
|
|
if (fUseSSL) |
|
|
@ -901,8 +905,7 @@ void StartRPCThreads() |
|
|
|
else |
|
|
|
else |
|
|
|
boost::thread wst(boost::bind(&StartWSServer<wsserver>, boost::ref<wsserver>(wss))); |
|
|
|
boost::thread wst(boost::bind(&StartWSServer<wsserver>, boost::ref<wsserver>(wss))); |
|
|
|
} |
|
|
|
} |
|
|
|
if (!GetBoolArg("-jsonrpc", true)) |
|
|
|
#endif // ENABLE_WS
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
strRPCUserColonPass = mapArgs["-rpcuser"] + ":" + mapArgs["-rpcpassword"]; |
|
|
|
strRPCUserColonPass = mapArgs["-rpcuser"] + ":" + mapArgs["-rpcpassword"]; |
|
|
|
if (((mapArgs["-rpcpassword"] == "") || |
|
|
|
if (((mapArgs["-rpcpassword"] == "") || |
|
|
@ -1316,6 +1319,7 @@ json_spirit::Value CRPCTable::execute(const std::string &strMethod, const json_s |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef ENABLE_WS |
|
|
|
template <class WST> |
|
|
|
template <class WST> |
|
|
|
void on_message_client(WST* c, websocketpp::connection_hdl hdl, message_ptr msg) |
|
|
|
void on_message_client(WST* c, websocketpp::connection_hdl hdl, message_ptr msg) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1450,10 +1454,12 @@ Object StartWSClient(bool fUseSSL) |
|
|
|
reply.push_back(Pair("result", "OK")); |
|
|
|
reply.push_back(Pair("result", "OK")); |
|
|
|
return reply; |
|
|
|
return reply; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endif // ENABLE_WS
|
|
|
|
|
|
|
|
|
|
|
|
Object CallRPC(const string& strMethod, const Array& params) |
|
|
|
Object CallRPC(const string& strMethod, const Array& params) |
|
|
|
{ |
|
|
|
{ |
|
|
|
bool fUseSSL = GetBoolArg("-rpcssl", false); |
|
|
|
bool fUseSSL = GetBoolArg("-rpcssl", false); |
|
|
|
|
|
|
|
#ifdef ENABLE_WS |
|
|
|
if (strMethod == "openwebsocket") |
|
|
|
if (strMethod == "openwebsocket") |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (fUseSSL) |
|
|
|
if (fUseSSL) |
|
|
@ -1461,6 +1467,7 @@ Object CallRPC(const string& strMethod, const Array& params) |
|
|
|
else |
|
|
|
else |
|
|
|
return StartWSClient<wsclient>(fUseSSL); |
|
|
|
return StartWSClient<wsclient>(fUseSSL); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endif // ENABLE_WS
|
|
|
|
|
|
|
|
|
|
|
|
if (mapArgs["-rpcuser"] == "" && mapArgs["-rpcpassword"] == "") |
|
|
|
if (mapArgs["-rpcuser"] == "" && mapArgs["-rpcpassword"] == "") |
|
|
|
throw runtime_error(strprintf( |
|
|
|
throw runtime_error(strprintf( |
|
|
@ -1728,6 +1735,7 @@ int CommandLineRPC(int argc, char *argv[]) |
|
|
|
return nRet; |
|
|
|
return nRet; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef ENABLE_WS |
|
|
|
template <class WST> |
|
|
|
template <class WST> |
|
|
|
void on_message_server(WST* s, websocketpp::connection_hdl hdl, message_ptr msg) |
|
|
|
void on_message_server(WST* s, websocketpp::connection_hdl hdl, message_ptr msg) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1817,7 +1825,7 @@ void WriteToWS(Value const& val) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endif // ENABLE_WS
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef TEST |
|
|
|
#ifdef TEST |
|
|
|
int main(int argc, char *argv[]) |
|
|
|
int main(int argc, char *argv[]) |
|
|
|