mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-25 23:49:35 -05:00
Major cleanup of Retroshare Logging - aimed at enabling proper UDP testing.
* Switched off most of std::cerr output. (expect UPnP) * moved pqi/pqidebug to util/rsdebug to allow greater usage. * added Mutexes to logging. * Downgraded many log messages to DEBUG. * New Log messages for connections, dht and udp code. * Added check for bad UDP socket. * Added check for non-firewalled scenario. * Increased Storage period from 1 Month to 6 Months for Links & Blog. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@644 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
afeb93d0f3
commit
d36b15d526
@ -7,7 +7,7 @@ RS_TOP_DIR = ..
|
||||
include $(RS_TOP_DIR)/scripts/config.mk
|
||||
###############################################################
|
||||
|
||||
BASE_OBJ = pqidebug.o pqisecurity.o pqinetwork.o
|
||||
BASE_OBJ = pqisecurity.o pqinetwork.o
|
||||
#pqi_base.o
|
||||
|
||||
LOOP_OBJ = pqiloopback.o
|
||||
|
@ -874,8 +874,10 @@ XPGP *AuthXPGP::loadXPGPFromFile(std::string fname, std::string hash)
|
||||
// load certificates from file.
|
||||
if (pcertfp == NULL)
|
||||
{
|
||||
#ifdef AUTHXPGP_DEBUG
|
||||
std::cerr << "sslroot::loadcertificate() Bad File: " << fname;
|
||||
std::cerr << " Cannot be Hashed!" << std::endl;
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -900,7 +902,9 @@ XPGP *AuthXPGP::loadXPGPFromFile(std::string fname, std::string hash)
|
||||
char inall[maxsize];
|
||||
if (0 == (rbytes = fread(inall, 1, maxsize, pcertfp)))
|
||||
{
|
||||
#ifdef AUTHXPGP_DEBUG
|
||||
std::cerr << "Error Reading Peer Record!" << std::endl;
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
//std::cerr << "Read " << rbytes << std::endl;
|
||||
@ -928,8 +932,10 @@ XPGP *AuthXPGP::loadXPGPFromFile(std::string fname, std::string hash)
|
||||
bool same = true;
|
||||
if (signlen != hash.length())
|
||||
{
|
||||
#ifdef AUTHXPGP_DEBUG
|
||||
std::cerr << "Different Length Signatures... ";
|
||||
std::cerr << "Cannot Load Certificate!" << std::endl;
|
||||
#endif
|
||||
fclose(pcertfp);
|
||||
return NULL;
|
||||
}
|
||||
@ -939,18 +945,24 @@ XPGP *AuthXPGP::loadXPGPFromFile(std::string fname, std::string hash)
|
||||
if (signature[i] != (unsigned char) hash[i])
|
||||
{
|
||||
same = false;
|
||||
#ifdef AUTHXPGP_DEBUG
|
||||
std::cerr << "Invalid Signature... ";
|
||||
std::cerr << "Cannot Load Certificate!" << std::endl;
|
||||
#endif
|
||||
fclose(pcertfp);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
#ifdef AUTHXPGP_DEBUG
|
||||
std::cerr << "Verified Signature for: " << fname;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef AUTHXPGP_DEBUG
|
||||
std::cerr << "Not checking cert signature" << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
fseek(pcertfp, 0, SEEK_SET); /* rewind */
|
||||
@ -960,7 +972,9 @@ XPGP *AuthXPGP::loadXPGPFromFile(std::string fname, std::string hash)
|
||||
if (pc != NULL)
|
||||
{
|
||||
// read a certificate.
|
||||
#ifdef AUTHXPGP_DEBUG
|
||||
std::cerr << "Loaded Certificate: " << pc -> name << std::endl;
|
||||
#endif
|
||||
}
|
||||
else // (pc == NULL)
|
||||
{
|
||||
@ -984,12 +998,16 @@ bool AuthXPGP::saveXPGPToFile(XPGP *xpgp, std::string fname, std::string &hash
|
||||
FILE *setfp = fopen(fname.c_str(), "wb");
|
||||
if (setfp == NULL)
|
||||
{
|
||||
#ifdef AUTHXPGP_DEBUG
|
||||
std::cerr << "sslroot::savecertificate() Bad File: " << fname;
|
||||
std::cerr << " Cannot be Written!" << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef AUTHXPGP_DEBUG
|
||||
std::cerr << "Writing out Cert...:" << xpgp->name << std::endl;
|
||||
#endif
|
||||
PEM_write_XPGP(setfp, xpgp);
|
||||
|
||||
fclose(setfp);
|
||||
@ -998,8 +1016,10 @@ bool AuthXPGP::saveXPGPToFile(XPGP *xpgp, std::string fname, std::string &hash
|
||||
setfp = fopen(fname.c_str(), "rb");
|
||||
if (setfp == NULL)
|
||||
{
|
||||
#ifdef AUTHXPGP_DEBUG
|
||||
std::cerr << "sslroot::savecertificate() Bad File: " << fname;
|
||||
std::cerr << " Opened for ReHash!" << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1011,10 +1031,14 @@ bool AuthXPGP::saveXPGPToFile(XPGP *xpgp, std::string fname, std::string &hash
|
||||
char inall[maxsize];
|
||||
if (0 == (rbytes = fread(inall, 1, maxsize, setfp)))
|
||||
{
|
||||
#ifdef AUTHXPGP_DEBUG
|
||||
std::cerr << "Error Writing Peer Record!" << std::endl;
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
#ifdef AUTHXPGP_DEBUG
|
||||
std::cerr << "Read " << rbytes << std::endl;
|
||||
#endif
|
||||
|
||||
EVP_MD_CTX *mdctx = EVP_MD_CTX_create();
|
||||
|
||||
@ -1033,17 +1057,25 @@ bool AuthXPGP::saveXPGPToFile(XPGP *xpgp, std::string fname, std::string &hash
|
||||
std::cerr << "EVP_SignFinal Failure!" << std::endl;
|
||||
}
|
||||
|
||||
#ifdef AUTHXPGP_DEBUG
|
||||
std::cerr << "Saved Cert: " << xpgp->name;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
#ifdef AUTHXPGP_DEBUG
|
||||
std::cerr << "Cert + Setting Signature is(" << signlen << "): ";
|
||||
#endif
|
||||
std::string signstr;
|
||||
for(uint32_t i = 0; i < signlen; i++)
|
||||
{
|
||||
#ifdef AUTHXPGP_DEBUG
|
||||
fprintf(stderr, "%02x", signature[i]);
|
||||
#endif
|
||||
signstr += signature[i];
|
||||
}
|
||||
#ifdef AUTHXPGP_DEBUG
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
hash = signstr;
|
||||
fclose(setfp);
|
||||
|
@ -25,11 +25,16 @@
|
||||
|
||||
#include "pqi/p3connmgr.h"
|
||||
#include "tcponudp/tou.h"
|
||||
|
||||
#include "util/rsprint.h"
|
||||
#include "util/rsdebug.h"
|
||||
const int p3connectzone = 3431;
|
||||
|
||||
#include "serialiser/rsconfigitems.h"
|
||||
#include "pqi/pqinotify.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
/* Network setup States */
|
||||
|
||||
const uint32_t RS_NET_UNKNOWN = 0x0001;
|
||||
@ -57,7 +62,6 @@ const uint32_t MAX_UPNP_INIT = 10; /* seconds UPnP timeout */
|
||||
* #define P3CONNMGR_NO_AUTO_CONNECTION 1
|
||||
***/
|
||||
|
||||
|
||||
const uint32_t P3CONNMGR_TCP_DEFAULT_DELAY = 2; /* 2 Seconds? is it be enough! */
|
||||
const uint32_t P3CONNMGR_UDP_DHT_DELAY = DHT_NOTIFY_PERIOD + 60; /* + 1 minute for DHT POST */
|
||||
const uint32_t P3CONNMGR_UDP_PROXY_DELAY = 30; /* 30 seconds (NOT IMPLEMENTED YET!) */
|
||||
@ -623,6 +627,13 @@ void p3ConnectMgr::netUdpCheck()
|
||||
}
|
||||
else // if (extAddrStable)
|
||||
{
|
||||
/* Check if extAddr == intAddr (Not Firewalled) */
|
||||
if ((0 == inaddr_cmp(iaddr, extAddr)) &&
|
||||
isExternalNet(&(extAddr.sin_addr)))
|
||||
{
|
||||
mode |= RS_NET_CONN_TCP_EXTERNAL;
|
||||
}
|
||||
|
||||
mode |= RS_NET_CONN_UDP_DHT_SYNC;
|
||||
}
|
||||
|
||||
@ -1442,6 +1453,20 @@ void p3ConnectMgr::peerStatus(std::string id,
|
||||
std::cerr << " source: " << source;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
{
|
||||
/* Log */
|
||||
std::ostringstream out;
|
||||
out << "p3ConnectMgr::peerStatus()";
|
||||
out << " id: " << id;
|
||||
out << " laddr: " << inet_ntoa(laddr.sin_addr);
|
||||
out << " lport: " << ntohs(laddr.sin_port);
|
||||
out << " raddr: " << inet_ntoa(raddr.sin_addr);
|
||||
out << " rport: " << ntohs(raddr.sin_port);
|
||||
out << " type: " << type;
|
||||
out << " flags: " << flags;
|
||||
out << " source: " << source;
|
||||
rslog(RSL_WARNING, p3connectzone, out.str());
|
||||
}
|
||||
|
||||
/* look up the id */
|
||||
it = mFriendList.find(id);
|
||||
@ -1605,6 +1630,12 @@ void p3ConnectMgr::peerStatus(std::string id,
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
{
|
||||
/* Log */
|
||||
std::ostringstream out;
|
||||
out << "p3ConnectMgr::peerStatus() NO CONNECT (not friend)";
|
||||
rslog(RSL_WARNING, p3connectzone, out.str());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1616,6 +1647,12 @@ void p3ConnectMgr::peerStatus(std::string id,
|
||||
std::cerr << " id: " << id;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
{
|
||||
/* Log */
|
||||
std::ostringstream out;
|
||||
out << "p3ConnectMgr::peerStatus() NO CONNECT (already connected!)";
|
||||
rslog(RSL_WARNING, p3connectzone, out.str());
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@ -1680,6 +1717,20 @@ void p3ConnectMgr::peerStatus(std::string id,
|
||||
std::cerr << " source: " << source;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
{
|
||||
/* Log */
|
||||
std::ostringstream out;
|
||||
out << "p3ConnectMgr::peerStatus() PushBack Local TCP Address: ";
|
||||
out << " id: " << id;
|
||||
out << " laddr: " << inet_ntoa(pca.addr.sin_addr);
|
||||
out << ":" << ntohs(pca.addr.sin_port);
|
||||
out << " type: " << pca.type;
|
||||
out << " delay: " << pca.delay;
|
||||
out << " period: " << pca.period;
|
||||
out << " ts: " << pca.ts;
|
||||
out << " source: " << source;
|
||||
rslog(RSL_WARNING, p3connectzone, out.str());
|
||||
}
|
||||
|
||||
it->second.connAddrs.push_back(pca);
|
||||
}
|
||||
@ -1712,14 +1763,28 @@ void p3ConnectMgr::peerStatus(std::string id,
|
||||
#ifdef CONN_DEBUG
|
||||
std::cerr << "p3ConnectMgr::peerStatus() ADDING TCP_REMOTE ADDR: ";
|
||||
std::cerr << " id: " << id;
|
||||
std::cerr << " laddr: " << inet_ntoa(pca.addr.sin_addr);
|
||||
std::cerr << " lport: " << ntohs(pca.addr.sin_port);
|
||||
std::cerr << " raddr: " << inet_ntoa(pca.addr.sin_addr);
|
||||
std::cerr << " rport: " << ntohs(pca.addr.sin_port);
|
||||
std::cerr << " delay: " << pca.delay;
|
||||
std::cerr << " period: " << pca.period;
|
||||
std::cerr << " type: " << pca.type;
|
||||
std::cerr << " source: " << source;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
{
|
||||
/* Log */
|
||||
std::ostringstream out;
|
||||
out << "p3ConnectMgr::peerStatus() PushBack Remote TCP Address: ";
|
||||
out << " id: " << id;
|
||||
out << " raddr: " << inet_ntoa(pca.addr.sin_addr);
|
||||
out << ":" << ntohs(pca.addr.sin_port);
|
||||
out << " type: " << pca.type;
|
||||
out << " delay: " << pca.delay;
|
||||
out << " period: " << pca.period;
|
||||
out << " ts: " << pca.ts;
|
||||
out << " source: " << source;
|
||||
rslog(RSL_WARNING, p3connectzone, out.str());
|
||||
}
|
||||
|
||||
it->second.connAddrs.push_back(pca);
|
||||
}
|
||||
@ -1808,6 +1873,16 @@ void p3ConnectMgr::peerConnectRequest(std::string id, struct sockaddr_in radd
|
||||
std::cerr << " source: " << source;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
{
|
||||
/* Log */
|
||||
std::ostringstream out;
|
||||
out << "p3ConnectMgr::peerConnectRequest()";
|
||||
out << " id: " << id;
|
||||
out << " raddr: " << inet_ntoa(raddr.sin_addr);
|
||||
out << ":" << ntohs(raddr.sin_port);
|
||||
out << " source: " << source;
|
||||
rslog(RSL_WARNING, p3connectzone, out.str());
|
||||
}
|
||||
|
||||
/******************** TCP PART *****************************/
|
||||
|
||||
@ -1910,6 +1985,20 @@ void p3ConnectMgr::peerConnectRequest(std::string id, struct sockaddr_in radd
|
||||
|
||||
pca.addr = raddr;
|
||||
|
||||
{
|
||||
/* Log */
|
||||
std::ostringstream out;
|
||||
out << "p3ConnectMgr::peerConnectRequest() PushBack UDP Address: ";
|
||||
out << " id: " << id;
|
||||
out << " raddr: " << inet_ntoa(pca.addr.sin_addr);
|
||||
out << ":" << ntohs(pca.addr.sin_port);
|
||||
out << " type: " << pca.type;
|
||||
out << " delay: " << pca.delay;
|
||||
out << " period: " << pca.period;
|
||||
out << " ts: " << pca.ts;
|
||||
rslog(RSL_WARNING, p3connectzone, out.str());
|
||||
}
|
||||
|
||||
/* push to the back ... TCP ones should be tried first */
|
||||
it->second.connAddrs.push_back(pca);
|
||||
}
|
||||
@ -2270,7 +2359,21 @@ bool p3ConnectMgr::retryConnectTCP(std::string id)
|
||||
pca.ts = now;
|
||||
pca.type = RS_NET_CONN_TCP_LOCAL;
|
||||
pca.addr = it->second.localaddr;
|
||||
|
||||
|
||||
{
|
||||
/* Log */
|
||||
std::ostringstream out;
|
||||
out << "p3ConnectMgr::retryConnectTCP() PushBack Local TCP Address: ";
|
||||
out << " id: " << id;
|
||||
out << " raddr: " << inet_ntoa(pca.addr.sin_addr);
|
||||
out << ":" << ntohs(pca.addr.sin_port);
|
||||
out << " type: " << pca.type;
|
||||
out << " delay: " << pca.delay;
|
||||
out << " period: " << pca.period;
|
||||
out << " ts: " << pca.ts;
|
||||
rslog(RSL_WARNING, p3connectzone, out.str());
|
||||
}
|
||||
|
||||
it->second.connAddrs.push_back(pca);
|
||||
}
|
||||
else
|
||||
@ -2328,6 +2431,20 @@ bool p3ConnectMgr::retryConnectTCP(std::string id)
|
||||
pca.type = RS_NET_CONN_TCP_EXTERNAL;
|
||||
pca.addr = it->second.serveraddr;
|
||||
|
||||
{
|
||||
/* Log */
|
||||
std::ostringstream out;
|
||||
out << "p3ConnectMgr::retryConnectTCP() PushBack Ext TCP Address: ";
|
||||
out << " id: " << id;
|
||||
out << " raddr: " << inet_ntoa(pca.addr.sin_addr);
|
||||
out << ":" << ntohs(pca.addr.sin_port);
|
||||
out << " type: " << pca.type;
|
||||
out << " delay: " << pca.delay;
|
||||
out << " period: " << pca.period;
|
||||
out << " ts: " << pca.ts;
|
||||
rslog(RSL_WARNING, p3connectzone, out.str());
|
||||
}
|
||||
|
||||
it->second.connAddrs.push_back(pca);
|
||||
}
|
||||
else
|
||||
@ -2425,6 +2542,13 @@ bool p3ConnectMgr::retryConnectNotify(std::string id)
|
||||
std::cerr << " id: " << id;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
{
|
||||
/* Log */
|
||||
std::ostringstream out;
|
||||
out << "p3ConnectMgr::retryConnectNotify() Notifying Peer";
|
||||
out << " id: " << id;
|
||||
rslog(RSL_WARNING, p3connectzone, out.str());
|
||||
}
|
||||
|
||||
/* attempt UDP connection */
|
||||
mDhtMgr->notifyPeer(id);
|
||||
|
@ -30,6 +30,8 @@
|
||||
#include <iomanip>
|
||||
|
||||
#include "util/rsprint.h"
|
||||
#include "util/rsdebug.h"
|
||||
const int p3dhtzone = 3892;
|
||||
|
||||
/*****
|
||||
* #define DHT_DEBUG 1
|
||||
@ -193,6 +195,18 @@ bool p3DhtMgr::setExternalInterface(
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
/* Log External Interface too */
|
||||
std::ostringstream out;
|
||||
out << "p3DhtMgr::setExternalInterface()";
|
||||
out << " laddr: " << inet_ntoa(ownEntry.laddr.sin_addr);
|
||||
out << " lport: " << ntohs(ownEntry.laddr.sin_port);
|
||||
out << " raddr: " << inet_ntoa(ownEntry.raddr.sin_addr);
|
||||
out << " rport: " << ntohs(ownEntry.raddr.sin_port);
|
||||
out << " type: " << ownEntry.type;
|
||||
out << " state: " << ownEntry.state;
|
||||
|
||||
rslog(RSL_WARNING, p3dhtzone, out.str());
|
||||
|
||||
dhtMtx.unlock(); /* UNLOCK MUTEX */
|
||||
|
||||
return true;
|
||||
@ -293,6 +307,13 @@ bool p3DhtMgr::notifyPeer(std::string id)
|
||||
#ifdef DHT_DEBUG
|
||||
std::cerr << "p3DhtMgr::notifyPeer() TO SOON - DROPPING" << std::endl;
|
||||
#endif
|
||||
{
|
||||
/* Log */
|
||||
std::ostringstream out;
|
||||
out << "p3DhtMgr::notifyPeer() Id: " << id;
|
||||
out << " TO SOON - DROPPING";
|
||||
rslog(RSL_WARNING, p3dhtzone, out.str());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -305,6 +326,13 @@ bool p3DhtMgr::notifyPeer(std::string id)
|
||||
#ifdef DHT_DEBUG
|
||||
std::cerr << "p3DhtMgr::notifyPeer() PEER NOT FOUND - Trigger search" << std::endl;
|
||||
#endif
|
||||
{
|
||||
/* Log */
|
||||
std::ostringstream out;
|
||||
out << "p3DhtMgr::notifyPeer() Id: " << id;
|
||||
out << " PEER NOT FOUND - Trigger Search";
|
||||
rslog(RSL_WARNING, p3dhtzone, out.str());
|
||||
}
|
||||
it->second.lastTS = 0;
|
||||
}
|
||||
|
||||
@ -566,7 +594,21 @@ int p3DhtMgr::checkOwnDHTKeys()
|
||||
std::cerr << " type: " << peer.type;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
|
||||
{
|
||||
/* Log */
|
||||
std::ostringstream out;
|
||||
out << "p3DhtMgr::checkOwnDHTKeys() PUBLISH OWN ADDR:";
|
||||
out << " hash1: " << RsUtil::BinToHex(peer.hash1);
|
||||
out << " laddr: " << inet_ntoa(peer.laddr.sin_addr);
|
||||
out << " :" << ntohs(peer.laddr.sin_port);
|
||||
out << " raddr: " << inet_ntoa(peer.raddr.sin_addr);
|
||||
out << ":" << ntohs(peer.raddr.sin_port);
|
||||
out << " type: " << peer.type;
|
||||
|
||||
rslog(RSL_WARNING, p3dhtzone, out.str());
|
||||
}
|
||||
|
||||
/* publish own key */
|
||||
if (dhtPublish(peer.hash1, peer.laddr, peer.raddr, peer.type, ""))
|
||||
{
|
||||
@ -626,6 +668,13 @@ int p3DhtMgr::checkOwnDHTKeys()
|
||||
std::cerr << "p3DhtMgr::checkOwnDHTKeys() check for Notify (rep=0)";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
{
|
||||
/* Log */
|
||||
std::ostringstream out;
|
||||
out << "p3DhtMgr::checkOwnDHTKeys() Checking for NOTIFY";
|
||||
rslog(RSL_WARNING, p3dhtzone, out.str());
|
||||
}
|
||||
|
||||
if (dhtSearch(peer.hash1, DHT_MODE_NOTIFY))
|
||||
{
|
||||
dhtMtx.lock(); /* LOCK MUTEX */
|
||||
@ -805,12 +854,6 @@ int p3DhtMgr::checkNotifyDHT()
|
||||
|
||||
if (it->second.notifyPending)
|
||||
{
|
||||
if (it->second.state == DHT_PEER_FOUND)
|
||||
{
|
||||
notifyType = it->second.notifyPending;
|
||||
break;
|
||||
}
|
||||
|
||||
/* if very old drop it */
|
||||
if (now - it->second.notifyTS > DHT_NOTIFY_PERIOD)
|
||||
{
|
||||
@ -820,6 +863,12 @@ int p3DhtMgr::checkNotifyDHT()
|
||||
#endif
|
||||
it->second.notifyPending = 0;
|
||||
}
|
||||
|
||||
if (it->second.state == DHT_PEER_FOUND)
|
||||
{
|
||||
notifyType = it->second.notifyPending;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -833,6 +882,12 @@ int p3DhtMgr::checkNotifyDHT()
|
||||
std::cerr << "p3DhtMgr::checkNotifyDHT() Notify From: ";
|
||||
std::cerr << it->first << std::endl;
|
||||
#endif
|
||||
{
|
||||
/* Log */
|
||||
std::ostringstream out;
|
||||
out << "p3DhtMgr::checkNotifyDHT() Notify Request for Known Peer: " << it->first;
|
||||
rslog(RSL_WARNING, p3dhtzone, out.str());
|
||||
}
|
||||
|
||||
/* update timestamp */
|
||||
it->second.notifyTS = now;
|
||||
@ -853,6 +908,12 @@ int p3DhtMgr::checkNotifyDHT()
|
||||
std::cerr << "p3DhtMgr::checkNotifyDHT() Posting Active Notify";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
{
|
||||
/* Log */
|
||||
std::ostringstream out;
|
||||
out << "p3DhtMgr::checkNotifyDHT() POST DHT (Active Notify) for Peer: " << peer.id;
|
||||
rslog(RSL_WARNING, p3dhtzone, out.str());
|
||||
}
|
||||
|
||||
dhtNotify(peer.hash1, own.hash2, "");
|
||||
}
|
||||
@ -1565,6 +1626,13 @@ bool p3DhtMgr::dhtResultNotify(std::string idhash)
|
||||
#ifdef DHT_DEBUG
|
||||
std::cerr << "p3DhtMgr::dhtResult() NOTIFY for id: " << it->first << std::endl;
|
||||
#endif
|
||||
{
|
||||
/* Log */
|
||||
std::ostringstream out;
|
||||
out << "p3DhtMgr::dhtResultNotify() NOTIFY from Id: " << it->first;
|
||||
rslog(RSL_WARNING, p3dhtzone, out.str());
|
||||
}
|
||||
|
||||
/* delay callback -> if they are not found */
|
||||
it->second.notifyTS = now;
|
||||
it->second.notifyPending = RS_CONNECT_PASSIVE;
|
||||
@ -1618,6 +1686,19 @@ bool p3DhtMgr::dhtResultSearch(std::string idhash,
|
||||
#endif
|
||||
it->second.lastTS = now;
|
||||
|
||||
{
|
||||
/* Log */
|
||||
std::ostringstream out;
|
||||
out << "p3DhtMgr::dhtSearchResult() for Id: " << it->first;
|
||||
out << " laddr: " << inet_ntoa(laddr.sin_addr);
|
||||
out << ":" << ntohs(laddr.sin_port);
|
||||
out << " raddr: " << inet_ntoa(raddr.sin_addr);
|
||||
out << ":" << ntohs(raddr.sin_port);
|
||||
out << " type: " << ownEntry.type;
|
||||
|
||||
rslog(RSL_WARNING, p3dhtzone, out.str());
|
||||
}
|
||||
|
||||
/* update info .... always */
|
||||
it->second.state = DHT_PEER_FOUND;
|
||||
it->second.laddr = laddr;
|
||||
|
@ -46,7 +46,7 @@
|
||||
#include <fstream>
|
||||
|
||||
#include <sstream>
|
||||
#include "pqi/pqidebug.h"
|
||||
#include "util/rsdebug.h"
|
||||
|
||||
const int pqiarchivezone = 9326;
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include "pqi/pqihandler.h"
|
||||
|
||||
#include <sstream>
|
||||
#include "pqi/pqidebug.h"
|
||||
#include "util/rsdebug.h"
|
||||
const int pqihandlerzone = 34283;
|
||||
|
||||
/****
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include <errno.h>
|
||||
#include <iostream>
|
||||
|
||||
#include "pqi/pqidebug.h"
|
||||
#include "util/rsdebug.h"
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
static const int pqinetzone = 96184;
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include "pqi/pqipersongrp.h"
|
||||
|
||||
const int pqipersonzone = 82371;
|
||||
#include "pqi/pqidebug.h"
|
||||
#include "util/rsdebug.h"
|
||||
#include <sstream>
|
||||
|
||||
/****
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
#include "pqi/pqipersongrp.h"
|
||||
#include "pqi/p3connmgr.h"
|
||||
#include "pqi/pqidebug.h"
|
||||
#include "util/rsdebug.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
|
@ -24,15 +24,22 @@
|
||||
*/
|
||||
|
||||
#include "pqi/pqiservice.h"
|
||||
#include "pqi/pqidebug.h"
|
||||
#include "util/rsdebug.h"
|
||||
#include <sstream>
|
||||
|
||||
const int pqiservicezone = 60478;
|
||||
|
||||
/****
|
||||
* #define SERVICE_DEBUG 1
|
||||
****/
|
||||
|
||||
p3ServiceServer::p3ServiceServer()
|
||||
{
|
||||
|
||||
#ifdef SERVICE_DEBUG
|
||||
pqioutput(PQL_DEBUG_BASIC, pqiservicezone,
|
||||
"p3ServiceServer::p3ServiceServer()");
|
||||
#endif
|
||||
|
||||
rrit = services.begin();
|
||||
return;
|
||||
@ -40,8 +47,10 @@ p3ServiceServer::p3ServiceServer()
|
||||
|
||||
int p3ServiceServer::addService(pqiService *ts)
|
||||
{
|
||||
#ifdef SERVICE_DEBUG
|
||||
pqioutput(PQL_DEBUG_BASIC, pqiservicezone,
|
||||
"p3ServiceServer::addService()");
|
||||
#endif
|
||||
|
||||
std::map<uint32_t, pqiService *>::iterator it;
|
||||
it = services.find(ts -> getType());
|
||||
@ -58,6 +67,7 @@ int p3ServiceServer::addService(pqiService *ts)
|
||||
|
||||
int p3ServiceServer::incoming(RsRawItem *item)
|
||||
{
|
||||
#ifdef SERVICE_DEBUG
|
||||
pqioutput(PQL_DEBUG_BASIC, pqiservicezone,
|
||||
"p3ServiceServer::incoming()");
|
||||
|
||||
@ -73,13 +83,16 @@ int p3ServiceServer::incoming(RsRawItem *item)
|
||||
out << std::endl;
|
||||
pqioutput(PQL_DEBUG_BASIC, pqiservicezone, out.str());
|
||||
}
|
||||
#endif
|
||||
|
||||
std::map<uint32_t, pqiService *>::iterator it;
|
||||
it = services.find(item -> PacketId() & 0xffffff00);
|
||||
if (it == services.end())
|
||||
{
|
||||
#ifdef SERVICE_DEBUG
|
||||
pqioutput(PQL_DEBUG_BASIC, pqiservicezone,
|
||||
"p3ServiceServer::incoming() Service: No Service - deleting");
|
||||
#endif
|
||||
|
||||
// delete it.
|
||||
delete item;
|
||||
@ -89,10 +102,12 @@ int p3ServiceServer::incoming(RsRawItem *item)
|
||||
}
|
||||
|
||||
{
|
||||
#ifdef SERVICE_DEBUG
|
||||
std::ostringstream out;
|
||||
out << "p3ServiceServer::incoming() Sending to";
|
||||
out << it -> second << std::endl;
|
||||
pqioutput(PQL_DEBUG_BASIC, pqiservicezone, out.str());
|
||||
#endif
|
||||
|
||||
return (it->second) -> receive(item);
|
||||
}
|
||||
@ -105,8 +120,11 @@ int p3ServiceServer::incoming(RsRawItem *item)
|
||||
|
||||
RsRawItem *p3ServiceServer::outgoing()
|
||||
{
|
||||
|
||||
#ifdef SERVICE_DEBUG
|
||||
pqioutput(PQL_DEBUG_ALL, pqiservicezone,
|
||||
"p3ServiceServer::outgoing()");
|
||||
#endif
|
||||
|
||||
if (rrit != services.end())
|
||||
{
|
||||
@ -126,6 +144,8 @@ RsRawItem *p3ServiceServer::outgoing()
|
||||
{
|
||||
if (NULL != (item = (rrit -> second) -> send()))
|
||||
{
|
||||
|
||||
#ifdef SERVICE_DEBUG
|
||||
std::ostringstream out;
|
||||
out << "p3ServiceServer::outgoing() Got Item From:";
|
||||
out << rrit -> second << std::endl;
|
||||
@ -133,6 +153,8 @@ RsRawItem *p3ServiceServer::outgoing()
|
||||
item -> print(out);
|
||||
out << std::endl;
|
||||
pqioutput(PQL_DEBUG_BASIC, pqiservicezone, out.str());
|
||||
#endif
|
||||
|
||||
return item;
|
||||
}
|
||||
}
|
||||
@ -142,6 +164,8 @@ RsRawItem *p3ServiceServer::outgoing()
|
||||
{
|
||||
if (NULL != (item = (rrit -> second) -> send()))
|
||||
{
|
||||
|
||||
#ifdef SERVICE_DEBUG
|
||||
std::ostringstream out;
|
||||
out << "p3ServiceServer::outgoing() Got Item From:";
|
||||
out << rrit -> second << std::endl;
|
||||
@ -149,6 +173,8 @@ RsRawItem *p3ServiceServer::outgoing()
|
||||
item -> print(out);
|
||||
out << std::endl;
|
||||
pqioutput(PQL_DEBUG_BASIC, pqiservicezone, out.str());
|
||||
#endif
|
||||
|
||||
return item;
|
||||
}
|
||||
}
|
||||
@ -159,19 +185,25 @@ RsRawItem *p3ServiceServer::outgoing()
|
||||
|
||||
int p3ServiceServer::tick()
|
||||
{
|
||||
|
||||
#ifdef SERVICE_DEBUG
|
||||
pqioutput(PQL_DEBUG_ALL, pqiservicezone,
|
||||
"p3ServiceServer::tick()");
|
||||
#endif
|
||||
|
||||
std::map<uint32_t, pqiService *>::iterator it;
|
||||
|
||||
// from the beginning to where we started.
|
||||
for(it = services.begin();it != services.end(); it++)
|
||||
{
|
||||
|
||||
#ifdef SERVICE_DEBUG
|
||||
std::ostringstream out;
|
||||
out << "p3ServiceServer::service id:" << it -> first;
|
||||
out << " -> Service: " << it -> second;
|
||||
out << std::endl;
|
||||
pqioutput(PQL_DEBUG_ALL, pqiservicezone, out.str());
|
||||
#endif
|
||||
|
||||
// now we should actually tick the service.
|
||||
(it -> second) -> tick();
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -34,7 +34,7 @@
|
||||
#include <errno.h>
|
||||
#include <openssl/err.h>
|
||||
|
||||
#include "pqi/pqidebug.h"
|
||||
#include "util/rsdebug.h"
|
||||
#include <sstream>
|
||||
|
||||
const int pqissllistenzone = 49787;
|
||||
|
@ -23,11 +23,13 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "util/rsdebug.h"
|
||||
|
||||
#include "pqi/pqisslpersongrp.h"
|
||||
#include "pqi/pqidebug.h"
|
||||
#include "pqi/p3authmgr.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
const int pqipersongrpzone = 354;
|
||||
|
||||
|
@ -36,9 +36,9 @@
|
||||
#include <errno.h>
|
||||
#include <openssl/err.h>
|
||||
|
||||
#include "pqi/pqidebug.h"
|
||||
#include <sstream>
|
||||
|
||||
#include "util/rsdebug.h"
|
||||
#include "util/rsnet.h"
|
||||
|
||||
const int pqissludpzone = 3144;
|
||||
@ -63,7 +63,7 @@ pqissludp::pqissludp(PQInterface *parent, p3AuthMgr *am, p3ConnectMgr *cm)
|
||||
|
||||
pqissludp::~pqissludp()
|
||||
{
|
||||
pqioutput(PQL_ALERT, pqissludpzone,
|
||||
rslog(RSL_ALERT, pqissludpzone,
|
||||
"pqissludp::~pqissludp -> destroying pqissludp");
|
||||
|
||||
/* must call reset from here, so that the
|
||||
@ -102,13 +102,13 @@ int pqissludp::attach()
|
||||
sockfd = tou_socket(0,0,0);
|
||||
if (0 > sockfd)
|
||||
{
|
||||
pqioutput(PQL_WARNING, pqissludpzone,
|
||||
rslog(RSL_WARNING, pqissludpzone,
|
||||
"pqissludp::attach() failed to create a socket");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// setup remote address
|
||||
pqioutput(PQL_WARNING, pqissludpzone,
|
||||
rslog(RSL_WARNING, pqissludpzone,
|
||||
"pqissludp::attach() Opened Local Udp Socket");
|
||||
|
||||
return 1;
|
||||
@ -123,7 +123,7 @@ int pqissludp::Initiate_Connection()
|
||||
attach(); /* open socket */
|
||||
remote_addr.sin_family = AF_INET;
|
||||
|
||||
pqioutput(PQL_DEBUG_BASIC, pqissludpzone,
|
||||
rslog(RSL_DEBUG_BASIC, pqissludpzone,
|
||||
"pqissludp::Initiate_Connection() Attempting Outgoing Connection....");
|
||||
|
||||
/* decide if we're active or passive */
|
||||
@ -138,29 +138,37 @@ int pqissludp::Initiate_Connection()
|
||||
|
||||
if (waiting != WAITING_DELAY)
|
||||
{
|
||||
pqioutput(PQL_WARNING, pqissludpzone,
|
||||
rslog(RSL_WARNING, pqissludpzone,
|
||||
"pqissludp::Initiate_Connection() Already Attempt in Progress!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
pqioutput(PQL_DEBUG_BASIC, pqissludpzone,
|
||||
if (sockfd < 0)
|
||||
{
|
||||
rslog(RSL_ALERT, pqissludpzone,
|
||||
"pqissludp::Initiate_Connection() Socket Creation Failed!");
|
||||
waiting = WAITING_FAIL_INTERFACE;
|
||||
return -1;
|
||||
}
|
||||
|
||||
rslog(RSL_DEBUG_BASIC, pqissludpzone,
|
||||
"pqissludp::Initiate_Connection() Opening Socket");
|
||||
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqissludp::Initiate_Connection() ";
|
||||
out << "Connecting To: " << inet_ntoa(remote_addr.sin_addr) << ":";
|
||||
out << ntohs(remote_addr.sin_port) << std::endl;
|
||||
out << "Connecting To: " << PeerId();
|
||||
out << " via: " << inet_ntoa(remote_addr.sin_addr) << ":";
|
||||
out << ntohs(remote_addr.sin_port) << " ";
|
||||
if (sslmode)
|
||||
{
|
||||
out << "Using ACTIVE Connect Mode (SSL_Connect)";
|
||||
out << "ACTIVE Connect (SSL_Connect)";
|
||||
}
|
||||
else
|
||||
{
|
||||
out << "Using PASSIVE Connect Mode (SSL_Accept)";
|
||||
out << "PASSIVE Connect (SSL_Accept)";
|
||||
}
|
||||
out << std::endl;
|
||||
pqioutput(PQL_WARNING, pqissludpzone, out.str());
|
||||
rslog(RSL_WARNING, pqissludpzone, out.str());
|
||||
}
|
||||
|
||||
if (remote_addr.sin_addr.s_addr == 0)
|
||||
@ -170,25 +178,16 @@ int pqissludp::Initiate_Connection()
|
||||
out << "Invalid (0.0.0.0) Remote Address,";
|
||||
out << " Aborting Connect.";
|
||||
out << std::endl;
|
||||
pqioutput(PQL_WARNING, pqissludpzone, out.str());
|
||||
rslog(RSL_WARNING, pqissludpzone, out.str());
|
||||
waiting = WAITING_FAIL_INTERFACE;
|
||||
|
||||
reset();
|
||||
return -1;
|
||||
}
|
||||
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "Connecting to ";
|
||||
out << PeerId() << " via ";
|
||||
out << inet_ntoa(remote_addr.sin_addr);
|
||||
out << ":" << ntohs(remote_addr.sin_port);
|
||||
pqioutput(PQL_DEBUG_BASIC, pqissludpzone, out.str());
|
||||
}
|
||||
|
||||
mTimeoutTS = time(NULL) + mConnectTimeout;
|
||||
std::cerr << "Setting Connect Timeout " << mConnectTimeout << " Seconds into Future " << std::endl;
|
||||
std::cerr << " Connect Period is:" << mConnectPeriod << std::endl;
|
||||
//std::cerr << "Setting Connect Timeout " << mConnectTimeout << " Seconds into Future " << std::endl;
|
||||
//std::cerr << " Connect Period is:" << mConnectPeriod << std::endl;
|
||||
|
||||
/* <===================== UDP Difference *******************/
|
||||
if (0 != (err = tou_connect(sockfd, (struct sockaddr *) &remote_addr,
|
||||
@ -196,9 +195,6 @@ int pqissludp::Initiate_Connection()
|
||||
/* <===================== UDP Difference *******************/
|
||||
{
|
||||
int tou_err = tou_errno(sockfd);
|
||||
std::cerr << "pqissludp::Initiate_Connection() connect returns:";
|
||||
std::cerr << err << " -> errno: " << tou_err << " error: ";
|
||||
std::cerr << socket_errorType(tou_err) << std::endl;
|
||||
|
||||
std::ostringstream out;
|
||||
out << "pqissludp::Initiate_Connection()";
|
||||
@ -209,13 +205,13 @@ int pqissludp::Initiate_Connection()
|
||||
waiting = WAITING_SOCK_CONNECT;
|
||||
|
||||
out << " EINPROGRESS Waiting for Socket Connection";
|
||||
pqioutput(PQL_WARNING, pqissludpzone, out.str());
|
||||
rslog(RSL_WARNING, pqissludpzone, out.str());
|
||||
|
||||
return 0;
|
||||
}
|
||||
else if ((tou_err == ENETUNREACH) || (tou_err == ETIMEDOUT))
|
||||
{
|
||||
out << "ENETUNREACHABLE: cert" << PeerId();
|
||||
out << "ENETUNREACHABLE: cert: " << PeerId();
|
||||
out << std::endl;
|
||||
|
||||
// Then send unreachable message.
|
||||
@ -226,20 +222,21 @@ int pqissludp::Initiate_Connection()
|
||||
out << "Error: Connection Failed: " << tou_err;
|
||||
out << " - " << socket_errorType(tou_err) << std::endl;
|
||||
|
||||
rslog(RSL_WARNING, pqissludpzone, out.str());
|
||||
|
||||
reset();
|
||||
|
||||
pqioutput(PQL_WARNING, pqissludpzone, out.str());
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
pqioutput(PQL_WARNING, pqissludpzone,
|
||||
rslog(RSL_DEBUG_BASIC, pqissludpzone,
|
||||
"pqissludp::Init_Connection() connect returned 0");
|
||||
}
|
||||
|
||||
waiting = WAITING_SOCK_CONNECT;
|
||||
|
||||
pqioutput(PQL_DEBUG_BASIC, pqissludpzone,
|
||||
rslog(RSL_DEBUG_BASIC, pqissludpzone,
|
||||
"pqissludp::Initiate_Connection() Waiting for Socket Connect");
|
||||
|
||||
return 1;
|
||||
@ -248,20 +245,21 @@ int pqissludp::Initiate_Connection()
|
||||
/********* VERY DIFFERENT **********/
|
||||
int pqissludp::Basic_Connection_Complete()
|
||||
{
|
||||
pqioutput(PQL_DEBUG_BASIC, pqissludpzone,
|
||||
rslog(RSL_DEBUG_BASIC, pqissludpzone,
|
||||
"pqissludp::Basic_Connection_Complete()...");
|
||||
|
||||
|
||||
if (time(NULL) > mTimeoutTS)
|
||||
{
|
||||
pqioutput(PQL_DEBUG_BASIC, pqissludpzone,
|
||||
"pqissludp::Basic_Connection_Complete() Connection Timed Out!");
|
||||
std::ostringstream out;
|
||||
out << "pqissludp::Basic_Connection_Complete() Connection Timed Out. ";
|
||||
out << "Peer: " << PeerId() << " Period: ";
|
||||
out << mConnectTimeout;
|
||||
|
||||
rslog(RSL_WARNING, pqissludpzone, out.str());
|
||||
|
||||
/* as sockfd is valid, this should close it all up */
|
||||
|
||||
std::cerr << "pqissludp::Basic_Connection_Complete() Connection Timed Out!";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "pqissludp::Basic_Connection_Complete() Timeout Period: " << mConnectTimeout;
|
||||
std::cerr << std::endl;
|
||||
reset();
|
||||
return -1;
|
||||
}
|
||||
@ -269,14 +267,12 @@ int pqissludp::Basic_Connection_Complete()
|
||||
|
||||
if (waiting != WAITING_SOCK_CONNECT)
|
||||
{
|
||||
pqioutput(PQL_DEBUG_BASIC, pqissludpzone,
|
||||
rslog(RSL_DEBUG_BASIC, pqissludpzone,
|
||||
"pqissludp::Basic_Connection_Complete() Wrong Mode");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* new approach is to check for an error */
|
||||
/* check for an error */
|
||||
int err;
|
||||
@ -286,17 +282,25 @@ int pqissludp::Basic_Connection_Complete()
|
||||
{
|
||||
|
||||
std::ostringstream out;
|
||||
out << "pqissludp::Basic_Connection_Complete()";
|
||||
out << "EINPROGRESS: cert" << PeerId();
|
||||
pqioutput(PQL_WARNING, pqissludpzone, out.str());
|
||||
out << "pqissludp::Basic_Connection_Complete() ";
|
||||
out << "EINPROGRESS: cert: " << PeerId();
|
||||
rslog(RSL_DEBUG_BASIC, pqissludpzone, out.str());
|
||||
|
||||
}
|
||||
else if ((err == ENETUNREACH) || (err == ETIMEDOUT))
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqissludp::Basic_Connection_Complete()";
|
||||
out << "ENETUNREACH/ETIMEDOUT: cert";
|
||||
out << PeerId() << std::endl;
|
||||
out << "pqissludp::Basic_Connection_Complete() ";
|
||||
out << "ENETUNREACH/ETIMEDOUT: cert: ";
|
||||
out << PeerId();
|
||||
rslog(RSL_WARNING, pqissludpzone, out.str());
|
||||
|
||||
/* is the second one needed? */
|
||||
std::ostringstream out2;
|
||||
out2 << "pqissludp::Basic_Connection_Complete() ";
|
||||
out2 << "Error: Connection Failed: " << err;
|
||||
out2 << " - " << socket_errorType(err);
|
||||
rslog(RSL_DEBUG_BASIC, pqissludpzone, out2.str());
|
||||
|
||||
net_unreachable |= net_attempt;
|
||||
|
||||
@ -305,10 +309,6 @@ int pqissludp::Basic_Connection_Complete()
|
||||
// Then send unreachable message.
|
||||
waiting = WAITING_FAIL_INTERFACE;
|
||||
|
||||
out << "pqissludp::Basic_Connection_Complete()";
|
||||
out << "Error: Connection Failed: " << err;
|
||||
out << " - " << socket_errorType(err);
|
||||
pqioutput(PQL_WARNING, pqissludpzone, out.str());
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -317,14 +317,18 @@ int pqissludp::Basic_Connection_Complete()
|
||||
if (tou_connected(sockfd))
|
||||
/* <===================== UDP Difference *******************/
|
||||
{
|
||||
pqioutput(PQL_WARNING, pqissludpzone,
|
||||
"pqissludp::Basic_Connection_Complete() Connection Complete!");
|
||||
std::ostringstream out;
|
||||
out << "pqissludp::Basic_Connection_Complete() ";
|
||||
out << "Connection Complete: cert: ";
|
||||
out << PeerId();
|
||||
rslog(RSL_WARNING, pqissludpzone, out.str());
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// not ready return -1;
|
||||
pqioutput(PQL_WARNING, pqissludpzone,
|
||||
rslog(RSL_DEBUG_BASIC, pqissludpzone,
|
||||
"pqissludp::Basic_Connection_Complete() Not Yet Ready!");
|
||||
return 0;
|
||||
}
|
||||
@ -340,7 +344,7 @@ int pqissludp::Basic_Connection_Complete()
|
||||
// used everywhere
|
||||
int pqissludp::net_internal_close(int fd)
|
||||
{
|
||||
pqioutput(PQL_ALERT, pqissludpzone,
|
||||
rslog(RSL_ALERT, pqissludpzone,
|
||||
"pqissludp::net_internal_close() -> tou_close()");
|
||||
return tou_close(fd);
|
||||
}
|
||||
@ -348,7 +352,7 @@ int pqissludp::net_internal_close(int fd)
|
||||
// install udp BIO.
|
||||
int pqissludp::net_internal_SSL_set_fd(SSL *ssl, int fd)
|
||||
{
|
||||
pqioutput(PQL_DEBUG_BASIC, pqissludpzone,
|
||||
rslog(RSL_DEBUG_BASIC, pqissludpzone,
|
||||
"pqissludp::net_internal_SSL_set_fd()");
|
||||
|
||||
/* create the bio's */
|
||||
@ -362,7 +366,7 @@ int pqissludp::net_internal_SSL_set_fd(SSL *ssl, int fd)
|
||||
|
||||
int pqissludp::net_internal_fcntl_nonblock(int fd)
|
||||
{
|
||||
pqioutput(PQL_DEBUG_BASIC, pqissludpzone,
|
||||
rslog(RSL_DEBUG_BASIC, pqissludpzone,
|
||||
"pqissludp::net_internal_fcntl_nonblock()");
|
||||
return 0;
|
||||
}
|
||||
@ -383,7 +387,7 @@ int pqissludp::listen()
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqissludp::listen() (NULLOP)";
|
||||
pqioutput(PQL_ALERT, pqissludpzone, out.str());
|
||||
rslog(RSL_DEBUG_BASIC, pqissludpzone, out.str());
|
||||
}
|
||||
return 1; //udpproxy->listen();
|
||||
}
|
||||
@ -393,7 +397,7 @@ int pqissludp::stoplistening()
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqissludp::stoplistening() (NULLOP)";
|
||||
pqioutput(PQL_ALERT, pqissludpzone, out.str());
|
||||
rslog(RSL_DEBUG_BASIC, pqissludpzone, out.str());
|
||||
}
|
||||
return 1; //udpproxy->stoplistening();
|
||||
}
|
||||
@ -401,10 +405,13 @@ int pqissludp::stoplistening()
|
||||
|
||||
bool pqissludp::connect_parameter(uint32_t type, uint32_t value)
|
||||
{
|
||||
std::cerr << "pqissludp::connect_parameter() type: " << type << "value: " << value << std::endl;
|
||||
//std::cerr << "pqissludp::connect_parameter() type: " << type << "value: " << value << std::endl;
|
||||
if (type == NET_PARAM_CONNECT_PERIOD)
|
||||
{
|
||||
std::cerr << "pqissludp::connect_parameter() PERIOD: " << value << std::endl;
|
||||
std::ostringstream out;
|
||||
out << "pqissludp::connect_parameter() Peer: " << PeerId() << " PERIOD: " << value;
|
||||
rslog(RSL_WARNING, pqissludpzone, out.str());
|
||||
|
||||
mConnectPeriod = value;
|
||||
return true;
|
||||
}
|
||||
@ -419,7 +426,7 @@ bool pqissludp::moretoread()
|
||||
std::ostringstream out;
|
||||
out << "pqissludp::moretoread()";
|
||||
out << " polling socket (" << sockfd << ")";
|
||||
pqioutput(PQL_DEBUG_ALL, pqissludpzone, out.str());
|
||||
rslog(RSL_DEBUG_ALL, pqissludpzone, out.str());
|
||||
}
|
||||
|
||||
/* check for more to read first ... if nothing... check error
|
||||
@ -428,13 +435,13 @@ bool pqissludp::moretoread()
|
||||
if (tou_maxread(sockfd))
|
||||
/* <===================== UDP Difference *******************/
|
||||
{
|
||||
pqioutput(PQL_DEBUG_BASIC, pqissludpzone,
|
||||
rslog(RSL_DEBUG_BASIC, pqissludpzone,
|
||||
"pqissludp::moretoread() Data to Read!");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* else check the error */
|
||||
pqioutput(PQL_DEBUG_ALL, pqissludpzone,
|
||||
rslog(RSL_DEBUG_ALL, pqissludpzone,
|
||||
"pqissludp::moretoread() No Data to Read!");
|
||||
|
||||
int err;
|
||||
@ -445,8 +452,8 @@ bool pqissludp::moretoread()
|
||||
|
||||
std::ostringstream out;
|
||||
out << "pqissludp::moretoread() ";
|
||||
out << "EAGAIN/EINPROGRESS: cert" << PeerId();
|
||||
pqioutput(PQL_WARNING, pqissludpzone, out.str());
|
||||
out << "EAGAIN/EINPROGRESS: cert " << PeerId();
|
||||
rslog(RSL_DEBUG_BASIC, pqissludpzone, out.str());
|
||||
return 0;
|
||||
|
||||
}
|
||||
@ -454,27 +461,27 @@ bool pqissludp::moretoread()
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqissludp::moretoread() ";
|
||||
out << "ENETUNREACH/ETIMEDOUT: cert";
|
||||
out << "ENETUNREACH/ETIMEDOUT: cert ";
|
||||
out << PeerId();
|
||||
pqioutput(PQL_WARNING, pqissludpzone, out.str());
|
||||
rslog(RSL_WARNING, pqissludpzone, out.str());
|
||||
|
||||
}
|
||||
else if (err == EBADF)
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqissludp::moretoread() ";
|
||||
out << "EBADF: cert";
|
||||
out << "EBADF: cert ";
|
||||
out << PeerId();
|
||||
pqioutput(PQL_WARNING, pqissludpzone, out.str());
|
||||
rslog(RSL_WARNING, pqissludpzone, out.str());
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqissludp::moretoread() ";
|
||||
out << " Unknown ERROR: " << err << ": cert";
|
||||
out << " Unknown ERROR: " << err << ": cert ";
|
||||
out << PeerId();
|
||||
pqioutput(PQL_WARNING, pqissludpzone, out.str());
|
||||
rslog(RSL_WARNING, pqissludpzone, out.str());
|
||||
|
||||
}
|
||||
|
||||
@ -483,7 +490,7 @@ bool pqissludp::moretoread()
|
||||
}
|
||||
|
||||
/* otherwise - not error - strange! */
|
||||
pqioutput(PQL_DEBUG_BASIC, pqissludpzone,
|
||||
rslog(RSL_DEBUG_BASIC, pqissludpzone,
|
||||
"pqissludp::moretoread() No Data + No Error (really nothing)");
|
||||
|
||||
return 0;
|
||||
@ -493,7 +500,7 @@ bool pqissludp::moretoread()
|
||||
|
||||
bool pqissludp::cansend()
|
||||
{
|
||||
pqioutput(PQL_DEBUG_ALL, pqissludpzone,
|
||||
rslog(RSL_DEBUG_ALL, pqissludpzone,
|
||||
"pqissludp::cansend() polling socket!");
|
||||
|
||||
/* <===================== UDP Difference *******************/
|
||||
|
@ -24,18 +24,18 @@
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "pqi/pqistreamer.h"
|
||||
#include "serialiser/rsserial.h"
|
||||
#include "serialiser/rsbaseitems.h" /***** For RsFileData *****/
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#include <sstream>
|
||||
#include "pqi/pqidebug.h"
|
||||
#include "util/rsdebug.h"
|
||||
|
||||
#include "pqi/pqistreamer.h"
|
||||
#include "pqi/pqinotify.h"
|
||||
|
||||
#include "serialiser/rsserial.h"
|
||||
#include "serialiser/rsbaseitems.h" /***** For RsFileData *****/
|
||||
|
||||
|
||||
const int pqistreamerzone = 8221;
|
||||
|
||||
const int PQISTREAM_ABS_MAX = 100000000; /* 100 MB/sec (actually per loop) */
|
||||
|
@ -30,7 +30,7 @@
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include "pqi/pqidebug.h"
|
||||
#include "util/rsdebug.h"
|
||||
const int p3facemsgzone = 11453;
|
||||
|
||||
#include <sys/time.h>
|
||||
|
@ -34,7 +34,7 @@
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include "pqi/pqidebug.h"
|
||||
#include "util/rsdebug.h"
|
||||
const int p3facefilezone = 11452;
|
||||
|
||||
#include <sys/time.h>
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include "pqi/pqidebug.h"
|
||||
#include "util/rsdebug.h"
|
||||
const int p3facemsgzone = 11453;
|
||||
|
||||
#include <sys/time.h>
|
||||
@ -57,7 +57,7 @@ int RsServer::SetInChat(std::string id, bool in) /* friend : cha
|
||||
/* so we send this.... */
|
||||
lockRsCore(); /* LOCK */
|
||||
|
||||
std::cerr << "Set InChat(" << id << ") to " << (in ? "True" : "False") << std::endl;
|
||||
//std::cerr << "Set InChat(" << id << ") to " << (in ? "True" : "False") << std::endl;
|
||||
std::list<std::string>::iterator it;
|
||||
it = std::find(mInChatList.begin(), mInChatList.end(), id);
|
||||
if (it == mInChatList.end())
|
||||
@ -98,7 +98,7 @@ int RsServer::SetInMsg(std::string id, bool in) /* friend : msgs
|
||||
/* so we send this.... */
|
||||
lockRsCore(); /* LOCK */
|
||||
|
||||
std::cerr << "Set InMsg(" << id << ") to " << (in ? "True" : "False") << std::endl;
|
||||
//std::cerr << "Set InMsg(" << id << ") to " << (in ? "True" : "False") << std::endl;
|
||||
std::list<std::string>::iterator it;
|
||||
it = std::find(mInMsgList.begin(), mInMsgList.end(), id);
|
||||
if (it == mInMsgList.end())
|
||||
@ -207,7 +207,7 @@ int RsServer::SetInRecommend(std::string id, bool in) /* file : recom
|
||||
{
|
||||
/* set flag */
|
||||
it -> inRecommend = in;
|
||||
std::cerr << "Set InRecommend (" << id << ") to " << (in ? "True" : "False") << std::endl;
|
||||
//std::cerr << "Set InRecommend (" << id << ") to " << (in ? "True" : "False") << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include "pqi/pqidebug.h"
|
||||
#include "util/rsdebug.h"
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
|
@ -89,7 +89,7 @@ void intNotifyChangeCert(RsCertId &id)
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include "pqi/pqidebug.h"
|
||||
#include "util/rsdebug.h"
|
||||
const int fltksrvrzone = 25915;
|
||||
|
||||
#include <sys/time.h>
|
||||
|
@ -35,8 +35,8 @@
|
||||
#include "pqi/pqisslpersongrp.h"
|
||||
#include "pqi/pqiloopback.h"
|
||||
#include "pqi/p3cfgmgr.h"
|
||||
#include "pqi/pqidebug.h"
|
||||
|
||||
#include "util/rsdebug.h"
|
||||
#include "util/rsdir.h"
|
||||
|
||||
#include "upnp/upnphandler.h"
|
||||
@ -591,7 +591,7 @@ int RsServer::StartupRetroShare(RsInit *config)
|
||||
|
||||
mRanking = new p3Ranking(mConnMgr, RS_SERVICE_TYPE_RANK, /* declaration of cache enable service rank */
|
||||
mCacheStrapper, mCacheTransfer,
|
||||
localcachedir, remotecachedir, 3600 * 24 * 30);
|
||||
localcachedir, remotecachedir, 3600 * 24 * 30 * 6); // 6 Months
|
||||
|
||||
CachePair cp(mRanking, mRanking, CacheId(RS_SERVICE_TYPE_RANK, 0));
|
||||
mCacheStrapper -> addCachePair(cp); /* end of declaration */
|
||||
@ -609,7 +609,7 @@ int RsServer::StartupRetroShare(RsInit *config)
|
||||
|
||||
mQblog = new p3Qblog(mConnMgr, RS_SERVICE_TYPE_QBLOG, /* ...then for Qblog */
|
||||
mCacheStrapper, mCacheTransfer,
|
||||
localcachedir, remotecachedir, 3600 * 24 * 30);
|
||||
localcachedir, remotecachedir, 3600 * 24 * 30 * 6); // 6 Months
|
||||
|
||||
CachePair cp3(mQblog, mQblog, CacheId(RS_SERVICE_TYPE_QBLOG, 0));
|
||||
mCacheStrapper -> addCachePair(cp3);
|
||||
|
@ -29,14 +29,14 @@
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include "pqi/pqidebug.h"
|
||||
#include "util/rsdir.h"
|
||||
#include "util/rsdebug.h"
|
||||
const int p3facemsgzone = 11453;
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "rsiface/rstypes.h"
|
||||
#include "util/rsdir.h"
|
||||
#include "rsserver/p3msgs.h"
|
||||
|
||||
#include "services/p3msgservice.h"
|
||||
@ -74,8 +74,8 @@ bool p3Msgs::MessageSend(MessageInfo &info)
|
||||
/****************************************/
|
||||
bool p3Msgs::MessageDelete(std::string mid)
|
||||
{
|
||||
std::cerr << "p3Msgs::MessageDelete() ";
|
||||
std::cerr << "mid: " << mid << std::endl;
|
||||
//std::cerr << "p3Msgs::MessageDelete() ";
|
||||
//std::cerr << "mid: " << mid << std::endl;
|
||||
|
||||
mMsgSrv -> removeMsgId(mid);
|
||||
|
||||
@ -84,8 +84,8 @@ bool p3Msgs::MessageDelete(std::string mid)
|
||||
|
||||
bool p3Msgs::MessageRead(std::string mid)
|
||||
{
|
||||
std::cerr << "p3Msgs::MessageRead() ";
|
||||
std::cerr << "mid: " << mid << std::endl;
|
||||
//std::cerr << "p3Msgs::MessageRead() ";
|
||||
//std::cerr << "mid: " << mid << std::endl;
|
||||
|
||||
mMsgSrv -> markMsgIdRead(mid);
|
||||
|
||||
@ -150,14 +150,14 @@ void p3Msgs::initRsChatInfo(RsChatItem *c, ChatInfo &i)
|
||||
i.msg = c -> message;
|
||||
if (c -> chatFlags & RS_CHAT_FLAG_PRIVATE)
|
||||
{
|
||||
std::cerr << "RsServer::initRsChatInfo() Chat Private!!!";
|
||||
i.chatflags = RS_CHAT_PRIVATE;
|
||||
//std::cerr << "RsServer::initRsChatInfo() Chat Private!!!";
|
||||
}
|
||||
else
|
||||
{
|
||||
i.chatflags = RS_CHAT_PUBLIC;
|
||||
std::cerr << "RsServer::initRsChatInfo() Chat Public!!!";
|
||||
//std::cerr << "RsServer::initRsChatInfo() Chat Public!!!";
|
||||
}
|
||||
std::cerr << std::endl;
|
||||
//std::cerr << std::endl;
|
||||
}
|
||||
|
||||
|
@ -29,9 +29,10 @@
|
||||
|
||||
#include "pqi/pqibin.h"
|
||||
#include "pqi/pqiarchive.h"
|
||||
#include "pqi/pqidebug.h"
|
||||
|
||||
#include "util/rsdebug.h"
|
||||
#include "util/rsdir.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
|
@ -28,8 +28,8 @@
|
||||
|
||||
#include "server/ftfiler.h"
|
||||
#include "util/rsdir.h"
|
||||
#include "util/rsdebug.h"
|
||||
|
||||
#include "pqi/pqidebug.h"
|
||||
#include "pqi/pqinotify.h"
|
||||
|
||||
#include <errno.h>
|
||||
|
@ -38,7 +38,7 @@ const uint32_t AUTODISC_LDI_SUBTYPE_RPLY = 0x02;
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "pqi/pqidebug.h"
|
||||
#include "util/rsdebug.h"
|
||||
#include "util/rsprint.h"
|
||||
|
||||
const int pqidisczone = 2482;
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
#include "services/p3gamelauncher.h"
|
||||
#include "services/p3gameservice.h"
|
||||
#include "pqi/pqidebug.h"
|
||||
#include "util/rsdebug.h"
|
||||
#include "pqi/p3connmgr.h"
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
@ -26,12 +26,12 @@
|
||||
|
||||
#include "pqi/pqibin.h"
|
||||
#include "pqi/pqiarchive.h"
|
||||
#include "pqi/pqidebug.h"
|
||||
#include "pqi/p3connmgr.h"
|
||||
|
||||
#include "services/p3msgservice.h"
|
||||
#include "pqi/pqinotify.h"
|
||||
|
||||
#include "util/rsdebug.h"
|
||||
#include "util/rsdir.h"
|
||||
|
||||
#include <sstream>
|
||||
@ -209,7 +209,7 @@ int p3MsgService::checkOutgoingMessages()
|
||||
if (toSend)
|
||||
{
|
||||
/* send msg */
|
||||
pqioutput(PQL_ALERT, msgservicezone,
|
||||
pqioutput(PQL_DEBUG_BASIC, msgservicezone,
|
||||
"p3MsgService::checkOutGoingMessages() Sending out message");
|
||||
/* remove the pending flag */
|
||||
(mit->second)->msgFlags &= ~RS_MSG_FLAGS_PENDING;
|
||||
@ -219,7 +219,7 @@ int p3MsgService::checkOutgoingMessages()
|
||||
}
|
||||
else
|
||||
{
|
||||
pqioutput(PQL_ALERT, msgservicezone,
|
||||
pqioutput(PQL_DEBUG_BASIC, msgservicezone,
|
||||
"p3MsgService::checkOutGoingMessages() Delaying until available...");
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,9 @@
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
#define SERV_DEBUG 1
|
||||
/*****
|
||||
* #define SERV_DEBUG 1
|
||||
****/
|
||||
|
||||
void p3Service::addSerialType(RsSerialType *st)
|
||||
{
|
||||
|
@ -29,6 +29,7 @@
|
||||
|
||||
#include "tcpstream.h"
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
@ -36,6 +37,10 @@
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
|
||||
/* Debugging for STATE change, and Startup SYNs */
|
||||
#include "util/rsdebug.h"
|
||||
const int rstcpstreamzone = 28455;
|
||||
|
||||
|
||||
/*
|
||||
* #define DEBUG_TCP_STREAM 1
|
||||
@ -158,9 +163,18 @@ int TcpStream::connect(const struct sockaddr_in &raddr, uint32_t conn_period)
|
||||
toSend(pkt);
|
||||
/* change state */
|
||||
state = TCP_SYN_SENT;
|
||||
std::cerr << "TcpStream STATE -> TCP_SYN_SENT" << std::endl;
|
||||
errorState = EAGAIN;
|
||||
|
||||
#ifdef DEBUG_TCP_STREAM
|
||||
std::cerr << "TcpStream STATE -> TCP_SYN_SENT" << std::endl;
|
||||
#endif
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "TcpStream::state => TCP_SYN_SENT";
|
||||
out << " (Connect)";
|
||||
rslog(RSL_WARNING,rstcpstreamzone,out.str());
|
||||
}
|
||||
|
||||
tcpMtx.unlock(); /******** UNLOCK MUTEX *********/
|
||||
|
||||
return -1;
|
||||
@ -979,6 +993,13 @@ int TcpStream::recv_check()
|
||||
* for max efficiency
|
||||
*/
|
||||
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "TcpStream::state => TCP_CLOSED";
|
||||
out << " (kNoPktTimeout)";
|
||||
rslog(RSL_WARNING, rstcpstreamzone, out.str());
|
||||
}
|
||||
|
||||
outStreamActive = false;
|
||||
inStreamActive = false;
|
||||
state = TCP_CLOSED;
|
||||
@ -990,11 +1011,19 @@ int TcpStream::recv_check()
|
||||
int TcpStream::cleanup()
|
||||
{
|
||||
// This shuts it all down! no matter what.
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "TcpStream::cleanup() state = TCP_CLOSED";
|
||||
rslog(RSL_WARNING, rstcpstreamzone, out.str());
|
||||
}
|
||||
|
||||
outStreamActive = false;
|
||||
inStreamActive = false;
|
||||
state = TCP_CLOSED;
|
||||
|
||||
#ifdef DEBUG_TCP_STREAM
|
||||
std::cerr << "TcpStream STATE -> TCP_CLOSED" << std::endl;
|
||||
#endif
|
||||
|
||||
//peerKnown = false; //??? NOT SURE -> for a rapid reconnetion this might be key??
|
||||
|
||||
@ -1147,6 +1176,12 @@ int TcpStream::handleIncoming(TcpPacket *pkt)
|
||||
*/
|
||||
state = TCP_CLOSED;
|
||||
// return incoming_TimedWait(pkt);
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "TcpStream::state => TCP_CLOSED";
|
||||
out << " (recvd TCP_TIMED_WAIT?)";
|
||||
rslog(RSL_WARNING, rstcpstreamzone, out.str());
|
||||
}
|
||||
break;
|
||||
}
|
||||
delete pkt;
|
||||
@ -1163,7 +1198,9 @@ int TcpStream::incoming_Closed(TcpPacket *pkt)
|
||||
* else Discard.
|
||||
*/
|
||||
|
||||
#ifdef DEBUG_TCP_STREAM
|
||||
std::cerr << "TcpStream::incoming_Closed()" << std::endl;
|
||||
#endif
|
||||
if ((pkt -> hasSyn()) && (!pkt -> hasAck()))
|
||||
{
|
||||
/* Init Connection */
|
||||
@ -1212,7 +1249,16 @@ int TcpStream::incoming_Closed(TcpPacket *pkt)
|
||||
toSend(rsp);
|
||||
/* change state */
|
||||
state = TCP_SYN_RCVD;
|
||||
|
||||
#ifdef DEBUG_TCP_STREAM
|
||||
std::cerr << "TcpStream STATE -> TCP_SYN_RCVD" << std::endl;
|
||||
#endif
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "TcpStream::state => TCP_SYN_RECVD";
|
||||
out << " (recvd SYN & !ACK)";
|
||||
rslog(RSL_WARNING, rstcpstreamzone, out.str());
|
||||
}
|
||||
}
|
||||
|
||||
delete pkt;
|
||||
@ -1233,14 +1279,18 @@ int TcpStream::incoming_SynSent(TcpPacket *pkt)
|
||||
* else Discard.
|
||||
*/
|
||||
|
||||
#ifdef DEBUG_TCP_STREAM
|
||||
std::cerr << "TcpStream::incoming_SynSent()" << std::endl;
|
||||
#endif
|
||||
|
||||
if ((pkt -> hasSyn()) && (pkt -> hasAck()))
|
||||
{
|
||||
/* check stuff */
|
||||
if (pkt -> getAck() != outSeqno)
|
||||
{
|
||||
#ifdef DEBUG_TCP_STREAM
|
||||
std::cerr << "TcpStream::incoming_SynSent() Bad Ack - Deleting " << std::endl;
|
||||
#endif
|
||||
/* bad ignore */
|
||||
delete pkt;
|
||||
return -1;
|
||||
@ -1270,7 +1320,15 @@ int TcpStream::incoming_SynSent(TcpPacket *pkt)
|
||||
outStreamActive = true;
|
||||
inStreamActive = true;
|
||||
|
||||
#ifdef DEBUG_TCP_STREAM
|
||||
std::cerr << "TcpStream STATE -> TCP_ESTABLISHED" << std::endl;
|
||||
#endif
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "TcpStream::state => TCP_ESTABLISHED";
|
||||
out << " (recvd SUN & ACK)";
|
||||
rslog(RSL_WARNING, rstcpstreamzone, out.str());
|
||||
}
|
||||
|
||||
delete pkt;
|
||||
}
|
||||
@ -1291,7 +1349,15 @@ int TcpStream::incoming_SynRcvd(TcpPacket *pkt)
|
||||
{
|
||||
/* trouble */
|
||||
state = TCP_CLOSED;
|
||||
#ifdef DEBUG_TCP_STREAM
|
||||
std::cerr << "TcpStream STATE -> TCP_CLOSED" << std::endl;
|
||||
#endif
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "TcpStream::state => TCP_CLOSED";
|
||||
out << " (recvd RST)";
|
||||
rslog(RSL_WARNING, rstcpstreamzone, out.str());
|
||||
}
|
||||
delete pkt;
|
||||
return 1;
|
||||
}
|
||||
@ -1303,14 +1369,18 @@ int TcpStream::incoming_SynRcvd(TcpPacket *pkt)
|
||||
if (pkt -> hasSyn())
|
||||
{
|
||||
/* has resent syn -> check it matches */
|
||||
#ifdef DEBUG_TCP_STREAM
|
||||
std::cerr << "incoming_SynRcvd -> Pkt with ACK + SYN" << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* check stuff */
|
||||
if (pkt -> getAck() != outSeqno)
|
||||
{
|
||||
/* bad ignore */
|
||||
#ifdef DEBUG_TCP_STREAM
|
||||
std::cerr << "incoming_SynRcvd -> Ignoring Pkt with bad ACK" << std::endl;
|
||||
#endif
|
||||
delete pkt;
|
||||
return -1;
|
||||
}
|
||||
@ -1320,8 +1390,10 @@ int TcpStream::incoming_SynRcvd(TcpPacket *pkt)
|
||||
/* save seqno */
|
||||
if (pkt -> datasize > 0)
|
||||
{
|
||||
#ifdef DEBUG_TCP_STREAM
|
||||
std::cerr << "TcpStream::incoming_SynRcvd() ACK with Data!" << std::endl;
|
||||
std::cerr << "TcpStream::incoming_SynRcvd() Shoudn't recv ... unless initACK lost!" << std::endl;
|
||||
#endif
|
||||
// managed to trigger this under windows...
|
||||
// perhaps the initial Ack was lost,
|
||||
// believe we should just pass this packet
|
||||
@ -1347,20 +1419,32 @@ int TcpStream::incoming_SynRcvd(TcpPacket *pkt)
|
||||
state = TCP_ESTABLISHED;
|
||||
outStreamActive = true;
|
||||
inStreamActive = true;
|
||||
#ifdef DEBUG_TCP_STREAM
|
||||
std::cerr << "TcpStream STATE -> TCP_ESTABLISHED" << std::endl;
|
||||
#endif
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "TcpStream::state => TCP_ESTABLISHED";
|
||||
out << " (have SYN, recvd ACK)";
|
||||
rslog(RSL_WARNING, rstcpstreamzone, out.str());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (ackWithData)
|
||||
{
|
||||
/* connection Established -> handle normally */
|
||||
#ifdef DEBUG_TCP_STREAM
|
||||
std::cerr << "incoming_SynRcvd -> Handling Data with Ack Pkt!";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
incoming_Established(pkt);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef DEBUG_TCP_STREAM
|
||||
std::cerr << "incoming_SynRcvd -> Ignoring Pkt!" << std::endl;
|
||||
#endif
|
||||
/* else nothing */
|
||||
delete pkt;
|
||||
}
|
||||
@ -1575,20 +1659,44 @@ int TcpStream::check_InPkts()
|
||||
if (state == TCP_ESTABLISHED)
|
||||
{
|
||||
state = TCP_CLOSE_WAIT;
|
||||
std::cerr << "TcpStream::state = TCP_CLOSE_WAIT";
|
||||
std::cerr << std::endl;
|
||||
#ifdef DEBUG_TCP_STREAM
|
||||
std::cerr << "TcpStream::state = TCP_CLOSE_WAIT";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "TcpStream::state => TCP_CLOSE_WAIT";
|
||||
out << " (recvd FIN)";
|
||||
rslog(RSL_WARNING, rstcpstreamzone, out.str());
|
||||
}
|
||||
}
|
||||
else if (state == TCP_FIN_WAIT_1)
|
||||
{
|
||||
state = TCP_CLOSING;
|
||||
std::cerr << "TcpStream::state = TCP_CLOSING";
|
||||
std::cerr << std::endl;
|
||||
#ifdef DEBUG_TCP_STREAM
|
||||
std::cerr << "TcpStream::state = TCP_CLOSING";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "TcpStream::state => TCP_CLOSING";
|
||||
out << " (FIN_WAIT_1, recvd FIN)";
|
||||
rslog(RSL_WARNING, rstcpstreamzone, out.str());
|
||||
}
|
||||
}
|
||||
else if (state == TCP_FIN_WAIT_2)
|
||||
{
|
||||
state = TCP_TIMED_WAIT;
|
||||
std::cerr << "TcpStream::state = TCP_TIMED_WAIT";
|
||||
std::cerr << std::endl;
|
||||
#ifdef DEBUG_TCP_STREAM
|
||||
std::cerr << "TcpStream::state = TCP_TIMED_WAIT";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "TcpStream::state => TCP_TIMED_WAIT";
|
||||
out << " (FIN_WAIT_2, recvd FIN)";
|
||||
rslog(RSL_WARNING, rstcpstreamzone, out.str());
|
||||
}
|
||||
cleanup();
|
||||
}
|
||||
}
|
||||
@ -1600,21 +1708,45 @@ int TcpStream::check_InPkts()
|
||||
if (state == TCP_FIN_WAIT_1)
|
||||
{
|
||||
state = TCP_FIN_WAIT_2;
|
||||
std::cerr << "TcpStream::state = TCP_FIN_WAIT_2";
|
||||
std::cerr << std::endl;
|
||||
#ifdef DEBUG_TCP_STREAM
|
||||
std::cerr << "TcpStream::state = TCP_FIN_WAIT_2";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "TcpStream::state => TCP_FIN_WAIT_2";
|
||||
out << " (FIN_WAIT_1, recvd ACK)";
|
||||
rslog(RSL_WARNING, rstcpstreamzone, out.str());
|
||||
}
|
||||
}
|
||||
else if (state == TCP_LAST_ACK)
|
||||
{
|
||||
state = TCP_CLOSED;
|
||||
std::cerr << "TcpStream::state = TCP_CLOSED";
|
||||
std::cerr << std::endl;
|
||||
#ifdef DEBUG_TCP_STREAM
|
||||
std::cerr << "TcpStream::state = TCP_CLOSED";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "TcpStream::state => TCP_CLOSED";
|
||||
out << " (LAST_ACK, recvd ACK)";
|
||||
rslog(RSL_WARNING, rstcpstreamzone, out.str());
|
||||
}
|
||||
cleanup();
|
||||
}
|
||||
else if (state == TCP_CLOSING)
|
||||
{
|
||||
state = TCP_TIMED_WAIT;
|
||||
std::cerr << "TcpStream::state = TCP_TIMED_WAIT";
|
||||
std::cerr << std::endl;
|
||||
#ifdef DEBUG_TCP_STREAM
|
||||
std::cerr << "TcpStream::state = TCP_TIMED_WAIT";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "TcpStream::state => TCP_TIMED_WAIT";
|
||||
out << " (TCP_CLOSING, recvd ACK)";
|
||||
rslog(RSL_WARNING, rstcpstreamzone, out.str());
|
||||
}
|
||||
cleanup();
|
||||
}
|
||||
}
|
||||
@ -1681,8 +1813,10 @@ int TcpStream::toSend(TcpPacket *pkt, bool retrans)
|
||||
if (!peerKnown)
|
||||
{
|
||||
/* Major Error! */
|
||||
#ifdef DEBUG_TCP_STREAM
|
||||
std::cerr << "TcpStream::toSend() peerUnknown ERROR!!!";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -1769,8 +1903,10 @@ int TcpStream::retrans()
|
||||
if (!peerKnown)
|
||||
{
|
||||
/* Major Error! */
|
||||
#ifdef DEBUG_TCP_STREAM
|
||||
std::cerr << "TcpStream::retrans() peerUnknown ERROR!!!";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -1871,14 +2007,6 @@ int TcpStream::retrans()
|
||||
|
||||
if ((pkt->hasSyn()) && (getTTL() < TCP_STD_TTL))
|
||||
{
|
||||
std::cerr << "TcpStream::retrans() Startup SYNs";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "TcpStream::retrans() retransTimeout: ";
|
||||
std::cerr << retransTimeout << std::endl;
|
||||
|
||||
//setTTL(1 + pkt->retrans /
|
||||
// TCP_STARTUP_COUNT_PER_TTL);
|
||||
|
||||
/* calculate a new TTL */
|
||||
if (mTTL_end > cts)
|
||||
{
|
||||
@ -1889,10 +2017,17 @@ int TcpStream::retrans()
|
||||
setTTL(getTTL() + 1);
|
||||
}
|
||||
|
||||
std::cerr << "TcpStream::retrans() retrans count: ";
|
||||
std::cerr << pkt->retrans << std::endl;
|
||||
std::cerr << "TcpStream::retrans() Setting TTL to: ";
|
||||
std::cerr << getTTL() << std::endl;
|
||||
std::ostringstream out;
|
||||
out << "TcpStream::retrans() Startup SYNs ";
|
||||
out << "retrans count: " << pkt->retrans;
|
||||
out << " New TTL: " << getTTL();
|
||||
|
||||
rslog(RSL_WARNING, rstcpstreamzone, out.str());
|
||||
|
||||
#ifdef DEBUG_TCP_STREAM
|
||||
std::cerr << out.str() << std::endl;
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1913,6 +2048,13 @@ int TcpStream::retrans()
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "TcpStream::state => TCP_CLOSED";
|
||||
out << " (Too Many Retransmits)";
|
||||
rslog(RSL_WARNING,rstcpstreamzone,out.str());
|
||||
}
|
||||
|
||||
outStreamActive = false;
|
||||
inStreamActive = false;
|
||||
state = TCP_CLOSED;
|
||||
@ -2236,17 +2378,29 @@ int TcpStream::send()
|
||||
{
|
||||
state = TCP_FIN_WAIT_1;
|
||||
#ifdef DEBUG_TCP_STREAM
|
||||
std::cerr << "TcpStream::state = TCP_FIN_WAIT_1";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "TcpStream::state = TCP_FIN_WAIT_1";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "TcpStream::state => TCP_FIN_WAIT_1";
|
||||
out << " (End of Stream)";
|
||||
rslog(RSL_WARNING, rstcpstreamzone, out.str());
|
||||
}
|
||||
}
|
||||
else if (state == TCP_CLOSE_WAIT)
|
||||
{
|
||||
state = TCP_LAST_ACK;
|
||||
#ifdef DEBUG_TCP_STREAM
|
||||
std::cerr << "TcpStream::state = TCP_LAST_ACK";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "TcpStream::state = TCP_LAST_ACK";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "TcpStream::state => TCP_LAST_ACK";
|
||||
out << " (CLOSE_WAIT, End of Stream)";
|
||||
rslog(RSL_WARNING, rstcpstreamzone, out.str());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -32,6 +32,9 @@
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
#include "util/rsdebug.h"
|
||||
const int rsudpsorterzone = 28477;
|
||||
|
||||
static const int STUN_TTL = 64;
|
||||
|
||||
/*
|
||||
@ -86,6 +89,10 @@ void UdpSorter::recvPkt(void *data, int size, struct sockaddr_in &from)
|
||||
std::cerr << "UdpSorter::recvPkt() Peer Unknown!";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
std::ostringstream out;
|
||||
out << "UdpSorter::recvPkt() ";
|
||||
out << "from unknown: " << from;
|
||||
rslog(RSL_WARNING,rsudpsorterzone,out.str());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -233,6 +240,11 @@ bool UdpSorter::locked_handleStunPkt(void *data, int size, struct sockaddr_in &f
|
||||
std::cerr << inet_ntoa(from.sin_addr) << ":" << ntohs(from.sin_port);
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "UdpSorter::handleStunPkt() got Request from: " << from;
|
||||
rslog(RSL_WARNING,rsudpsorterzone,out.str());
|
||||
}
|
||||
|
||||
/* generate a response */
|
||||
int len;
|
||||
@ -266,6 +278,13 @@ bool UdpSorter::locked_handleStunPkt(void *data, int size, struct sockaddr_in &f
|
||||
std::cerr << inet_ntoa(eAddr.sin_addr) << ":" << ntohs(eAddr.sin_port);
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "UdpSorter::handleStunPkt() got Response from: " << from;
|
||||
out << " Ext Addr: " << eAddr;
|
||||
rslog(RSL_WARNING,rsudpsorterzone,out.str());
|
||||
}
|
||||
|
||||
locked_recvdStun(from, eAddr);
|
||||
|
||||
return true;
|
||||
|
@ -7,7 +7,7 @@ RS_TOP_DIR = ..
|
||||
include $(RS_TOP_DIR)/scripts/config.mk
|
||||
###############################################################
|
||||
|
||||
RSOBJ = rsthreads.o rsdir.o rsprint.o rsnet.o
|
||||
RSOBJ = rsthreads.o rsdir.o rsprint.o rsnet.o rsdebug.o
|
||||
|
||||
TESTOBJ = dirtest.o dir2test.o
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* "$Id: pqidebug.cc,v 1.6 2007-02-18 21:46:49 rmf24 Exp $"
|
||||
*
|
||||
* 3P/PQI network interface for RetroShare.
|
||||
* 3P/RS network interface for RetroShare.
|
||||
*
|
||||
* Copyright 2004-2006 by Robert Fernie.
|
||||
*
|
||||
@ -26,28 +26,35 @@
|
||||
|
||||
|
||||
|
||||
#include "pqi/pqidebug.h"
|
||||
#include "util/rsdebug.h"
|
||||
#include "util/rsthreads.h"
|
||||
|
||||
#include <map>
|
||||
#include <stdio.h>
|
||||
|
||||
const int PQI_DEBUG_STDERR = 1; /* stuff goes to stderr */
|
||||
const int PQI_DEBUG_LOGFILE = 2; /* stuff goes to logfile */
|
||||
const int PQI_DEBUG_LOGCRASH = 3; /* minimal logfile stored after crashes */
|
||||
const int PQI_DEBUG_LOGC_MAX = 1000; /* max length of carshfile log */
|
||||
const int PQI_DEBUG_LOGC_MIN_SAVE = 100; /* max length of carshfile log */
|
||||
const int RS_DEBUG_STDERR = 1; /* stuff goes to stderr */
|
||||
const int RS_DEBUG_LOGFILE = 2; /* stuff goes to logfile */
|
||||
const int RS_DEBUG_LOGCRASH = 3; /* minimal logfile stored after crashes */
|
||||
const int RS_DEBUG_LOGC_MAX = 100000; /* max length of crashfile log */
|
||||
const int RS_DEBUG_LOGC_MIN_SAVE = 100; /* min length of crashfile log */
|
||||
|
||||
static std::map<int, int> zoneLevel;
|
||||
static int defaultLevel = PQL_WARNING;
|
||||
static int defaultLevel = RSL_WARNING;
|
||||
static FILE *ofd = stderr;
|
||||
|
||||
static int debugMode = PQI_DEBUG_STDERR;
|
||||
static int debugMode = RS_DEBUG_STDERR;
|
||||
static int lineCount = 0;
|
||||
static std::string crashfile;
|
||||
static int debugTS = 0;
|
||||
|
||||
static RsMutex logMtx;
|
||||
|
||||
int locked_setDebugFile(const char *fname);
|
||||
int locked_getZoneLevel(int zone);
|
||||
|
||||
int setDebugCrashMode(const char *cfile)
|
||||
{
|
||||
RsStackMutex stack(logMtx); /******** LOCKED ****************/
|
||||
crashfile = cfile;
|
||||
/* if the file exists - then we crashed, save it */
|
||||
FILE *tmpin = fopen(crashfile.c_str(), "r");
|
||||
@ -55,7 +62,7 @@ int setDebugCrashMode(const char *cfile)
|
||||
{
|
||||
/* see how long it is */
|
||||
fseek(tmpin, 0, SEEK_END);
|
||||
if (ftell(tmpin) > PQI_DEBUG_LOGC_MIN_SAVE)
|
||||
if (ftell(tmpin) > RS_DEBUG_LOGC_MIN_SAVE)
|
||||
{
|
||||
std::string crashfile_save = crashfile + "-save";
|
||||
fprintf(stderr, "Detected Old Crash File: %s\n", crashfile.c_str());
|
||||
@ -95,10 +102,10 @@ int setDebugCrashMode(const char *cfile)
|
||||
}
|
||||
}
|
||||
|
||||
if (0 < setDebugFile(crashfile.c_str()))
|
||||
if (0 < locked_setDebugFile(crashfile.c_str()))
|
||||
{
|
||||
fprintf(stderr, "Switching To CrashLog Mode!\n");
|
||||
debugMode = PQI_DEBUG_LOGCRASH;
|
||||
debugMode = RS_DEBUG_LOGCRASH;
|
||||
lineCount = 0;
|
||||
debugTS = time(NULL);
|
||||
}
|
||||
@ -109,8 +116,9 @@ int setDebugCrashMode(const char *cfile)
|
||||
/* this is called when we exit normally */
|
||||
int clearDebugCrashLog()
|
||||
{
|
||||
RsStackMutex stack(logMtx); /******** LOCKED ****************/
|
||||
/* check we are in crashLog Mode */
|
||||
if (debugMode != PQI_DEBUG_LOGCRASH)
|
||||
if (debugMode != RS_DEBUG_LOGCRASH)
|
||||
{
|
||||
fprintf(stderr, "Not in CrashLog Mode - nothing to clear!\n");
|
||||
return 1;
|
||||
@ -120,7 +128,7 @@ int clearDebugCrashLog()
|
||||
/* shutdown crashLog Mode */
|
||||
fclose(ofd);
|
||||
ofd = stderr;
|
||||
debugMode = PQI_DEBUG_STDERR;
|
||||
debugMode = RS_DEBUG_STDERR;
|
||||
|
||||
/* just open the file, and then close */
|
||||
FILE *tmpin = fopen(crashfile.c_str(), "w");
|
||||
@ -132,17 +140,23 @@ int clearDebugCrashLog()
|
||||
|
||||
|
||||
int setDebugFile(const char *fname)
|
||||
{
|
||||
RsStackMutex stack(logMtx); /******** LOCKED ****************/
|
||||
return locked_setDebugFile(fname);
|
||||
}
|
||||
|
||||
int locked_setDebugFile(const char *fname)
|
||||
{
|
||||
if (NULL != (ofd = fopen(fname, "w")))
|
||||
{
|
||||
fprintf(stderr, "Logging redirected to %s\n", fname);
|
||||
debugMode = PQI_DEBUG_LOGFILE;
|
||||
debugMode = RS_DEBUG_LOGFILE;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
ofd = stderr;
|
||||
debugMode = PQI_DEBUG_STDERR;
|
||||
debugMode = RS_DEBUG_STDERR;
|
||||
fprintf(stderr, "Logging redirect to %s FAILED\n", fname);
|
||||
return -1;
|
||||
}
|
||||
@ -151,17 +165,25 @@ int setDebugFile(const char *fname)
|
||||
|
||||
int setOutputLevel(int lvl)
|
||||
{
|
||||
RsStackMutex stack(logMtx); /******** LOCKED ****************/
|
||||
return defaultLevel = lvl;
|
||||
}
|
||||
|
||||
int setZoneLevel(int lvl, int zone)
|
||||
{
|
||||
RsStackMutex stack(logMtx); /******** LOCKED ****************/
|
||||
zoneLevel[zone] = lvl;
|
||||
return zone;
|
||||
}
|
||||
|
||||
|
||||
int getZoneLevel(int zone)
|
||||
{
|
||||
RsStackMutex stack(logMtx); /******** LOCKED ****************/
|
||||
return locked_getZoneLevel(zone);
|
||||
}
|
||||
|
||||
int locked_getZoneLevel(int zone)
|
||||
{
|
||||
std::map<int, int>::iterator it = zoneLevel.find(zone);
|
||||
if (it == zoneLevel.end())
|
||||
@ -171,27 +193,28 @@ int getZoneLevel(int zone)
|
||||
return it -> second;
|
||||
}
|
||||
|
||||
int pqioutput(unsigned int lvl, int zone, std::string msg)
|
||||
int rslog(unsigned int lvl, int zone, std::string msg)
|
||||
{
|
||||
if ((signed) lvl <= getZoneLevel(zone))
|
||||
RsStackMutex stack(logMtx); /******** LOCKED ****************/
|
||||
if ((signed) lvl <= locked_getZoneLevel(zone))
|
||||
{
|
||||
time_t t = time(NULL);
|
||||
|
||||
if (debugMode == PQI_DEBUG_LOGCRASH)
|
||||
if (debugMode == RS_DEBUG_LOGCRASH)
|
||||
{
|
||||
if (lineCount > PQI_DEBUG_LOGC_MAX)
|
||||
if (lineCount > RS_DEBUG_LOGC_MAX)
|
||||
{
|
||||
/* restarting logging */
|
||||
fprintf(stderr, "Rolling over the CrashLog\n");
|
||||
fclose(ofd);
|
||||
ofd = NULL;
|
||||
if (0 < setDebugFile(crashfile.c_str()))
|
||||
if (0 < locked_setDebugFile(crashfile.c_str()))
|
||||
{
|
||||
fprintf(ofd, "Debug CrashLog:");
|
||||
fprintf(ofd, " retroShare uptime %ld secs\n",
|
||||
t-debugTS);
|
||||
|
||||
debugMode = PQI_DEBUG_LOGCRASH;
|
||||
debugMode = RS_DEBUG_LOGCRASH;
|
||||
lineCount = 0;
|
||||
}
|
||||
else
|
@ -1,9 +1,9 @@
|
||||
/*
|
||||
* "$Id: pqidebug.h,v 1.4 2007-02-18 21:46:49 rmf24 Exp $"
|
||||
* libretroshare/src/util: rsdebug.h
|
||||
*
|
||||
* 3P/PQI network interface for RetroShare.
|
||||
* Debug interface for RetroShare.
|
||||
*
|
||||
* Copyright 2004-2006 by Robert Fernie.
|
||||
* Copyright 2004-2008 by Robert Fernie.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
@ -24,17 +24,22 @@
|
||||
*/
|
||||
|
||||
|
||||
/* Moved from pqi/ to util/ so it can be used more generally.
|
||||
*/
|
||||
|
||||
#ifndef PQI_LOG_DEBUG_H
|
||||
#define PQI_LOG_DEBUG_H
|
||||
#ifndef RS_LOG_DEBUG_H
|
||||
#define RS_LOG_DEBUG_H
|
||||
|
||||
|
||||
|
||||
#define RSL_NONE -1
|
||||
#define RSL_ALERT 1
|
||||
#define RSL_ERROR 3
|
||||
#define RSL_WARNING 5
|
||||
#define RSL_DEBUG_ALERT 6
|
||||
#define RSL_DEBUG_BASIC 8
|
||||
#define RSL_DEBUG_ALL 10
|
||||
|
||||
#define PQL_NONE -1
|
||||
#define PQL_ALERT 1
|
||||
#define PQL_ERROR 3
|
||||
#define PQL_WARNING 5
|
||||
#define PQL_DEBUG_ALERT 6
|
||||
#define PQL_DEBUG_BASIC 8
|
||||
#define PQL_DEBUG_ALL 10
|
||||
|
||||
#include <string>
|
||||
|
||||
@ -44,6 +49,25 @@ int clearDebugCrashLog();
|
||||
int setDebugFile(const char *fname);
|
||||
int setOutputLevel(int lvl);
|
||||
int setZoneLevel(int lvl, int zone);
|
||||
int pqioutput(unsigned int lvl, int zone, std::string msg);
|
||||
int rslog(unsigned int lvl, int zone, std::string msg);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* retaining old #DEFINES and functions for backward compatibility.
|
||||
*/
|
||||
|
||||
//int pqioutput(unsigned int lvl, int zone, std::string msg);
|
||||
#define pqioutput rslog
|
||||
|
||||
#define PQL_NONE RSL_NONE
|
||||
#define PQL_ALERT RSL_ALERT
|
||||
#define PQL_ERROR RSL_ERROR
|
||||
#define PQL_WARNING RSL_WARNING
|
||||
#define PQL_DEBUG_ALERT RSL_DEBUG_ALERT
|
||||
#define PQL_DEBUG_BASIC RSL_DEBUG_BASIC
|
||||
#define PQL_DEBUG_ALL RSL_DEBUG_ALL
|
||||
|
||||
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user