mirror of
https://github.com/twisterarmy/twister-core.git
synced 2025-03-09 20:11:14 +00:00
makes websocket optional
This commit is contained in:
parent
158f42e610
commit
8d060063e3
@ -1,7 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
git submodule update --init
|
||||
|
||||
./autotool.sh
|
||||
./configure $@
|
||||
|
||||
|
24
configure.ac
24
configure.ac
@ -420,6 +420,14 @@ AC_ARG_WITH(
|
||||
[[ARG_WITH_LIBICONV=no]]
|
||||
)
|
||||
|
||||
AC_ARG_ENABLE(
|
||||
[websocket],
|
||||
[AS_HELP_STRING(
|
||||
[--enable-websocket],
|
||||
[enable websocket [default=no]])],
|
||||
[[ARG_ENABLE_WS=$enableval]],
|
||||
[[ARG_ENABLE_WS=no]]
|
||||
)
|
||||
###############################################################################
|
||||
# Checking configure options
|
||||
###############################################################################
|
||||
@ -631,6 +639,20 @@ AS_CASE(["$ARG_ENABLE_RSS"],
|
||||
AC_MSG_ERROR([Unknown option "$ARG_ENABLE_RSS". Use either "yes" or "no".])]
|
||||
)
|
||||
|
||||
AC_MSG_CHECKING([whether websocket should be enabled])
|
||||
AS_CASE(["$ARG_ENABLE_WS"],
|
||||
["yes"|"on"], [
|
||||
AC_MSG_RESULT([yes])
|
||||
AC_DEFINE([ENABLE_WS],[1],[Enable WebSocket])
|
||||
CXXFLAGS="$CXXFLAGS -DENABLE_WS "
|
||||
],
|
||||
["no"|"off"], [
|
||||
AC_MSG_RESULT([no])
|
||||
],
|
||||
[AC_MSG_RESULT([$ARG_ENABLE_WS])
|
||||
AC_MSG_ERROR([Unknown option "$ARG_ENABLE_WS". Use either "yes" or "no".])]
|
||||
)
|
||||
|
||||
AS_ECHO
|
||||
AS_ECHO "Checking for extra build files:"
|
||||
|
||||
@ -749,6 +771,7 @@ AM_CONDITIONAL([WITH_SHIPPED_GEOIP], [test "x$ARG_WITH_LIBGEOIP" = "xno" ])
|
||||
AM_CONDITIONAL([WITH_OPENSSL], [test "x$ARG_ENABLE_ENCRYPTION" = "xyes" -o "x$ARG_ENABLE_ENCRYPTION" = "xon" ])
|
||||
AM_CONDITIONAL([USE_SSE2], [test "x$ARG_ENABLE_SSE2" = "xyes" -o "x$ARG_ENABLE_SSE2" = "xon" ])
|
||||
AM_CONDITIONAL([ENABLE_RSS], [test "x$ARG_ENABLE_RSS" = "xyes" -o "x$ARG_ENABLE_RSS" = "xon" ])
|
||||
AM_CONDITIONAL([ENABLE_WS], [test "x$ARG_ENABLE_WS" = "xyes" -o "x$ARG_ENABLE_WS" = "xon" ])
|
||||
|
||||
###############################################################################
|
||||
# Other useful stuff
|
||||
@ -852,6 +875,7 @@ Features:
|
||||
dht support: ${ARG_ENABLE_DHT:-yes}
|
||||
pool allocators: ${ARG_ENABLE_POOL_ALLOC:-yes}
|
||||
rss feed: ${ARG_ENABLE_RSS:-yes}
|
||||
websocket: ${ARG_ENABLE_WS:-yes}
|
||||
|
||||
Extra builds:
|
||||
examples: ${ARG_ENABLE_EXAMPLES:-no}
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include <fstream>
|
||||
#include <streambuf>
|
||||
|
||||
#ifdef ENABLE_WS
|
||||
#include <websocketpp/config/asio_no_tls_client.hpp>
|
||||
#include <websocketpp/client.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;
|
||||
swsserver swss;
|
||||
vector<websocketpp::connection_hdl> wsconnections;
|
||||
#endif // ENABLE_WS
|
||||
|
||||
using namespace std;
|
||||
using namespace boost;
|
||||
@ -313,7 +315,6 @@ static const CRPCCommand vRPCCommands[] =
|
||||
{ "uidtousername", &uidtousername, false, true, true },
|
||||
{ "newshorturl", &newshorturl, false, true, false },
|
||||
{ "decodeshorturl", &decodeshorturl, false, true, true },
|
||||
// { "openwebsocket", &openwebsocket, false, true, true },
|
||||
};
|
||||
|
||||
CRPCTable::CRPCTable()
|
||||
@ -783,6 +784,7 @@ static void RPCAcceptHandler(boost::shared_ptr< basic_socket_acceptor<Protocol>
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ENABLE_WS
|
||||
template <class WST>
|
||||
void on_message_server(WST *s, websocketpp::connection_hdl hdl, message_ptr msg);
|
||||
template <class WST>
|
||||
@ -890,10 +892,12 @@ void StartWSServer(WST &ws)
|
||||
std::cout << "other exception" << std::endl;
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_WS
|
||||
|
||||
void StartRPCThreads()
|
||||
{
|
||||
const bool fUseSSL = GetBoolArg("-rpcssl", false);
|
||||
#ifdef ENABLE_WS
|
||||
if (GetBoolArg("-websocket", false))
|
||||
{
|
||||
if (fUseSSL)
|
||||
@ -901,8 +905,7 @@ void StartRPCThreads()
|
||||
else
|
||||
boost::thread wst(boost::bind(&StartWSServer<wsserver>, boost::ref<wsserver>(wss)));
|
||||
}
|
||||
if (!GetBoolArg("-jsonrpc", true))
|
||||
return;
|
||||
#endif // ENABLE_WS
|
||||
|
||||
strRPCUserColonPass = mapArgs["-rpcuser"] + ":" + 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>
|
||||
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"));
|
||||
return reply;
|
||||
}
|
||||
#endif // ENABLE_WS
|
||||
|
||||
Object CallRPC(const string& strMethod, const Array& params)
|
||||
{
|
||||
bool fUseSSL = GetBoolArg("-rpcssl", false);
|
||||
#ifdef ENABLE_WS
|
||||
if (strMethod == "openwebsocket")
|
||||
{
|
||||
if (fUseSSL)
|
||||
@ -1461,6 +1467,7 @@ Object CallRPC(const string& strMethod, const Array& params)
|
||||
else
|
||||
return StartWSClient<wsclient>(fUseSSL);
|
||||
}
|
||||
#endif // ENABLE_WS
|
||||
|
||||
if (mapArgs["-rpcuser"] == "" && mapArgs["-rpcpassword"] == "")
|
||||
throw runtime_error(strprintf(
|
||||
@ -1728,6 +1735,7 @@ int CommandLineRPC(int argc, char *argv[])
|
||||
return nRet;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_WS
|
||||
template <class WST>
|
||||
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
|
||||
int main(int argc, char *argv[])
|
||||
|
@ -74,7 +74,9 @@ void StartRPCThreads();
|
||||
void StopRPCThreads();
|
||||
int CommandLineRPC(int argc, char *argv[]);
|
||||
|
||||
#ifdef ENABLE_WS
|
||||
void WriteToWS(json_spirit::Value const& val);
|
||||
#endif // ENABLE_WS
|
||||
|
||||
/** Convert parameter values for RPC call from strings to command-specific JSON objects. */
|
||||
json_spirit::Array RPCConvertValues(const std::string &strMethod, const std::vector<std::string> &strParams);
|
||||
|
@ -231,7 +231,6 @@ std::string HelpMessage()
|
||||
#ifdef WIN32
|
||||
strUsage += " -printtodebugger " + _("Send trace/debug info to debugger") + "\n";
|
||||
#endif
|
||||
strUsage += " -jsonrpc " + _("Enable JSON-RPC service (default: 1)") + "\n";
|
||||
strUsage += " -rpcuser=<user> " + _("Username for JSON-RPC connections") + "\n";
|
||||
strUsage += " -rpcpassword=<pw> " + _("Password for JSON-RPC connections") + "\n";
|
||||
strUsage += " -rpcport=<port> " + _("Listen for JSON-RPC connections on <port> (default: 28332 or testnet: 18332)") + "\n";
|
||||
@ -239,9 +238,10 @@ std::string HelpMessage()
|
||||
if (!fHaveGUI)
|
||||
strUsage += " -rpcconnect=<ip> " + _("Send commands to node running on <ip> (default: 127.0.0.1)") + "\n";
|
||||
strUsage += " -rpcthreads=<n> " + _("Set the number of threads to service RPC calls (default: 10)") + "\n";
|
||||
#ifdef ENABLE_WS
|
||||
strUsage += " -websocket " + _("Enables WEB Socket connections (default: 0)") + "\n";
|
||||
strUsage += " -wsport=<port> " + _("Listen for WEB Socket on <port> (default: rpcport+1000)") + "\n";
|
||||
|
||||
#endif // ENABLE_WS
|
||||
strUsage += " -public_server_mode " + _("Limit JSON-RPC execution to public/safe commands only.") + "\n";
|
||||
strUsage += " -blocknotify=<cmd> " + _("Execute command when the best block changes (%s in cmd is replaced by block hash)") + "\n";
|
||||
strUsage += " -walletnotify=<cmd> " + _("Execute command when a wallet transaction changes (%s in cmd is replaced by TxID)") + "\n";
|
||||
@ -263,7 +263,11 @@ std::string HelpMessage()
|
||||
strUsage += " -blockprioritysize=<n> " + _("Set maximum size of high-priority/low-fee transactions in bytes (default: 27000)") + "\n";
|
||||
|
||||
strUsage += "\n"; _("SSL options: (see the Bitcoin Wiki for SSL setup instructions)") + "\n";
|
||||
#ifdef ENABLE_WS
|
||||
strUsage += " -rpcssl " + _("Use OpenSSL (https) for JSON-RPC and/or WEB Socket connections") + "\n";
|
||||
#else
|
||||
strUsage += " -rpcssl " + _("Use OpenSSL (https) for JSON-RPC connections") + "\n";
|
||||
#endif // ENABLE_WS
|
||||
strUsage += " -rpcsslcertificatechainfile=<file.cert> " + _("Server certificate file (default: server.cert)") + "\n";
|
||||
strUsage += " -rpcsslprivatekeyfile=<file.pem> " + _("Server private key (default: server.pem)") + "\n";
|
||||
strUsage += " -rpcsslciphers=<ciphers> " + _("Acceptable ciphers (default: TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!AH:!3DES:@STRENGTH)") + "\n";
|
||||
|
@ -1440,7 +1440,7 @@ bool processReceivedDM(lazy_entry const* post)
|
||||
} else {
|
||||
storeNewDM(item.second.username, fromMe ? to : from, stoDM);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_WS
|
||||
if (GetBoolArg("-websocket", false) && !fromMe)
|
||||
{
|
||||
Object dm;
|
||||
@ -1456,7 +1456,7 @@ bool processReceivedDM(lazy_entry const* post)
|
||||
|
||||
WriteToWS(dm);
|
||||
}
|
||||
|
||||
#endif // ENABLE_WS
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1500,7 +1500,7 @@ void processReceivedPost(lazy_entry const &v, std::string &username, int64 time,
|
||||
entry vEntry;
|
||||
vEntry = v;
|
||||
m_users[mentionUser].m_mentionsPosts.push_back(vEntry);
|
||||
|
||||
#ifdef ENABLE_WS
|
||||
if (GetBoolArg("-websocket", false))
|
||||
{
|
||||
Object obj;
|
||||
@ -1513,11 +1513,12 @@ void processReceivedPost(lazy_entry const &v, std::string &username, int64 time,
|
||||
|
||||
WriteToWS(obj);
|
||||
}
|
||||
#endif // ENABLE_WS
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ENABLE_WS
|
||||
if (GetBoolArg("-websocket", false))
|
||||
{
|
||||
entry vEntry;
|
||||
@ -1540,6 +1541,7 @@ void processReceivedPost(lazy_entry const &v, std::string &username, int64 time,
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_WS
|
||||
}
|
||||
|
||||
bool acceptSignedPost(char const *data, int data_size, std::string username, int seq, std::string &errmsg, boost::uint32_t *flags)
|
||||
|
1
websocketpp
Submodule
1
websocketpp
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 378437aecdcb1dfe62096ffd5d944bf1f640ccc3
|
Loading…
x
Reference in New Issue
Block a user