mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-24 23:19:29 -05:00
Changed DHT string output to use std::ostringstream, as snprintf wasn't working
with inet_ntoa.... also added some other debug and fixed notifytxt. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@353 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
39d8b258ab
commit
100a7aea82
@ -230,6 +230,10 @@ bool OpenDHTClient::dhtActive()
|
||||
bool OpenDHTClient::publishKey(std::string key, std::string value, uint32_t ttl)
|
||||
{
|
||||
/* create request */
|
||||
#ifdef OPENDHT_DEBUG
|
||||
std::cerr << "OpenDHTClient::openDHT_publishKey() key: " << key << " value: " << value;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
std::string putmsg = createOpenDHT_put(key, value, ttl, openDHT_Client);
|
||||
std::string response;
|
||||
|
||||
|
@ -497,6 +497,18 @@ int p3DhtMgr::checkOwnDHTKeys()
|
||||
#ifdef DHT_DEBUG
|
||||
std::cerr << "p3DhtMgr::checkOwnDHTKeys() OWN ADDR REPUB" << std::endl;
|
||||
#endif
|
||||
|
||||
#ifdef DHT_DEBUG
|
||||
std::cerr << "PUBLISH: ";
|
||||
std::cerr << " hash1: " << peer.hash1;
|
||||
std::cerr << " laddr: " << inet_ntoa(peer.laddr.sin_addr);
|
||||
std::cerr << ":" << ntohs(peer.laddr.sin_port);
|
||||
std::cerr << " raddr: " << inet_ntoa(peer.raddr.sin_addr);
|
||||
std::cerr << ":" << ntohs(peer.raddr.sin_port);
|
||||
std::cerr << " type: " << peer.type;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
/* publish own key */
|
||||
if (dhtPublish(peer.hash1, peer.laddr, peer.raddr, peer.type, ""))
|
||||
{
|
||||
@ -1016,11 +1028,29 @@ bool p3DhtMgr::dhtPublish(std::string idhash,
|
||||
uint32_t type, std::string sign)
|
||||
{
|
||||
/* ... goes and searches */
|
||||
#ifdef DHT_DEBUG
|
||||
std::cerr << "p3DhtMgr::dhtPublish()" << std::endl;
|
||||
|
||||
/* Create a Value from addresses and type */
|
||||
std::cerr << "PUBLISHing: idhash: " << idhash;
|
||||
std::cerr << " laddr: " << inet_ntoa(laddr.sin_addr);
|
||||
std::cerr << ":" << ntohs(laddr.sin_port);
|
||||
std::cerr << " raddr: " << inet_ntoa(raddr.sin_addr);
|
||||
std::cerr << ":" << ntohs(raddr.sin_port);
|
||||
std::cerr << " type: " << type;
|
||||
std::cerr << " sign: " << sign;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
/* 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=" << inet_ntoa(laddr.sin_addr) << ":" << ntohs(laddr.sin_port) << ", ";
|
||||
out << "IPE=" << 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,
|
||||
@ -1031,6 +1061,17 @@ bool p3DhtMgr::dhtPublish(std::string idhash,
|
||||
type);
|
||||
|
||||
std::string value = valuearray;
|
||||
******/
|
||||
|
||||
std::string value = out.str();
|
||||
|
||||
#ifdef DHT_DEBUG
|
||||
std::cerr << "p3DhtMgr::dhtPublish()" << std::endl;
|
||||
|
||||
std::cerr << "PUBLISH: key: " << idhash;
|
||||
std::cerr << " value: " << value;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
/* call to the real DHT */
|
||||
return publishDHT(idhash, value, DHT_TTL_PUBLISH);
|
||||
|
@ -139,31 +139,6 @@ void NotifyTxt::displaySearch()
|
||||
void NotifyTxt::displayMessages()
|
||||
{
|
||||
iface->lockData(); /* Lock Interface */
|
||||
|
||||
std::ostringstream out;
|
||||
std::cerr << out.str();
|
||||
|
||||
std::list<MessageInfo>::const_iterator it;
|
||||
const std::list<MessageInfo> &msgs = iface->getMessages();
|
||||
|
||||
std::list<FileInfo>::const_iterator fit;
|
||||
int i;
|
||||
|
||||
for(it = msgs.begin(); it != msgs.end(); it++)
|
||||
{
|
||||
out << "Message: ";
|
||||
std::string cnv_title(it->title.begin(), it->title.end());
|
||||
out << cnv_title << std::endl;
|
||||
std::string cnv_msg(it->msg.begin(), it->msg.end());
|
||||
out << "\t" << cnv_msg << std::endl;
|
||||
const std::list<FileInfo> &files = it -> files;
|
||||
for(fit = files.begin(), i = 1; fit != files.end(); fit++, i++)
|
||||
{
|
||||
out << "\t\tFile(" << i << ") " << fit->fname << std::endl;
|
||||
}
|
||||
out << std::endl;
|
||||
}
|
||||
|
||||
iface->unlockData(); /* UnLock Interface */
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user