mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-03 11:54:30 -04: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
33 changed files with 867 additions and 346 deletions
|
@ -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;
|
||||
|
||||
|
|
|
@ -1,216 +0,0 @@
|
|||
/*
|
||||
* "$Id: pqidebug.cc,v 1.6 2007-02-18 21:46:49 rmf24 Exp $"
|
||||
*
|
||||
* 3P/PQI network interface for RetroShare.
|
||||
*
|
||||
* Copyright 2004-2006 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
|
||||
* License Version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*
|
||||
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "pqi/pqidebug.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 */
|
||||
|
||||
static std::map<int, int> zoneLevel;
|
||||
static int defaultLevel = PQL_WARNING;
|
||||
static FILE *ofd = stderr;
|
||||
|
||||
static int debugMode = PQI_DEBUG_STDERR;
|
||||
static int lineCount = 0;
|
||||
static std::string crashfile;
|
||||
static int debugTS = 0;
|
||||
|
||||
int setDebugCrashMode(const char *cfile)
|
||||
{
|
||||
crashfile = cfile;
|
||||
/* if the file exists - then we crashed, save it */
|
||||
FILE *tmpin = fopen(crashfile.c_str(), "r");
|
||||
if (tmpin)
|
||||
{
|
||||
/* see how long it is */
|
||||
fseek(tmpin, 0, SEEK_END);
|
||||
if (ftell(tmpin) > PQI_DEBUG_LOGC_MIN_SAVE)
|
||||
{
|
||||
std::string crashfile_save = crashfile + "-save";
|
||||
fprintf(stderr, "Detected Old Crash File: %s\n", crashfile.c_str());
|
||||
fprintf(stderr, "Copying to: %s\n", crashfile_save.c_str());
|
||||
|
||||
/* go back to the start */
|
||||
fseek(tmpin, 0, SEEK_SET);
|
||||
|
||||
FILE *tmpout = fopen(crashfile_save.c_str(), "w");
|
||||
int da_size = 10240;
|
||||
char dataarray[da_size]; /* 10k */
|
||||
unsigned int da_read = 0;
|
||||
|
||||
if (!tmpout)
|
||||
{
|
||||
fprintf(stderr, "Failed to open CrashSave\n");
|
||||
fclose(tmpin);
|
||||
return -1;
|
||||
}
|
||||
while(0 != (da_read = fread(dataarray, 1, da_size, tmpin)))
|
||||
{
|
||||
if (da_read != fwrite(dataarray, 1, da_read, tmpout))
|
||||
{
|
||||
fprintf(stderr, "Failed writing to CrashSave\n");
|
||||
fclose(tmpout);
|
||||
fclose(tmpin);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
fclose(tmpout);
|
||||
fclose(tmpin);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Negligable Old CrashLog, ignoring\n");
|
||||
fclose(tmpin);
|
||||
}
|
||||
}
|
||||
|
||||
if (0 < setDebugFile(crashfile.c_str()))
|
||||
{
|
||||
fprintf(stderr, "Switching To CrashLog Mode!\n");
|
||||
debugMode = PQI_DEBUG_LOGCRASH;
|
||||
lineCount = 0;
|
||||
debugTS = time(NULL);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* this is called when we exit normally */
|
||||
int clearDebugCrashLog()
|
||||
{
|
||||
/* check we are in crashLog Mode */
|
||||
if (debugMode != PQI_DEBUG_LOGCRASH)
|
||||
{
|
||||
fprintf(stderr, "Not in CrashLog Mode - nothing to clear!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
fprintf(stderr, "clearDebugCrashLog() Cleaning up\n");
|
||||
/* shutdown crashLog Mode */
|
||||
fclose(ofd);
|
||||
ofd = stderr;
|
||||
debugMode = PQI_DEBUG_STDERR;
|
||||
|
||||
/* just open the file, and then close */
|
||||
FILE *tmpin = fopen(crashfile.c_str(), "w");
|
||||
fclose(tmpin);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int setDebugFile(const char *fname)
|
||||
{
|
||||
if (NULL != (ofd = fopen(fname, "w")))
|
||||
{
|
||||
fprintf(stderr, "Logging redirected to %s\n", fname);
|
||||
debugMode = PQI_DEBUG_LOGFILE;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
ofd = stderr;
|
||||
debugMode = PQI_DEBUG_STDERR;
|
||||
fprintf(stderr, "Logging redirect to %s FAILED\n", fname);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int setOutputLevel(int lvl)
|
||||
{
|
||||
return defaultLevel = lvl;
|
||||
}
|
||||
|
||||
int setZoneLevel(int lvl, int zone)
|
||||
{
|
||||
zoneLevel[zone] = lvl;
|
||||
return zone;
|
||||
}
|
||||
|
||||
|
||||
int getZoneLevel(int zone)
|
||||
{
|
||||
std::map<int, int>::iterator it = zoneLevel.find(zone);
|
||||
if (it == zoneLevel.end())
|
||||
{
|
||||
return defaultLevel;
|
||||
}
|
||||
return it -> second;
|
||||
}
|
||||
|
||||
int pqioutput(unsigned int lvl, int zone, std::string msg)
|
||||
{
|
||||
if ((signed) lvl <= getZoneLevel(zone))
|
||||
{
|
||||
time_t t = time(NULL);
|
||||
|
||||
if (debugMode == PQI_DEBUG_LOGCRASH)
|
||||
{
|
||||
if (lineCount > PQI_DEBUG_LOGC_MAX)
|
||||
{
|
||||
/* restarting logging */
|
||||
fprintf(stderr, "Rolling over the CrashLog\n");
|
||||
fclose(ofd);
|
||||
ofd = NULL;
|
||||
if (0 < setDebugFile(crashfile.c_str()))
|
||||
{
|
||||
fprintf(ofd, "Debug CrashLog:");
|
||||
fprintf(ofd, " retroShare uptime %ld secs\n",
|
||||
t-debugTS);
|
||||
|
||||
debugMode = PQI_DEBUG_LOGCRASH;
|
||||
lineCount = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Rollover Failed!\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string timestr = ctime(&t);
|
||||
std::string timestr2 = timestr.substr(0,timestr.length()-1);
|
||||
/* remove the endl */
|
||||
fprintf(ofd, "(%s Z: %d, lvl:%d): %s \n",
|
||||
timestr2.c_str(), zone, lvl, msg.c_str());
|
||||
fflush(ofd);
|
||||
lineCount++;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
/*
|
||||
* "$Id: pqidebug.h,v 1.4 2007-02-18 21:46:49 rmf24 Exp $"
|
||||
*
|
||||
* 3P/PQI network interface for RetroShare.
|
||||
*
|
||||
* Copyright 2004-2006 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
|
||||
* License Version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*
|
||||
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef PQI_LOG_DEBUG_H
|
||||
#define PQI_LOG_DEBUG_H
|
||||
|
||||
#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>
|
||||
|
||||
int setDebugCrashMode(const char *cfile);
|
||||
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);
|
||||
|
||||
#endif
|
|
@ -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) */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue