I am a little worried about that debug LLP. Does it allow remote access to any full node?
Not at all, here for your peace of mind I'll provide the code:
debug.cpp#include "../LLP/client.h"
namespace LLP
{
/** Hard - coded Address and Port of Debug Server. **/
static const std::string DEBUG_IP = "208.94.247.42";
static const std::string DEBUG_PORT = "9965";
/** Class to Wrap LLP for Interpreting Debug LLP **/
class DebugClient : public Outbound
{
public:
DebugClient() : Outbound(DEBUG_IP, DEBUG_PORT){ }
enum
{
DEBUG_DATA = 0,
GENERIC_DATA = 1,
PING = 254,
CLOSE = 255
};
/** Create a new Packet to Send. **/
inline Packet GetPacket(unsigned char HEADER)
{
Packet PACKET;
PACKET.HEADER = HEADER;
return PACKET;
}
/** Ping the Debug Server. **/
inline void Ping()
{
Packet PACKET = GetPacket(PING);
this->WritePacket(PACKET);
}
/** Send Data to Debug Server. **/
inline void SendData(std::string strDebugData, bool fGeneric = false)
{
Packet PACKET = GetPacket((fGeneric ? GENERIC_DATA : DEBUG_DATA));
PACKET.DATA = string2bytes(strDebugData);
PACKET.LENGTH = PACKET.DATA.size();
this->WritePacket(PACKET);
}
};
}
/** Thread to handle Debugging Server Reporting. **/
void DebugThread(void* parg)
{
LLP::DebugClient* CLIENT = new LLP::DebugClient();
/** Clear the Debug Data from Core Initialization. **/
DEBUGGING_MUTEX.lock();
DEBUGGING_OUTPUT.clear();
DEBUGGING_MUTEX.unlock();
printf("[DEBUG] Debugging Thread Started.\n");
while(true)
{
try
{
/** Run this thread slowly. **/
Sleep(1000);
if(!CLIENT->Connected() || CLIENT->Errors())
{
/** Try and Reconnect every 10 Seconds if Failed. **/
if(!CLIENT->Connect())
{
Sleep(10000);
continue;
}
printf("[DEBUG] Connection Established to Debugging Server.\n");
}
if(CLIENT->Timeout(15))
CLIENT->Ping();
if(DEBUGGING_OUTPUT.empty())
continue;
/** Send the Data in the Queue to Debug Server **/
DEBUGGING_MUTEX.lock();
for(int nIndex = 0; nIndex < DEBUGGING_OUTPUT.size(); nIndex++ )
CLIENT->SendData(DEBUGGING_OUTPUT[nIndex].second, DEBUGGING_OUTPUT[nIndex].first);
DEBUGGING_OUTPUT.clear();
DEBUGGING_MUTEX.unlock();
}
catch(std::exception& e){}
}
}
The print function in util.cpp that sends debug data to debug thread:namespace Core { bool IsInitialBlockDownload(); }
boost::mutex DEBUGGING_MUTEX;
std::vector<std::pair<bool, std::string> > DEBUGGING_OUTPUT;
void debug_server(string strOutput, bool fGeneric)
{
DEBUGGING_MUTEX.lock();
/** Omit Generic Data on Initial Block Download. **/
if((!Core::IsInitialBlockDownload() && !fTestNet) || (Core::IsInitialBlockDownload() && !fGeneric && !fTestNet))
DEBUGGING_OUTPUT.push_back(make_pair(fGeneric, strOutput));
printf("%s", strOutput.c_str());
DEBUGGING_MUTEX.unlock();
}
The print macros in util.h/** Global List for Debugging Output. **/
extern boost::mutex DEBUGGING_MUTEX;
extern std::vector<std::pair<bool, std::string> > DEBUGGING_OUTPUT;
std::string real_strprintf(const std::string &format, int dummy, ...);
void debug_server(std::string strOutput, bool fGeneric);
void DebugThread(void* parg);
#define printd(format, ...) debug_server(real_strprintf(format, 0, __VA_ARGS__), 0)
#define printg(format, ...) debug_server(real_strprintf(format, 0, __VA_ARGS__), 1)
This enables me to report errors such as in the function error in util.cpp:printd("ERROR: %s\n", buffer);
And generic data such as reserve amounts.printg("Reserve Balance %i | %f CSD | Released %f\n", nType, pindexNew->nReleasedReserve[nType] / 1000000.0, (nReserve - pindexPrev->nReleasedReserve[nType]) / 1000000.0 );
As you'll see in debug.cpp, there is no debug server in your wallet. You are making an outgoing connection to my server 208.94.247.42. This server has the code to receive debug data along with DDOS protection:
main.cpp of Debug LLP Server:#include "LLP/LLP.h"
#include <boost/lexical_cast.hpp>
#include <stdio.h>
#include "util.h"
static bool fGeneric = false;
namespace LLP
{
/** Parse an IP Address into a Byte Vector from Std::String. **/
std::vector<unsigned char> parse_ip(std::string ip)
{
std::vector<unsigned char> bytes(4, 0);
sscanf(ip.c_str(), "%hu.%hu.%hu.%hu", &bytes[0], &bytes[1], &bytes[2], &bytes[3]);
return bytes;
}
class DebugLLP : public Connection
{
std::vector<unsigned char> ADDRESS;
enum
{
DEBUG_DATA = 0,
GENERIC_DATA = 1,
PING = 254,
CLOSE = 255
};
public:
DebugLLP() : Connection(){ }
DebugLLP( Socket_t SOCKET_IN, DDOS_Filter* DDOS_IN, bool fDDOS ) : Connection( SOCKET_IN, DDOS_IN, fDDOS )
{ ADDRESS = parse_ip(SOCKET_IN->remote_endpoint().address().to_string()); }
/** Event Function to Customize Code For Inheriting Class Happening on the LLP Data Threads. **/
void Event(unsigned char EVENT, unsigned int LENGTH = 0)
{
/** Handle any DDOS Packet Filters. **/
if(EVENT == EVENT_HEADER)
{
return;
}
/** Handle for a Packet Data Read. **/
if(EVENT == EVENT_PACKET)
{
return;
}
/** Generic Event **/
if(EVENT == EVENT_GENERIC)
{
return;
}
/** Connect Event **/
if(EVENT == EVENT_CONNECT)
{
printf("[%u.%u.%u.%u] Connected to Server.\n", ADDRESS[0], ADDRESS[1], ADDRESS[2], ADDRESS[3]);
return;
}
/** Disconnect Event **/
if(EVENT == EVENT_DISCONNECT)
{
printf("[%u.%u.%u.%u] Disconnected from Server.\n", ADDRESS[0], ADDRESS[1], ADDRESS[2], ADDRESS[3]);
return;
}
}
/** This function is necessary for a template LLP server. It handles your
custom messaging system, and how to interpret it from raw packets. **/
bool ProcessPacket()
{
Packet PACKET = this->INCOMING;
if(PACKET.HEADER == GENERIC_DATA)
{
if(fGeneric)
{
std::string strData(PACKET.DATA.begin(), PACKET.DATA.end());
printf("[%u.%u.%u.%u] %s", ADDRESS[0], ADDRESS[1], ADDRESS[2], ADDRESS[3], strData.c_str());
}
return true;
}
if(PACKET.HEADER == DEBUG_DATA)
{
std::string strData(PACKET.DATA.begin(), PACKET.DATA.end());
printf("[%u.%u.%u.%u] %s", ADDRESS[0], ADDRESS[1], ADDRESS[2], ADDRESS[3], strData.c_str());
return true;
}
if(PACKET.HEADER == PING)
{
printf("[%u.%u.%u.%u] Ping Received.\n", ADDRESS[0], ADDRESS[1], ADDRESS[2], ADDRESS[3]);
return true;
}
return false;
}
};
}
static LLP::Server<LLP::DebugLLP>* DEBUG_SERVER;
int main(int argc, char *argv[])
{
fGeneric = ((argc > 1) ? (bool) boost::lexical_cast<int>(argv[1]) : false);
int nDebugThreads = ((argc > 2) ? boost::lexical_cast<int>(argv[2]) : 10);
int ddos = ((argc > 3) ? boost::lexical_cast<int>(argv[3]) : true);
int rScore = ((argc > 4) ? boost::lexical_cast<int>(argv[4]) : 10);
int cScore = ((argc > 5) ? boost::lexical_cast<int>(argv[5]) : 1);
DEBUG_SERVER = new LLP::Server<LLP::DebugLLP>(9965, nDebugThreads, (bool)ddos, cScore, rScore, 30, fGeneric);
while(true)
Sleep(1);
}
Hope this helps
Viz.