mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Removed some std::ostringstream.
To be continued. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5103 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
60a68210d5
commit
83bd45caa4
@ -229,33 +229,19 @@ bool p3BitDht::saveList(bool &cleanup, std::list<RsItem *> &saveList)
|
||||
int i;
|
||||
for(i = 0; i < RSDHT_RELAY_NUM_CLASS; i++)
|
||||
{
|
||||
std::ostringstream keyout;
|
||||
keyout << "RELAY_CLASS" << i;
|
||||
|
||||
std::string countkey = keyout.str() + "_COUNT";
|
||||
std::string bandkey = keyout.str() + "_BANDWIDTH";
|
||||
|
||||
std::ostringstream countout;
|
||||
std::ostringstream bandout;
|
||||
countout << mRelay->getRelayClassMax(i);
|
||||
bandout << mRelay->getRelayClassBandwidth(i);
|
||||
|
||||
kv.key = countkey;
|
||||
kv.value = countout.str();
|
||||
rs_sprintf(kv.key, "RELAY_CLASS%d_COUNT", i);
|
||||
rs_sprintf(kv.value, "%d", mRelay->getRelayClassMax(i));
|
||||
config->tlvkvs.pairs.push_back(kv);
|
||||
|
||||
kv.key = bandkey;
|
||||
kv.value = bandout.str();
|
||||
config->tlvkvs.pairs.push_back(kv);
|
||||
rs_sprintf(kv.key, "RELAY_CLASS%d_BANDWIDTH", i);
|
||||
rs_sprintf(kv.value, "%d", mRelay->getRelayClassBandwidth(i));
|
||||
config->tlvkvs.pairs.push_back(kv);
|
||||
}
|
||||
|
||||
/* add RelayMode */
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << mRelayMode;
|
||||
|
||||
kv.key = "RELAY_MODE";
|
||||
kv.value = out.str();
|
||||
kv.key = "RELAY_MODE";
|
||||
rs_sprintf(kv.value, "%lu", mRelayMode);
|
||||
config->tlvkvs.pairs.push_back(kv);
|
||||
}
|
||||
|
||||
@ -263,11 +249,8 @@ bool p3BitDht::saveList(bool &cleanup, std::list<RsItem *> &saveList)
|
||||
std::list<std::string>::iterator it;
|
||||
for(i = 0, it = mRelayServerList.begin(); it != mRelayServerList.end(); it++, i++)
|
||||
{
|
||||
std::ostringstream key;
|
||||
key << "RELAY_SERVER" << i;
|
||||
|
||||
kv.key = key.str();
|
||||
kv.value = *it;
|
||||
rs_sprintf(kv.key, "RELAY_SERVER%d", i);
|
||||
kv.value = *it;
|
||||
config->tlvkvs.pairs.push_back(kv);
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "retroshare/rsdistrib.h"
|
||||
#include "retroshare/rspeers.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
p3DistribSecurity::p3DistribSecurity()
|
||||
{
|
||||
|
@ -250,18 +250,18 @@ bool ftFiMonitor::saveList(bool &cleanup, std::list<RsItem *>& sList)
|
||||
|
||||
/* basic control parameters */
|
||||
{
|
||||
std::ostringstream s ;
|
||||
s << rememberHashFilesDuration() ;
|
||||
std::string s ;
|
||||
rs_sprintf(s, "%lu", rememberHashFilesDuration()) ;
|
||||
|
||||
configMap[hash_cache_duration_ss] = s.str() ;
|
||||
configMap[hash_cache_duration_ss] = s ;
|
||||
}
|
||||
configMap[hash_cache_ss] = rememberHashFiles()?"YES":"NO" ;
|
||||
|
||||
{
|
||||
std::ostringstream s ;
|
||||
s << watchPeriod() ;
|
||||
std::string s ;
|
||||
rs_sprintf(s, "%d", watchPeriod()) ;
|
||||
|
||||
configMap[watch_file_duration_ss] = s.str() ;
|
||||
configMap[watch_file_duration_ss] = s ;
|
||||
}
|
||||
|
||||
RsConfigKeyValueSet *rskv = new RsConfigKeyValueSet();
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "authgpg.h"
|
||||
#include "serialiser/rsconfigitems.h"
|
||||
#include "util/rsdir.h"
|
||||
#include "util/rsstring.h"
|
||||
|
||||
#include "retroshare/rspeers.h" // for RsPeerDetails structure
|
||||
|
||||
@ -48,7 +49,6 @@
|
||||
#include <openssl/rand.h>
|
||||
#include <openssl/x509.h>
|
||||
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
/****
|
||||
@ -380,16 +380,11 @@ bool AuthSSLimpl::SignData(const void *data, const uint32_t len, std::string &si
|
||||
EVP_MD_CTX_destroy(mdctx);
|
||||
|
||||
sign.clear();
|
||||
std::ostringstream out;
|
||||
out << std::hex;
|
||||
for(uint32_t i = 0; i < signlen; i++)
|
||||
{
|
||||
out << std::setw(2) << std::setfill('0');
|
||||
out << (uint32_t) (signature[i]);
|
||||
rs_sprintf_append(sign, "%02x", (uint32_t) (signature[i]));
|
||||
}
|
||||
|
||||
sign = out.str();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1172,9 +1167,7 @@ bool AuthSSLimpl::FailedCertificate(X509 *x509, const struct sockaddr_in &add
|
||||
|
||||
{
|
||||
// Hacky - adding IpAddress to SSLId.
|
||||
std::ostringstream out;
|
||||
out << "/" << rs_inet_ntoa(addr.sin_addr) << ":" << ntohs(addr.sin_port);
|
||||
peerId += out.str();
|
||||
rs_sprintf(peerId, "/%s:%u", rs_inet_ntoa(addr.sin_addr).c_str(), ntohs(addr.sin_port));
|
||||
}
|
||||
|
||||
uint32_t notifyType = 0;
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "pqi/pqinotify.h"
|
||||
#include <errno.h>
|
||||
#include <util/rsdiscspace.h>
|
||||
#include "util/rsstring.h"
|
||||
|
||||
#include "serialiser/rsconfigitems.h"
|
||||
|
||||
@ -180,11 +181,7 @@ void p3ConfigMgr::globalSaveConfig()
|
||||
}
|
||||
|
||||
RsTlvKeyValue kv;
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << it->first;
|
||||
kv.key = out.str();
|
||||
}
|
||||
rs_sprintf(kv.key, "%lu", it->first);
|
||||
kv.value = it->second->Hash();
|
||||
item->tlvkvs.pairs.push_back(kv);
|
||||
}
|
||||
|
@ -24,7 +24,6 @@
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <stdio.h>
|
||||
#include <openssl/sha.h>
|
||||
@ -35,6 +34,7 @@
|
||||
|
||||
#include "util/rsprint.h"
|
||||
#include "util/rsdebug.h"
|
||||
#include "util/rsstring.h"
|
||||
const int p3dhtzone = 3892;
|
||||
|
||||
/*****
|
||||
@ -215,16 +215,15 @@ bool p3DhtMgr::setExternalInterface(
|
||||
#endif
|
||||
|
||||
/* Log External Interface too */
|
||||
std::ostringstream out;
|
||||
out << "p3DhtMgr::setExternalInterface()";
|
||||
out << " laddr: " << rs_inet_ntoa(ownEntry.laddr.sin_addr);
|
||||
out << " lport: " << ntohs(ownEntry.laddr.sin_port);
|
||||
out << " raddr: " << rs_inet_ntoa(ownEntry.raddr.sin_addr);
|
||||
out << " rport: " << ntohs(ownEntry.raddr.sin_port);
|
||||
out << " type: " << ownEntry.type;
|
||||
out << " state: " << ownEntry.state;
|
||||
std::string out = "p3DhtMgr::setExternalInterface()";
|
||||
out += " laddr: " + rs_inet_ntoa(ownEntry.laddr.sin_addr);
|
||||
rs_sprintf_append(out, " lport: %u", ntohs(ownEntry.laddr.sin_port));
|
||||
out += " raddr: " + rs_inet_ntoa(ownEntry.raddr.sin_addr);
|
||||
rs_sprintf_append(out, " rport: %u", ntohs(ownEntry.raddr.sin_port));
|
||||
rs_sprintf_append(out, " type: %lu", ownEntry.type);
|
||||
rs_sprintf_append(out, " state: %lu", ownEntry.state);
|
||||
|
||||
rslog(RSL_WARNING, p3dhtzone, out.str());
|
||||
rslog(RSL_WARNING, p3dhtzone, out);
|
||||
|
||||
dhtMtx.unlock(); /* UNLOCK MUTEX */
|
||||
|
||||
@ -329,10 +328,7 @@ bool p3DhtMgr::notifyPeer(std::string id)
|
||||
#endif
|
||||
{
|
||||
/* Log */
|
||||
std::ostringstream out;
|
||||
out << "p3DhtMgr::notifyPeer() Id: " << id;
|
||||
out << " TO SOON - DROPPING";
|
||||
rslog(RSL_WARNING, p3dhtzone, out.str());
|
||||
rslog(RSL_WARNING, p3dhtzone, "p3DhtMgr::notifyPeer() Id: " + id + " TO SOON - DROPPING");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -348,10 +344,7 @@ bool p3DhtMgr::notifyPeer(std::string id)
|
||||
#endif
|
||||
{
|
||||
/* Log */
|
||||
std::ostringstream out;
|
||||
out << "p3DhtMgr::notifyPeer() Id: " << id;
|
||||
out << " PEER NOT FOUND - Trigger Search";
|
||||
rslog(RSL_WARNING, p3dhtzone, out.str());
|
||||
rslog(RSL_WARNING, p3dhtzone, "p3DhtMgr::notifyPeer() Id: " + id + " PEER NOT FOUND - Trigger Search");
|
||||
}
|
||||
it->second.lastTS = 0;
|
||||
}
|
||||
@ -620,16 +613,15 @@ int p3DhtMgr::checkOwnDHTKeys()
|
||||
|
||||
{
|
||||
/* Log */
|
||||
std::ostringstream out;
|
||||
out << "p3DhtMgr::checkOwnDHTKeys() PUBLISH OWN ADDR:";
|
||||
out << " hash1: " << RsUtil::BinToHex(peer.hash1);
|
||||
out << " laddr: " << rs_inet_ntoa(peer.laddr.sin_addr);
|
||||
out << " :" << ntohs(peer.laddr.sin_port);
|
||||
out << " raddr: " << rs_inet_ntoa(peer.raddr.sin_addr);
|
||||
out << ":" << ntohs(peer.raddr.sin_port);
|
||||
out << " type: " << peer.type;
|
||||
std::string out = "p3DhtMgr::checkOwnDHTKeys() PUBLISH OWN ADDR:";
|
||||
out += " hash1: " + RsUtil::BinToHex(peer.hash1);
|
||||
out += " laddr: " + rs_inet_ntoa(peer.laddr.sin_addr);
|
||||
rs_sprintf_append(out, ":%u", ntohs(peer.laddr.sin_port));
|
||||
out += " raddr: " + rs_inet_ntoa(peer.raddr.sin_addr);
|
||||
rs_sprintf_append(out, ":%u", ntohs(peer.raddr.sin_port));
|
||||
rs_sprintf_append(out, " type: %lu", peer.type);
|
||||
|
||||
rslog(RSL_WARNING, p3dhtzone, out.str());
|
||||
rslog(RSL_WARNING, p3dhtzone, out);
|
||||
}
|
||||
|
||||
/* publish own key */
|
||||
@ -693,9 +685,7 @@ int p3DhtMgr::checkOwnDHTKeys()
|
||||
#endif
|
||||
{
|
||||
/* Log */
|
||||
std::ostringstream out;
|
||||
out << "p3DhtMgr::checkOwnDHTKeys() Checking for NOTIFY";
|
||||
rslog(RSL_WARNING, p3dhtzone, out.str());
|
||||
rslog(RSL_WARNING, p3dhtzone, "p3DhtMgr::checkOwnDHTKeys() Checking for NOTIFY");
|
||||
}
|
||||
|
||||
if (dhtSearch(peer.hash1, DHT_MODE_NOTIFY))
|
||||
@ -907,9 +897,7 @@ int p3DhtMgr::checkNotifyDHT()
|
||||
#endif
|
||||
{
|
||||
/* Log */
|
||||
std::ostringstream out;
|
||||
out << "p3DhtMgr::checkNotifyDHT() Notify Request for Known Peer: " << it->first;
|
||||
rslog(RSL_WARNING, p3dhtzone, out.str());
|
||||
rslog(RSL_WARNING, p3dhtzone, "p3DhtMgr::checkNotifyDHT() Notify Request for Known Peer: " + it->first);
|
||||
}
|
||||
|
||||
/* update timestamp */
|
||||
@ -933,9 +921,7 @@ int p3DhtMgr::checkNotifyDHT()
|
||||
#endif
|
||||
{
|
||||
/* Log */
|
||||
std::ostringstream out;
|
||||
out << "p3DhtMgr::checkNotifyDHT() POST DHT (Active Notify) for Peer: " << peer.id;
|
||||
rslog(RSL_WARNING, p3dhtzone, out.str());
|
||||
rslog(RSL_WARNING, p3dhtzone, "p3DhtMgr::checkNotifyDHT() POST DHT (Active Notify) for Peer: " + peer.id);
|
||||
}
|
||||
|
||||
dhtNotify(peer.hash1, own.hash2, "");
|
||||
@ -1117,20 +1103,18 @@ std::string p3DhtMgr::BootstrapId(uint32_t bin)
|
||||
* Make sure that NUM_BOOTSTRAP_BINS doesn't affect ids
|
||||
*/
|
||||
|
||||
std::ostringstream genId;
|
||||
genId << "BootstrapId";
|
||||
|
||||
uint32_t id = (bin % DHT_NUM_BOOTSTRAP_BINS) * 1234;
|
||||
|
||||
genId << id;
|
||||
std::string genId;
|
||||
rs_sprintf(genId, "BootstrapId%lu", id);
|
||||
|
||||
#ifdef DHT_DEBUG
|
||||
std::cerr << "p3DhtMgr::BootstrapId() generatedId: ";
|
||||
std::cerr << genId.str() << std::endl;
|
||||
std::cerr << genId << std::endl;
|
||||
#endif
|
||||
|
||||
/* now hash this to create a bootstrap Bin Id */
|
||||
std::string bootId = RsUtil::HashId(genId.str(), false);
|
||||
std::string bootId = RsUtil::HashId(genId, false);
|
||||
|
||||
#ifdef DHT_DEBUG
|
||||
std::cerr << "p3DhtMgr::BootstrapId() bootId: 0x";
|
||||
@ -1375,26 +1359,11 @@ bool p3DhtMgr::dhtPublish(std::string idhash,
|
||||
/* Create a Value from addresses and type */
|
||||
/* to store the ip address and flags */
|
||||
|
||||
std::ostringstream out;
|
||||
out << "RSDHT:" << std::setw(2) << std::setfill('0') << DHT_MODE_SEARCH << ": ";
|
||||
out << "IPL=" << rs_inet_ntoa(laddr.sin_addr) << ":" << ntohs(laddr.sin_port) << ", ";
|
||||
out << "IPE=" << rs_inet_ntoa(raddr.sin_addr) << ":" << ntohs(raddr.sin_port) << ", ";
|
||||
out << "type=" << std::setw(4) << std::setfill('0') << std::hex << type << ", ";
|
||||
|
||||
/*******
|
||||
char valuearray[1024];
|
||||
snprintf(valuearray, 1024, "RSDHT:%02d: IPL=%s:%d, IPE=%s:%d, type=%04X,",
|
||||
DHT_MODE_SEARCH,
|
||||
rs_inet_ntoa(laddr.sin_addr),
|
||||
ntohs(laddr.sin_port),
|
||||
rs_inet_ntoa(raddr.sin_addr),
|
||||
ntohs(raddr.sin_port),
|
||||
type);
|
||||
|
||||
std::string value = valuearray;
|
||||
******/
|
||||
|
||||
std::string value = out.str();
|
||||
std::string value;
|
||||
rs_sprintf(value, "RSDHT:%02d: ", DHT_MODE_SEARCH);
|
||||
rs_sprintf_append(value, "IPL=%s:%u, ", rs_inet_ntoa(laddr.sin_addr).c_str(), ntohs(laddr.sin_port));
|
||||
rs_sprintf_append(value, "IPE=%s:%u, ", rs_inet_ntoa(raddr.sin_addr).c_str(), ntohs(raddr.sin_port));
|
||||
rs_sprintf_append(value, "type=%04x, ", type);
|
||||
|
||||
#ifdef DHT_DEBUG
|
||||
std::cerr << "p3DhtMgr::dhtPublish()" << std::endl;
|
||||
@ -1414,12 +1383,11 @@ bool p3DhtMgr::dhtNotify(std::string idhash, std::string ownIdHash, std::string
|
||||
std::cerr << "p3DhtMgr::dhtNotify()" << std::endl;
|
||||
#endif
|
||||
|
||||
std::ostringstream value;
|
||||
value << "RSDHT:" << std::setw(2) << std::setfill('0') << DHT_MODE_NOTIFY << ":";
|
||||
value << ownIdHash;
|
||||
std::string value;
|
||||
rs_sprintf(value, "RSDHT:%02d:%s", DHT_MODE_NOTIFY, ownIdHash.c_str());
|
||||
|
||||
/* call to the real DHT */
|
||||
return publishDHT(idhash, value.str(), DHT_TTL_NOTIFY);
|
||||
return publishDHT(idhash, value, DHT_TTL_NOTIFY);
|
||||
}
|
||||
|
||||
bool p3DhtMgr::dhtSearch(std::string idhash, uint32_t /*mode*/)
|
||||
@ -1439,12 +1407,11 @@ bool p3DhtMgr::dhtBootstrap(std::string storehash, std::string ownIdHash, std::s
|
||||
std::cerr << "p3DhtMgr::dhtBootstrap()" << std::endl;
|
||||
#endif
|
||||
|
||||
std::ostringstream value;
|
||||
value << "RSDHT:" << std::setw(2) << std::setfill('0') << DHT_MODE_BOOTSTRAP << ":";
|
||||
value << ownIdHash;
|
||||
std::string value;
|
||||
rs_sprintf(value, "RSDHT:%02d:%s", DHT_MODE_BOOTSTRAP, ownIdHash.c_str());
|
||||
|
||||
/* call to the real DHT */
|
||||
return publishDHT(storehash, value.str(), DHT_TTL_BOOTSTRAP);
|
||||
return publishDHT(storehash, value, DHT_TTL_BOOTSTRAP);
|
||||
}
|
||||
|
||||
|
||||
@ -1544,21 +1511,21 @@ bool p3DhtMgr::resultDHT(std::string key, std::string value)
|
||||
return false;
|
||||
}
|
||||
|
||||
std::ostringstream out1;
|
||||
out1 << a1 << "." << b1 << "." << c1 << "." << d1;
|
||||
inet_aton(out1.str().c_str(), &(laddr.sin_addr));
|
||||
std::string out1;
|
||||
rs_sprintf(out1, "%d.%d.%d.%d", a1, b1, c1, d1);
|
||||
inet_aton(out1.c_str(), &(laddr.sin_addr));
|
||||
laddr.sin_port = htons(e1);
|
||||
laddr.sin_family = AF_INET;
|
||||
|
||||
std::ostringstream out2;
|
||||
out2 << a2 << "." << b2 << "." << c2 << "." << d2;
|
||||
inet_aton(out2.str().c_str(), &(raddr.sin_addr));
|
||||
std::string out2;
|
||||
rs_sprintf(out2, "%d.%d.%d.%d", a2, b2, c2, d2);
|
||||
inet_aton(out2.c_str(), &(raddr.sin_addr));
|
||||
raddr.sin_port = htons(e2);
|
||||
raddr.sin_family = AF_INET;
|
||||
|
||||
#ifdef DHT_DEBUG
|
||||
std::cerr << "p3DhtMgr::resultDHT() SEARCH laddr: " << out1.str() << ":" << e1;
|
||||
std::cerr << " raddr: " << out2.str() << ":" << e2;
|
||||
std::cerr << "p3DhtMgr::resultDHT() SEARCH laddr: " << out1 << ":" << e1;
|
||||
std::cerr << " raddr: " << out2 << ":" << e2;
|
||||
std::cerr << " flags: " << flags;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
@ -1655,9 +1622,7 @@ bool p3DhtMgr::dhtResultNotify(std::string idhash)
|
||||
#endif
|
||||
{
|
||||
/* Log */
|
||||
std::ostringstream out;
|
||||
out << "p3DhtMgr::dhtResultNotify() NOTIFY from Id: " << it->first;
|
||||
rslog(RSL_WARNING, p3dhtzone, out.str());
|
||||
rslog(RSL_WARNING, p3dhtzone, "p3DhtMgr::dhtResultNotify() NOTIFY from Id: " + it->first);
|
||||
}
|
||||
|
||||
/* delay callback -> if they are not found */
|
||||
@ -1715,15 +1680,12 @@ bool p3DhtMgr::dhtResultSearch(std::string idhash,
|
||||
|
||||
{
|
||||
/* Log */
|
||||
std::ostringstream out;
|
||||
out << "p3DhtMgr::dhtSearchResult() for Id: " << it->first;
|
||||
out << " laddr: " << rs_inet_ntoa(laddr.sin_addr);
|
||||
out << ":" << ntohs(laddr.sin_port);
|
||||
out << " raddr: " << rs_inet_ntoa(raddr.sin_addr);
|
||||
out << ":" << ntohs(raddr.sin_port);
|
||||
out << " type: " << ownEntry.type;
|
||||
std::string out ="p3DhtMgr::dhtSearchResult() for Id: " + it->first;
|
||||
rs_sprintf_append(out, " laddr: %s:%u", rs_inet_ntoa(laddr.sin_addr).c_str(), ntohs(laddr.sin_port));
|
||||
rs_sprintf_append(out, " raddr: %s:%u", rs_inet_ntoa(raddr.sin_addr).c_str(), ntohs(raddr.sin_port));
|
||||
rs_sprintf_append(out, " type: %lu", ownEntry.type);
|
||||
|
||||
rslog(RSL_WARNING, p3dhtzone, out.str());
|
||||
rslog(RSL_WARNING, p3dhtzone, out);
|
||||
}
|
||||
|
||||
/* update info .... always */
|
||||
|
@ -160,15 +160,11 @@ bool p3HistoryMgr::saveList(bool& cleanup, std::list<RsItem*>& saveData)
|
||||
vitem->tlvkvs.pairs.push_back(kv);
|
||||
|
||||
kv.key = "PUBLIC_SAVECOUNT";
|
||||
std::ostringstream s1;
|
||||
s1 << mPublicSaveCount;
|
||||
kv.value = s1.str();
|
||||
rs_sprintf(kv.value, "%lu", mPublicSaveCount);
|
||||
vitem->tlvkvs.pairs.push_back(kv);
|
||||
|
||||
kv.key = "PRIVATE_SAVECOUNT";
|
||||
std::ostringstream s2;
|
||||
s2 << mPrivateSaveCount;
|
||||
kv.value = s2.str();
|
||||
rs_sprintf(kv.value, "%lu", mPrivateSaveCount);
|
||||
vitem->tlvkvs.pairs.push_back(kv);
|
||||
|
||||
saveData.push_back(vitem);
|
||||
|
@ -39,6 +39,7 @@
|
||||
|
||||
#include "util/rsprint.h"
|
||||
#include "util/rsdebug.h"
|
||||
#include "util/rsstring.h"
|
||||
const int p3connectzone = 3431;
|
||||
|
||||
#include "serialiser/rsconfigitems.h"
|
||||
@ -47,8 +48,6 @@ const int p3connectzone = 3431;
|
||||
#include "retroshare/rsiface.h"
|
||||
#include "retroshare/rspeers.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
/* Network setup States */
|
||||
|
||||
|
||||
@ -115,16 +114,9 @@ peerConnectState::peerConnectState()
|
||||
|
||||
std::string textPeerConnectState(peerConnectState &state)
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "Id: " << state.id << std::endl;
|
||||
|
||||
|
||||
std::string output = out.str();
|
||||
return output;
|
||||
return "Id: " + state.id + "\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*********
|
||||
* NOTES:
|
||||
*
|
||||
@ -764,7 +756,7 @@ bool p3LinkMgrIMPL::connectAttempt(const std::string &id, struct sockaddr_in &ra
|
||||
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgrIMPL::connectAttempt() found an address: id: " << id << std::endl;
|
||||
std::cerr << " laddr: " << rs_inet_ntoa(addr.sin_addr) << " lport: " << ntohs(addr.sin_port) << " delay: " << delay << " period: " << period;
|
||||
std::cerr << " laddr: " << rs_inet_ntoa(addr.sin_addr) << " lport: " << ntohs(addr.sin_port) << " delay: " << delay << " period: " << period;
|
||||
std::cerr << " type: " << type << std::endl;
|
||||
std::cerr << "p3LinkMgrIMPL::connectAttempt() set LinkType to: " << it->second.linkType << std::endl;
|
||||
#endif
|
||||
@ -799,9 +791,7 @@ bool p3LinkMgrIMPL::connectResult(const std::string &id, bool success, uint32_t
|
||||
|
||||
if (id == getOwnId())
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "p3LinkMgrIMPL::connectResult() ERROR Trying to Connect to OwnId: " << id;
|
||||
rslog(RSL_ALERT, p3connectzone, out.str());
|
||||
rslog(RSL_ALERT, p3connectzone, "p3LinkMgrIMPL::connectResult() ERROR Trying to Connect to OwnId: " + id);
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -810,9 +800,7 @@ bool p3LinkMgrIMPL::connectResult(const std::string &id, bool success, uint32_t
|
||||
it = mFriendList.find(id);
|
||||
if (it == mFriendList.end())
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "p3LinkMgrIMPL::connectResult() ERROR Missing Friend: " << id;
|
||||
rslog(RSL_ALERT, p3connectzone, out.str());
|
||||
rslog(RSL_ALERT, p3connectzone, "p3LinkMgrIMPL::connectResult() ERROR Missing Friend: " + id);
|
||||
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << "p3LinkMgrIMPL::connectResult() ERROR, missing Friend " << " id: " << id << std::endl;
|
||||
@ -823,28 +811,27 @@ bool p3LinkMgrIMPL::connectResult(const std::string &id, bool success, uint32_t
|
||||
/* now we can tell if we think we were connected - proper point to log */
|
||||
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "p3LinkMgrIMPL::connectResult() id: " << id;
|
||||
std::string out = "p3LinkMgrIMPL::connectResult() id: " + id;
|
||||
if (success)
|
||||
{
|
||||
out << " SUCCESS ";
|
||||
out += " SUCCESS ";
|
||||
if (it->second.state & RS_PEER_S_CONNECTED)
|
||||
{
|
||||
out << " WARNING: State says: Already Connected";
|
||||
out += " WARNING: State says: Already Connected";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (it->second.state & RS_PEER_S_CONNECTED)
|
||||
{
|
||||
out << " FAILURE OF THE CONNECTION (Was Connected)";
|
||||
out += " FAILURE OF THE CONNECTION (Was Connected)";
|
||||
}
|
||||
else
|
||||
{
|
||||
out << " FAILED ATTEMPT (Not Connected)";
|
||||
out += " FAILED ATTEMPT (Not Connected)";
|
||||
}
|
||||
}
|
||||
rslog(RSL_WARNING, p3connectzone, out.str());
|
||||
rslog(RSL_WARNING, p3connectzone, out);
|
||||
}
|
||||
|
||||
|
||||
@ -1077,16 +1064,13 @@ void p3LinkMgrIMPL::peerStatus(std::string id, const pqiIpAddrSet &addrs,
|
||||
|
||||
{
|
||||
/* Log */
|
||||
std::ostringstream out;
|
||||
out << "p3LinkMgrIMPL::peerStatus()" << " id: " << id;
|
||||
out << " type: " << type << " flags: " << flags;
|
||||
out << " source: " << source;
|
||||
out << std::endl;
|
||||
std::string out = "p3LinkMgrIMPL::peerStatus() id: " + id;
|
||||
rs_sprintf_append(out, " type: %lu flags: %lu source: %lu\n", type, flags, source);
|
||||
addrs.printAddrs(out);
|
||||
|
||||
rslog(RSL_WARNING, p3connectzone, out.str());
|
||||
rslog(RSL_WARNING, p3connectzone, out);
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::cerr << out.str();
|
||||
std::cerr << out << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1297,8 +1281,9 @@ void p3LinkMgrIMPL::peerStatus(std::string id, const pqiIpAddrSet &addrs,
|
||||
std::cerr << " type: " << type << " flags: " << flags;
|
||||
std::cerr << " source: " << source << std::endl;
|
||||
std::cerr << " addrs: " << std::endl;
|
||||
addrs.printAddrs(std::cerr);
|
||||
std::cerr << std::endl;
|
||||
std::string out;
|
||||
addrs.printAddrs(out);
|
||||
std::cerr << out << std::endl;
|
||||
|
||||
#endif
|
||||
|
||||
@ -1341,17 +1326,16 @@ void p3LinkMgrIMPL::peerConnectRequest(std::string id, struct sockaddr_in rad
|
||||
#endif
|
||||
{
|
||||
/* Log */
|
||||
std::ostringstream out;
|
||||
out << "p3LinkMgrIMPL::peerConnectRequest() id: " << id;
|
||||
out << " raddr: " << rs_inet_ntoa(raddr.sin_addr) << ":" << ntohs(raddr.sin_port);
|
||||
std::cerr << " proxyaddr: " << rs_inet_ntoa(proxyaddr.sin_addr) << ":" << ntohs(proxyaddr.sin_port);
|
||||
std::cerr << " srcaddr: " << rs_inet_ntoa(srcaddr.sin_addr) << ":" << ntohs(srcaddr.sin_port);
|
||||
out << " source: " << source;
|
||||
out << " flags: " << flags;
|
||||
out << " delay: " << delay;
|
||||
out << " bandwidth: " << bandwidth;
|
||||
std::string out = "p3LinkMgrIMPL::peerConnectRequest() id: " + id;
|
||||
rs_sprintf_append(out, " raddr: %s:%u", rs_inet_ntoa(raddr.sin_addr).c_str(), ntohs(raddr.sin_port));
|
||||
rs_sprintf_append(out, " proxyaddr: %s:%u", rs_inet_ntoa(proxyaddr.sin_addr).c_str(), ntohs(proxyaddr.sin_port));
|
||||
rs_sprintf_append(out, " srcaddr: %s:%u", rs_inet_ntoa(srcaddr.sin_addr).c_str(), ntohs(srcaddr.sin_port));
|
||||
rs_sprintf_append(out, " source: %lu", source);
|
||||
rs_sprintf_append(out, " flags: %lu", flags);
|
||||
rs_sprintf_append(out, " delay: %lu", delay);
|
||||
rs_sprintf_append(out, " bandwidth: %lu", bandwidth);
|
||||
|
||||
rslog(RSL_WARNING, p3connectzone, out.str());
|
||||
rslog(RSL_WARNING, p3connectzone, out);
|
||||
}
|
||||
|
||||
/******************** TCP PART *****************************/
|
||||
@ -2055,13 +2039,10 @@ bool p3LinkMgrIMPL::locked_ConnectAttempt_Complete(peerConnectState *peer)
|
||||
if (peer->connAddrs.size() > 0)
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::ostringstream out;
|
||||
out << "p3LinkMgrIMPL::locked_ConnectAttempt_Complete() Started CONNECT ATTEMPT! " ;
|
||||
out << std::endl;
|
||||
out << "p3LinkMgrIMPL::locked_ConnectAttempt_Complete() ConnAddr Count: " << peer->connAddrs.size();
|
||||
rslog(RSL_DEBUG_ALERT, p3connectzone, out.str());
|
||||
std::cerr << out.str() << std::endl;
|
||||
|
||||
std::string out = "p3LinkMgrIMPL::locked_ConnectAttempt_Complete() Started CONNECT ATTEMPT!\n" ;
|
||||
rs_sprintf_append(out, "p3LinkMgrIMPL::locked_ConnectAttempt_Complete() ConnAddr Count: %u", peer->connAddrs.size());
|
||||
rslog(RSL_DEBUG_ALERT, p3connectzone, out);
|
||||
std::cerr << out << std::endl;
|
||||
#endif
|
||||
|
||||
peer->actions |= RS_PEER_CONNECT_REQ;
|
||||
@ -2071,10 +2052,9 @@ bool p3LinkMgrIMPL::locked_ConnectAttempt_Complete(peerConnectState *peer)
|
||||
else
|
||||
{
|
||||
#ifdef LINKMGR_DEBUG
|
||||
std::ostringstream out;
|
||||
out << "p3LinkMgrIMPL::locked_ConnectAttempt_Complete() No addr in the connect attempt list. Not suitable for CONNECT ATTEMPT! ";
|
||||
rslog(RSL_DEBUG_ALERT, p3connectzone, out.str());
|
||||
std::cerr << out.str() << std::endl;
|
||||
std::string out = "p3LinkMgrIMPL::locked_ConnectAttempt_Complete() No addr in the connect attempt list. Not suitable for CONNECT ATTEMPT!";
|
||||
rslog(RSL_DEBUG_ALERT, p3connectzone, out);
|
||||
std::cerr << out << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
@ -44,8 +44,6 @@ const int p3netmgrzone = 7563;
|
||||
#include "retroshare/rsiface.h"
|
||||
#include "retroshare/rsconfig.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
/* Network setup States */
|
||||
|
||||
const uint32_t RS_NET_NEEDS_RESET = 0x0000;
|
||||
@ -138,11 +136,7 @@ p3NetMgrIMPL::p3NetMgrIMPL()
|
||||
std::cerr << "p3NetMgr() Startup" << std::endl;
|
||||
#endif
|
||||
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "p3NetMgr() Startup, resetting network";
|
||||
rslog(RSL_WARNING, p3netmgrzone, out.str());
|
||||
}
|
||||
rslog(RSL_WARNING, p3netmgrzone, "p3NetMgr() Startup, resetting network");
|
||||
netReset();
|
||||
|
||||
return;
|
||||
@ -235,11 +229,7 @@ void p3NetMgrIMPL::netReset()
|
||||
#ifdef NETMGR_DEBUG_RESET
|
||||
std::cerr << "p3NetMgrIMPL::netReset() Called" << std::endl;
|
||||
#endif
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "p3NetMgr::netReset() Called";
|
||||
rslog(RSL_ALERT, p3netmgrzone, out.str());
|
||||
}
|
||||
rslog(RSL_ALERT, p3netmgrzone, "p3NetMgr::netReset() Called");
|
||||
|
||||
shutdown(); /* blocking shutdown call */
|
||||
|
||||
@ -482,11 +472,7 @@ void p3NetMgrIMPL::netTick()
|
||||
#if defined(NETMGR_DEBUG_TICK) || defined(NETMGR_DEBUG_RESET)
|
||||
std::cerr << "p3NetMgrIMPL::netTick() STATUS: NEEDS_RESET" << std::endl;
|
||||
#endif
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "p3NetMgr::netTick() RS_NET_NEEDS_RESET, resetting network";
|
||||
rslog(RSL_WARNING, p3netmgrzone, out.str());
|
||||
}
|
||||
rslog(RSL_WARNING, p3netmgrzone, "p3NetMgr::netTick() RS_NET_NEEDS_RESET, resetting network");
|
||||
|
||||
netReset();
|
||||
break;
|
||||
@ -897,9 +883,7 @@ void p3NetMgrIMPL::netExtCheck()
|
||||
std::string fakeId;
|
||||
netAssistKnownPeer(fakeId, mExtAddr, NETASSIST_KNOWN_PEER_SELF | NETASSIST_KNOWN_PEER_ONLINE);
|
||||
|
||||
std::ostringstream out;
|
||||
out << "p3NetMgr::netExtCheck() Network Setup Complete";
|
||||
rslog(RSL_WARNING, p3netmgrzone, out.str());
|
||||
rslog(RSL_WARNING, p3netmgrzone, "p3NetMgr::netExtCheck() Network Setup Complete");
|
||||
}
|
||||
|
||||
}
|
||||
@ -925,11 +909,7 @@ bool p3NetMgrIMPL::checkNetAddress()
|
||||
std::cerr << "p3NetMgrIMPL::checkNetAddress() no Valid Network Address, resetting network." << std::endl;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "p3NetMgr::checkNetAddress() No Valid Network Address, resetting network";
|
||||
rslog(RSL_WARNING, p3netmgrzone, out.str());
|
||||
}
|
||||
rslog(RSL_WARNING, p3netmgrzone, "p3NetMgr::checkNetAddress() No Valid Network Address, resetting network");
|
||||
netReset();
|
||||
return false;
|
||||
}
|
||||
@ -1043,11 +1023,7 @@ bool p3NetMgrIMPL::checkNetAddress()
|
||||
mPeerMgr->UpdateOwnAddress(mLocalAddr, mExtAddr);
|
||||
}
|
||||
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "p3NetMgr::checkNetAddress() local address changed, resetting network";
|
||||
rslog(RSL_WARNING, p3netmgrzone, out.str());
|
||||
}
|
||||
rslog(RSL_WARNING, p3netmgrzone, "p3NetMgr::checkNetAddress() local address changed, resetting network");
|
||||
netReset();
|
||||
}
|
||||
|
||||
@ -1087,11 +1063,7 @@ bool p3NetMgrIMPL::setLocalAddress(struct sockaddr_in addr)
|
||||
#ifdef NETMGR_DEBUG_RESET
|
||||
std::cerr << "p3NetMgrIMPL::setLocalAddress() Calling NetReset" << std::endl;
|
||||
#endif
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "p3NetMgr::setLocalAddress() local address changed, resetting network";
|
||||
rslog(RSL_WARNING, p3netmgrzone, out.str());
|
||||
}
|
||||
rslog(RSL_WARNING, p3netmgrzone, "p3NetMgr::setLocalAddress() local address changed, resetting network");
|
||||
netReset();
|
||||
}
|
||||
return true;
|
||||
@ -1116,11 +1088,7 @@ bool p3NetMgrIMPL::setExtAddress(struct sockaddr_in addr)
|
||||
#ifdef NETMGR_DEBUG_RESET
|
||||
std::cerr << "p3NetMgrIMPL::setExtAddress() Calling NetReset" << std::endl;
|
||||
#endif
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "p3NetMgr::setExtAddress() ext address changed, resetting network";
|
||||
rslog(RSL_WARNING, p3netmgrzone, out.str());
|
||||
}
|
||||
rslog(RSL_WARNING, p3netmgrzone, "p3NetMgr::setExtAddress() ext address changed, resetting network");
|
||||
netReset();
|
||||
}
|
||||
return true;
|
||||
@ -1164,11 +1132,7 @@ bool p3NetMgrIMPL::setNetworkMode(uint32_t netMode)
|
||||
#ifdef NETMGR_DEBUG_RESET
|
||||
std::cerr << "p3NetMgrIMPL::setNetworkMode() Calling NetReset" << std::endl;
|
||||
#endif
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "p3NetMgr::setNetworkMode() Net Mode changed, resetting network";
|
||||
rslog(RSL_WARNING, p3netmgrzone, out.str());
|
||||
}
|
||||
rslog(RSL_WARNING, p3netmgrzone, "p3NetMgr::setNetworkMode() Net Mode changed, resetting network");
|
||||
netReset();
|
||||
}
|
||||
return true;
|
||||
|
@ -38,6 +38,7 @@
|
||||
//#include "util/dnsresolver.h"
|
||||
|
||||
#include "util/rsprint.h"
|
||||
#include "util/rsstring.h"
|
||||
#include "util/rsdebug.h"
|
||||
const int p3peermgrzone = 9531;
|
||||
|
||||
@ -47,9 +48,6 @@ const int p3peermgrzone = 9531;
|
||||
#include "retroshare/rsiface.h" // Needed for rsicontrol (should remove this dependancy)
|
||||
#include "retroshare/rspeers.h" // Needed for Group Parameters.
|
||||
|
||||
|
||||
#include <sstream>
|
||||
|
||||
/* Network setup States */
|
||||
|
||||
const uint32_t RS_NET_NEEDS_RESET = 0x0000;
|
||||
@ -89,17 +87,13 @@ peerState::peerState()
|
||||
|
||||
std::string textPeerConnectState(peerState &state)
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "Id: " << state.id << std::endl;
|
||||
out << "NetMode: " << state.netMode << std::endl;
|
||||
out << "VisState: " << state.visState << std::endl;
|
||||
out << "laddr: " << rs_inet_ntoa(state.localaddr.sin_addr)
|
||||
<< ":" << ntohs(state.localaddr.sin_port) << std::endl;
|
||||
out << "eaddr: " << rs_inet_ntoa(state.serveraddr.sin_addr)
|
||||
<< ":" << ntohs(state.serveraddr.sin_port) << std::endl;
|
||||
std::string out = "Id: " + state.id + "\n";
|
||||
rs_sprintf_append(out, "NetMode: %lu\n", state.netMode);
|
||||
rs_sprintf_append(out, "VisState: %lu\n", state.visState);
|
||||
rs_sprintf_append(out, "laddr: %s:%u\n", rs_inet_ntoa(state.localaddr.sin_addr).c_str(), ntohs(state.localaddr.sin_port));
|
||||
rs_sprintf_append(out, "eaddr: %s:%u\n", rs_inet_ntoa(state.serveraddr.sin_addr).c_str(), ntohs(state.serveraddr.sin_port));
|
||||
|
||||
std::string output = out.str();
|
||||
return output;
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
@ -166,11 +160,9 @@ void p3PeerMgrIMPL::setOwnVisState(uint32_t visState)
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
std::ostringstream out;
|
||||
out << "p3PeerMgr::setOwnVisState()";
|
||||
out << "Existing vis: " << mOwnState.visState;
|
||||
out << "Input vis: " << visState;
|
||||
rslog(RSL_WARNING, p3peermgrzone, out.str());
|
||||
std::string out;
|
||||
rs_sprintf(out, "p3PeerMgr::setOwnVisState() Existing vis: %lu Input vis: %lu", mOwnState.visState, visState);
|
||||
rslog(RSL_WARNING, p3peermgrzone, out);
|
||||
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << out.str() << std::endl;
|
||||
@ -1126,11 +1118,9 @@ bool p3PeerMgrIMPL::setLocation(const std::string &id, const std::string &loc
|
||||
bool p3PeerMgrIMPL::setVisState(const std::string &id, uint32_t visState)
|
||||
{
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "p3PeerMgr::setVisState(";
|
||||
out << id;
|
||||
out << ", " << visState << ")";
|
||||
rslog(RSL_WARNING, p3peermgrzone, out.str());
|
||||
std::string out;
|
||||
rs_sprintf(out, "p3PeerMgr::setVisState(%s, %lu)", id.c_str(), visState);
|
||||
rslog(RSL_WARNING, p3peermgrzone, out);
|
||||
}
|
||||
|
||||
if (id == AuthSSL::getAuthSSL()->OwnId())
|
||||
@ -1514,9 +1504,7 @@ bool p3PeerMgrIMPL::loadList(std::list<RsItem *>& load)
|
||||
} else {
|
||||
uint32_t groupId = atoi((*groupIt)->id.c_str());
|
||||
if (groupId == 0) {
|
||||
std::ostringstream out;
|
||||
out << (lastGroupId++);
|
||||
(*groupIt)->id = out.str();
|
||||
rs_sprintf((*groupIt)->id, "%lu", lastGroupId++);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1585,9 +1573,7 @@ bool p3PeerMgrIMPL::addGroup(RsGroupInfo &groupInfo)
|
||||
RsPeerGroupItem *groupItem = new RsPeerGroupItem;
|
||||
groupItem->set(groupInfo);
|
||||
|
||||
std::ostringstream out;
|
||||
out << (++lastGroupId);
|
||||
groupItem->id = out.str();
|
||||
rs_sprintf(groupItem->id, "%lu", ++lastGroupId);
|
||||
|
||||
// remove standard flag
|
||||
groupItem->flag &= ~RS_GROUP_FLAG_STANDARD;
|
||||
|
@ -23,9 +23,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
/* This is dependent on the sslroot at the moment.
|
||||
* -> as we need to create/restore references to the Person.
|
||||
* -> and store the signatures to do this.
|
||||
@ -45,8 +42,8 @@
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#include <sstream>
|
||||
#include "util/rsdebug.h"
|
||||
#include "util/rsstring.h"
|
||||
#include <time.h>
|
||||
|
||||
const int pqiarchivezone = 9326;
|
||||
@ -69,19 +66,11 @@ pqiarchive::pqiarchive(RsSerialiser *rss, BinInterface *bio_in, int bio_flags_in
|
||||
:PQInterface(""), rsSerialiser(rss), bio(bio_in), bio_flags(bio_flags_in),
|
||||
nextPkt(NULL), nextPktTS(0), firstPktTS(0), initTS(0),realTime(false)
|
||||
{
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqiarchive::pqiarchive()";
|
||||
out << " Initialisation!" << std::endl;
|
||||
pqioutput(PQL_DEBUG_ALL, pqiarchivezone, out.str());
|
||||
}
|
||||
pqioutput(PQL_DEBUG_ALL, pqiarchivezone, "pqiarchive::pqiarchive() Initialisation!\n");
|
||||
|
||||
if (!bio_in)
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqiarchive::pqiarchive()";
|
||||
out << " NULL bio, FATAL ERROR!" << std::endl;
|
||||
pqioutput(PQL_ALERT, pqiarchivezone, out.str());
|
||||
{
|
||||
pqioutput(PQL_ALERT, pqiarchivezone, "pqiarchive::pqiarchive() NULL bio, FATAL ERROR!\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -90,28 +79,17 @@ pqiarchive::pqiarchive(RsSerialiser *rss, BinInterface *bio_in, int bio_flags_in
|
||||
|
||||
pqiarchive::~pqiarchive()
|
||||
{
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqiarchive::~pqiarchive()";
|
||||
out << " Destruction!" << std::endl;
|
||||
pqioutput(PQL_DEBUG_ALL, pqiarchivezone, out.str());
|
||||
}
|
||||
pqioutput(PQL_DEBUG_ALL, pqiarchivezone, "pqiarchive::~pqiarchive() Destruction!\n");
|
||||
|
||||
if (bio_flags & BIN_FLAGS_NO_CLOSE)
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqiarchive::~pqiarchive()";
|
||||
out << " Not Closing BinInterface!" << std::endl;
|
||||
pqioutput(PQL_DEBUG_ALL, pqiarchivezone, out.str());
|
||||
pqioutput(PQL_DEBUG_ALL, pqiarchivezone, "pqiarchive::~pqiarchive() Not Closing BinInterface!\n");
|
||||
}
|
||||
else if (bio)
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqiarchive::~pqiarchive()";
|
||||
out << " Deleting BinInterface!" << std::endl;
|
||||
pqioutput(PQL_DEBUG_ALL, pqiarchivezone, out.str());
|
||||
pqioutput(PQL_DEBUG_ALL, pqiarchivezone, "pqiarchive::~pqiarchive() Deleting BinInterface!\n");
|
||||
|
||||
delete bio;
|
||||
delete bio;
|
||||
}
|
||||
|
||||
if (rsSerialiser)
|
||||
@ -128,11 +106,10 @@ pqiarchive::~pqiarchive()
|
||||
// Get/Send Items.
|
||||
int pqiarchive::SendItem(RsItem *si)
|
||||
{
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqiarchive::SendItem()" << std::endl;
|
||||
si -> print(out);
|
||||
pqioutput(PQL_DEBUG_BASIC, pqiarchivezone, out.str());
|
||||
{
|
||||
std::string out = "pqiarchive::SendItem()\n";
|
||||
si -> print_string(out);
|
||||
pqioutput(PQL_DEBUG_BASIC, pqiarchivezone, out);
|
||||
}
|
||||
|
||||
// check if this is a writing bio.
|
||||
@ -152,19 +129,12 @@ int pqiarchive::SendItem(RsItem *si)
|
||||
|
||||
RsItem *pqiarchive::GetItem()
|
||||
{
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqiarchive::GetItem()";
|
||||
pqioutput(PQL_DEBUG_ALL, pqiarchivezone, out.str());
|
||||
}
|
||||
pqioutput(PQL_DEBUG_ALL, pqiarchivezone, "pqiarchive::GetItem()");
|
||||
|
||||
// check if this is a reading bio.
|
||||
if (!(bio_flags & BIN_FLAGS_READABLE))
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqiarchive::GetItem()";
|
||||
out << "Error Not Readable" << std::endl;
|
||||
pqioutput(PQL_DEBUG_BASIC, pqiarchivezone, out.str());
|
||||
pqioutput(PQL_DEBUG_BASIC, pqiarchivezone, "pqiarchive::GetItem() Error Not Readable");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -173,10 +143,7 @@ RsItem *pqiarchive::GetItem()
|
||||
{
|
||||
if (!readPkt(&nextPkt, &nextPktTS))
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqiarchive::GetItem()";
|
||||
out << "Failed to ReadPkt" << std::endl;
|
||||
pqioutput(PQL_DEBUG_BASIC, pqiarchivezone, out.str());
|
||||
pqioutput(PQL_DEBUG_BASIC, pqiarchivezone, "pqiarchive::GetItem() Failed to ReadPkt");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@ -212,11 +179,10 @@ RsItem *pqiarchive::GetItem()
|
||||
nextPkt = NULL;
|
||||
|
||||
if (outPkt != NULL)
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqiarchive::GetItem() Returning:" << std::endl;
|
||||
outPkt -> print(out);
|
||||
pqioutput(PQL_DEBUG_BASIC, pqiarchivezone, out.str());
|
||||
{
|
||||
std::string out = "pqiarchive::GetItem() Returning:\n";
|
||||
outPkt -> print_string(out);
|
||||
pqioutput(PQL_DEBUG_BASIC, pqiarchivezone, out);
|
||||
}
|
||||
return outPkt;
|
||||
}
|
||||
@ -226,21 +192,12 @@ RsItem *pqiarchive::GetItem()
|
||||
// // PQInterface
|
||||
int pqiarchive::tick()
|
||||
{
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqiarchive::tick()";
|
||||
out << std::endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pqiarchive::status()
|
||||
{
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqiarchive::status()";
|
||||
pqioutput(PQL_DEBUG_ALL, pqiarchivezone, out.str());
|
||||
}
|
||||
pqioutput(PQL_DEBUG_ALL, pqiarchivezone, "pqiarchive::status()");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -250,22 +207,15 @@ int pqiarchive::status()
|
||||
int pqiarchive::writePkt(RsItem *pqi)
|
||||
{
|
||||
// std::cerr << "writePkt, pqi->peerId()=" << pqi->PeerId() << std::endl ;
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqiarchive::writePkt()";
|
||||
pqioutput(PQL_DEBUG_ALL, pqiarchivezone, out.str());
|
||||
}
|
||||
pqioutput(PQL_DEBUG_ALL, pqiarchivezone, "pqiarchive::writePkt()");
|
||||
|
||||
uint32_t pktsize = rsSerialiser->size(pqi);
|
||||
void *ptr = malloc(pktsize);
|
||||
if (!(rsSerialiser->serialise(pqi, ptr, &pktsize)))
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqiarchive::writePkt() Null Pkt generated!";
|
||||
out << std::endl;
|
||||
out << "Caused By: " << std::endl;
|
||||
pqi -> print(out);
|
||||
pqioutput(PQL_ALERT, pqiarchivezone, out.str());
|
||||
std::string out = "pqiarchive::writePkt() Null Pkt generated!\nCaused By:\n";
|
||||
pqi -> print_string(out);
|
||||
pqioutput(PQL_ALERT, pqiarchivezone, out);
|
||||
|
||||
free(ptr);
|
||||
if (!(bio_flags & BIN_FLAGS_NO_DELETE))
|
||||
@ -277,13 +227,10 @@ int pqiarchive::writePkt(RsItem *pqi)
|
||||
uint32_t len = getRsItemSize(ptr);
|
||||
if (len != pktsize)
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqiarchive::writePkt() Length MisMatch: len: " << len;
|
||||
out << " != pktsize: " << pktsize;
|
||||
out << std::endl;
|
||||
out << "Caused By: " << std::endl;
|
||||
pqi -> print(out);
|
||||
pqioutput(PQL_ALERT, pqiarchivezone, out.str());
|
||||
std::string out;
|
||||
rs_sprintf(out, "pqiarchive::writePkt() Length MisMatch: len: %lu != pktsize: %lu\nCaused By:\n", len, pktsize);
|
||||
pqi -> print_string(out);
|
||||
pqioutput(PQL_ALERT, pqiarchivezone, out);
|
||||
|
||||
free(ptr);
|
||||
if (!(bio_flags & BIN_FLAGS_NO_DELETE))
|
||||
@ -294,12 +241,9 @@ int pqiarchive::writePkt(RsItem *pqi)
|
||||
|
||||
if (!(bio->cansend()))
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqiarchive::writePkt() BIO cannot write!";
|
||||
out << std::endl;
|
||||
out << "Discarding: " << std::endl;
|
||||
pqi -> print(out);
|
||||
pqioutput(PQL_ALERT, pqiarchivezone, out.str());
|
||||
std::string out = "pqiarchive::writePkt() BIO cannot write!\nDiscarding:\n";
|
||||
pqi -> print_string(out);
|
||||
pqioutput(PQL_ALERT, pqiarchivezone, out);
|
||||
|
||||
free(ptr);
|
||||
if (!(bio_flags & BIN_FLAGS_NO_DELETE))
|
||||
@ -311,14 +255,11 @@ int pqiarchive::writePkt(RsItem *pqi)
|
||||
// using the peerid from the item.
|
||||
if (pqi->PeerId().length() != PQI_PEERID_LENGTH)
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqiarchive::writePkt() Invalid peerId Length!";
|
||||
out << std::endl;
|
||||
out << "Found " << pqi->PeerId().length() << " instead of " << PQI_PEERID_LENGTH << std::endl ;
|
||||
out << "pqi->PeerId() = " << pqi->PeerId() << std::endl ;
|
||||
out << "Caused By: " << std::endl;
|
||||
pqi -> print(out);
|
||||
pqioutput(PQL_ALERT, pqiarchivezone, out.str());
|
||||
std::string out = "pqiarchive::writePkt() Invalid peerId Length!\n";
|
||||
rs_sprintf_append(out, "Found %ld instead of %ld\n", pqi->PeerId().length(), PQI_PEERID_LENGTH);
|
||||
out += "pqi->PeerId() = " + pqi->PeerId() + "\nCaused By:\n";
|
||||
pqi -> print_string(out);
|
||||
pqioutput(PQL_ALERT, pqiarchivezone, out);
|
||||
|
||||
free(ptr);
|
||||
if (!(bio_flags & BIN_FLAGS_NO_DELETE))
|
||||
@ -326,8 +267,7 @@ int pqiarchive::writePkt(RsItem *pqi)
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::ostringstream out;
|
||||
out << "Writing Pkt Header" << std::endl;
|
||||
std::string out = "Writing Pkt Header\n";
|
||||
struct pqiarchive_header hdr;
|
||||
hdr.type = PQIARCHIVE_TYPE_PQITEM;
|
||||
hdr.length = len;
|
||||
@ -337,9 +277,8 @@ int pqiarchive::writePkt(RsItem *pqi)
|
||||
// write packet header.
|
||||
if (sizeof(hdr) != bio->senddata(&hdr, sizeof(hdr)))
|
||||
{
|
||||
out << "Trouble writing header!";
|
||||
out << std::endl;
|
||||
pqioutput(PQL_ALERT, pqiarchivezone, out.str());
|
||||
out += "Trouble writing header!\n";
|
||||
pqioutput(PQL_ALERT, pqiarchivezone, out);
|
||||
|
||||
free(ptr);
|
||||
if (!(bio_flags & BIN_FLAGS_NO_DELETE))
|
||||
@ -348,14 +287,13 @@ int pqiarchive::writePkt(RsItem *pqi)
|
||||
return 0;
|
||||
}
|
||||
|
||||
out << "Writing Pkt Body" << std::endl;
|
||||
out += "Writing Pkt Body\n";
|
||||
|
||||
// write packet.
|
||||
if ((int) len != bio->senddata(ptr, len))
|
||||
{
|
||||
out << "Problems with Send Data!";
|
||||
out << std::endl;
|
||||
pqioutput(PQL_ALERT, pqiarchivezone, out.str());
|
||||
out += "Problems with Send Data!\n";
|
||||
pqioutput(PQL_ALERT, pqiarchivezone, out);
|
||||
|
||||
free(ptr);
|
||||
if (!(bio_flags & BIN_FLAGS_NO_DELETE))
|
||||
@ -364,8 +302,8 @@ int pqiarchive::writePkt(RsItem *pqi)
|
||||
return 0;
|
||||
}
|
||||
|
||||
out << " Success!" << std::endl;
|
||||
pqioutput(PQL_DEBUG_BASIC, pqiarchivezone, out.str());
|
||||
out += " Success!";
|
||||
pqioutput(PQL_DEBUG_BASIC, pqiarchivezone, out);
|
||||
|
||||
free(ptr);
|
||||
if (!(bio_flags & BIN_FLAGS_NO_DELETE))
|
||||
@ -381,11 +319,7 @@ int pqiarchive::writePkt(RsItem *pqi)
|
||||
|
||||
int pqiarchive::readPkt(RsItem **item_out, long *ts_out)
|
||||
{
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqiarchive::readPkt()";
|
||||
pqioutput(PQL_DEBUG_ALL, pqiarchivezone, out.str());
|
||||
}
|
||||
pqioutput(PQL_DEBUG_ALL, pqiarchivezone, "pqiarchive::readPkt()");
|
||||
|
||||
if ((!(bio->isactive())) || (!(bio->moretoread())))
|
||||
{
|
||||
@ -435,11 +369,9 @@ int pqiarchive::readPkt(RsItem **item_out, long *ts_out)
|
||||
if (extralen != (tmplen = bio->readdata(extradata, extralen)))
|
||||
{
|
||||
|
||||
std::ostringstream out;
|
||||
out << "pqiarchive::readPkt() ";
|
||||
out << "Error Completing Read (read ";
|
||||
out << tmplen << "/" << extralen << ")" << std::endl;
|
||||
pqioutput(PQL_ALERT, pqiarchivezone, out.str());
|
||||
std::string out;
|
||||
rs_sprintf(out, "pqiarchive::readPkt() Error Completing Read (read %d/%d)\n", tmplen, extralen);
|
||||
pqioutput(PQL_ALERT, pqiarchivezone, out);
|
||||
|
||||
free(block);
|
||||
return 0;
|
||||
|
@ -25,8 +25,8 @@
|
||||
|
||||
#include <openssl/sha.h>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include "util/rsstring.h"
|
||||
|
||||
class pqihash
|
||||
{
|
||||
@ -66,13 +66,11 @@ void Complete(std::string &hash)
|
||||
|
||||
SHA1_Final(sha_hash, sha_ctx);
|
||||
|
||||
std::ostringstream out;
|
||||
endHash.clear();
|
||||
for(int i = 0; i < SHA_DIGEST_LENGTH; i++)
|
||||
{
|
||||
out << std::setw(2) << std::setfill('0') << std::hex;
|
||||
out << (unsigned int) (sha_hash[i]);
|
||||
rs_sprintf_append(endHash, "%02x", (unsigned int) (sha_hash[i]));
|
||||
}
|
||||
endHash = out.str();
|
||||
hash = endHash;
|
||||
doHash = false;
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include <time.h>
|
||||
#include "pqi/pqiipset.h"
|
||||
#include "util/rsstring.h"
|
||||
|
||||
bool pqiIpAddress::sameAddress(const pqiIpAddress &a) const
|
||||
{
|
||||
@ -192,16 +193,13 @@ void pqiIpAddrList::loadTlv(RsTlvIpAddrSet &tlvAddrs)
|
||||
|
||||
|
||||
|
||||
void pqiIpAddrList::printIpAddressList(std::ostream &out) const
|
||||
void pqiIpAddrList::printIpAddressList(std::string &out) const
|
||||
{
|
||||
std::list<pqiIpAddress>::const_iterator it;
|
||||
time_t now = time(NULL);
|
||||
for(it = mAddrs.begin(); it != mAddrs.end(); it++)
|
||||
{
|
||||
out << rs_inet_ntoa(it->mAddr.sin_addr) << ":"
|
||||
<< ntohs(it->mAddr.sin_port) << " ( "
|
||||
<< now - it->mSeenTime << " old) " << std::endl;
|
||||
|
||||
rs_sprintf_append(out, "%s:%u ( %ld old)\n", rs_inet_ntoa(it->mAddr.sin_addr).c_str(), ntohs(it->mAddr.sin_port), now - it->mSeenTime);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -254,14 +252,13 @@ bool pqiIpAddrSet::updateAddrs(const pqiIpAddrSet &addrs)
|
||||
|
||||
|
||||
|
||||
void pqiIpAddrSet::printAddrs(std::ostream &out) const
|
||||
void pqiIpAddrSet::printAddrs(std::string &out) const
|
||||
{
|
||||
out << "Local Addresses: ";
|
||||
out += "Local Addresses: ";
|
||||
mLocal.printIpAddressList(out);
|
||||
out << std::endl;
|
||||
out << "Ext Addresses: ";
|
||||
out += "\nExt Addresses: ";
|
||||
mExt.printIpAddressList(out);
|
||||
out << std::endl;
|
||||
out += "\n";
|
||||
}
|
||||
|
||||
|
||||
|
@ -49,7 +49,7 @@ class pqiIpAddrList
|
||||
|
||||
// returns true if new address added.
|
||||
bool updateIpAddressList(const pqiIpAddress &addr);
|
||||
void printIpAddressList(std::ostream &out) const;
|
||||
void printIpAddressList(std::string &out) const;
|
||||
void extractFromTlv(const RsTlvIpAddrSet &tlvAddrs);
|
||||
void loadTlv(RsTlvIpAddrSet &tlvAddrs);
|
||||
|
||||
@ -65,7 +65,7 @@ class pqiIpAddrSet
|
||||
bool updateLocalAddrs(const pqiIpAddress &addr);
|
||||
bool updateExtAddrs(const pqiIpAddress &addr);
|
||||
bool updateAddrs(const pqiIpAddrSet &addrs);
|
||||
void printAddrs(std::ostream &out) const;
|
||||
void printAddrs(std::string &out) const;
|
||||
pqiIpAddrList mLocal;
|
||||
pqiIpAddrList mExt;
|
||||
};
|
||||
|
@ -56,8 +56,9 @@ void pqiConnectCbDummy::peerStatus(std::string id, const pqiIpAddrSet &addrs,
|
||||
|
||||
std::cerr << " addrs: ";
|
||||
std::cerr << std::endl;
|
||||
addrs.printAddrs(std::cerr);
|
||||
std::cerr << std::endl;
|
||||
std::string out;
|
||||
addrs.printAddrs(out);
|
||||
std::cerr << out << std::endl;
|
||||
}
|
||||
|
||||
void pqiConnectCbDummy::peerConnectRequest(std::string id,
|
||||
|
@ -23,8 +23,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "util/rsdebug.h"
|
||||
|
||||
#include "pqi/pqisslpersongrp.h"
|
||||
@ -59,11 +57,7 @@ pqilistener * pqisslpersongrp::createListener(struct sockaddr_in laddr)
|
||||
|
||||
pqiperson * pqisslpersongrp::createPerson(std::string id, pqilistener *listener)
|
||||
{
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqipersongrp::createPerson() PeerId: " << id;
|
||||
pqioutput(PQL_DEBUG_BASIC, pqipersongrpzone, out.str());
|
||||
}
|
||||
pqioutput(PQL_DEBUG_BASIC, pqipersongrpzone, "pqipersongrp::createPerson() PeerId: " + id);
|
||||
|
||||
pqiperson *pqip = new pqiperson(id, this);
|
||||
pqissl *pqis = new pqissl((pqissllistener *) listener, pqip, mLinkMgr);
|
||||
|
@ -23,10 +23,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "pqi/pqissltunnel.h"
|
||||
#include "pqi/pqinetwork.h"
|
||||
#include "pqi/p3linkmgr.h"
|
||||
@ -35,13 +31,12 @@
|
||||
|
||||
#include "util/rsnet.h"
|
||||
#include "util/rsdebug.h"
|
||||
#include "util/rsstring.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <openssl/err.h>
|
||||
|
||||
#include <sstream>
|
||||
|
||||
const int pqisslzone = 37714;
|
||||
|
||||
#define TUNNEL_WAITING_NOT 0
|
||||
@ -97,11 +92,7 @@ pqissltunnel::pqissltunnel(PQInterface *parent, p3LinkMgr *cm, p3tunnel *p3t)
|
||||
active = false;
|
||||
waiting = TUNNEL_WAITING_NOT;
|
||||
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqissltunnel for PeerId: " << PeerId();
|
||||
rslog(RSL_ALERT, pqisslzone, out.str());
|
||||
}
|
||||
rslog(RSL_ALERT, pqisslzone, "pqissltunnel for PeerId: " + PeerId());
|
||||
|
||||
// if (!(AuthSSL::getAuthSSL()->isAuthenticated(PeerId()))) {
|
||||
// rslog(RSL_ALERT, pqisslzone,
|
||||
@ -204,27 +195,24 @@ int pqissltunnel::getConnectAddress(struct sockaddr_in &raddr) {
|
||||
bool pqissltunnel::connect_parameter(uint32_t type, uint32_t value)
|
||||
{
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqissltunnel::connect_parameter() (not used) Peer: " << PeerId();
|
||||
out << " type: " << type << "value: " << value;
|
||||
rslog(RSL_DEBUG_ALL, pqisslzone, out.str());
|
||||
std::string out = "pqissltunnel::connect_parameter() (not used) Peer: " + PeerId();
|
||||
rs_sprintf_append(out, " type: %lu value: %lu", type, value);
|
||||
rslog(RSL_DEBUG_ALL, pqisslzone, out);
|
||||
}
|
||||
|
||||
if (type == NET_PARAM_CONNECT_DELAY)
|
||||
if (type == NET_PARAM_CONNECT_DELAY)
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqissltunnel::connect_parameter() (not used) Peer: " << PeerId();
|
||||
out << " DELAY: " << value;
|
||||
rslog(RSL_WARNING, pqisslzone, out.str());
|
||||
std::string out = "pqissltunnel::connect_parameter() (not used) Peer: " + PeerId();
|
||||
rs_sprintf_append(out, " DELAY: %lu", value);
|
||||
rslog(RSL_WARNING, pqisslzone, out);
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (type == NET_PARAM_CONNECT_TIMEOUT)
|
||||
else if (type == NET_PARAM_CONNECT_TIMEOUT)
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqissltunnel::connect_parameter() (not used) Peer: " << PeerId();
|
||||
out << " TIMEOUT: " << value;
|
||||
rslog(RSL_WARNING, pqisslzone, out.str());
|
||||
std::string out = "pqissltunnel::connect_parameter() (not used) Peer: " + PeerId();
|
||||
rs_sprintf_append(out, " TIMEOUT: %lu", value);
|
||||
rslog(RSL_WARNING, pqisslzone, out);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -23,10 +23,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "pqi/pqissludp.h"
|
||||
#include "pqi/pqinetwork.h"
|
||||
|
||||
@ -40,6 +36,7 @@
|
||||
|
||||
#include "util/rsdebug.h"
|
||||
#include "util/rsnet.h"
|
||||
#include "util/rsstring.h"
|
||||
|
||||
#include "pqi/p3linkmgr.h"
|
||||
|
||||
@ -199,30 +196,22 @@ int pqissludp::Initiate_Connection()
|
||||
"pqissludp::Initiate_Connection() Opening Socket");
|
||||
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqissludp::Initiate_Connection() ";
|
||||
out << "Connecting To: " << PeerId();
|
||||
out << " via: " << rs_inet_ntoa(remote_addr.sin_addr) << ":";
|
||||
out << ntohs(remote_addr.sin_port) << " ";
|
||||
std::string out = "pqissludp::Initiate_Connection() Connecting To: " + PeerId();
|
||||
rs_sprintf(out, " via: %s:%u", rs_inet_ntoa(remote_addr.sin_addr).c_str(), ntohs(remote_addr.sin_port));
|
||||
if (sslmode)
|
||||
{
|
||||
out << "ACTIVE Connect (SSL_Connect)";
|
||||
out += "ACTIVE Connect (SSL_Connect)";
|
||||
}
|
||||
else
|
||||
{
|
||||
out << "PASSIVE Connect (SSL_Accept)";
|
||||
out += "PASSIVE Connect (SSL_Accept)";
|
||||
}
|
||||
rslog(RSL_WARNING, pqissludpzone, out.str());
|
||||
rslog(RSL_WARNING, pqissludpzone, out);
|
||||
}
|
||||
|
||||
if (remote_addr.sin_addr.s_addr == 0)
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqissludp::Initiate_Connection() ";
|
||||
out << "Invalid (0.0.0.0) Remote Address,";
|
||||
out << " Aborting Connect.";
|
||||
out << std::endl;
|
||||
rslog(RSL_WARNING, pqissludpzone, out.str());
|
||||
rslog(RSL_WARNING, pqissludpzone, "pqissludp::Initiate_Connection() Invalid (0.0.0.0) Remote Address, Aborting Connect.");
|
||||
waiting = WAITING_FAIL_INTERFACE;
|
||||
|
||||
reset();
|
||||
@ -270,32 +259,29 @@ int pqissludp::Initiate_Connection()
|
||||
{
|
||||
int tou_err = tou_errno(sockfd);
|
||||
|
||||
std::ostringstream out;
|
||||
out << "pqissludp::Initiate_Connection()";
|
||||
std::string out = "pqissludp::Initiate_Connection()";
|
||||
|
||||
if ((tou_err == EINPROGRESS) || (tou_err == EAGAIN))
|
||||
{
|
||||
// set state to waiting.....
|
||||
waiting = WAITING_SOCK_CONNECT;
|
||||
|
||||
out << " EINPROGRESS Waiting for Socket Connection";
|
||||
rslog(RSL_WARNING, pqissludpzone, out.str());
|
||||
out += " EINPROGRESS Waiting for Socket Connection";
|
||||
rslog(RSL_WARNING, pqissludpzone, out);
|
||||
|
||||
return 0;
|
||||
}
|
||||
else if ((tou_err == ENETUNREACH) || (tou_err == ETIMEDOUT))
|
||||
{
|
||||
out << "ENETUNREACHABLE: cert: " << PeerId();
|
||||
out << std::endl;
|
||||
out += "ENETUNREACHABLE: cert: " + PeerId() + "\n";
|
||||
|
||||
// Then send unreachable message.
|
||||
waiting = WAITING_FAIL_INTERFACE;
|
||||
}
|
||||
|
||||
out << "Error: Connection Failed: " << tou_err;
|
||||
out << " - " << socket_errorType(tou_err) << std::endl;
|
||||
rs_sprintf_append(out, "Error: Connection Failed: %d - %s", tou_err, socket_errorType(tou_err).c_str());
|
||||
|
||||
rslog(RSL_WARNING, pqissludpzone, out.str());
|
||||
rslog(RSL_WARNING, pqissludpzone, out);
|
||||
|
||||
reset();
|
||||
|
||||
@ -324,12 +310,10 @@ int pqissludp::Basic_Connection_Complete()
|
||||
|
||||
if (time(NULL) > mTimeoutTS)
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqissludp::Basic_Connection_Complete() Connection Timed Out. ";
|
||||
out << "Peer: " << PeerId() << " Period: ";
|
||||
out << mConnectTimeout;
|
||||
std::string out = "pqissludp::Basic_Connection_Complete() Connection Timed Out. Peer: " + PeerId();
|
||||
rs_sprintf_append(out, " Period: %lu", mConnectTimeout);
|
||||
|
||||
rslog(RSL_WARNING, pqissludpzone, out.str());
|
||||
rslog(RSL_WARNING, pqissludpzone, out);
|
||||
|
||||
/* as sockfd is valid, this should close it all up */
|
||||
|
||||
@ -353,27 +337,16 @@ int pqissludp::Basic_Connection_Complete()
|
||||
{
|
||||
if (err == EINPROGRESS)
|
||||
{
|
||||
|
||||
std::ostringstream out;
|
||||
out << "pqissludp::Basic_Connection_Complete() ";
|
||||
out << "EINPROGRESS: cert: " << PeerId();
|
||||
rslog(RSL_DEBUG_BASIC, pqissludpzone, out.str());
|
||||
|
||||
rslog(RSL_DEBUG_BASIC, pqissludpzone, "pqissludp::Basic_Connection_Complete() EINPROGRESS: cert: " + PeerId());
|
||||
}
|
||||
else if ((err == ENETUNREACH) || (err == ETIMEDOUT))
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqissludp::Basic_Connection_Complete() ";
|
||||
out << "ENETUNREACH/ETIMEDOUT: cert: ";
|
||||
out << PeerId();
|
||||
rslog(RSL_WARNING, pqissludpzone, out.str());
|
||||
rslog(RSL_WARNING, pqissludpzone, "pqissludp::Basic_Connection_Complete() ENETUNREACH/ETIMEDOUT: cert: " + PeerId());
|
||||
|
||||
/* 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());
|
||||
std::string out = "pqissludp::Basic_Connection_Complete() ";
|
||||
rs_sprintf_append(out, "Error: Connection Failed: %d - %s", err, socket_errorType(err).c_str());
|
||||
rslog(RSL_DEBUG_BASIC, pqissludpzone, out);
|
||||
|
||||
reset();
|
||||
|
||||
@ -388,11 +361,7 @@ int pqissludp::Basic_Connection_Complete()
|
||||
if (tou_connected(sockfd))
|
||||
/* <===================== UDP Difference *******************/
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqissludp::Basic_Connection_Complete() ";
|
||||
out << "Connection Complete: cert: ";
|
||||
out << PeerId();
|
||||
rslog(RSL_WARNING, pqissludpzone, out.str());
|
||||
rslog(RSL_WARNING, pqissludpzone, "pqissludp::Basic_Connection_Complete() Connection Complete: cert: " + PeerId());
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -455,21 +424,15 @@ int pqissludp::tick()
|
||||
// listen fns call the udpproxy.
|
||||
int pqissludp::listen()
|
||||
{
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqissludp::listen() (NULLOP)";
|
||||
rslog(RSL_DEBUG_BASIC, pqissludpzone, out.str());
|
||||
}
|
||||
rslog(RSL_DEBUG_BASIC, pqissludpzone, "pqissludp::listen() (NULLOP)");
|
||||
|
||||
return 1; //udpproxy->listen();
|
||||
}
|
||||
|
||||
int pqissludp::stoplistening()
|
||||
{
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqissludp::stoplistening() (NULLOP)";
|
||||
rslog(RSL_DEBUG_BASIC, pqissludpzone, out.str());
|
||||
}
|
||||
rslog(RSL_DEBUG_BASIC, pqissludpzone, "pqissludp::stoplistening() (NULLOP)");
|
||||
|
||||
return 1; //udpproxy->stoplistening();
|
||||
}
|
||||
|
||||
@ -479,32 +442,32 @@ bool pqissludp::connect_parameter(uint32_t type, uint32_t value)
|
||||
//std::cerr << "pqissludp::connect_parameter() type: " << type << "value: " << value << std::endl;
|
||||
if (type == NET_PARAM_CONNECT_PERIOD)
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqissludp::connect_parameter() Peer: " << PeerId() << " PERIOD: " << value;
|
||||
rslog(RSL_WARNING, pqissludpzone, out.str());
|
||||
std::string out;
|
||||
rs_sprintf(out, "pqissludp::connect_parameter() Peer: %s PERIOD: %lu", PeerId().c_str(), value);
|
||||
rslog(RSL_WARNING, pqissludpzone, out);
|
||||
|
||||
mConnectPeriod = value;
|
||||
std::cerr << out.str() << std::endl;
|
||||
std::cerr << out << std::endl;
|
||||
return true;
|
||||
}
|
||||
else if (type == NET_PARAM_CONNECT_FLAGS)
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqissludp::connect_parameter() Peer: " << PeerId() << " FLAGS: " << value;
|
||||
rslog(RSL_WARNING, pqissludpzone, out.str());
|
||||
std::string out;
|
||||
rs_sprintf(out, "pqissludp::connect_parameter() Peer: %s FLAGS: %lu", PeerId().c_str(), value);
|
||||
rslog(RSL_WARNING, pqissludpzone, out);
|
||||
|
||||
mConnectFlags = value;
|
||||
std::cerr << out.str() << std::endl;
|
||||
std::cerr << out<< std::endl;
|
||||
return true;
|
||||
}
|
||||
else if (type == NET_PARAM_CONNECT_BANDWIDTH)
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqissludp::connect_parameter() Peer: " << PeerId() << " BANDWIDTH: " << value;
|
||||
rslog(RSL_WARNING, pqissludpzone, out.str());
|
||||
std::string out;
|
||||
rs_sprintf(out, "pqissludp::connect_parameter() Peer: %s BANDWIDTH: %lu", PeerId().c_str(), value);
|
||||
rslog(RSL_WARNING, pqissludpzone, out);
|
||||
|
||||
mConnectBandwidth = value;
|
||||
std::cerr << out.str() << std::endl;
|
||||
std::cerr << out << std::endl;
|
||||
return true;
|
||||
}
|
||||
return pqissl::connect_parameter(type, value);
|
||||
@ -514,26 +477,24 @@ bool pqissludp::connect_additional_address(uint32_t type, struct sockaddr_in *ad
|
||||
{
|
||||
if (type == NET_PARAM_CONNECT_PROXY)
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqissludp::connect_parameter() Peer: " << PeerId() << " PROXYADDR: ";
|
||||
out << rs_inet_ntoa(addr->sin_addr) << ":" << ntohs(addr->sin_port);
|
||||
rslog(RSL_WARNING, pqissludpzone, out.str());
|
||||
std::string out;
|
||||
rs_sprintf(out, "pqissludp::connect_additional_address() Peer: %s PROXYADDR: %s:%u", PeerId().c_str(), rs_inet_ntoa(addr->sin_addr).c_str(), ntohs(addr->sin_port));
|
||||
rslog(RSL_WARNING, pqissludpzone, out);
|
||||
|
||||
mConnectProxyAddr = *addr;
|
||||
|
||||
std::cerr << out.str() << std::endl;
|
||||
std::cerr << out << std::endl;
|
||||
return true;
|
||||
}
|
||||
else if (type == NET_PARAM_CONNECT_SOURCE)
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqissludp::connect_parameter() Peer: " << PeerId() << " SRCADDR: ";
|
||||
out << rs_inet_ntoa(addr->sin_addr) << ":" << ntohs(addr->sin_port);
|
||||
rslog(RSL_WARNING, pqissludpzone, out.str());
|
||||
std::string out;
|
||||
rs_sprintf(out, "pqissludp::connect_additional_address() Peer: %s SRCADDR: %s:%u", PeerId().c_str(), rs_inet_ntoa(addr->sin_addr).c_str(), ntohs(addr->sin_port));
|
||||
rslog(RSL_WARNING, pqissludpzone, out);
|
||||
|
||||
mConnectSrcAddr = *addr;
|
||||
|
||||
std::cerr << out.str() << std::endl;
|
||||
std::cerr << out << std::endl;
|
||||
return true;
|
||||
}
|
||||
return pqissl::connect_additional_address(type, addr);
|
||||
@ -544,10 +505,9 @@ bool pqissludp::connect_additional_address(uint32_t type, struct sockaddr_in *ad
|
||||
bool pqissludp::moretoread()
|
||||
{
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqissludp::moretoread()";
|
||||
out << " polling socket (" << sockfd << ")";
|
||||
rslog(RSL_DEBUG_ALL, pqissludpzone, out.str());
|
||||
std::string out = "pqissludp::moretoread()";
|
||||
rs_sprintf_append(out, " polling socket (%d)", sockfd);
|
||||
rslog(RSL_DEBUG_ALL, pqissludpzone, out);
|
||||
}
|
||||
|
||||
/* check for more to read first ... if nothing... check error
|
||||
@ -570,40 +530,23 @@ bool pqissludp::moretoread()
|
||||
{
|
||||
if ((err == EAGAIN) || (err == EINPROGRESS))
|
||||
{
|
||||
|
||||
std::ostringstream out;
|
||||
out << "pqissludp::moretoread() ";
|
||||
out << "EAGAIN/EINPROGRESS: cert " << PeerId();
|
||||
rslog(RSL_DEBUG_BASIC, pqissludpzone, out.str());
|
||||
rslog(RSL_DEBUG_BASIC, pqissludpzone, "pqissludp::moretoread() EAGAIN/EINPROGRESS: cert " + PeerId());
|
||||
return 0;
|
||||
|
||||
}
|
||||
else if ((err == ENETUNREACH) || (err == ETIMEDOUT))
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqissludp::moretoread() ";
|
||||
out << "ENETUNREACH/ETIMEDOUT: cert ";
|
||||
out << PeerId();
|
||||
rslog(RSL_WARNING, pqissludpzone, out.str());
|
||||
|
||||
rslog(RSL_WARNING, pqissludpzone, "pqissludp::moretoread() ENETUNREACH/ETIMEDOUT: cert " + PeerId());
|
||||
}
|
||||
else if (err == EBADF)
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqissludp::moretoread() ";
|
||||
out << "EBADF: cert ";
|
||||
out << PeerId();
|
||||
rslog(RSL_WARNING, pqissludpzone, out.str());
|
||||
|
||||
rslog(RSL_WARNING, pqissludpzone, "pqissludp::moretoread() EBADF: cert " + PeerId());
|
||||
}
|
||||
else
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqissludp::moretoread() ";
|
||||
out << " Unknown ERROR: " << err << ": cert ";
|
||||
out << PeerId();
|
||||
rslog(RSL_WARNING, pqissludpzone, out.str());
|
||||
|
||||
std::string out = "pqissludp::moretoread() ";
|
||||
rs_sprintf_append(out, " Unknown ERROR: %d: cert ", err, PeerId().c_str());
|
||||
rslog(RSL_WARNING, pqissludpzone, out);
|
||||
}
|
||||
|
||||
reset();
|
||||
|
@ -26,8 +26,8 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include "util/rsdebug.h"
|
||||
#include "util/rsstring.h"
|
||||
|
||||
#include "pqi/pqistreamer.h"
|
||||
#include "pqi/pqinotify.h"
|
||||
@ -35,7 +35,6 @@
|
||||
#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) */
|
||||
@ -77,19 +76,11 @@ pqistreamer::pqistreamer(RsSerialiser *rss, std::string id, BinInterface *bio_in
|
||||
setRate(true, 0);
|
||||
setRate(false, 0);
|
||||
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqistreamer::pqistreamer()";
|
||||
out << " Initialisation!" << std::endl;
|
||||
pqioutput(PQL_DEBUG_ALL, pqistreamerzone, out.str());
|
||||
}
|
||||
pqioutput(PQL_DEBUG_ALL, pqistreamerzone, "pqistreamer::pqistreamer() Initialisation!");
|
||||
|
||||
if (!bio_in)
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqistreamer::pqistreamer()";
|
||||
out << " NULL bio, FATAL ERROR!" << std::endl;
|
||||
pqioutput(PQL_ALERT, pqistreamerzone, out.str());
|
||||
pqioutput(PQL_ALERT, pqistreamerzone, "pqistreamer::pqistreamer() NULL bio, FATAL ERROR!");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -102,26 +93,15 @@ pqistreamer::~pqistreamer()
|
||||
{
|
||||
RsStackMutex stack(streamerMtx) ; // lock out_pkt and out_data
|
||||
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqistreamer::~pqistreamer()";
|
||||
out << " Destruction!" << std::endl;
|
||||
pqioutput(PQL_DEBUG_ALL, pqistreamerzone, out.str());
|
||||
}
|
||||
pqioutput(PQL_DEBUG_ALL, pqistreamerzone, "pqistreamer::~pqistreamer() Destruction!");
|
||||
|
||||
if (bio_flags & BIN_FLAGS_NO_CLOSE)
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqistreamer::~pqistreamer()";
|
||||
out << " Not Closing BinInterface!" << std::endl;
|
||||
pqioutput(PQL_DEBUG_ALL, pqistreamerzone, out.str());
|
||||
pqioutput(PQL_DEBUG_ALL, pqistreamerzone, "pqistreamer::~pqistreamer() Not Closing BinInterface!");
|
||||
}
|
||||
else if (bio)
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqistreamer::~pqistreamer()";
|
||||
out << " Deleting BinInterface!" << std::endl;
|
||||
pqioutput(PQL_DEBUG_ALL, pqistreamerzone, out.str());
|
||||
pqioutput(PQL_DEBUG_ALL, pqistreamerzone, "pqistreamer::~pqistreamer() Deleting BinInterface!");
|
||||
|
||||
delete bio;
|
||||
}
|
||||
@ -161,12 +141,11 @@ pqistreamer::~pqistreamer()
|
||||
int pqistreamer::SendItem(RsItem *si,uint32_t& out_size)
|
||||
{
|
||||
#ifdef RSITEM_DEBUG
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqistreamer::SendItem():" << std::endl;
|
||||
si -> print(out);
|
||||
pqioutput(PQL_DEBUG_ALL, pqistreamerzone, out.str());
|
||||
std::cerr << out.str();
|
||||
{
|
||||
std::string out = "pqistreamer::SendItem():\n";
|
||||
si -> print_string(out);
|
||||
pqioutput(PQL_DEBUG_ALL, pqistreamerzone, out);
|
||||
std::cerr << out;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -175,11 +154,7 @@ int pqistreamer::SendItem(RsItem *si,uint32_t& out_size)
|
||||
|
||||
RsItem *pqistreamer::GetItem()
|
||||
{
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqistreamer::GetItem()";
|
||||
pqioutput(PQL_DEBUG_ALL, pqistreamerzone, out.str());
|
||||
}
|
||||
pqioutput(PQL_DEBUG_ALL, pqistreamerzone, "pqistreamer::GetItem()");
|
||||
|
||||
if(incoming.empty())
|
||||
return NULL;
|
||||
@ -195,13 +170,10 @@ int pqistreamer::tick()
|
||||
{
|
||||
#ifdef DEBUG_PQISTREAMER
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqistreamer::tick()";
|
||||
out << std::endl;
|
||||
out << PeerId() << ": currRead/Sent: " << currRead << "/" << currSent;
|
||||
out << std::endl;
|
||||
std::string out = "pqistreamer::tick()\n" + PeerId();
|
||||
rs_sprintf_append(out, ": currRead/Sent: %d/%d", currRead, currSent);
|
||||
|
||||
pqioutput(PQL_DEBUG_ALL, pqistreamerzone, out.str());
|
||||
pqioutput(PQL_DEBUG_ALL, pqistreamerzone, out);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -226,19 +198,17 @@ int pqistreamer::tick()
|
||||
{
|
||||
std::list<void *>::iterator it;
|
||||
|
||||
std::ostringstream out;
|
||||
out << "pqistreamer::tick() Queued Data:";
|
||||
out << " for " << PeerId();
|
||||
std::string out = "pqistreamer::tick() Queued Data: for " + PeerId();
|
||||
|
||||
if (bio->isactive())
|
||||
{
|
||||
out << " (active)";
|
||||
out += " (active)";
|
||||
}
|
||||
else
|
||||
{
|
||||
out << " (waiting)";
|
||||
out += " (waiting)";
|
||||
}
|
||||
out << std::endl;
|
||||
out += "\n";
|
||||
|
||||
{
|
||||
RsStackMutex stack(streamerMtx) ; // lock out_pkt and out_data
|
||||
@ -249,23 +219,20 @@ int pqistreamer::tick()
|
||||
total += getRsItemSize(*it);
|
||||
}
|
||||
|
||||
out << "\t Out Packets [" << out_pkt.size() << "] => " << total;
|
||||
out << " bytes" << std::endl;
|
||||
rs_sprintf_append(out, "\t Out Packets [%d] => %d bytes\n", out_pkt.size(), total);
|
||||
|
||||
total = 0;
|
||||
for(it = out_data.begin(); it != out_data.end(); it++)
|
||||
for(it = out_pkt.begin(); it != out_pkt.end(); it++)
|
||||
{
|
||||
total += getRsItemSize(*it);
|
||||
}
|
||||
|
||||
out << "\t Out Data [" << out_data.size() << "] => " << total;
|
||||
out << " bytes" << std::endl;
|
||||
rs_sprintf_append(out, "\t Out Data [%d] => %d bytes\n", out_pkt.size(), total);
|
||||
|
||||
out << "\t Incoming [" << incoming.size() << "]";
|
||||
out << std::endl;
|
||||
rs_sprintf_append(out, "\t Incoming [%d]\n", incoming.size());
|
||||
}
|
||||
|
||||
pqioutput(PQL_DEBUG_BASIC, pqistreamerzone, out.str());
|
||||
pqioutput(PQL_DEBUG_BASIC, pqistreamerzone, out);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -279,17 +246,13 @@ int pqistreamer::tick()
|
||||
|
||||
int pqistreamer::status()
|
||||
{
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqistreamer::status()";
|
||||
pqioutput(PQL_DEBUG_ALL, pqistreamerzone, out.str());
|
||||
}
|
||||
pqioutput(PQL_DEBUG_ALL, pqistreamerzone, "pqistreamer::status()");
|
||||
|
||||
if (bio->isactive())
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "Data in:" << totalRead << " out:" << totalSent;
|
||||
pqioutput(PQL_DEBUG_BASIC, pqistreamerzone, out.str());
|
||||
std::string out;
|
||||
rs_sprintf(out, "Data in:%d out:%d", totalRead, totalSent);
|
||||
pqioutput(PQL_DEBUG_BASIC, pqistreamerzone, out);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -315,11 +278,7 @@ int pqistreamer::queue_outpqi(RsItem *pqi,uint32_t& pktsize)
|
||||
std::cerr << "Having file data with flags = " << bio_flags << std::endl ;
|
||||
}
|
||||
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqistreamer::queue_outpqi()";
|
||||
pqioutput(PQL_DEBUG_ALL, pqistreamerzone, out.str());
|
||||
}
|
||||
pqioutput(PQL_DEBUG_ALL, pqistreamerzone, "pqistreamer::queue_outpqi()");
|
||||
#endif
|
||||
|
||||
/* decide which type of packet it is */
|
||||
@ -346,12 +305,9 @@ int pqistreamer::queue_outpqi(RsItem *pqi,uint32_t& pktsize)
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
std::ostringstream out;
|
||||
out << "pqistreamer::queue_outpqi() Null Pkt generated!";
|
||||
out << std::endl;
|
||||
out << "Caused By: " << std::endl;
|
||||
pqi -> print(out);
|
||||
pqioutput(PQL_ALERT, pqistreamerzone, out.str());
|
||||
std::string out = "pqistreamer::queue_outpqi() Null Pkt generated!\nCaused By:\n";
|
||||
pqi -> print_string(out);
|
||||
pqioutput(PQL_ALERT, pqistreamerzone, out);
|
||||
|
||||
if (!(bio_flags & BIN_FLAGS_NO_DELETE))
|
||||
{
|
||||
@ -363,11 +319,7 @@ int pqistreamer::queue_outpqi(RsItem *pqi,uint32_t& pktsize)
|
||||
int pqistreamer::handleincomingitem(RsItem *pqi)
|
||||
{
|
||||
#ifdef DEBUG_PQISTREAMER
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqistreamer::handleincomingitem()";
|
||||
pqioutput(PQL_DEBUG_ALL, pqistreamerzone, out.str());
|
||||
}
|
||||
pqioutput(PQL_DEBUG_ALL, pqistreamerzone, "pqistreamer::handleincomingitem()");
|
||||
#endif
|
||||
// timestamp last received packet.
|
||||
mLastIncomingTs = time(NULL);
|
||||
@ -388,11 +340,7 @@ int pqistreamer::handleoutgoing()
|
||||
RsStackMutex stack(streamerMtx) ; // lock out_pkt and out_data
|
||||
|
||||
#ifdef DEBUG_PQISTREAMER
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqistreamer::handleoutgoing()";
|
||||
pqioutput(PQL_DEBUG_ALL, pqistreamerzone, out.str());
|
||||
}
|
||||
pqioutput(PQL_DEBUG_ALL, pqistreamerzone, "pqistreamer::handleoutgoing()");
|
||||
#endif
|
||||
|
||||
int maxbytes = outAllowedBytes();
|
||||
@ -412,10 +360,9 @@ int pqistreamer::handleoutgoing()
|
||||
free(*it);
|
||||
it = out_pkt.erase(it);
|
||||
#ifdef DEBUG_PQISTREAMER
|
||||
std::ostringstream out;
|
||||
out << "pqistreamer::handleoutgoing() Not active -> Clearing Pkt!";
|
||||
// std::cerr << out.str() ;
|
||||
pqioutput(PQL_DEBUG_BASIC, pqistreamerzone, out.str());
|
||||
std::string out = "pqistreamer::handleoutgoing() Not active -> Clearing Pkt!";
|
||||
// std::cerr << out ;
|
||||
pqioutput(PQL_DEBUG_BASIC, pqistreamerzone, out);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -481,11 +428,10 @@ int pqistreamer::handleoutgoing()
|
||||
|
||||
if (len != (ss = bio->senddata(pkt_wpending, len)))
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "Problems with Send Data! (only " << ss << " bytes sent" << ", total pkt size=" << len ;
|
||||
out << std::endl;
|
||||
// std::cerr << out.str() ;
|
||||
pqioutput(PQL_DEBUG_BASIC, pqistreamerzone, out.str());
|
||||
std::string out;
|
||||
rs_sprintf(out, "Problems with Send Data! (only %d bytes sent, total pkt size=%d)", ss, len);
|
||||
// std::cerr << out << std::endl ;
|
||||
pqioutput(PQL_DEBUG_BASIC, pqistreamerzone, out);
|
||||
|
||||
outSentBytes(sentbytes);
|
||||
// pkt_wpending will kept til next time.
|
||||
@ -518,11 +464,7 @@ int pqistreamer::handleincoming()
|
||||
static const int max_failed_read_attempts = 2000 ;
|
||||
|
||||
#ifdef DEBUG_PQISTREAMER
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqistreamer::handleincoming()";
|
||||
pqioutput(PQL_DEBUG_ALL, pqistreamerzone, out.str());
|
||||
}
|
||||
pqioutput(PQL_DEBUG_ALL, pqistreamerzone, "pqistreamer::handleincoming()");
|
||||
#endif
|
||||
|
||||
if(!(bio->isactive()))
|
||||
@ -589,10 +531,9 @@ start_packet_read:
|
||||
else // tmplen > 0
|
||||
{
|
||||
// strange case....This should never happen as partial reads are handled by pqissl below.
|
||||
std::ostringstream out;
|
||||
out << "pqistreamer::handleincoming() Incomplete ";
|
||||
out << "(Strange) read of " << tmplen << " bytes";
|
||||
pqioutput(PQL_ALERT, pqistreamerzone, out.str());
|
||||
std::string out = "pqistreamer::handleincoming() Incomplete ";
|
||||
rs_sprintf_append(out, "(Strange) read of %d bytes", tmplen);
|
||||
pqioutput(PQL_ALERT, pqistreamerzone, out);
|
||||
#ifdef DEBUG_PQISTREAMER
|
||||
std::cerr << "[" << (void*)pthread_self() << "] " << "given up 3" << std::endl ;
|
||||
#endif
|
||||
@ -600,11 +541,11 @@ start_packet_read:
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG_PQISTREAMER
|
||||
std::cerr << "[" << (void*)pthread_self() << "] " << "block 0 : " << (int)(((unsigned char*)block)[0]) << " " << (int)(((unsigned char*)block)[1]) << " " << (int)(((unsigned char*)block)[2]) << " "
|
||||
std::cerr << "[" << (void*)pthread_self() << "] " << "block 0 : " << (int)(((unsigned char*)block)[0]) << " " << (int)(((unsigned char*)block)[1]) << " " << (int)(((unsigned char*)block)[2]) << " "
|
||||
<< (int)(((unsigned char*)block)[3]) << " "
|
||||
<< (int)(((unsigned char*)block)[4]) << " "
|
||||
<< (int)(((unsigned char*)block)[5]) << " "
|
||||
<< (int)(((unsigned char*)block)[6]) << " "
|
||||
<< (int)(((unsigned char*)block)[4]) << " "
|
||||
<< (int)(((unsigned char*)block)[5]) << " "
|
||||
<< (int)(((unsigned char*)block)[6]) << " "
|
||||
<< (int)(((unsigned char*)block)[7]) << " " << std::endl ;
|
||||
#endif
|
||||
|
||||
@ -621,11 +562,11 @@ continue_packet:
|
||||
std::cerr << "[" << (void*)pthread_self() << "] " << "continuing packet getRsItemSize(block) = " << getRsItemSize(block) << std::endl ;
|
||||
std::cerr << "[" << (void*)pthread_self() << "] " << "continuing packet extralen = " << extralen << std::endl ;
|
||||
|
||||
std::cerr << "[" << (void*)pthread_self() << "] " << "continuing packet state=" << reading_state << std::endl ;
|
||||
std::cerr << "[" << (void*)pthread_self() << "] " << "continuing packet state=" << reading_state << std::endl ;
|
||||
std::cerr << "[" << (void*)pthread_self() << "] " << "block 1 : " << (int)(((unsigned char*)block)[0]) << " " << (int)(((unsigned char*)block)[1]) << " " << (int)(((unsigned char*)block)[2]) << " " << (int)(((unsigned char*)block)[3]) << " "
|
||||
<< (int)(((unsigned char*)block)[4]) << " "
|
||||
<< (int)(((unsigned char*)block)[5]) << " "
|
||||
<< (int)(((unsigned char*)block)[6]) << " "
|
||||
<< (int)(((unsigned char*)block)[4]) << " "
|
||||
<< (int)(((unsigned char*)block)[5]) << " "
|
||||
<< (int)(((unsigned char*)block)[6]) << " "
|
||||
<< (int)(((unsigned char*)block)[7]) << " " << std::endl ;
|
||||
#endif
|
||||
if (extralen > maxlen - blen)
|
||||
@ -638,38 +579,37 @@ continue_packet:
|
||||
std::string title =
|
||||
"Warning: Bad Packet Read";
|
||||
|
||||
std::ostringstream msgout;
|
||||
msgout << " **** WARNING **** \n";
|
||||
msgout << "Retroshare has caught a BAD Packet Read";
|
||||
msgout << "\n";
|
||||
msgout << "This is normally caused by connecting to an";
|
||||
msgout << " OLD version of Retroshare";
|
||||
msgout << "\n";
|
||||
msgout << "(M:" << maxlen << " B:" << blen << " E:" << extralen << ")\n";
|
||||
msgout << "\n";
|
||||
msgout << "block = "
|
||||
<< (int)(((unsigned char*)block)[0]) << " "
|
||||
<< (int)(((unsigned char*)block)[1]) << " "
|
||||
<< (int)(((unsigned char*)block)[2]) << " "
|
||||
<< (int)(((unsigned char*)block)[3]) << " "
|
||||
<< (int)(((unsigned char*)block)[4]) << " "
|
||||
<< (int)(((unsigned char*)block)[5]) << " "
|
||||
<< (int)(((unsigned char*)block)[6]) << " "
|
||||
<< (int)(((unsigned char*)block)[7]) << "\n" ;
|
||||
msgout << "\n";
|
||||
msgout << "Please get your friends to upgrade to the latest version";
|
||||
msgout << "\n";
|
||||
msgout << "\n";
|
||||
msgout << "If you are sure the error was not caused by an old version";
|
||||
msgout << "\n";
|
||||
msgout << "Please report the problem to Retroshare's developers";
|
||||
msgout << "\n";
|
||||
std::string msg;
|
||||
msg = " **** WARNING **** \n";
|
||||
msg += "Retroshare has caught a BAD Packet Read";
|
||||
msg += "\n";
|
||||
msg += "This is normally caused by connecting to an";
|
||||
msg += " OLD version of Retroshare";
|
||||
msg += "\n";
|
||||
rs_sprintf_append(msg, "(M:%d B:%d E:%d)\n", maxlen, blen, extralen);
|
||||
msg += "\n";
|
||||
rs_sprintf_append(msg, "block = %d %d %d %d %d %d %d %d\n",
|
||||
(int)(((unsigned char*)block)[0]),
|
||||
(int)(((unsigned char*)block)[1]),
|
||||
(int)(((unsigned char*)block)[2]),
|
||||
(int)(((unsigned char*)block)[3]),
|
||||
(int)(((unsigned char*)block)[4]),
|
||||
(int)(((unsigned char*)block)[5]),
|
||||
(int)(((unsigned char*)block)[6]),
|
||||
(int)(((unsigned char*)block)[7])) ;
|
||||
msg += "\n";
|
||||
msg += "Please get your friends to upgrade to the latest version";
|
||||
msg += "\n";
|
||||
msg += "\n";
|
||||
msg += "If you are sure the error was not caused by an old version";
|
||||
msg += "\n";
|
||||
msg += "Please report the problem to Retroshare's developers";
|
||||
msg += "\n";
|
||||
|
||||
std::string msg = msgout.str();
|
||||
notify->AddLogMessage(0, RS_SYS_WARNING, title, msg);
|
||||
|
||||
std::cerr << "pqistreamer::handle_incoming() ERROR: Read Packet too Big" << std::endl;
|
||||
std::cerr << msgout.str();
|
||||
std::cerr << msg;
|
||||
std::cerr << std::endl;
|
||||
|
||||
}
|
||||
@ -703,43 +643,39 @@ continue_packet:
|
||||
|
||||
if(++failed_read_attempts > max_failed_read_attempts)
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "Error Completing Read (read ";
|
||||
out << tmplen << "/" << extralen << ")" << std::endl;
|
||||
std::cerr << out.str() ;
|
||||
pqioutput(PQL_ALERT, pqistreamerzone, out.str());
|
||||
std::string out;
|
||||
rs_sprintf(out, "Error Completing Read (read %d/%d)", tmplen, extralen);
|
||||
std::cerr << out << std::endl ;
|
||||
pqioutput(PQL_ALERT, pqistreamerzone, out);
|
||||
|
||||
pqiNotify *notify = getPqiNotify();
|
||||
if (notify)
|
||||
{
|
||||
std::string title = "Warning: Error Completing Read";
|
||||
|
||||
std::ostringstream msgout;
|
||||
msgout << " **** WARNING **** \n";
|
||||
msgout << "Retroshare has experienced an unexpected Read ERROR";
|
||||
msgout << "\n";
|
||||
msgout << "(M:" << maxlen << " B:" << blen;
|
||||
msgout << " E:" << extralen << " R:" << tmplen << ")\n";
|
||||
msgout << "\n";
|
||||
msgout << "Note: this error might as well happen (rarely) when a peer disconnects in between a transmission of a large packet." << std::endl;
|
||||
msgout << "If it happens manny time, please contact the developers, and send them these numbers:";
|
||||
msgout << "\n";
|
||||
|
||||
msgout << "block = "
|
||||
<< (int)(((unsigned char*)block)[0]) << " "
|
||||
<< (int)(((unsigned char*)block)[1]) << " "
|
||||
<< (int)(((unsigned char*)block)[2]) << " "
|
||||
<< (int)(((unsigned char*)block)[3]) << " "
|
||||
<< (int)(((unsigned char*)block)[4]) << " "
|
||||
<< (int)(((unsigned char*)block)[5]) << " "
|
||||
<< (int)(((unsigned char*)block)[6]) << " "
|
||||
<< (int)(((unsigned char*)block)[7]) << " "
|
||||
<< std::endl ;
|
||||
std::string msgout;
|
||||
msgout = " **** WARNING **** \n";
|
||||
msgout += "Retroshare has experienced an unexpected Read ERROR";
|
||||
msgout += "\n";
|
||||
rs_sprintf_append(msgout, "(M:%d B:%d E:%d R:%d)\n", maxlen, blen, extralen, tmplen);
|
||||
msgout += "\n";
|
||||
msgout += "Note: this error might as well happen (rarely) when a peer disconnects in between a transmission of a large packet.\n";
|
||||
msgout += "If it happens manny time, please contact the developers, and send them these numbers:";
|
||||
msgout += "\n";
|
||||
|
||||
rs_sprintf_append(msgout, "block = %d %d %d %d %d %d %d %d\n",
|
||||
(int)(((unsigned char*)block)[0]),
|
||||
(int)(((unsigned char*)block)[1]),
|
||||
(int)(((unsigned char*)block)[2]),
|
||||
(int)(((unsigned char*)block)[3]),
|
||||
(int)(((unsigned char*)block)[4]),
|
||||
(int)(((unsigned char*)block)[5]),
|
||||
(int)(((unsigned char*)block)[6]),
|
||||
(int)(((unsigned char*)block)[7]));
|
||||
|
||||
//notify->AddSysMessage(0, RS_SYS_WARNING, title, msgout.str());
|
||||
|
||||
std::cerr << msgout.str() << std::endl;
|
||||
std::cerr << msgout << std::endl;
|
||||
}
|
||||
|
||||
bio->close();
|
||||
@ -759,9 +695,9 @@ continue_packet:
|
||||
#ifdef DEBUG_PQISTREAMER
|
||||
std::cerr << "[" << (void*)pthread_self() << "] " << "continuing packet state=" << reading_state << std::endl ;
|
||||
std::cerr << "[" << (void*)pthread_self() << "] " << "block 2 : " << (int)(((unsigned char*)extradata)[0]) << " " << (int)(((unsigned char*)extradata)[1]) << " " << (int)(((unsigned char*)extradata)[2]) << " " << (int)(((unsigned char*)extradata)[3]) << " "
|
||||
<< (int)(((unsigned char*)extradata)[4]) << " "
|
||||
<< (int)(((unsigned char*)extradata)[5]) << " "
|
||||
<< (int)(((unsigned char*)extradata)[6]) << " "
|
||||
<< (int)(((unsigned char*)extradata)[4]) << " "
|
||||
<< (int)(((unsigned char*)extradata)[5]) << " "
|
||||
<< (int)(((unsigned char*)extradata)[6]) << " "
|
||||
<< (int)(((unsigned char*)extradata)[7]) << " " << std::endl ;
|
||||
#endif
|
||||
|
||||
@ -771,11 +707,10 @@ continue_packet:
|
||||
|
||||
// create packet, based on header.
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "Read Data Block -> Incoming Pkt(";
|
||||
out << blen + extralen << ")" << std::endl;
|
||||
//std::cerr << out.str() ;
|
||||
pqioutput(PQL_DEBUG_BASIC, pqistreamerzone, out.str());
|
||||
std::string out;
|
||||
rs_sprintf(out, "Read Data Block -> Incoming Pkt(%d)", blen + extralen);
|
||||
//std::cerr << out ;
|
||||
pqioutput(PQL_DEBUG_BASIC, pqistreamerzone, out);
|
||||
}
|
||||
|
||||
// std::cerr << "Deserializing packet of size " << pktlen <<std::endl ;
|
||||
@ -823,11 +758,7 @@ continue_packet:
|
||||
|
||||
float pqistreamer::outTimeSlice()
|
||||
{
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqistreamer::outTimeSlice()";
|
||||
pqioutput(PQL_DEBUG_ALL, pqistreamerzone, out.str());
|
||||
}
|
||||
pqioutput(PQL_DEBUG_ALL, pqistreamerzone, "pqistreamer::outTimeSlice()");
|
||||
|
||||
//fixme("pqistreamer::outTimeSlice()", 1);
|
||||
return 1;
|
||||
@ -860,12 +791,10 @@ int pqistreamer::outAllowedBytes()
|
||||
|
||||
currSentTS = t;
|
||||
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqistreamer::outAllowedBytes() is ";
|
||||
out << maxout - currSent << "/";
|
||||
out << maxout;
|
||||
pqioutput(PQL_DEBUG_ALL, pqistreamerzone, out.str());
|
||||
{
|
||||
std::string out;
|
||||
rs_sprintf(out, "pqistreamer::outAllowedBytes() is %d/%d", maxout - currSent, maxout);
|
||||
pqioutput(PQL_DEBUG_ALL, pqistreamerzone, out);
|
||||
}
|
||||
|
||||
|
||||
@ -898,12 +827,10 @@ int pqistreamer::inAllowedBytes()
|
||||
|
||||
currReadTS = t;
|
||||
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqistreamer::inAllowedBytes() is ";
|
||||
out << maxin - currRead << "/";
|
||||
out << maxin;
|
||||
pqioutput(PQL_DEBUG_ALL, pqistreamerzone, out.str());
|
||||
{
|
||||
std::string out;
|
||||
rs_sprintf(out, "pqistreamer::inAllowedBytes() is %d/%d", maxin - currRead, maxin);
|
||||
pqioutput(PQL_DEBUG_ALL, pqistreamerzone, out);
|
||||
}
|
||||
|
||||
|
||||
@ -916,11 +843,10 @@ static const float AVG_FRAC = 0.8; // for low pass filter.
|
||||
|
||||
void pqistreamer::outSentBytes(int outb)
|
||||
{
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqistreamer::outSentBytes(): ";
|
||||
out << outb << "@" << getRate(false) << "kB/s" << std::endl;
|
||||
pqioutput(PQL_DEBUG_ALL, pqistreamerzone, out.str());
|
||||
{
|
||||
std::string out;
|
||||
rs_sprintf(out, "pqistreamer::outSentBytes(): %d@%gkB/s", outb, getRate(false));
|
||||
pqioutput(PQL_DEBUG_ALL, pqistreamerzone, out);
|
||||
}
|
||||
|
||||
|
||||
@ -967,11 +893,10 @@ void pqistreamer::outSentBytes(int outb)
|
||||
|
||||
void pqistreamer::inReadBytes(int inb)
|
||||
{
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "pqistreamer::inReadBytes(): ";
|
||||
out << inb << "@" << getRate(true) << "kB/s" << std::endl;
|
||||
pqioutput(PQL_DEBUG_ALL, pqistreamerzone, out.str());
|
||||
{
|
||||
std::string out;
|
||||
rs_sprintf(out, "pqistreamer::inReadBytes(): %d@%gkB/s", inb, getRate(true));
|
||||
pqioutput(PQL_DEBUG_ALL, pqistreamerzone, out);
|
||||
}
|
||||
|
||||
totalRead += inb;
|
||||
|
@ -2173,10 +2173,10 @@ bool p3ChatService::acceptLobbyInvite(const ChatLobbyId& lobby_id)
|
||||
|
||||
std::string p3ChatService::makeVirtualPeerId(ChatLobbyId lobby_id)
|
||||
{
|
||||
std::ostringstream os ;
|
||||
os << "Chat Lobby 0x" << std::hex << lobby_id << std::dec ;
|
||||
std::string s;
|
||||
rs_sprintf(s, "Chat Lobby 0x%llx", lobby_id);
|
||||
|
||||
return os.str() ;
|
||||
return s ;
|
||||
}
|
||||
|
||||
|
||||
|
@ -31,6 +31,8 @@
|
||||
#include "pqi/p3linkmgr.h"
|
||||
#include "util/rsrandom.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include <openssl/sha.h>
|
||||
|
||||
/****
|
||||
|
@ -30,6 +30,8 @@
|
||||
|
||||
#include "util/rsdir.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
std::string generateRandomShowId();
|
||||
|
||||
/****
|
||||
@ -306,7 +308,7 @@ void p3PhotoService::publishPhotos()
|
||||
std::string path = CacheSource::getCacheDir();
|
||||
std::ostringstream out;
|
||||
out << "photo-index-" << time(NULL) << ".pdx";
|
||||
|
||||
|
||||
std::string tmpname = out.str();
|
||||
std::string fname = path + "/" + tmpname;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user