* Removed old DHT Code, removed other references too.

* Added interface class to bitDHT. (p3bitdht.h)
 * Added Optional section in libretroshare.pro



git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3296 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2010-07-17 17:00:19 +00:00
parent de57423733
commit 4157aff291
25 changed files with 466 additions and 4645 deletions

View File

@ -1,46 +0,0 @@
RS_TOP_DIR = ..
##### Define any flags that are needed for this section #######
###############################################################
###############################################################
include $(RS_TOP_DIR)/scripts/config.mk
###############################################################
RSOBJ = b64.o opendhtstr.o opendht.o opendhtmgr.o
TESTOBJ = odhtstr_test.o odhtpost_test.o odhtmgr_test.o \
dht_bootstrap.o dht_check_peers.o
TESTS = odhtstr_test odhtpost_test odhtmgr_test \
dht_bootstrap dht_check_peers
all: librs tests
#dhttest is OLD
dhttest: $(OBJ) dhttest.o
$(CC) $(CFLAGS) -o dhttest $(OBJ) dhttest.o $(LIBS)
dht_check_peers: $(OBJ) dht_check_peers.o
$(CC) $(CFLAGS) -o dht_check_peers $(OBJ) dht_check_peers.o $(LIBS)
odhtpost_test: $(OBJ) odhtpost_test.o
$(CC) $(CFLAGS) -o odhtpost_test $(OBJ) odhtpost_test.o $(LIBS)
odhtstr_test: $(OBJ) odhtstr_test.o
$(CC) $(CFLAGS) -o odhtstr_test $(OBJ) odhtstr_test.o $(LIBS)
odhtmgr_test: $(OBJ) odhtmgr_test.o
$(CC) $(CFLAGS) -o odhtmgr_test $(OBJ) odhtmgr_test.o $(LIBS)
dht_bootstrap: dht_bootstrap.o
$(CC) $(CFLAGS) -o dht_bootstrap dht_bootstrap.o $(LIBS)
# Extra Rule...
.c.o:
$(CC) $(CFLAGS) -c $<
###############################################################
include $(RS_TOP_DIR)/scripts/rules.mk
###############################################################

View File

@ -1,478 +0,0 @@
/*********************************************************************\
MODULE NAME: b64.c
AUTHOR: Bob Trower 08/04/01
PROJECT: Crypt Data Packaging
COPYRIGHT: Copyright (c) Trantor Standard Systems Inc., 2001
NOTE: This source code may be used as you wish, subject to
the MIT license. See the LICENCE section below.
DESCRIPTION:
This little utility implements the Base64
Content-Transfer-Encoding standard described in
RFC1113 (http://www.faqs.org/rfcs/rfc1113.html).
This is the coding scheme used by MIME to allow
binary data to be transferred by SMTP mail.
Groups of 3 bytes from a binary stream are coded as
groups of 4 bytes in a text stream.
The input stream is 'padded' with zeros to create
an input that is an even multiple of 3.
A special character ('=') is used to denote padding so
that the stream can be decoded back to its exact size.
Encoded output is formatted in lines which should
be a maximum of 72 characters to conform to the
specification. This program defaults to 72 characters,
but will allow more or less through the use of a
switch. The program enforces a minimum line size
of 4 characters.
Example encoding:
The stream 'ABCD' is 32 bits long. It is mapped as
follows:
ABCD
A (65) B (66) C (67) D (68) (None) (None)
01000001 01000010 01000011 01000100
16 (Q) 20 (U) 9 (J) 3 (D) 17 (R) 0 (A) NA (=) NA (=)
010000 010100 001001 000011 010001 000000 000000 000000
QUJDRA==
Decoding is the process in reverse. A 'decode' lookup
table has been created to avoid string scans.
DESIGN GOALS: Specifically:
Code is a stand-alone utility to perform base64
encoding/decoding. It should be genuinely useful
when the need arises and it meets a need that is
likely to occur for some users.
Code acts as sample code to show the author's
design and coding style.
Generally:
This program is designed to survive:
Everything you need is in a single source file.
It compiles cleanly using a vanilla ANSI C compiler.
It does its job correctly with a minimum of fuss.
The code is not overly clever, not overly simplistic
and not overly verbose.
Access is 'cut and paste' from a web page.
Terms of use are reasonable.
VALIDATION: Non-trivial code is never without errors. This
file likely has some problems, since it has only
been tested by the author. It is expected with most
source code that there is a period of 'burn-in' when
problems are identified and corrected. That being
said, it is possible to have 'reasonably correct'
code by following a regime of unit test that covers
the most likely cases and regression testing prior
to release. This has been done with this code and
it has a good probability of performing as expected.
Unit Test Cases:
case 0:empty file:
CASE0.DAT -> ->
(Zero length target file created
on both encode and decode.)
case 1:One input character:
CASE1.DAT A -> QQ== -> A
case 2:Two input characters:
CASE2.DAT AB -> QUJD -> AB
case 3:Three input characters:
CASE3.DAT ABC -> QUJD -> ABC
case 4:Four input characters:
case4.dat ABCD -> QUJDRA== -> ABCD
case 5:All chars from 0 to ff, linesize set to 50:
AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIj
JCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+P0BBQkNERUZH
SElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWpr
bG1ub3BxcnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6P
kJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmqq6ytrq+wsbKz
tLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX
2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7
/P3+/w==
case 6:Mime Block from e-mail:
(Data same as test case 5)
case 7: Large files:
Tested 28 MB file in/out.
case 8: Random Binary Integrity:
This binary program (b64.exe) was encoded to base64,
back to binary and then executed.
case 9 Stress:
All files in a working directory encoded/decoded
and compared with file comparison utility to
ensure that multiple runs do not cause problems
such as exhausting file handles, tmp storage, etc.
-------------
Syntax, operation and failure:
All options/switches tested. Performs as
expected.
case 10:
No Args -- Shows Usage Screen
Return Code 1 (Invalid Syntax)
case 11:
One Arg (invalid) -- Shows Usage Screen
Return Code 1 (Invalid Syntax)
case 12:
One Arg Help (-?) -- Shows detailed Usage Screen.
Return Code 0 (Success -- help request is valid).
case 13:
One Arg Help (-h) -- Shows detailed Usage Screen.
Return Code 0 (Success -- help request is valid).
case 14:
One Arg (valid) -- Uses stdin/stdout (filter)
Return Code 0 (Sucess)
case 15:
Two Args (invalid file) -- shows system error.
Return Code 2 (File Error)
case 16:
Encode non-existent file -- shows system error.
Return Code 2 (File Error)
case 17:
Out of disk space -- shows system error.
Return Code 3 (File I/O Error)
-------------
Compile/Regression test:
gcc compiled binary under Cygwin
Microsoft Visual Studio under Windows 2000
Microsoft Version 6.0 C under Windows 2000
DEPENDENCIES: None
LICENCE: Copyright (c) 2001 Bob Trower, Trantor Standard Systems Inc.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall
be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
VERSION HISTORY:
Bob Trower 08/04/01 -- Create Version 0.00.00B
\******************************************************************* */
#include <stdio.h>
#include <stdlib.h>
/*
** Translation Table as described in RFC1113
*/
static const char cb64[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
/*
** Translation Table to decode (created by author)
*/
static const char cd64[]="|$$$}rstuvwxyz{$$$$$$$>?@ABCDEFGHIJKLMNOPQRSTUVW$$$$$$XYZ[\\]^_`abcdefghijklmnopq";
/*
** encodeblock
**
** encode 3 8-bit binary bytes as 4 '6-bit' characters
*/
void encodeblock( unsigned char in[3], unsigned char out[4], int len )
{
out[0] = cb64[ in[0] >> 2 ];
out[1] = cb64[ ((in[0] & 0x03) << 4) | ((in[1] & 0xf0) >> 4) ];
out[2] = (unsigned char) (len > 1 ? cb64[ ((in[1] & 0x0f) << 2) | ((in[2] & 0xc0) >> 6) ] : '=');
out[3] = (unsigned char) (len > 2 ? cb64[ in[2] & 0x3f ] : '=');
}
/*
** decodeblock
**
** decode 4 '6-bit' characters into 3 8-bit binary bytes
*/
void decodeblock( unsigned char in[4], unsigned char out[3] )
{
out[ 0 ] = (unsigned char ) (((in[0] << 2) & 0xff) | ((in[1] >> 4) & 0xff));
out[ 1 ] = (unsigned char ) (((in[1] << 4) & 0xff) | ((in[2] >> 2) & 0xff));
out[ 2 ] = (unsigned char ) (((in[2] << 6) & 0xc0) | (in[3] & 0xff));
}
/* mods ... Hacked it up badly ...Robert Fernie (c) */
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <stdint.h>
#include "b64.h"
std::string displayBlock(unsigned char *arr, unsigned int len);
std::string convertToBase64(std::string input)
{
unsigned char in[3];
unsigned char out[4];
unsigned int len;
std::string result;
for(unsigned int i = 0; i < input.length(); i+= 3)
{
len = input.length() - i;
in[0] = input[i];
if (len > 1)
in[1] = input[i+1];
else
in[1] = 0;
if (len > 2)
in[2] = input[i+2];
else
in[2] = 0;
encodeblock(in, out, len);
//std::cerr << "eNcode Block in :" << displayBlock(in, 3);
//std::cerr << "eNcode Block out:" << displayBlock(out, 4);
for(unsigned int j = 0; j < 4; j++)
{
result += out[j];
}
}
return result;
}
std::string convertFromBase64(std::string input)
{
unsigned char in[4];
unsigned char out[3];
unsigned int len, outlen;
std::string result;
for(unsigned int i = 0; i < input.length(); i+= 4)
{
len = input.length() - i;
if (len < 4)
{
/* error */
std::cerr << "ERROR LENGTH in convertFromBase64";
std::cerr << std::endl;
return result;
}
outlen = 3;
in[0] = input[i];
in[1] = input[i+1];
in[2] = input[i+2];
in[3] = input[i+3];
if (in[3] == '=')
{
outlen--;
}
if (in[2] == '=')
{
outlen--;
}
//std::cerr << "Decode Block in :" << displayBlock(in, 4);
for(unsigned int j = 0; j < 4; j++)
{
unsigned char v = input[i+j];
v = (unsigned char) ((v < 43 || v > 122) ? 0 : cd64[ v - 43 ]);
if( v ) {
v = (unsigned char) ((v == '$') ? 0 : v - 61);
}
in[j] = v-1;
}
decodeblock(in, out);
//std::cerr << "Decode Block out:" << displayBlock(out, 3);
for(unsigned int j = 0; j < outlen; j++)
{
result += out[j];
}
}
return result;
}
std::string convertDataToBase64(unsigned char *data, uint32_t dlen)
{
unsigned char in[3];
unsigned char out[4];
unsigned int len;
std::string result;
for(unsigned int i = 0; i < dlen; i+= 3)
{
len = dlen - i;
in[0] = data[i];
if (len > 1)
in[1] = data[i+1];
else
in[1] = 0;
if (len > 2)
in[2] = data[i+2];
else
in[2] = 0;
encodeblock(in, out, len);
//std::cerr << "eNcode Block in :" << displayBlock(in, 3);
//std::cerr << "eNcode Block out:" << displayBlock(out, 4);
for(unsigned int j = 0; j < 4; j++)
{
result += out[j];
}
}
return result;
}
uint32_t DataLenFromBase64(std::string input)
{
uint32_t len = input.length();
len = (len / 4) * 3;
/* remove extra char - if '=' */
if (input[input.length()-1] == '=')
len--;
if (input[input.length()-2] == '=')
len--;
return len;
}
bool convertDataFromBase64(std::string input, unsigned char *data, uint32_t *dlen)
{
unsigned char in[4];
unsigned char out[3];
unsigned int len, outlen;
unsigned int offset = 0;
std::string result;
len = DataLenFromBase64(input);
if (len > *dlen)
{
std::cerr << "ERROR LENGTH(1) in convertDataFromBase64";
std::cerr << std::endl;
return false;
}
for(unsigned int i = 0; i < input.length(); i+= 4)
{
len = input.length() - i;
if (len < 4)
{
/* error */
std::cerr << "ERROR LENGTH in convertDataFromBase64";
std::cerr << std::endl;
return false;
}
outlen = 3;
in[0] = input[i];
in[1] = input[i+1];
in[2] = input[i+2];
in[3] = input[i+3];
if (in[3] == '=')
{
outlen--;
}
if (in[2] == '=')
{
outlen--;
}
//std::cerr << "Decode Block in :" << displayBlock(in, 4);
for(unsigned int j = 0; j < 4; j++)
{
unsigned char v = input[i+j];
v = (unsigned char) ((v < 43 || v > 122) ? 0 : cd64[ v - 43 ]);
if( v ) {
v = (unsigned char) ((v == '$') ? 0 : v - 61);
}
in[j] = v-1;
}
decodeblock(in, out);
//std::cerr << "Decode Block out:" << displayBlock(out, 3);
for(unsigned int j = 0; j < outlen; j++)
{
data[offset++] = out[j];
}
}
*dlen = offset;
return true;
}
std::string displayBlock(unsigned char *arr, unsigned int len)
{
std::ostringstream out;
for(unsigned int j = 0; j < len; j++)
{
out << std::hex << (int) arr[j] << "[" << arr[j] << "] ";
}
out << std::endl;
return out.str();
}

View File

@ -1,42 +0,0 @@
/*
* libretroshare/src/dht: b64.h
*
* Interface with OpenDHT for RetroShare.
*
* Copyright 2007-2008 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#ifndef BASE64_CODE_H
#define BASE64_CODE_H
#include <string>
std::string convertToBase64(std::string input);
std::string convertFromBase64(std::string input);
uint32_t DataLenFromBase64(std::string input);
std::string convertDataToBase64(unsigned char *data, uint32_t dlen);
bool convertDataFromBase64(std::string input, unsigned char *data, uint32_t *dlen);
#endif

View File

@ -1,489 +0,0 @@
/*
* libretroshare/src/dht: odhtmgr_test.cc
*
* Interface with OpenDHT for RetroShare.
*
* Copyright 2007-2008 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
/***** Test for the new DHT system *****/
#include "pqi/p3dhtmgr.h"
#include "pqi/p3connmgr.h"
#include "pqi/pqimonitor.h"
#include "dht/opendhtmgr.h"
#include "util/rsnet.h"
#include "util/rsthreads.h"
#include "util/rsprint.h"
#include "tcponudp/tou_net.h"
#include "tcponudp/udpsorter.h"
#include <iostream>
#include <sstream>
#include <iomanip>
#include <unistd.h>
#define BOOTSTRAP_DEBUG 1
void usage(char *name)
{
std::cerr << "USAGE: " << name << " -o OwnId [ -p PeerId1 [ -p PeerId2 [ ... ] ] ] ";
std::cerr << std::endl;
exit(1);
}
void loadBootStrapIds(std::list<std::string> &peerIds);
bool stunPeer(struct sockaddr_in toaddr, struct sockaddr_in &ansaddr);
class pqiConnectCbStun;
class dhtStunData
{
public:
pqiConnectCbStun *stunCb;
std::string id;
struct sockaddr_in toaddr;
struct sockaddr_in ansaddr;
};
extern "C" void* doStunPeer(void* p);
class StunDetails
{
public:
StunDetails()
{
lastStatus = 0;
lastStunResult = 0;
stunAttempts = 0;
stunResults = 0;
}
std::string id;
/* peerStatus details */
struct sockaddr_in laddr, raddr;
uint32_t type, mode, source;
/* stun response */
uint32_t stunAttempts;
uint32_t stunResults;
struct sockaddr_in stunaddr;
/* timestamps */
time_t lastStatus;
time_t lastStunResult;
};
class pqiConnectCbStun: public pqiConnectCb
{
public:
pqiConnectCbStun()
{
return;
}
virtual ~pqiConnectCbStun()
{
return;
}
void addPeer(std::string id)
{
RsStackMutex stack(peerMtx); /**** LOCK MUTEX ***/
std::map<std::string, StunDetails>::iterator it;
it = peerMap.find(id);
if (it == peerMap.end())
{
StunDetails sd;
sd.id = id;
peerMap[id] = sd;
}
}
virtual void peerStatus(std::string id,
struct sockaddr_in laddr, struct sockaddr_in raddr,
uint32_t type, uint32_t mode, uint32_t source)
{
}
void printPeerStatus()
{
RsStackMutex stack(peerMtx); /**** LOCK MUTEX ***/
time_t t = time(NULL);
std::string timestr = ctime(&t);
std::cerr << "BootstrapStatus: " << timestr;
std::cerr << "BootstrapStatus: " << peerMap.size() << " Peers";
std::cerr << std::endl;
std::cerr << "BootstrapStatus: ID --------------------- DHT ENTRY ---";
std::cerr << " EXT PORT -- STUN OK -- %AVAIL -- LAST DHT TS";
std::cerr << std::endl;
std::map<std::string, StunDetails>::iterator it;
for(it = peerMap.begin(); it != peerMap.end(); it++)
{
std::cerr << RsUtil::BinToHex(it->first);
bool dhtActive = (time(NULL) - it->second.lastStatus < 1900);
bool stunActive = (time(NULL) - it->second.lastStunResult < 1900);
bool extPort = it->second.type & RS_NET_CONN_TCP_EXTERNAL;
float percentAvailable = it->second.stunResults * 100.0 / (it->second.stunAttempts + 0.0001);
if (dhtActive)
{
std::cerr << " Yes --->";
}
else
{
std::cerr << " No ";
}
if (extPort)
{
std::cerr << " Yes --->";
}
else
{
std::cerr << " No ";
}
if (stunActive)
{
std::cerr << " Yes --->";
}
else
{
std::cerr << " No ";
}
std::cerr << " " << std::setw(4) << percentAvailable;
std::cerr << " ";
if (it->second.lastStatus == 0)
{
std::cerr << " NEVER ";
}
else
{
std::cerr << " " << time(NULL) - it->second.lastStatus;
std::cerr << " secs ago ";
}
std::cerr << std::endl;
}
}
void stunPeer(std::string id, struct sockaddr_in peeraddr)
{
std::cerr << "stunPeer: 0x" << RsUtil::BinToHex(id);
std::cerr << std::endl;
/* launch a publishThread */
pthread_t tid;
dhtStunData *pub = new dhtStunData;
pub->stunCb = this;
pub->id = id;
pub->toaddr = peeraddr;
void *data = (void *) pub;
pthread_create(&tid, 0, &doStunPeer, data);
pthread_detach(tid);
return;
}
virtual void peerConnectRequest(std::string id,
struct sockaddr_in raddr, uint32_t source)
{
return;
}
virtual void stunStatus(std::string id, struct sockaddr_in raddr, uint32_t type, uint32_t flags)
{
addPeer(id);
{
RsStackMutex stack(peerMtx); /**** LOCK MUTEX ***/
std::map<std::string, StunDetails>::iterator it;
it = peerMap.find(id);
if (it == peerMap.end())
{
std::cerr << "peerStatus() for unknown Peer id: 0x" << RsUtil::BinToHex(id);
std::cerr << std::endl;
return;
}
it->second.raddr = raddr;
it->second.type = type;
it->second.lastStatus = time(NULL);
it->second.stunAttempts++; /* as we are about to try! */
}
printPeerStatus();
stunPeer(id, raddr);
return;
}
virtual void stunSuccess(std::string id, struct sockaddr_in toaddr, struct sockaddr_in ansaddr)
{
{
RsStackMutex stack(peerMtx); /**** LOCK MUTEX ***/
std::map<std::string, StunDetails>::iterator it;
it = peerMap.find(id);
if (it == peerMap.end())
{
std::cerr << "stunSuccess() for unknown Peer id: 0x" << RsUtil::BinToHex(id);
std::cerr << std::endl;
return;
}
std::cerr << "stunSuccess() for id: 0x" << RsUtil::BinToHex(id);
std::cerr << std::endl;
it->second.lastStunResult = time(NULL);
it->second.stunResults++;
}
printPeerStatus();
}
private:
RsMutex peerMtx;
std::map<std::string, StunDetails> peerMap;
};
extern "C" void* doStunPeer(void* p)
{
dhtStunData *data = (dhtStunData *) p;
if ((!data) || (!data->stunCb))
{
pthread_exit(NULL);
}
/* stun it! */
if (stunPeer(data->toaddr, data->ansaddr))
{
data->stunCb->stunSuccess(data->id, data->toaddr, data->ansaddr);
}
delete data;
pthread_exit(NULL);
return NULL;
}
int main(int argc, char **argv)
{
int c;
bool setOwnId = false;
std::string ownId;
std::list<std::string> peerIds;
while(-1 != (c = getopt(argc, argv, "o:p:")))
{
switch (c)
{
case 'o':
ownId = optarg;
setOwnId = true;
break;
case 'p':
peerIds.push_back(std::string(optarg));
break;
default:
usage(argv[0]);
break;
}
}
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/
#ifndef WINDOWS_SYS
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
#else
/* for static PThreads under windows... we need to init the library...
*/
#ifdef PTW32_STATIC_LIB
pthread_win32_process_attach_np();
#endif
// Windows Networking Init.
WORD wVerReq = MAKEWORD(2,2);
WSADATA wsaData;
if (0 != WSAStartup(wVerReq, &wsaData))
{
std::cerr << "Failed to Startup Windows Networking";
std::cerr << std::endl;
}
else
{
std::cerr << "Started Windows Networking";
std::cerr << std::endl;
}
#endif
srand(time(NULL)); /* randomise! */
if (!setOwnId)
{
std::cerr << "Missing OwnId: Setting dummy Id";
std::cerr << std::endl;
setOwnId = true;
ownId = "dummyOwnId";
}
pqiConnectCbStun cbStun;
OpenDHTMgr dhtTester(ownId, &cbStun, ".");
/* startup dht */
std::cerr << "Starting up DhtTester()" << std::endl;
dhtTester.start();
/* wait for a little before switching on */
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
#ifndef WINDOWS_SYS
sleep(1);
#else
Sleep(1000);
#endif
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
std::cerr << "Switching on DhtTester()" << std::endl;
dhtTester.enable(true);
/* wait loop */
while(1)
{
cbStun.printPeerStatus();
std::cerr << "Main waiting..." << std::endl;
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
#ifndef WINDOWS_SYS
sleep(30);
#else
Sleep(30000);
#endif
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
}
};
bool stunPeer(struct sockaddr_in toaddr, struct sockaddr_in &ansaddr)
{
#ifdef BOOTSTRAP_DEBUG
std::cerr << "stunPeer: " << toaddr << std::endl;
#endif
/* open a socket */
int sockfd = tounet_socket(PF_INET, SOCK_DGRAM, 0);
if (-1 == tounet_fcntl(sockfd, F_SETFL, O_NONBLOCK))
{
#ifdef BOOTSTRAP_DEBUG
std::cerr << "Failed to Make Non-Blocking" << std::endl;
#endif
}
/* create a stun packet */
char stunpkt[100];
int maxlen = 100;
int len = maxlen;
UdpStun_generate_stun_pkt((void *) stunpkt, &len);
#ifdef BOOTSTRAP_DEBUG
std::cerr << "stunPeer() Send packet length: " << len << std::endl;
#endif
/* send stun packet */
tounet_sendto(sockfd, stunpkt, len, 0,
(struct sockaddr *) &(toaddr),
sizeof(toaddr));
/* wait */
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
#ifndef WINDOWS_SYS
sleep(2);
#else
Sleep(2000);
#endif
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
/* check for response */
struct sockaddr_in fromaddr;
socklen_t fromsize = sizeof(fromaddr);
int insize = maxlen;
insize = tounet_recvfrom(sockfd,stunpkt,insize,0,
(struct sockaddr*)&fromaddr,&fromsize);
tounet_close(sockfd);
if (0 >= insize)
{
#ifdef BOOTSTRAP_DEBUG
std::cerr << "No Stun response from: " << toaddr;
std::cerr << std::endl;
#endif
return false;
}
if (UdpStun_response(stunpkt, insize, ansaddr))
{
#ifdef BOOTSTRAP_DEBUG
std::cerr << "received Stun Reply from : " << fromaddr;
std::cerr << std::endl;
std::cerr << "External Address is: " << ansaddr;
std::cerr << std::endl;
#endif
return true;
}
#ifdef BOOTSTRAP_DEBUG
std::cerr << "received Data (not Stun Reply) from : " << fromaddr;
std::cerr << std::endl;
#endif
return false;
}

View File

@ -1,500 +0,0 @@
/*
* libretroshare/src/dht: odhtmgr_test.cc
*
* Interface with OpenDHT for RetroShare.
*
* Copyright 2007-2008 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
/***** Test for the new DHT system *****/
#include "pqi/p3dhtmgr.h"
#include "pqi/p3connmgr.h"
#include "pqi/pqimonitor.h"
#include "dht/opendhtmgr.h"
#include "util/rsnet.h"
#include "util/rsthreads.h"
#include "util/rsprint.h"
#include "tcponudp/tou_net.h"
#include "tcponudp/udpsorter.h"
#include <iostream>
#include <sstream>
#include <iomanip>
#include <unistd.h>
#define BOOTSTRAP_DEBUG 1
void usage(char *name)
{
std::cerr << "USAGE: " << name << " -o OwnId [ -p PeerId1 [ -p PeerId2 [ ... ] ] ] ";
std::cerr << std::endl;
exit(1);
}
bool stunPeer(struct sockaddr_in toaddr, struct sockaddr_in &ansaddr);
class pqiConnectCbStun;
class dhtStunData
{
public:
pqiConnectCbStun *stunCb;
std::string id;
struct sockaddr_in toaddr;
struct sockaddr_in ansaddr;
};
extern "C" void* doStunPeer(void* p);
class StunDetails
{
public:
StunDetails()
{
lastStatus = 0;
lastStunResult = 0;
stunAttempts = 0;
stunResults = 0;
}
std::string id;
/* peerStatus details */
struct sockaddr_in laddr, raddr;
uint32_t type, mode, source;
/* stun response */
uint32_t stunAttempts;
uint32_t stunResults;
struct sockaddr_in stunaddr;
/* timestamps */
time_t lastStatus;
time_t lastStunResult;
};
class pqiConnectCbStun: public pqiConnectCb
{
public:
pqiConnectCbStun()
{
return;
}
virtual ~pqiConnectCbStun()
{
return;
}
void addPeer(std::string id)
{
RsStackMutex stack(peerMtx); /**** LOCK MUTEX ***/
std::map<std::string, StunDetails>::iterator it;
it = peerMap.find(id);
if (it == peerMap.end())
{
StunDetails sd;
sd.id = id;
peerMap[id] = sd;
}
}
virtual void peerStatus(std::string id,
struct sockaddr_in laddr, struct sockaddr_in raddr,
uint32_t type, uint32_t mode, uint32_t source)
{
{
RsStackMutex stack(peerMtx); /**** LOCK MUTEX ***/
std::map<std::string, StunDetails>::iterator it;
it = peerMap.find(id);
if (it == peerMap.end())
{
std::cerr << "peerStatus() for unknown Peer id: " << id;
std::cerr << std::endl;
return;
}
it->second.laddr = laddr;
it->second.raddr = raddr;
it->second.type = type;
it->second.mode = mode;
it->second.source= source;
it->second.lastStatus = time(NULL);
it->second.stunAttempts++; /* as we are about to try! */
}
printPeerStatus();
stunPeer(id, raddr);
}
void printPeerStatus()
{
RsStackMutex stack(peerMtx); /**** LOCK MUTEX ***/
time_t t = time(NULL);
std::string timestr = ctime(&t);
std::cerr << "BootstrapStatus: " << timestr;
std::cerr << "BootstrapStatus: " << peerMap.size() << " Peers";
std::cerr << std::endl;
std::cerr << "BootstrapStatus: ID ---------- DHT ENTRY ---";
std::cerr << " EXT PORT -- STUN OK -- %AVAIL -- LAST DHT TS";
std::cerr << std::endl;
std::map<std::string, StunDetails>::iterator it;
for(it = peerMap.begin(); it != peerMap.end(); it++)
{
std::cerr << it->first;
bool dhtActive = (time(NULL) - it->second.lastStatus < 1900);
bool stunActive = (time(NULL) - it->second.lastStunResult < 1900);
bool extPort = it->second.type & RS_NET_CONN_TCP_EXTERNAL;
float percentAvailable = it->second.stunResults * 100.0 / (it->second.stunAttempts + 0.0001);
if (dhtActive)
{
std::cerr << " Yes --->";
}
else
{
std::cerr << " No ";
}
if (extPort)
{
std::cerr << " Yes --->";
}
else
{
std::cerr << " No ";
}
if (stunActive)
{
std::cerr << " Yes --->";
}
else
{
std::cerr << " No ";
}
std::cerr << " " << std::setw(4) << percentAvailable;
std::cerr << " ";
if (it->second.lastStatus == 0)
{
std::cerr << " NEVER ";
}
else
{
std::cerr << " " << time(NULL) - it->second.lastStatus;
std::cerr << " secs ago ";
}
std::cerr << std::endl;
}
}
void stunPeer(std::string id, struct sockaddr_in peeraddr)
{
std::cerr << "Should Stun Peer: " << id;
std::cerr << std::endl;
/* launch a publishThread */
pthread_t tid;
dhtStunData *pub = new dhtStunData;
pub->stunCb = this;
pub->id = id;
pub->toaddr = peeraddr;
void *data = (void *) pub;
pthread_create(&tid, 0, &doStunPeer, data);
return;
}
virtual void peerConnectRequest(std::string id,
struct sockaddr_in raddr, uint32_t source)
{
return;
}
virtual void stunStatus(std::string id, struct sockaddr_in raddr, uint32_t type, uint32_t flags)
{
return;
}
virtual void stunSuccess(std::string id, struct sockaddr_in toaddr, struct sockaddr_in ansaddr)
{
{
RsStackMutex stack(peerMtx); /**** LOCK MUTEX ***/
std::map<std::string, StunDetails>::iterator it;
it = peerMap.find(id);
if (it == peerMap.end())
{
std::cerr << "stunSuccess() for unknown Peer id: " << id;
std::cerr << std::endl;
return;
}
std::cerr << "stunSuccess() for id: " << id;
std::cerr << std::endl;
it->second.lastStunResult = time(NULL);
it->second.stunResults++;
}
printPeerStatus();
}
private:
RsMutex peerMtx;
std::map<std::string, StunDetails> peerMap;
};
extern "C" void* doStunPeer(void* p)
{
dhtStunData *data = (dhtStunData *) p;
if ((!data) || (!data->stunCb))
{
pthread_exit(NULL);
}
/* stun it! */
if (stunPeer(data->toaddr, data->ansaddr))
{
data->stunCb->stunSuccess(data->id, data->toaddr, data->ansaddr);
}
delete data;
pthread_exit(NULL);
return NULL;
}
int main(int argc, char **argv)
{
int c;
bool setOwnId = false;
std::string ownId;
std::list<std::string> peerIds;
while(-1 != (c = getopt(argc, argv, "o:p:")))
{
switch (c)
{
case 'o':
ownId = optarg;
setOwnId = true;
break;
case 'p':
peerIds.push_back(std::string(optarg));
break;
default:
usage(argv[0]);
break;
}
}
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/
#ifndef WINDOWS_SYS
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
#else
/* for static PThreads under windows... we need to init the library...
*/
#ifdef PTW32_STATIC_LIB
pthread_win32_process_attach_np();
#endif
// Windows Networking Init.
WORD wVerReq = MAKEWORD(2,2);
WSADATA wsaData;
if (0 != WSAStartup(wVerReq, &wsaData))
{
std::cerr << "Failed to Startup Windows Networking";
std::cerr << std::endl;
}
else
{
std::cerr << "Started Windows Networking";
std::cerr << std::endl;
}
#endif
if (!setOwnId)
{
std::cerr << "Missing OwnId: Setting dummy Id";
std::cerr << std::endl;
setOwnId = true;
ownId = "dummyOwnId";
}
pqiConnectCbStun cbStun;
OpenDHTMgr dhtTester(ownId, &cbStun, ".");
/* startup dht */
std::cerr << "Starting up DhtTester()" << std::endl;
dhtTester.start();
/* wait for a little before switching on */
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
#ifndef WINDOWS_SYS
sleep(1);
#else
Sleep(1000);
#endif
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
std::cerr << "Switching on DhtTester()" << std::endl;
dhtTester.enable(true);
std::cerr << "Adding a List of Peers" << std::endl;
std::list<std::string>::iterator it;
for(it = peerIds.begin(); it != peerIds.end(); it++)
{
cbStun.addPeer(*it);
dhtTester.findPeer(*it);
}
/* switch off Stun/Bootstrap stuff */
dhtTester.enableStun(false);
dhtTester.setBootstrapAllowed(false);
/* wait loop */
while(1)
{
cbStun.printPeerStatus();
std::cerr << "Main waiting..." << std::endl;
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
#ifndef WINDOWS_SYS
sleep(30);
#else
Sleep(30000);
#endif
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
}
};
bool stunPeer(struct sockaddr_in toaddr, struct sockaddr_in &ansaddr)
{
#ifdef BOOTSTRAP_DEBUG
std::cerr << "stunPeer: " << toaddr << std::endl;
#endif
/* open a socket */
int sockfd = tounet_socket(PF_INET, SOCK_DGRAM, 0);
if (-1 == tounet_fcntl(sockfd, F_SETFL, O_NONBLOCK))
{
#ifdef BOOTSTRAP_DEBUG
std::cerr << "Failed to Make Non-Blocking" << std::endl;
#endif
}
/* create a stun packet */
char stunpkt[100];
int maxlen = 100;
int len = maxlen;
UdpStun_generate_stun_pkt((void *) stunpkt, &len);
#ifdef BOOTSTRAP_DEBUG
std::cerr << "stunPeer() Send packet length: " << len << std::endl;
#endif
/* send stun packet */
tounet_sendto(sockfd, stunpkt, len, 0,
(struct sockaddr *) &(toaddr),
sizeof(toaddr));
/* wait */
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
#ifndef WINDOWS_SYS
sleep(2);
#else
Sleep(2000);
#endif
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
/* check for response */
struct sockaddr_in fromaddr;
socklen_t fromsize = sizeof(fromaddr);
int insize = maxlen;
insize = tounet_recvfrom(sockfd,stunpkt,insize,0,
(struct sockaddr*)&fromaddr,&fromsize);
tounet_close(sockfd);
if (0 >= insize)
{
#ifdef BOOTSTRAP_DEBUG
std::cerr << "No Stun response from: " << toaddr;
std::cerr << std::endl;
#endif
return false;
}
if (UdpStun_response(stunpkt, insize, ansaddr))
{
#ifdef BOOTSTRAP_DEBUG
std::cerr << "received Stun Reply from : " << fromaddr;
std::cerr << std::endl;
std::cerr << "External Address is: " << ansaddr;
std::cerr << std::endl;
#endif
return true;
}
#ifdef BOOTSTRAP_DEBUG
std::cerr << "received Data (not Stun Reply) from : " << fromaddr;
std::cerr << std::endl;
#endif
return false;
}

View File

@ -1,74 +0,0 @@
/*
* libretroshare/src/dht: dhtclient.h
*
* Interface with DHT Client for RetroShare.
*
* Copyright 2007-2008 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#ifndef RS_GENERIC_DHT_CLIENT_H
#define RS_GENERIC_DHT_CLIENT_H
#include <inttypes.h>
#include <string>
#include <list>
class DHTClient
{
public:
/* initialise from file */
virtual bool checkServerFile(std::string filename) = 0;
virtual bool loadServers(std::string filename) = 0;
virtual bool loadServersFromWeb(std::string storename) = 0;
virtual bool loadServers(std::istream&) = 0;
/* check that its working */
virtual bool dhtActive() = 0;
/* publish / search */
virtual bool publishKey(std::string key, std::string value, uint32_t ttl) = 0;
virtual bool searchKey(std::string key, std::list<std::string> &values) = 0;
};
class DHTClientDummy: public DHTClient
{
public:
/* initialise from file */
virtual bool checkServerFile(std::string) { return true; }
virtual bool loadServers(std::string) { return true; }
virtual bool loadServersFromWeb(std::string) { return true; }
virtual bool loadServers(std::istream&) { return true; }
/* check that its working */
virtual bool dhtActive() { return true; }
/* publish / search */
virtual bool publishKey(std::string, std::string, uint32_t) { return true; }
virtual bool searchKey(std::string, std::list<std::string> &) { return true; }
};
#endif

View File

@ -1,711 +0,0 @@
#include "dht/dhthandler.h"
/* This stuff is actually C */
#ifdef __cplusplus
extern "C" {
#endif
#include <int128.h>
#include <rbt.h>
#include <KadCalloc.h>
#include <KadClog.h>
#ifdef __cplusplus
} /* extern C */
#endif
/* This stuff is actually C */
/* HACK TO SWITCH THIS OFF during testing */
/*define NO_DHT_RUNNING 1*/
#include <iostream>
#include <sstream>
std::ostream &operator<<(std::ostream &out, dhtentry &ent)
{
out << "DHTENTRY(" << ent.id << "): Status: " << ent.status;
out << std::endl;
out << "\taddr: " << rs_inet_ntoa(ent.addr.sin_addr) << ":" << ntohs(ent.addr.sin_port);
out << std::endl;
out << "\tlastTS: " << time(NULL) - ent.lastTs << " secs ago";
out << "\tFlags: " << ent.flags;
out << std::endl;
return out;
}
#define DHT_UNKNOWN 0
#define DHT_SEARCHING 1 /* for peers */
#define DHT_PUBLISHING 1 /* for self */
#define DHT_FOUND 2
/* time periods */
#define DHT_MIN_PERIOD 10
#define DHT_SEARCH_PERIOD 300
#define DHT_REPUBLISH_PERIOD 1200
void cleardhtentry(dhtentry *ent, std::string id)
{
ent -> name = "";
ent -> id = id;
ent -> addr.sin_addr.s_addr = 0;
ent -> addr.sin_port = 0;
ent -> flags = 0;
ent -> status = DHT_UNKNOWN;
ent -> lastTs = 0;
return;
}
void initdhtentry(dhtentry *ent)
{
ent -> name = "";
// leave these ...
//ent -> addr.sin_addr.in_addr = 0;
//ent -> addr.sin_port = 0;
//ent -> flags = 0;
ent -> status = DHT_SEARCHING;
ent -> lastTs = time(NULL);
return;
}
void founddhtentry(dhtentry *ent, struct sockaddr_in inaddr, unsigned int flags)
{
ent -> addr = inaddr;
ent -> flags = flags;
ent -> status = DHT_FOUND;
ent -> lastTs = time(NULL);
return;
}
dhthandler::dhthandler(std::string inifile)
:mShutdown(false), dhtOk(false)
{
/* init own to null */
dataMtx.lock(); /* LOCK MUTEX */
cleardhtentry(&ownId, "");
kadcFile = inifile;
dataMtx.unlock(); /* UNLOCK MUTEX */
/* start up the threads... */
init();
}
dhthandler::~dhthandler()
{
}
/* This is internal - only called when active */
bool dhthandler::networkUp()
{
/* no need for mutex? */
return (20 < KadC_getnknodes(pkcc));
}
/* this is external */
int dhthandler::dhtPeers()
{
int count = 0;
dataMtx.lock(); /* LOCK MUTEX */
if (dhtOk)
{
count = KadC_getnknodes(pkcc);
}
dataMtx.unlock(); /* UNLOCK MUTEX */
return count;
}
/* set own tag */
void dhthandler::setOwnHash(std::string id)
{
dataMtx.lock(); /* LOCK MUTEX */
ownId.id = id;
dataMtx.unlock(); /* UNLOCK MUTEX */
}
void dhthandler::setOwnPort(short port)
{
dataMtx.lock(); /* LOCK MUTEX */
ownId.addr.sin_port = htons(port);
/* reset own status -> so we republish */
ownId.status = DHT_UNKNOWN;
dataMtx.unlock(); /* UNLOCK MUTEX */
}
bool dhthandler::getExtAddr(struct sockaddr_in &addr, unsigned int &flags)
{
dataMtx.lock(); /* LOCK MUTEX */
if (ownId.status == DHT_UNKNOWN)
{
dataMtx.unlock(); /* UNLOCK MUTEX */
return false;
}
addr = ownId.addr;
flags = ownId.flags;
dataMtx.unlock(); /* UNLOCK MUTEX */
return true;
}
/* at startup */
void dhthandler::addFriend(std::string id)
{
dataMtx.lock(); /* LOCK MUTEX */
std::map<std::string, dhtentry>::iterator it;
it = addrs.find(id);
if (it == addrs.end())
{
/* not found - add */
dhtentry ent;
cleardhtentry(&ent, id);
addrs[id] = ent;
}
else
{
/* already there */
std::cerr << "dhthandler::addFriend() Already there!" << std::endl;
}
dataMtx.unlock(); /* UNLOCK MUTEX */
}
void dhthandler::removeFriend(std::string id)
{
dataMtx.lock(); /* LOCK MUTEX */
std::map<std::string, dhtentry>::iterator it;
it = addrs.find(id);
if (it == addrs.end())
{
/* not found - complain*/
std::cerr << "dhthandler::addFriend() Already there!" << std::endl;
}
else
{
/* found */
addrs.erase(it);
}
dataMtx.unlock(); /* UNLOCK MUTEX */
}
/* called prior to connect */
bool dhthandler::addrFriend(std::string id, struct sockaddr_in &addr, unsigned int &flags)
{
dataMtx.lock(); /* LOCK MUTEX */
/* look it up */
bool ret = false;
std::map<std::string, dhtentry>::iterator it;
it = addrs.find(id);
if (it == addrs.end())
{
/* not found - complain*/
std::cerr << "dhthandler::addrFriend() Non-existant!" << std::endl;
ret = false;
}
else
{
if (it->second.status == DHT_FOUND)
{
addr = it->second.addr;
ret = true;
}
}
dataMtx.unlock(); /* UNLOCK MUTEX */
return ret;
}
int dhthandler::init()
{
dataMtx.lock(); /* LOCK MUTEX */
/* HACK TO SWITCH THIS OFF during testing */
#ifdef NO_DHT_RUNNING
dataMtx.unlock(); /* UNLOCK MUTEX */
dhtOk = false;
return 1;
#endif
char *filename = (char *) malloc(1024);
sprintf(filename, "%.1023s", kadcFile.c_str());
/* start up the dht server. */
KadC_log("KadC - library version: %d.%d.%d\n",
KadC_version.major, KadC_version.minor, KadC_version.patchlevel);
/* file, Leaf, StartNetworking (->false in full version) */
kcc = KadC_start(filename, true, 1);
if(kcc.s != KADC_OK) {
KadC_log("KadC_start(%s, %d) returned error %d:\n",
kadcFile.c_str(), 1, kcc.s);
KadC_log("%s %s", kcc.errmsg1, kcc.errmsg2);
dhtOk = false;
}
else
{
dhtOk = true;
}
pkcc = &kcc;
dataMtx.unlock(); /* UNLOCK MUTEX */
return 1;
}
int dhthandler::shutdown()
{
dataMtx.lock(); /* LOCK MUTEX */
/* end the dht server. */
kcs = KadC_stop(&kcc);
if(kcs != KADC_OK) {
KadC_log("KadC_stop(&kcc) returned error %d:\n", kcc.s);
KadC_log("%s %s", kcc.errmsg1, kcc.errmsg2);
}
KadC_list_outstanding_mallocs(10);
dataMtx.unlock(); /* UNLOCK MUTEX */
return 0;
}
int dhthandler::write_inifile()
{
/* if we're up and we have enough valid ones */
#define MIN_KONTACTS 50
if (KadC_getncontacts(pkcc) > MIN_KONTACTS)
{
std::cerr << "DhtHandler::Write_IniFile() Writing File" << std::endl;
if (KADC_OK != KadC_write_inifile(pkcc, NULL))
{
KadC_log("KadC_write_inifile(%s, %d) returned error %d:\n",
kadcFile.c_str(), 1, kcc.s);
KadC_log("%s %s", kcc.errmsg1, kcc.errmsg2);
}
}
else
{
std::cerr << "DhtHandler::Write_IniFile() Not enough contacts" << std::endl;
}
return 1;
}
void dhthandler::run()
{
/* infinite loop */
int totalsleep = 0;
while(1)
{
// std::cerr << "DhtHandler::Run()" << std::endl;
if (!dhtOk)
{
std::cerr << "DhtHandler::Run() Failed to Start" << std::endl;
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
#ifndef WINDOWS_SYS
sleep(1);
#else
Sleep(1000);
#endif
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
continue;
}
/* lock it up */
dataMtx.lock(); /* LOCK MUTEX */
bool toShutdown = mShutdown;
/* shutdown */
dataMtx.unlock(); /* UNLOCK MUTEX */
print();
if (toShutdown)
{
shutdown();
dhtOk = false;
}
/* check ids */
int allowedSleep = checkOwnStatus();
int nextPeerCheck = checkPeerIds();
if (nextPeerCheck < allowedSleep)
{
allowedSleep = nextPeerCheck;
}
if (allowedSleep > 10)
{
allowedSleep = 10;
}
else if (allowedSleep < 10)
{
allowedSleep = 10;
}
// std::cerr << "DhtHandler::Run() sleeping for:" << allowedSleep << std::endl;
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
#ifndef WINDOWS_SYS
sleep(allowedSleep);
#else
Sleep(1000 * allowedSleep);
#endif
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
#define DHT_INIT_STORE_PERIOD 300
totalsleep += allowedSleep;
if (totalsleep > DHT_INIT_STORE_PERIOD)
{
write_inifile();
totalsleep = 0;
}
}
return;
}
int dhthandler::print()
{
dataMtx.lock(); /* LOCK MUTEX */
std::cerr << "DHT Status:" << std::endl;
std::cerr << "KNodes: " << KadC_getnknodes(pkcc);
std::cerr << std::endl;
std::cerr << "Kontacts: " << KadC_getncontacts(pkcc);
std::cerr << std::endl;
std::cerr << "KBuckets: ";
std::cerr << std::endl;
KadC_listkbuckets(pkcc);
std::cerr << std::endl;
std::cerr << "Own DHT:" << std::endl;
std::cerr << ownId << std::endl;
std::cerr << addrs.size() << " Peers:" << std::endl;
std::map<std::string, dhtentry>::iterator it;
for(it = addrs.begin(); it != addrs.end(); it++)
{
std::cerr << "Peer DHT" << std::endl;
std::cerr << it -> second << std::endl;
}
dataMtx.unlock(); /* UNLOCK MUTEX */
return 1;
}
int dhthandler::checkOwnStatus()
{
dataMtx.lock(); /* LOCK MUTEX */
int nextcall = DHT_REPUBLISH_PERIOD;
bool toPublish = false;
/* if we are publishing, and time up ... republish */
if (ownId.status == DHT_UNKNOWN)
{
/* if valid Hash and Port */
if ((ownId.id != "") && (ownId.addr.sin_port != 0) &&
(networkUp())) /* network is up */
{
unsigned long int extip = KadC_getextIP(pkcc);
ownId.flags = KadC_getfwstatus(pkcc);
if (extip != 0)
{
ownId.addr.sin_addr.s_addr = htonl(extip);
toPublish = true;
}
}
nextcall = DHT_MIN_PERIOD;
}
else /* ownId.status == DHT_PUBLISHING */
{
/* check time.
*/
if (ownId.lastTs + DHT_REPUBLISH_PERIOD < time(NULL))
{
toPublish = true;
}
}
dataMtx.unlock(); /* UNLOCK MUTEX */
if (toPublish)
{
publishOwnId();
}
return nextcall;
}
int dhthandler::checkPeerIds()
{
dataMtx.lock(); /* LOCK MUTEX */
/* if we are unknown .... wait */
int nextcall = DHT_REPUBLISH_PERIOD;
std::map<std::string, dhtentry>::iterator it;
/* local list */
std::list<std::string> idsToUpdate;
std::list<std::string>::iterator it2;
for(it = addrs.begin(); it != addrs.end(); it++)
{
/* if we are publishing, and time up ... republish */
if (it -> second.status == DHT_UNKNOWN)
{
/* startup */
idsToUpdate.push_back(it->first);
}
else if (it -> second.status == DHT_SEARCHING)
{
/* check if time */
if (it -> second.lastTs + DHT_SEARCH_PERIOD < time(NULL))
{
idsToUpdate.push_back(it->first);
}
nextcall = DHT_SEARCH_PERIOD;
}
else if (it -> second.status == DHT_FOUND)
{
/* check if time */
if (it -> second.lastTs + DHT_REPUBLISH_PERIOD < time(NULL))
{
idsToUpdate.push_back(it->first);
}
}
}
dataMtx.unlock(); /* UNLOCK MUTEX */
for(it2 = idsToUpdate.begin(); it2 != idsToUpdate.end(); it2++)
{
searchId(*it2);
}
return nextcall;
}
/* already locked */
int dhthandler::publishOwnId()
{
dataMtx.lock(); /* LOCK MUTEX */
/* publish command */
/* publish {#[khash]|key} {#[vhash]|value} [meta-list [nthreads [nsecs]]] */
char index[1024];
sprintf(index, "#%.1023s", ownId.id.c_str());
char value[1024];
sprintf(value, "#%.1023s", ownId.id.c_str());
/* to store the ip address and flags */
char metalist[1024];
std::string addr = rs_inet_ntoa(ownId.addr.sin_addr),
sprintf(metalist, "rsid=%s:%d;flags=%04X;",
addr.c_str(),
ntohs(ownId.addr.sin_port),
ownId.flags);
dataMtx.unlock(); /* UNLOCK MUTEX */
int nthreads = 10;
int duration = 15;
int status;
/* might as well hash back to us? */
status = KadC_republish(pkcc, index, value, metalist, nthreads, duration);
if(status == 1)
{
KadC_log("Syntax error preparing search. Try: p key #hash [tagname=tagvalue[;...]]\n");
}
dataMtx.lock(); /* LOCK MUTEX */
/* update entry */
initdhtentry(&ownId);
dataMtx.unlock(); /* UNLOCK MUTEX */
return 1;
}
/* must be protected by mutex externally */
dhtentry *dhthandler::finddht(std::string id)
{
std::map<std::string, dhtentry>::iterator it;
it = addrs.find(id);
if (it == addrs.end())
{
return NULL;
}
return &(it->second);
}
int dhthandler::searchId(std::string id)
{
if (!networkUp())
return 0;
/* ack search */
bool updated = false;
/* search */
void *iter;
KadCdictionary *pkd;
char *filter = "";
int nthreads = 10;
int duration = 15;
int maxhits = 100;
time_t starttime = time(NULL);
void *resdictrbt;
int nhits;
char index[1024];
sprintf(index, "#%.1023s", id.c_str());
/* cannot be holding mutex here... (up to 15 secs) */
resdictrbt = KadC_find(pkcc, index, filter, nthreads, maxhits, duration);
nhits = rbt_size(resdictrbt);
/* list each KadCdictionary returned in the rbt */
for(iter = rbt_begin(resdictrbt); iter != NULL; iter = rbt_next(resdictrbt, iter)) {
pkd = rbt_value(iter);
KadC_log("Found: ");
KadC_int128flog(stdout, KadCdictionary_gethash(pkd));
KadC_log("\n");
KadCdictionary_dump(pkd);
KadC_log("\n");
KadCtag_iter iter;
unsigned int i;
bool found = false;
std::string addrline;
std::string flagsline;
for(i = 0, KadCtag_begin(pkd, &iter); (i < iter.tagsleft); i++, KadCtag_next(&iter)) {
if(i > 0)
KadC_log(";");
if ((strncmp("rsid", iter.tagname, 4) == 0)
&& (iter.tagtype == KADCTAG_STRING))
{
KadC_log("DECODING:%s", (char *)iter.tagvalue);
addrline = (char *) iter.tagvalue;
found = true;
}
if ((strncmp("flags", iter.tagname, 5) == 0)
&& (iter.tagtype == KADCTAG_STRING))
{
KadC_log("DECODING:%s", (char *)iter.tagvalue);
flagsline = (char *) iter.tagvalue;
}
}
/* must parse:rsid=ddd.ddd.ddd.ddd:dddd;flags=xxxx */
struct sockaddr_in addr;
unsigned int flags = 0;
unsigned int a, b, c, d, e;
if ((found) &&
(5 == sscanf(addrline.c_str(), "%d.%d.%d.%d:%d", &a, &b, &c, &d, &e)))
{
std::ostringstream out;
out << a << "." << b << "." << c << "." << d;
inet_aton(out.str().c_str(), &(addr.sin_addr));
addr.sin_port = htons(e);
if (flagsline != "")
sscanf(flagsline.c_str(), "%x", &flags);
std::cerr << "Decoded entry: " << out.str() << " : " << e << std::endl;
dataMtx.lock(); /* LOCK MUTEX */
dhtentry *ent = finddht(id);
if (ent)
{
founddhtentry(ent, addr, flags);
updated = true;
}
dataMtx.unlock(); /* UNLOCK MUTEX */
}
else
{
std::cerr << "Failed to Scan:" << addrline << " <-----" << std::endl;
}
}
KadC_log("Search completed in %d seconds - %d hit%s returned\n",
time(NULL)-starttime, nhits, (nhits == 1 ? "" : "s"));
for(iter = rbt_begin(resdictrbt); iter != NULL; iter = rbt_begin(resdictrbt)) {
pkd = rbt_value(iter);
rbt_erase(resdictrbt, iter);
KadCdictionary_destroy(pkd);
}
rbt_destroy(resdictrbt);
dataMtx.lock(); /* LOCK MUTEX */
if (!updated)
{
dhtentry *ent = finddht(id);
if (ent)
{
initdhtentry(ent);
}
}
dataMtx.unlock(); /* UNLOCK MUTEX */
return 1;
}
#if (0)
#include <pthread.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
#include <int128.h>
#include <rbt.h>
#include <KadCalloc.h>
#include <KadClog.h>
#include <config.h>
#include <queue.h> /* required by net.h, sigh... */
#include <net.h> /* only for domain2hip() */
#include <KadCapi.h>
#endif

View File

@ -1,97 +0,0 @@
#ifndef _RS_DHT_IFACE_H
#define _RS_DHT_IFACE_H
#include <string.h>
/* This stuff is actually C */
#ifdef __cplusplus
extern "C" {
#endif
#include <int128.h>
#include <KadCapi.h>
#ifdef __cplusplus
} /* extern C */
#endif
/* This stuff is actually C */
#include "util/rsthreads.h"
#include <string>
#include <map>
/* platform independent networking... */
#include "pqi/pqinetwork.h"
#include "pqi/pqiaddrstore.h"
class dhtentry
{
public:
std::string name;
std::string id;
struct sockaddr_in addr;
unsigned int flags;
int status;
int lastTs;
};
class dhthandler: public RsThread, public pqiAddrStore
{
public:
dhthandler(std::string inifile);
~dhthandler();
/* RsIface */
/* set own tag */
void setOwnHash(std::string id);
void setOwnPort(short port);
bool getExtAddr(sockaddr_in &addr, unsigned int &flags);
/* at startup */
void addFriend(std::string id);
void removeFriend(std::string id);
int dhtPeers();
/* pqiAddrStore ... called prior to connect */
virtual bool addrFriend(std::string id, struct sockaddr_in &addr, unsigned int &flags);
int init();
int shutdown();
int print();
/* must run thread */
virtual void run();
private:
int write_inifile();
bool networkUp(); /* get status */
int checkOwnStatus();
int checkPeerIds();
int publishOwnId();
int searchId(std::string id);
dhtentry *finddht(std::string id);
/* Mutex for data below */
RsMutex dataMtx;
dhtentry ownId;
std::map<std::string, dhtentry> addrs;
KadCcontext kcc, *pkcc;
KadC_status kcs;
std::string kadcFile;
bool mShutdown;
bool dhtOk;
};
#endif /* _RS_DHT_IFACE_H */

View File

@ -1,90 +0,0 @@
#include "dht/dhthandler.h"
int main(int argc, char **argv)
{
int id = argc % 3;
char *hash1 = "3509426505463458576487";
char *hash2 = "1549879882341985914515";
char *hash3 = "8743598543269526505434";
int port1 = 8754;
int port2 = 2355;
int port3 = 6621;
std::cerr << "Starting dhttest Id: " << id << std::endl;
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/
#ifndef WINDOWS_SYS
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
#else
// Windows Networking Init.
WORD wVerReq = MAKEWORD(2,2);
WSADATA wsaData;
if (0 != WSAStartup(wVerReq, &wsaData))
{
std::cerr << "Failed to Startup Windows Networking";
std::cerr << std::endl;
}
else
{
std::cerr << "Started Windows Networking";
std::cerr << std::endl;
}
#endif
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
#ifdef PTW32_STATIC_LIB
pthread_win32_process_attach_np();
#endif
dhthandler dht("tst.ini");
dht.start();
if (id == 0)
{
dht.setOwnPort(port1);
dht.setOwnHash(hash1);
dht.addFriend(hash2);
dht.addFriend(hash3);
}
else if (id == 1)
{
dht.setOwnPort(port2);
dht.setOwnHash(hash2);
dht.addFriend(hash1);
dht.addFriend(hash3);
}
else
{
dht.setOwnPort(port3);
dht.setOwnHash(hash3);
dht.addFriend(hash1);
dht.addFriend(hash2);
}
while(1)
{
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
#ifndef WINDOWS_SYS
sleep(1);
#else
Sleep(1000);
#endif
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
}
}

View File

@ -1,157 +0,0 @@
/*
* libretroshare/src/dht: odhtmgr_test.cc
*
* Interface with OpenDHT for RetroShare.
*
* Copyright 2007-2008 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
/***** Test for the new DHT system *****/
#include "pqi/p3dhtmgr.h"
#include "pqi/pqimonitor.h"
#include "dht/opendhtmgr.h"
#include "util/rsnet.h"
#include "util/rsthreads.h"
#include "util/rsprint.h"
#include <iostream>
#include <sstream>
#include <unistd.h>
void usage(char *name)
{
std::cerr << "USAGE: " << name << " -o OwnId [ -p PeerId1 [ -p PeerId2 [ ... ] ] ] ";
std::cerr << std::endl;
exit(1);
}
int main(int argc, char **argv)
{
int c;
bool setOwnId = false;
std::string ownId;
std::list<std::string> peerIds;
while(-1 != (c = getopt(argc, argv, "o:p:")))
{
switch (c)
{
case 'o':
ownId = optarg;
setOwnId = true;
break;
case 'p':
peerIds.push_back(std::string(optarg));
break;
default:
usage(argv[0]);
break;
}
}
if (!setOwnId)
{
std::cerr << "Missing OwnId!";
usage(argv[0]);
}
bool haveOwnAddress = false;
time_t startTime = time(NULL);
pqiConnectCbDummy cbTester;
OpenDHTMgr dhtTester(ownId, &cbTester, ".");
/* startup dht */
std::cerr << "Starting up DhtTester()" << std::endl;
dhtTester.start();
/* wait for a little before switching on */
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
#ifndef WINDOWS_SYS
sleep(1);
#else
Sleep(1000);
#endif
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
std::cerr << "Switching on DhtTester()" << std::endl;
dhtTester.enable(true);
std::cerr << "Adding a List of Peers" << std::endl;
std::list<std::string>::iterator it;
for(it = peerIds.begin(); it != peerIds.end(); it++)
{
dhtTester.findPeer(*it);
}
/* wait loop */
while(1)
{
std::cerr << "Main waiting..." << std::endl;
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
#ifndef WINDOWS_SYS
sleep(3);
#else
Sleep(3000);
#endif
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
if (!haveOwnAddress)
{
if (time(NULL) - startTime > 20)
{
std::cerr << "Setting Own Address!" << std::endl;
haveOwnAddress = true;
uint32_t type = DHT_ADDR_UDP;
struct sockaddr_in laddr;
inet_aton("10.0.0.111", &(laddr.sin_addr));
laddr.sin_port = htons(7812);
laddr.sin_family = AF_INET;
struct sockaddr_in raddr;
inet_aton("10.0.0.11", &(raddr.sin_addr));
raddr.sin_port = htons(7812);
raddr.sin_family = AF_INET;
dhtTester.setExternalInterface(laddr, raddr, type);
}
}
}
};

View File

@ -1,65 +0,0 @@
/*
* libretroshare/src/dht: odhtport_test.cc
*
* Interface with OpenDHT for RetroShare.
*
* Copyright 2007-2008 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#include "opendht.h"
#include "util/rsprint.h"
#include <openssl/sha.h>
int main()
{
std::string agent = "Hand-Crafted Thread";
std::string keyIn = "color";
//std::string value = "aaaaBBBBccccDDDDe";
std::string value = "1234567890aaaaBBBBccccDDDDe";
//std::string value = "12345678901234567890aaaaBBBBccccDDDDe";
//std::string value = "aaa12345678901234567890aaaaBBBBccccDDDDe";
uint32_t ttl = 600;
std::string client= "Retroshare v0.4";
uint32_t maxresp= 1024;
std::string key = RsUtil::HashId(keyIn, false);
OpenDHTClient dht;
dht.loadServers("./servers.txt");
dht.publishKey(key, value, ttl);
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
#ifndef WINDOWS_SYS
sleep(10);
#else
Sleep(10000);
#endif
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
std::list<std::string> values;
dht.searchKey(key, values);
return 1;
}

View File

@ -1,88 +0,0 @@
/*
* libretroshare/src/dht: odhtstr_test.cc
*
* Interface with OpenDHT for RetroShare.
*
* Copyright 2007-2008 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#include "opendhtstr.h"
#include "b64.h"
#include <iostream>
int main()
{
std::string host = "abc.bgg.trer.dgg";
uint16_t port = 9242;
std::string agent = "Hand-Crafted Thread";
std::string key = "BigKey";
std::string value = "96324623924";
uint32_t ttl = 600;
std::string client= "Retroshare v0.4";
uint32_t maxresp= 1024;
/* some encodings */
std::string i1 = "color";
std::string i2 = "green";
std::string i3 = "blue";
std::string i4 = "abdflhdffjadlgfal12=345==";
std::string o1 = convertToBase64(i1);
std::string o2 = convertToBase64(i2);
std::string o3 = convertToBase64(i3);
std::string o4 = convertToBase64(i4);
std::string o5 = "bdD+gAEUW+xKEtDiLacRxJcNAAs=";
std::cerr << "In:" << i1 << " encoded:" << o1 << " decoded:" << convertFromBase64(o1);
std::cerr << std::endl;
std::cerr << "In:" << i2 << " encoded:" << o2 << " decoded:" << convertFromBase64(o2);
std::cerr << std::endl;
std::cerr << "In:" << i3 << " encoded:" << o3 << " decoded:" << convertFromBase64(o3);
std::cerr << std::endl;
std::cerr << "In:" << i4 << " encoded:" << o4 << " decoded:" << convertFromBase64(o4);
std::cerr << std::endl;
std::cerr << "Encoded:" << o5 << " decoded:" << convertFromBase64(o5);
std::cerr << std::endl;
/* create some strings */
std::string req1 = createOpenDHT_put(key, value, ttl, client);
std::string req2 = createOpenDHT_get(key, maxresp, client);
std::string putheader = createHttpHeader(host, port, agent, req1.length());
std::string getheader = createHttpHeader(host, port, agent, req2.length());
std::string putreq = putheader + req1;
std::string getreq = getheader + req2;
std::cerr << "Example Put Request is:" << std::endl;
std::cerr << putreq << std::endl;
std::cerr << "Example Get Request is:" << std::endl;
std::cerr << getreq << std::endl;
return 1;
}

View File

@ -1,821 +0,0 @@
/*
* libretroshare/src/dht: opendht.cc
*
* Interface with OpenDHT for RetroShare.
*
* Copyright 2007-2008 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#include "dht/opendht.h"
#include "dht/opendhtstr.h"
#include "dht/b64.h"
#include <fstream>
#include <sstream>
#include <sys/time.h>
#include <time.h>
#include "util/rsnet.h"
#include "util/rsprint.h"
const std::string openDHT_Client = "Retroshare V0.4";
const std::string openDHT_Agent = "RS-HTTP-V0.4";
#define MAX_DHT_PEER_FAILS 2 /* then discard */
#define MAX_DHT_TOTAL_FAILS 10 /* in a row -> think we're not connected! */
#define MAX_DHT_ATTEMPTS 10 /* attempts per search/publish */
#define MIN_DHT_SERVERS 5
/****
* #define OPENDHT_DEBUG 1
****/
bool OpenDHTClient::checkServerFile(std::string filename)
{
#ifdef OPENDHT_DEBUG
std::cerr << "OpenDHTClient::checkServerFile(" << filename << ")" << std::endl;
#endif
/* open the file */
std::ifstream file(filename.c_str());
if (file.fail())
{
#ifdef OPENDHT_DEBUG
std::cerr << "OpenDHTClient::checkServerFile() Open Failed" << std::endl;
#endif
return false;
}
/* get the first line */
std::string line;
getline(file, line);
char day[16], month[16];
int date;
char day2[16], month2[16];
int date2;
if (3 != sscanf(line.c_str(), "%15s %15s %d", day, month, &date))
{
#ifdef OPENDHT_DEBUG
std::cerr << "OpenDHTClient::checkServerFile() failed file TS parse";
std::cerr << std::endl;
#endif
return false;
}
#ifdef OPENDHT_DEBUG
std::cerr << "OpenDHTClient::checkServerFile() file TS month: ";
std::cerr << month << " date: " << date << std::endl;
#endif
/* store current timestamp */
struct tm result;
time_t now = time(NULL);
char nowstr[1023];
asctime_r(gmtime_r(&now, &result), nowstr);
if (3 != sscanf(nowstr, "%15s %15s %d", day2, month2, &date2))
{
#ifdef OPENDHT_DEBUG
std::cerr << "OpenDHTClient::checkServerFile() failed now TS parse";
std::cerr << std::endl;
#endif
return false;
}
#ifdef OPENDHT_DEBUG
std::cerr << "OpenDHTClient::checkServerFile() current TS month: ";
std::cerr << month2 << " date: " << date2 << std::endl;
#endif
/* if month is different */
if (0 != strcmp(month, month2))
{
#ifdef OPENDHT_DEBUG
std::cerr << "OpenDHTClient::checkServerFile() different MONTHS fail";
std::cerr << std::endl;
#endif
return false;
}
/* if month is different */
int delta = abs(date-date2);
if (delta > 2)
{
#ifdef OPENDHT_DEBUG
std::cerr << "OpenDHTClient::checkServerFile() fail - large DATE diff: " << delta;
std::cerr << std::endl;
#endif
return false;
}
#ifdef OPENDHT_DEBUG
std::cerr << "OpenDHTClient::checkServerFile() file is up-to-date!";
std::cerr << std::endl;
#endif
return true;
}
bool OpenDHTClient::loadServers(std::string filename)
{
/* open the file */
std::ifstream file(filename.c_str());
return loadServers(file);
}
bool OpenDHTClient::loadServers(std::istream &instr)
{
std::string line;
char number[1024];
char ipaddr[1024];
char dnsname[1024];
dhtMutex.lock(); /**** LOCK ****/
mServers.clear();
dhtMutex.unlock(); /**** UNLOCK ****/
/* chew first line */
instr.ignore(1024, '\n');
while((!instr.eof()) && (!instr.fail()))
{
line = "";
getline(instr, line);
if (3 == sscanf(line.c_str(), "%1023s %1023s %1023s", number, ipaddr, dnsname))
{
dhtServer srv;
srv.host = dnsname;
srv.port = 5851;
srv.failed = 0;
srv.ts = 0;
srv.addr.sin_addr.s_addr = 0;
srv.addr.sin_port = 0;
#ifdef OPENDHT_DEBUG
std::cerr << "Read Server: " << dnsname << std::endl;
#endif
dhtMutex.lock(); /**** LOCK ****/
mServers[dnsname] = srv;
dhtMutex.unlock(); /**** UNLOCK ****/
}
else
{
#ifdef OPENDHT_DEBUG
std::cerr << "Failed to Read Server" << std::endl;
#endif
}
dhtMutex.lock(); /**** LOCK ****/
mDHTFailCount = 0;
dhtMutex.unlock(); /**** UNLOCK ****/
}
dhtMutex.lock(); /**** LOCK ****/
uint32_t count = mServers.size();
dhtMutex.unlock(); /**** UNLOCK ****/
return (count >= MIN_DHT_SERVERS);
}
/******* refresh Servers from WebPage ******/
bool OpenDHTClient::loadServersFromWeb(std::string storename)
{
#ifdef OPENDHT_DEBUG
std::cerr << "OpenDHTClient::loadServersFromWeb()" << std::endl;
#endif
std::string response;
if (!openDHT_getDHTList(response))
{
#ifdef OPENDHT_DEBUG
std::cerr << "OpenDHTClient::loadServersFromWeb() Web GET failed" << std::endl;
#endif
return false;
}
std::string::size_type i;
if (std::string::npos == (i = response.find("\r\n\r\n")))
{
#ifdef OPENDHT_DEBUG
std::cerr << "OpenDHTClient::loadServersFromWeb() Failed to Find Content" << std::endl;
#endif
return false;
}
/* now step past 4 chars */
i += 4;
std::string content(response, i, response.length() - i);
#ifdef OPENDHT_DEBUG
std::cerr << "OpenDHTClient::loadServersFromWeb() Content:" << std::endl;
std::cerr << content << std::endl;
std::cerr << "<== OpenDHTClient::loadServersFromWeb() Content" << std::endl;
#endif
std::istringstream iss(content);
if (loadServers(iss))
{
#ifdef OPENDHT_DEBUG
std::cerr << "OpenDHTClient::loadServersFromWeb() Saving WebData to: ";
std::cerr << storename << std::endl;
#endif
/* save the data to file - replacing old data */
std::ofstream ofstr(storename.c_str());
ofstr << content;
ofstr.close();
return true;
}
return false;
}
bool OpenDHTClient::getServer(std::string &host, uint16_t &port, struct sockaddr_in &addr)
{
/* randomly choose one */
dhtMutex.lock(); /**** LOCK ****/
#ifndef WINDOWS_SYS
#else
/* WINDOWS don't randomise properly so we'll do it ourselves...
*/
uint32_t randomize = timeGetTime();
srand(randomize);
#endif
uint32_t len = mServers.size();
uint32_t rnd = len * (rand() / (RAND_MAX + 1.0));
if (len < 1)
{
#ifdef OPENDHT_DEBUG
std::cerr << "OpenDHTClient::getServer() No Servers available!" << std::endl;
#endif
dhtMutex.unlock(); /**** UNLOCK ****/
return false;
}
std::map<std::string, dhtServer>::const_iterator it;
uint32_t i = 0;
for(it = mServers.begin(); (it != mServers.end()) && (i < rnd); it++, i++);
if (it == mServers.end())
{
#ifdef OPENDHT_DEBUG
std::cerr << "OpenDHTClient::getServer() Error getting Server!" << std::endl;
#endif
dhtMutex.unlock(); /**** UNLOCK ****/
return false;
}
host = (it->second).host;
port = (it->second).port;
time_t now = time(NULL);
if (now - (it->second).ts < 3600)
{
addr = (it->second).addr;
}
else
{
addr.sin_addr.s_addr = 0;
}
dhtMutex.unlock(); /**** UNLOCK ****/
return true;
}
bool OpenDHTClient::setServerIp(std::string host, struct sockaddr_in addr)
{
dhtMutex.lock(); /**** LOCK ****/
std::map<std::string, dhtServer>::iterator it;
it = mServers.find(host);
if (it == mServers.end())
{
dhtMutex.unlock(); /**** UNLOCK ****/
#ifdef OPENDHT_DEBUG
std::cerr << "OpenDHTClient::setServerIp() Error finding Server!" << std::endl;
#endif
return false;
}
(it -> second).addr = addr;
(it -> second).ts = time(NULL);
(it -> second).failed = 0;
mDHTFailCount = 0;
dhtMutex.unlock(); /**** UNLOCK ****/
return true;
}
void OpenDHTClient::setServerFailed(std::string host)
{
dhtMutex.lock(); /**** LOCK ****/
std::map<std::string, dhtServer>::iterator it;
it = mServers.find(host);
if (it == mServers.end())
{
#ifdef OPENDHT_DEBUG
std::cerr << "OpenDHTClient::setServerFailed() Error finding Server!" << std::endl;
#endif
dhtMutex.unlock(); /**** UNLOCK ****/
return;
}
mDHTFailCount++;
if (mDHTFailCount > MAX_DHT_TOTAL_FAILS) /* might be not connected to Internet */
{
#ifdef OPENDHT_DEBUG
std::cerr << "OpenDHTClient::setServerFailed() Probably not connected!" << std::endl;
#endif
dhtMutex.unlock(); /**** UNLOCK ****/
return;
}
/* up the fail count on this one */
(it -> second).failed++;
if ((it -> second).failed > MAX_DHT_PEER_FAILS)
{
#ifdef OPENDHT_DEBUG
std::cerr << "OpenDHTClient::setServerFailed() fail count high -> removing: ";
std::cerr << host << " from list" << std::endl;
#endif
/* remove from list */
mServers.erase(it);
}
dhtMutex.unlock(); /**** UNLOCK ****/
return;
}
bool OpenDHTClient::dhtActive()
{
dhtMutex.lock(); /**** LOCK ****/
bool ok = (mDHTFailCount <= MAX_DHT_TOTAL_FAILS) &&
(mServers.size() > MIN_DHT_SERVERS);
dhtMutex.unlock(); /**** UNLOCK ****/
return ok;
}
bool OpenDHTClient::publishKey(std::string key, std::string value, uint32_t ttl)
{
/* create request */
#ifdef OPENDHT_DEBUG
std::cerr << "OpenDHTClient::openDHT_publishKey() key: 0x" << RsUtil::BinToHex(key) << " value: 0x" << RsUtil::BinToHex(value);
std::cerr << std::endl;
#endif
std::string putmsg = createOpenDHT_put(key, value, ttl, openDHT_Client);
std::string response;
for(uint16_t i = 0; (!openDHT_sendMessage(putmsg, response)); i++)
{
if (i > MAX_DHT_ATTEMPTS)
{
#ifdef OPENDHT_DEBUG
std::cerr << "OpenDHTClient::openDHT_publishKey() Failed -> Giving Up";
std::cerr << std::endl;
#endif
return false;
}
#ifdef OPENDHT_DEBUG
std::cerr << "OpenDHTClient::openDHT_publishKey() Failed -> reattempting";
std::cerr << std::endl;
#endif
}
/* check response */
return true;
}
bool OpenDHTClient::searchKey(std::string key, std::list<std::string> &values)
{
#ifdef OPENDHT_DEBUG
std::cerr << "OpenDHTClient::openDHT_searchKey() key: 0x" << RsUtil::BinToHex(key);
std::cerr << std::endl;
#endif
/* create request */
std::string getmsg = createOpenDHT_get(key, 1024, openDHT_Client);
std::string response;
for(uint16_t i = 0; (!openDHT_sendMessage(getmsg, response)); i++)
{
if (i > MAX_DHT_ATTEMPTS)
{
#ifdef OPENDHT_DEBUG
std::cerr << "OpenDHTClient::openDHT_searchKey() Failed -> Giving Up";
std::cerr << std::endl;
#endif
return false;
}
#ifdef OPENDHT_DEBUG
std::cerr << "OpenDHTClient::openDHT_searchKey() Failed -> reattempting";
std::cerr << std::endl;
#endif
}
#ifdef OPENDHT_DEBUG
std::cerr << "Parsing expression :$$$$$$$$$-" << response << "-$$$$$$$$" << std::endl ;
#endif
/* search through the response for <base64> ... </base64> */
std::string::size_type start = 0;
std::string::size_type loc = 0;
std::string::size_type end = 0;
while(1)
{
loc = response.find("<base64>", start);
if (loc == std::string::npos)
return true; /* finished */
#ifdef OPENDHT_DEBUG
std::cerr << "found loc=" << loc << std::endl ;
#endif
loc += 8; /* shift to end of <base64> */
end = response.find("</base64>", loc);
if (end == std::string::npos)
return true; /* finished */
#ifdef OPENDHT_DEBUG
std::cerr << "found end=" << end << std::endl ;
#endif
std::string value = response.substr(loc, end-loc);
#ifdef OPENDHT_DEBUG
std::cerr << "found value=" << value << std::endl ;
#endif
/* clear out whitespace */
for(std::string::size_type i = 0; i < value.length();)
{
if (isspace(value[i]))
{
value.erase(i,1);
#ifdef OPENDHT_DEBUG
std::cerr << "Cleanup Result:" << value << ":END:" << std::endl;
#endif
}
else
{
i++;
}
}
if (value.length() > 0)
{
std::string result = convertFromBase64(value);
values.push_back(result);
#ifdef OPENDHT_DEBUG
std::cerr << "openDHT_searchKey() Value:" << value << ":END:" << std::endl;
std::cerr << "openDHT_searchKey() Result: 0x" << RsUtil::BinToHex(result) << ":END:" << std::endl;
#endif
}
/* the answer should be between loc and end */
start = end + 9;
}
/* parse response */
return true;
}
bool OpenDHTClient::openDHT_sendMessage(std::string msg, std::string &response)
{
struct sockaddr_in addr;
std::string host;
uint16_t port;
if (!getServer(host, port, addr))
{
#ifdef OPENDHT_DEBUG
std::cerr << "OpenDHTClient::openDHT_sendMessage() Failed to get Server";
std::cerr << std::endl;
#endif
return false;
}
if (addr.sin_addr.s_addr == 0)
{
/* lookup the address */
addr.sin_port = htons(port);
if (LookupDNSAddr(host, addr) &&
(addr.sin_addr.s_addr != 0))
{
/* update the IP addr if necessary */
setServerIp(host, addr);
}
else
{
/* no address */
#ifdef OPENDHT_DEBUG
std::cerr << "OpenDHTClient::openDHT_sendMessage()";
std::cerr << " ERROR: No Address";
std::cerr << std::endl;
#endif
setServerFailed(host);
return false;
}
}
#ifdef OPENDHT_DEBUG
std::cerr << "OpenDHTClient::openDHT_sendMessage()";
std::cerr << " Connecting to:" << host << ":" << port;
std::cerr << " (" << rs_inet_ntoa(addr.sin_addr) << ":" << ntohs(addr.sin_port) << ")";
std::cerr << std::endl;
#endif
/* create request */
std::string putheader = createHttpHeader(host, port, openDHT_Agent, msg.length());
/* open a socket */
int sockfd = unix_socket(PF_INET, SOCK_STREAM, 0);
/* connect */
int err = unix_connect(sockfd, (struct sockaddr *) &addr, sizeof(addr));
if (err)
{
unix_close(sockfd);
#ifdef OPENDHT_DEBUG
std::cerr << "OpenDHTClient::openDHT_sendMessage()";
std::cerr << " ERROR: Failed to Connect";
std::cerr << std::endl;
#endif
setServerFailed(host);
return false;
}
#ifdef OPENDHT_DEBUG
std::cerr << "HTTP message *******************" << std::endl;
std::cerr << putheader;
std::cerr << msg;
std::cerr << std::endl;
std::cerr << "HTTP message *******************" << std::endl;
#endif
/* send data */
int sendsize = strlen(putheader.c_str());
int size = send(sockfd, putheader.c_str(), sendsize, 0);
if (sendsize != size)
{
unix_close(sockfd);
#ifdef OPENDHT_DEBUG
std::cerr << "OpenDHTClient::openDHT_sendMessage()";
std::cerr << " ERROR: Failed to Send(1)";
std::cerr << std::endl;
#endif
setServerFailed(host);
return false;
}
#ifdef OPENDHT_DEBUG
std::cerr << "OpenDHTClient::openDHT_sendMessage()";
std::cerr << " Send(1):" << size;
std::cerr << std::endl;
#endif
sendsize = strlen(msg.c_str());
size = send(sockfd, msg.c_str(), sendsize, 0);
if (sendsize != size)
{
unix_close(sockfd);
#ifdef OPENDHT_DEBUG
std::cerr << "OpenDHTClient::openDHT_sendMessage()";
std::cerr << " ERROR: Failed to Send(2)";
std::cerr << std::endl;
#endif
setServerFailed(host);
return false;
}
#ifdef OPENDHT_DEBUG
std::cerr << "OpenDHTClient::openDHT_sendMessage()";
std::cerr << " Send(2):" << size;
std::cerr << std::endl;
#endif
/* now wait for the response */
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
#ifndef WINDOWS_SYS
sleep(1);
#else
Sleep(1000);
#endif
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
int recvsize = 51200; /* 50kb */
char *inbuf = (char *) malloc(recvsize);
uint32_t idx = 0;
while(0 < (size = recv(sockfd, &(inbuf[idx]), recvsize - idx, 0)))
{
#ifdef OPENDHT_DEBUG
std::cerr << "OpenDHTClient::openDHT_sendMessage()";
std::cerr << " Recvd Chunk:" << size;
std::cerr << std::endl;
#endif
idx += size;
}
#ifdef OPENDHT_DEBUG
std::cerr << "OpenDHTClient::openDHT_sendMessage()";
std::cerr << " Recvd Msg:" << idx;
#endif
response = std::string(inbuf, idx);
free(inbuf);
/* print it out */
#ifdef OPENDHT_DEBUG
std::cerr << "HTTP What We Sent ***************" << std::endl;
std::cerr << putheader;
std::cerr << msg;
std::cerr << std::endl;
std::cerr << "HTTP response *******************" << std::endl;
std::cerr << response;
std::cerr << std::endl;
std::cerr << "HTTP response *******************" << std::endl;
#endif
unix_close(sockfd);
return true;
}
bool OpenDHTClient::openDHT_getDHTList(std::string &response)
{
struct sockaddr_in addr;
std::string host = "www.opendht.org";
uint16_t port = 80;
sockaddr_clear(&addr);
/* lookup the address */
addr.sin_family = AF_INET;
addr.sin_port = htons(port);
if (!LookupDNSAddr(host, addr))
{
/* no address */
#ifdef OPENDHT_DEBUG
std::cerr << "OpenDHTClient::openDHT_getDHTList()";
std::cerr << " ERROR: No Address";
std::cerr << std::endl;
#endif
return false;
}
#ifdef OPENDHT_DEBUG
std::cerr << "OpenDHTClient::openDHT_getDHTList()";
std::cerr << " Connecting to:" << host << ":" << port;
std::cerr << " (" << rs_inet_ntoa(addr.sin_addr) << ":" << ntohs(addr.sin_port) << ")";
std::cerr << std::endl;
#endif
/* create request */
std::string putheader = createHttpHeaderGET(host, port, "servers.txt", openDHT_Agent, 0);
/* open a socket */
int sockfd = unix_socket(PF_INET, SOCK_STREAM, 0);
/* connect */
int err = unix_connect(sockfd, (struct sockaddr *) &addr, sizeof(addr));
if (err)
{
unix_close(sockfd);
#ifdef OPENDHT_DEBUG
std::cerr << "OpenDHTClient::openDHT_getDHTList()";
std::cerr << " ERROR: Failed to Connect";
std::cerr << std::endl;
#endif
return false;
}
#ifdef OPENDHT_DEBUG
std::cerr << "HTTP message *******************" << std::endl;
std::cerr << putheader;
std::cerr << std::endl;
std::cerr << "HTTP message *******************" << std::endl;
#endif
/* send data */
int sendsize = strlen(putheader.c_str());
int size = send(sockfd, putheader.c_str(), sendsize, 0);
if (sendsize != size)
{
unix_close(sockfd);
#ifdef OPENDHT_DEBUG
std::cerr << "OpenDHTClient::openDHT_getDHTList()";
std::cerr << " ERROR: Failed to Send(1)";
std::cerr << std::endl;
#endif
return false;
}
#ifdef OPENDHT_DEBUG
std::cerr << "OpenDHTClient::openDHT_getDHTList()";
std::cerr << " Send(1):" << size;
std::cerr << std::endl;
#endif
/* now wait for the response */
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
#ifndef WINDOWS_SYS
sleep(1);
#else
Sleep(1000);
#endif
/********************************** WINDOWS/UNIX SPECIFIC PART ******************/
int recvsize = 51200; /* 50kb */
char *inbuf = (char *) malloc(recvsize);
uint32_t idx = 0;
while(0 < (size = recv(sockfd, &(inbuf[idx]), recvsize - idx, 0)))
{
#ifdef OPENDHT_DEBUG
std::cerr << "OpenDHTClient::openDHT_getDHTList()";
std::cerr << " Recvd Chunk:" << size;
std::cerr << std::endl;
#endif
idx += size;
}
#ifdef OPENDHT_DEBUG
std::cerr << "OpenDHTClient::openDHT_getDHTList()";
std::cerr << " Recvd Msg:" << idx;
#endif
response = std::string(inbuf, idx);
free(inbuf);
/* print it out */
#ifdef OPENDHT_DEBUG
std::cerr << "HTTP response *******************" << std::endl;
std::cerr << response;
std::cerr << std::endl;
std::cerr << "HTTP response *******************" << std::endl;
#endif
unix_close(sockfd);
return true;
}

View File

@ -1,85 +0,0 @@
/*
* libretroshare/src/dht: opendht.h
*
* Interface with OpenDHT for RetroShare.
*
* Copyright 2007-2008 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#ifndef RS_OPEN_DHT_CLIENT_H
#define RS_OPEN_DHT_CLIENT_H
#include "pqi/pqinetwork.h"
#include "util/rsthreads.h"
#include <inttypes.h>
#include <string>
#include <list>
#include <map>
#include "dht/dhtclient.h"
class dhtServer
{
public:
std::string host;
uint16_t port;
uint16_t failed;
time_t ts;
struct sockaddr_in addr;
};
class OpenDHTClient: public DHTClient
{
public:
virtual bool publishKey(std::string key, std::string value, uint32_t ttl);
virtual bool searchKey(std::string key, std::list<std::string> &values);
/* Fns accessing data */
virtual bool checkServerFile(std::string filename);
virtual bool loadServers(std::string filename);
virtual bool loadServersFromWeb(std::string storefname);
virtual bool loadServers(std::istream&);
virtual bool dhtActive();
private:
bool getServer(std::string &host, uint16_t &port, struct sockaddr_in &addr);
bool setServerIp(std::string host, struct sockaddr_in addr);
void setServerFailed(std::string host);
private:
/* generic send msg */
bool openDHT_sendMessage(std::string msg, std::string &response);
bool openDHT_getDHTList(std::string &response);
RsMutex dhtMutex;
std::map<std::string, dhtServer> mServers;
uint32_t mDHTFailCount;
};
#endif

View File

@ -1,218 +0,0 @@
/*
* libretroshare/src/dht: opendhtmgr.cc
*
* Interface with OpenDHT for RetroShare.
*
* Copyright 2007-2008 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#include "dht/opendhtmgr.h"
#include "dht/opendht.h"
#include "util/rsthreads.h" /* for pthreads headers */
class dhtSearchData
{
public:
OpenDHTMgr *mgr;
DHTClient *client;
std::string key;
};
class dhtPublishData
{
public:
OpenDHTMgr *mgr;
DHTClient *client;
std::string key;
std::string value;
uint32_t ttl;
};
/* Thread routines */
extern "C" void* doDhtPublish(void* p)
{
#ifdef OPENDHT_DEBUG
std::cerr << "in doDhtPublish(void* p)" << std::endl ;
#endif
dhtPublishData *data = (dhtPublishData *) p;
if(data == NULL)
{
pthread_exit(NULL);
return NULL;
}
/* publish it! */
if(data->mgr != NULL && data->client != NULL)
data->client->publishKey(data->key, data->value, data->ttl);
delete data;
pthread_exit(NULL);
return NULL;
}
extern "C" void* doDhtSearch(void* p)
{
dhtSearchData *data = (dhtSearchData *) p;
if ((!data) || (!data->mgr) || (!data->client))
{
pthread_exit(NULL);
return NULL;
}
/* search it! */
std::list<std::string> values;
if (data->client->searchKey(data->key, values))
{
/* callback */
std::list<std::string>::iterator it;
for(it = values.begin(); it != values.end(); it++)
{
data->mgr->resultDHT(data->key, *it);
}
}
delete data;
pthread_exit(NULL);
return NULL;
}
OpenDHTMgr::OpenDHTMgr(std::string ownId, pqiConnectCb* cb, std::string configdir)
:p3DhtMgr(ownId, cb), mConfigDir(configdir)
{
return;
}
/********** OVERLOADED FROM p3DhtMgr ***************/
bool OpenDHTMgr::dhtInit()
{
std::string configpath = mConfigDir;
/* load up DHT gateways */
mClient = new OpenDHTClient();
//mClient = new DHTClientDummy();
std::string filename = configpath;
if (configpath.size() > 0)
{
filename += "/";
}
filename += "ODHTservers.txt";
/* check file date first */
if (mClient -> checkServerFile(filename))
{
return mClient -> loadServers(filename);
}
else if (!mClient -> loadServersFromWeb(filename))
{
return mClient -> loadServers(filename);
}
return true;
}
bool OpenDHTMgr::dhtShutdown()
{
/* do nothing */
if (mClient)
{
delete mClient;
mClient = NULL;
return true;
}
return false;
}
bool OpenDHTMgr::dhtActive()
{
/* do nothing */
if ((mClient) && (mClient -> dhtActive()))
{
return true;
}
return false;
}
int OpenDHTMgr::status(std::ostream &out)
{
/* do nothing */
return 1;
}
/* Blocking calls (only from thread) */
bool OpenDHTMgr::publishDHT(std::string key, std::string value, uint32_t ttl)
{
/* launch a publishThread */
pthread_t tid;
#ifdef OPENDHT_DEBUG
std::cerr << "in publishDHT(.......)" << std::endl ;
#endif
dhtPublishData *pub = new dhtPublishData;
pub->mgr = this;
pub->client = mClient;
pub->key = key;
pub->value = value;
pub->ttl = ttl;
void *data = (void *) pub;
pthread_create(&tid, 0, &doDhtPublish, data);
pthread_detach(tid); /* so memory is reclaimed in linux */
return true;
}
bool OpenDHTMgr::searchDHT(std::string key)
{
/* launch a publishThread */
pthread_t tid;
dhtSearchData *dht = new dhtSearchData;
dht->mgr = this;
dht->client = mClient;
dht->key = key;
void *data = (void *) dht;
pthread_create(&tid, 0, &doDhtSearch, data);
pthread_detach(tid); /* so memory is reclaimed in linux */
return true;
}
/********** OVERLOADED FROM p3DhtMgr ***************/

View File

@ -1,65 +0,0 @@
/*
* libretroshare/src/dht: opendhtmgr.h
*
* Interface with OpenDHT for RetroShare.
*
* Copyright 2007-2008 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#ifndef RS_OPEN_DHT_MGR_H
#define RS_OPEN_DHT_MGR_H
#include "pqi/p3dhtmgr.h"
#include "dht/dhtclient.h"
#include <string>
#include <inttypes.h>
#include <list>
class OpenDHTMgr: public p3DhtMgr
{
public:
OpenDHTMgr(std::string ownId, pqiConnectCb* cb, std::string configdir);
protected:
/********** OVERLOADED FROM p3DhtMgr ***************/
virtual bool dhtInit();
virtual bool dhtShutdown();
virtual bool dhtActive();
virtual int status(std::ostream &out);
/* Blocking calls (only from thread) */
virtual bool publishDHT(std::string key, std::string value, uint32_t ttl);
virtual bool searchDHT(std::string key);
/********** OVERLOADED FROM p3DhtMgr ***************/
private:
DHTClient *mClient;
std::string mConfigDir;
};
#endif

View File

@ -1,127 +0,0 @@
/*
* libretroshare/src/dht: opendhtstr.cc
*
* Interface with OpenDHT for RetroShare.
*
* Copyright 2007-2008 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#include <string>
#include <sstream>
#include "opendhtstr.h"
#include "b64.h"
std::string createHttpHeader(std::string host, uint16_t port, std::string agent, uint32_t length)
{
std::ostringstream req;
req << "POST / HTTP/1.0\r\n";
req << "Host: " << host << ":" << port << "\r\n";
req << "User-Agent: " << agent << "\r\n";
req << "Content-Type: text/xml\r\n";
req << "Content-Length: " << length << "\r\n";
req << "\r\n";
return req.str();
};
std::string createHttpHeaderGET(std::string host, uint16_t port, std::string page, std::string agent, uint32_t length)
{
std::ostringstream req;
req << "GET /" << page << " HTTP/1.0\r\n";
req << "Host: " << host << ":" << port << "\r\n";
req << "User-Agent: " << agent << "\r\n";
//req << "Content-Type: text/xml\r\n";
//req << "Content-Length: " << length << "\r\n";
req << "\r\n";
return req.str();
};
std::string createOpenDHT_put(std::string key, std::string value, uint32_t ttl, std::string client)
{
std::ostringstream req;
req << "<?xml version=\"1.0\"?>" << std::endl;
req << "<methodCall>" << std::endl;
req << "\t<methodName>put</methodName>" << std::endl;
req << "\t<params>" << std::endl;
req << "\t\t<param><value><base64>";
req << convertToBase64(key);
req << "</base64></value></param>" << std::endl;
req << "\t\t<param><value><base64>";
req << convertToBase64(value);
req << "</base64></value></param>" << std::endl;
req << "\t\t<param><value><int>";
req << ttl;
req << "</int></value></param>" << std::endl;
req << "\t\t<param><value><string>";
req << client;
req << "</string></value></param>" << std::endl;
req << "\t</params>" << std::endl;
req << "</methodCall>" << std::endl;
return req.str();
}
std::string createOpenDHT_get(std::string key, uint32_t maxresponse, std::string client)
{
std::ostringstream req;
req << "<?xml version=\"1.0\"?>" << std::endl;
req << "<methodCall>" << std::endl;
req << "\t<methodName>get</methodName>" << std::endl;
req << "\t<params>" << std::endl;
/* key */
req << "\t\t<param><value><base64>";
req << convertToBase64(key);
req << "</base64></value></param>" << std::endl;
/* max response */
req << "\t\t<param><value><int>";
req << maxresponse;
req << "</int></value></param>" << std::endl;
/* placemark (NULL) */
req << "\t\t<param><value><base64>";
req << "</base64></value></param>" << std::endl;
req << "\t\t<param><value><string>";
req << client;
req << "</string></value></param>" << std::endl;
req << "\t</params>" << std::endl;
req << "</methodCall>" << std::endl;
return req.str();
}

View File

@ -1,45 +0,0 @@
/*
* libretroshare/src/dht: opendhtstr.h
*
* Interface with OpenDHT for RetroShare.
*
* Copyright 2007-2008 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#ifndef OPENDHT_STRING_CODE_H
#define OPENDHT_STRING_CODE_H
#include <inttypes.h>
#include <string>
std::string createHttpHeader(std::string host, uint16_t port,
std::string agent, uint32_t length);
std::string createHttpHeaderGET(std::string host, uint16_t port,
std::string page, std::string agent, uint32_t length);
std::string createOpenDHT_put(std::string key, std::string value,
uint32_t ttl, std::string client);
std::string createOpenDHT_get(std::string key,
uint32_t maxresponse, std::string client);
#endif

View File

@ -0,0 +1,324 @@
/*
* libretroshare/src/dht: p3bitdht.h
*
* BitDht interface for RetroShare.
*
* Copyright 2009-2010 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#include "dht/p3bitdht.h"
#include "bitdht/bdstddht.h"
#include <openssl/sha.h>
/* This is a conversion callback class between pqi interface
* and the BitDht Interface.
*
*/
class p3BdCallback: public BitDhtCallback
{
public:
p3BdCallback(p3BitDht *parent)
:mParent(parent) { return; }
virtual int dhtNodeCallback(const bdId *id, uint32_t peerflags)
{
return mParent->NodeCallback(id, peerflags);
}
virtual int dhtPeerCallback(const bdNodeId *id, uint32_t status)
{
return mParent->PeerCallback(id, status);
}
virtual int dhtValueCallback(const bdNodeId *id, std::string key, uint32_t status)
{
return mParent->ValueCallback(id, key, status);
}
private:
p3BitDht *mParent;
};
p3BitDht::p3BitDht(std::string id, pqiConnectCb *cb, UdpStack *udpstack, std::string bootstrapfile)
:pqiNetAssistConnect(id, cb)
{
std::string dhtVersion = "RS51"; // should come from elsewhere!
bdNodeId ownId;
/* setup ownId */
storeTranslation(id);
lookupNodeId(id, &ownId);
/* standard dht behaviour */
bdDhtFunctions *stdfns = new bdStdDht();
/* create dht */
mUdpBitDht = new UdpBitDht(udpstack, &ownId, dhtVersion, bootstrapfile, stdfns);
/* setup callback to here */
p3BdCallback *bdcb = new p3BdCallback(this);
mUdpBitDht->addCallback(bdcb);
}
p3BitDht::~p3BitDht()
{
delete mUdpBitDht;
}
/* pqiNetAssist - external interface functions */
void p3BitDht::enable(bool on)
{
//mUdpBitDht->enable(on);
}
void p3BitDht::shutdown() /* blocking call */
{
//mUdpBitDht->shutdown();
}
void p3BitDht::restart()
{
//mUdpBitDht->restart();
}
bool p3BitDht::getEnabled()
{
return false;
}
bool p3BitDht::getActive()
{
return false;
}
/* pqiNetAssistConnect - external interface functions */
/* add / remove peers */
bool p3BitDht::findPeer(std::string pid)
{
/* convert id -> NodeId */
if (!storeTranslation(pid))
{
/* error */
return false;
}
bdNodeId nid;
if (!lookupNodeId(pid, &nid))
{
/* error */
return false;
}
/* add in peer */
mUdpBitDht->addFindNode(&nid, 0);
}
bool p3BitDht::dropPeer(std::string pid)
{
/* convert id -> NodeId */
bdNodeId nid;
if (!lookupNodeId(pid, &nid))
{
/* error */
return false;
}
/* remove in peer */
mUdpBitDht->removeFindNode(&nid);
/* remove from translation */
if (!removeTranslation(pid))
{
/* error */
return false;
}
}
/* extract current peer status */
bool p3BitDht::getPeerStatus(std::string id,
struct sockaddr_in &raddr, uint32_t &mode)
{
return false;
}
bool p3BitDht::getExternalInterface(struct sockaddr_in &raddr,
uint32_t &mode)
{
return false;
}
/* Adding a little bit of fixed test...
* This allows us to ensure that only compatible peers will find each other
*/
const uint8_t RS_DHT_VERSION_LEN = 17;
const uint8_t rs_dht_version_data[RS_DHT_VERSION_LEN] = "RS_VERSION_0.5.1";
/******************** Conversion Functions **************************/
int p3BitDht::calculateNodeId(const std::string pid, bdNodeId *id)
{
/* generate node id from pid */
/* use a hash to make it impossible to reverse */
uint8_t sha_hash[SHA_DIGEST_LENGTH];
memset(sha_hash,0,SHA_DIGEST_LENGTH*sizeof(uint8_t)) ;
SHA_CTX *sha_ctx = new SHA_CTX;
SHA1_Init(sha_ctx);
SHA1_Update(sha_ctx, rs_dht_version_data, RS_DHT_VERSION_LEN);
SHA1_Update(sha_ctx, pid.c_str(), pid.length());
SHA1_Final(sha_hash, sha_ctx);
for(int i = 0; i < SHA_DIGEST_LENGTH && (i < BITDHT_KEY_LEN); i++)
{
id->data[i] = sha_hash[i];
}
delete sha_ctx;
return 1;
}
int p3BitDht::lookupNodeId(const std::string pid, bdNodeId *id)
{
RsStackMutex stack(dhtMtx);
std::map<std::string, bdNodeId>::iterator it;
it = mTransToNodeId.find(pid);
if (it == mTransToNodeId.end())
{
return 0;
}
*id = it->second;
return 1;
}
int p3BitDht::lookupRsId(const bdNodeId *id, std::string &pid)
{
RsStackMutex stack(dhtMtx);
std::map<bdNodeId, std::string>::iterator nit;
nit = mTransToRsId.find(*id);
if (nit == mTransToRsId.end())
{
return 0;
}
pid = nit->second;
return 1;
}
int p3BitDht::storeTranslation(const std::string pid)
{
bdNodeId nid;
calculateNodeId(pid, &nid);
RsStackMutex stack(dhtMtx);
mTransToNodeId[pid] = nid;
mTransToRsId[nid] = pid;
return 1;
}
int p3BitDht::removeTranslation(const std::string pid)
{
RsStackMutex stack(dhtMtx);
std::map<std::string, bdNodeId>::iterator it = mTransToNodeId.find(pid);
it = mTransToNodeId.find(pid);
if (it == mTransToNodeId.end())
{
/* missing */
return 0;
}
bdNodeId nid = it->second;
std::map<bdNodeId, std::string>::iterator nit;
nit = mTransToRsId.find(nid);
if (nit == mTransToRsId.end())
{
/* inconsistent!!! */
return 0;
}
mTransToNodeId.erase(it);
mTransToRsId.erase(nit);
return 1;
}
/********************** Callback Functions **************************/
int p3BitDht::NodeCallback(const bdId *id, uint32_t peerflags)
{
/* is it one that we are interested in? */
std::string pid;
/* check for translation */
if (lookupRsId(&(id->id), pid))
{
/* we found it ... do callback to p3connmgr */
//uint32_t cbflags = ONLINE | UNREACHABLE;
return 1;
}
return 0;
}
int p3BitDht::PeerCallback(const bdNodeId *id, uint32_t status)
{
/* is it one that we are interested in? */
std::string pid;
/* check for translation */
if (lookupRsId(id, pid))
{
/* we found it ... do callback to p3connmgr */
//uint32_t cbflags = ONLINE | REACHABLE;
return 1;
}
return 0;
}
int p3BitDht::ValueCallback(const bdNodeId *id, std::string key, uint32_t status)
{
/* ignore for now */
return 0;
}

View File

@ -0,0 +1,95 @@
/*
* libretroshare/src/dht: p3bitdht.h
*
* BitDht interface for RetroShare.
*
* Copyright 2009-2010 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#ifndef MRK_P3_BITDHT_H
#define MRK_P3_BITDHT_H
#include "pqi/pqiassist.h"
#include <string>
#include <map>
#include "pqi/pqinetwork.h"
#include "pqi/pqimonitor.h"
#include "util/rsthreads.h"
#include "udp/udpstack.h"
#include "udp/udpbitdht.h"
#include "bitdht/bdiface.h"
class p3BitDht: public pqiNetAssistConnect
{
public:
p3BitDht(std::string id, pqiConnectCb *cb,
UdpStack *udpstack, std::string bootstrapfile);
virtual ~p3BitDht();
/* pqiNetAssist - external interface functions */
virtual void enable(bool on);
virtual void shutdown(); /* blocking call */
virtual void restart();
virtual bool getEnabled();
virtual bool getActive();
/* pqiNetAssistConnect - external interface functions */
/* add / remove peers */
virtual bool findPeer(std::string id);
virtual bool dropPeer(std::string id);
/* extract current peer status */
virtual bool getPeerStatus(std::string id, struct sockaddr_in &raddr,
uint32_t &mode);
virtual bool getExternalInterface(struct sockaddr_in &raddr,
uint32_t &mode);
/* Callback functions - from bitdht */
int NodeCallback(const bdId *id, uint32_t peerflags);
int PeerCallback(const bdNodeId *id, uint32_t status);
int ValueCallback(const bdNodeId *id, std::string key, uint32_t status);
private:
/* translation stuff */
int calculateNodeId(const std::string pid, bdNodeId *id);
int lookupNodeId(const std::string pid, bdNodeId *id);
int lookupRsId(const bdNodeId *id, std::string &pid);
int storeTranslation(const std::string pid);
int removeTranslation(const std::string pid);
UdpBitDht *mUdpBitDht; /* has own mutex */
RsMutex dhtMtx;
/* translation maps */
std::map<std::string, bdNodeId> mTransToNodeId;
std::map<bdNodeId, std::string> mTransToRsId;
};
#endif /* MRK_P3_BITDHT_H */

View File

@ -1,163 +0,0 @@
Wed Jan 16 04:13:01 UTC 2008
1: 128.84.154.45:5850 planetlab6.cs.cornell.edu
2: 129.107.35.132:5850 planetlab2.uta.edu
3: 128.8.126.112:5850 pepper.planetlab.cs.umd.edu
4: 128.220.247.29:5850 planetlab2.isi.jhu.edu
5: 141.117.68.62:5850 planetlab-2.rml.ryerson.ca
6: 128.119.247.211:5850 planetlab2.cs.umass.edu
7: 129.10.120.194:5850 planetlabtwo.ccs.neu.edu
8: 152.3.138.4:5850 planetlab4.cs.duke.edu
9: 138.23.204.232:5850 planet-lab2.cs.ucr.edu
10: 192.197.121.3:5850 node-2.mcgillplanetlab.org
11: 169.229.50.8:5850 planetlab6.Millennium.Berkeley.EDU
12: 75.130.96.12:5850 75-130-96-12.static.oxfr.ma.charter.com
13: 12.46.129.21:5850 planet1.berkeley.intel-research.net
14: 128.112.139.82:5850 planetlab-8.CS.Princeton.EDU
15: 128.31.1.13:5850 planetlab3.csail.mit.edu
16: 134.121.64.4:5850 planetlab1.eecs.wsu.edu
17: 205.189.33.178:5850 planet1.ottawa.canet4.nodes.planet-lab.org
18: 143.205.172.12:5850 plab2-itec.uni-klu.ac.at
19: 192.16.125.12:5850 planetlab-2.ssvl.kth.se
20: 128.238.88.65:5850 planetlab2.poly.edu
21: 193.10.133.129:5850 planetlab-2.it.uu.se
22: 128.227.56.81:5850 planetlab1.acis.ufl.edu
23: 130.75.87.83:5850 planet1.l3s.uni-hannover.de
24: 152.3.138.3:5850 planetlab3.cs.duke.edu
25: 213.19.160.196:5850 planetlab-3.amst.nodes.planet-lab.org
26: 195.116.60.1:5850 planetlab1.warsaw.rd.tp.pl
27: 128.83.122.180:5850 planetlab2.csres.utexas.edu
28: 128.114.63.14:5850 planetslug1.cse.ucsc.edu
29: 129.174.79.248:5850 plgmu2.gmu.edu
30: 169.229.50.18:5850 planetlab16.Millennium.Berkeley.EDU
31: 138.15.10.55:5850 plab1.nec-labs.com
32: 128.208.4.197:5850 planetlab01.cs.washington.edu
33: 129.108.202.11:5850 planetlab2.utep.edu
34: 128.220.247.28:5850 planetlab1.isi.jhu.edu
35: 131.179.112.70:5850 Planetlab1.CS.UCLA.EDU
36: 169.229.50.15:5850 planetlab13.Millennium.Berkeley.EDU
37: 129.137.253.252:5850 planetlab2.uc.edu
38: 128.112.139.96:5850 planetlab-4.CS.Princeton.EDU
39: 128.232.103.201:5850 planetlab1.xeno.cl.cam.ac.uk
40: 128.208.4.199:5850 planetlab03.cs.washington.edu
41: 194.80.38.243:5850 planetlab2.cs-ipv6.lancs.ac.uk
42: 193.1.201.26:5850 planetlab-1.tssg.org
43: 193.136.191.26:5850 planetlab-2.iscte.pt
44: 150.65.32.68:5850 planet1.jaist.ac.jp
45: 136.145.115.196:5850 planetlab-02.ece.uprm.edu
46: 192.6.26.33:5850 pli2-pa-3.hpl.hp.com
47: 203.178.133.11:5850 203.178.133.11
48: 128.31.1.12:5850 planetlab2.csail.mit.edu
49: 128.112.139.73:5850 planetlab-3.CS.Princeton.EDU
50: 129.137.253.253:5850 planetlab1.uc.edu
51: 131.246.191.41:5850 planetlab1.itwm.fhg.de
52: 129.170.214.192:5850 planetlab2.cs.dartmouth.edu
53: 128.31.1.17:5850 planetlab7.csail.mit.edu
54: 139.19.142.1:5850 planetlab01.mpi-sws.mpg.de
55: 129.105.44.253:5850 planetlab2.cs.northwestern.edu
56: 128.252.19.21:5850 vn2.cse.wustl.edu
57: 129.22.150.105:5850 planetlab-2.EECS.CWRU.Edu
58: 139.19.142.4:5850 planetlab04.mpi-sws.mpg.de
59: 142.150.238.13:5850 pl2.csl.utoronto.ca
60: 128.10.19.53:5850 planetlab2.cs.purdue.edu
61: 129.240.67.18:5850 planetlab4.ifi.uio.no
62: 128.163.142.20:5850 planetlab1.netlab.uky.edu
63: 163.221.11.74:5850 planetlab-04.naist.jp
64: 192.33.90.66:5850 planetlab1.inf.ethz.ch
65: 219.243.200.53:5850 dlut1.6planetlab.edu.cn
66: 128.112.139.78:5850 planetlab-10.CS.Princeton.EDU
67: 128.232.103.203:5850 planetlab3.xeno.cl.cam.ac.uk
68: 219.243.200.93:5850 ustc1.6planetlab.edu.cn
69: 128.42.6.143:5850 ricepl-1.cs.rice.edu
70: 152.15.98.227:5850 planetlab02.uncc.edu
71: 169.229.50.14:5850 planetlab12.Millennium.Berkeley.EDU
72: 129.22.150.90:5850 planetlab-1.EECS.CWRU.Edu
73: 128.10.19.52:5850 planetlab1.cs.purdue.edu
74: 128.252.19.20:5850 vn1.cse.wustl.edu
75: 64.161.10.2:5850 64.161.10.2
76: 206.207.248.34:5850 planetlab1.arizona-gigapop.net
77: 128.208.4.198:5850 planetlab02.cs.washington.edu
78: 169.229.50.11:5850 planetlab9.Millennium.Berkeley.EDU
79: 128.232.103.202:5850 planetlab2.xeno.cl.cam.ac.uk
80: 141.213.4.201:5850 planetlab1.eecs.umich.edu
81: 63.64.153.84:5850 63.64.153.84
82: 163.221.11.71:5850 planetlab-01.naist.jp
83: 128.208.4.99:5850 planetlab04.cs.washington.edu
84: 128.151.65.102:5850 planet2.cs.rochester.edu
85: 12.46.129.15:5850 planet5.berkeley.intel-research.net
86: 130.161.40.153:5850 planetlab1.ewi.tudelft.nl
87: 139.19.142.5:5850 planetlab05.mpi-sws.mpg.de
88: 141.76.45.17:5850 planet1.inf.tu-dresden.de
89: 150.65.32.66:5850 planet0.jaist.ac.jp
90: 128.119.247.210:5850 planetlab1.cs.umass.edu
91: 128.223.8.112:5850 planetlab2.cs.uoregon.edu
92: 132.68.237.34:5850 ds-pl1.technion.ac.il
93: 152.3.138.5:5850 planetlab5.cs.duke.edu
94: 132.252.152.194:5850 planetlab2.exp-math.uni-essen.de
95: 128.31.1.14:5850 planetlab4.csail.mit.edu
96: 64.161.10.3:5850 64.161.10.3
97: 63.64.153.82:5850 63.64.153.82
98: 192.42.83.252:5850 192.42.83.252
99: 130.136.254.21:5850 planetlab1.CS.UniBO.IT
100: 128.59.20.226:5850 planetlab1.cs.columbia.edu
101: 128.192.101.217:5850 itchy.cs.uga.edu
102: 128.2.223.65:5850 PLANETLAB-3.CMCL.CS.CMU.EDU
103: 128.59.20.227:5850 planetlab2.cs.columbia.edu
104: 128.31.1.11:5850 planetlab1.csail.mit.edu
105: 128.220.231.3:5850 128.220.231.3
106: 63.64.153.83:5850 63.64.153.83
107: 128.8.126.111:5850 salt.planetlab.cs.umd.edu
108: 128.31.1.16:5850 planetlab6.csail.mit.edu
109: 128.220.231.2:5850 128.220.231.2
110: 129.10.120.193:5850 planetlabone.ccs.neu.edu
111: 75.130.96.13:5850 75-130-96-13.static.oxfr.ma.charter.com
112: 202.244.160.251:5850 202.244.160.251
113: 128.42.6.145:5850 ricepl-3.cs.rice.edu
114: 194.29.178.13:5850 planetlab3.mini.pw.edu.pl
115: 192.33.210.16:5850 lsirextpc01.epfl.ch
116: 169.229.50.16:5850 planetlab14.Millennium.Berkeley.EDU
117: 128.252.19.22:5850 vn3.cse.wustl.edu
118: 194.70.143.50:5850 system18.ncl-ext.net
119: 143.215.129.115:5850 planet2.cc.gt.atl.ga.us
120: 141.24.249.130:5850 planetlab2.fem.tu-ilmenau.de
121: 132.68.237.36:5850 ds-pl3.technion.ac.il
122: 35.9.27.26:5850 planetlab1.cse.msu.edu
123: 195.130.121.204:5850 planetlab1.cs.uoi.gr
124: 203.178.133.3:5850 planetlab1.otemachi.wide.ad.jp
125: 128.135.11.149:5850 planetlab1.cs.uchicago.edu
126: 200.132.0.70:5850 planetlab2.pop-rs.rnp.br
127: 150.165.15.19:5850 planetlab2.lsd.ufcg.edu.br
128: 128.84.154.49:5850 planetlab1.cs.cornell.edu
129: 192.6.19.120:5850 grouse.hpl.external.hp.com
130: 193.136.227.163:5850 planetlab1.fct.ualg.pt
131: 158.130.6.254:5850 planetlab1.cis.UPENN.EDU
132: 194.36.10.154:5850 194.36.10.154
133: 69.110.237.115:5850 69.110.237.115
134: 194.80.38.242:5850 planetlab1.cs-ipv6.lancs.ac.uk
135: 128.138.207.181:5850 planetlab1.cs.colorado.edu
136: 129.69.210.97:5850 planetvs2.informatik.uni-stuttgart.de
137: 141.76.45.18:5850 planet2.inf.tu-dresden.de
138: 216.165.109.82:5850 planet2.scs.cs.nyu.edu
139: 128.223.8.113:5850 planetlab3.cs.uoregon.edu
140: 128.238.88.64:5850 planetlab1.poly.edu
141: 12.46.129.22:5850 planet2.berkeley.intel-research.net
142: 131.246.191.42:5850 planetlab2.itwm.fhg.de
143: 129.130.252.138:5850 plab1.eece.ksu.edu
144: 219.243.200.81:5850 uestc1.6planetlab.edu.cn
145: 129.82.12.187:5850 planetlab-1.cs.colostate.edu
146: 140.247.60.126:5850 righthand.eecs.harvard.edu
147: 132.252.152.193:5850 planetlab1.iem.uni-due.de
148: 12.46.129.14:5850 planet4.berkeley.intel-research.net
149: 128.59.20.228:5850 planetlab3.cs.columbia.edu
150: 192.42.83.251:5850 192.42.83.251
151: 128.84.154.71:5850 planetlab2.cs.cornell.edu
152: 203.30.39.241:5850 planetlab2.singaren.net.sg
153: 129.170.214.191:5850 planetlab1.cs.dartmouth.edu
154: 220.245.140.197:5850 220-245-140-197.static.tpgi.com.au
155: 133.11.240.56:5850 planetlab1.iii.u-tokyo.ac.jp
156: 129.69.210.96:5850 planetvs1.informatik.uni-stuttgart.de
157: 129.108.202.10:5850 planetlab1.utep.edu
158: 193.174.67.186:5850 planet01.HHI.FRAUNHOFER.DE
159: 128.135.11.152:5850 planetlab3.cs.uchicago.edu
160: 206.117.37.4:5850 206.117.37.4
161: 219.243.201.17:5850 thu2.6planetlab.edu.cn
162: 155.98.35.2:5850 planetlab1.flux.utah.edu

View File

@ -1,272 +0,0 @@
[local]
# if the hash (first arg) is 0, a random value will be used.
0 0.0.0.0 1234 4662 0
[some_ignored_stuff]
these lines...
...under unrecognized sections...
...are ignored and left alone...
[overnet_peers]
# 259 contacts follow
01e32c7d216d1479ff1738b88f81bf3b 82.224.47.90 11297 0
01ee86531f5070a344e9d0484744d14d 85.157.111.164 6267 0
028b0545ae661b53d1538d90a7728fac 87.238.10.193 8150 0
032a16ddd72ad9873e036db246930163 83.78.25.111 10089 0
035a2148d7da45022bc36088cbeaa2d5 84.188.185.143 6780 0
035d1f176411bd53b4578e383a66bcdd 82.82.140.226 4298 0
03b47000764e0b3be3efaff6f81e1a0b 24.0.148.14 4665 0
057b9a66771826db0bbd51483a10ff93 85.97.196.22 5678 0
084fe60f368e1117c52e88e8f209113e 85.16.152.185 9363 0
0857c84b6c77bf9e0d0cdeea6e56f11a 172.159.137.252 11316 1
08ca7126b6ead7e6ea3870d13f32d004 83.11.233.250 3911 0
090b57278c13cc673230893305538d1f 82.252.210.95 15030 1
09166e1c64456cc7b3a989d1acb6bd65 84.98.135.162 11933 0
092a05ae3c651f430c806bc49aeb2cb9 210.213.140.62 10521 0
0941d60b7b2d83ef565047610570998c 83.181.168.72 3450 0
09729bc4c1639fe3f4d914cbb8ddc213 82.247.37.205 7663 0
098b7599f442273d1ec2f04710ff436f 80.142.123.8 6133 0
09ebe97100d307d2e5419fa2f7cdfec3 87.10.147.210 10301 0
0a157ca24a7445da325322144ee01993 24.74.148.251 9464 0
0a23207ed240aa7f35202bd4e63b8bdd 84.170.225.102 22222 0
0a2e67bee755ff15c5518b3072867034 87.14.169.88 4445 0
0a39d5f89b4910945087ef9886f58c77 82.235.178.185 9818 0
0becaf5dbbe2eb30694c86408cffb25b 82.234.43.27 19632 0
1284fc9d5064cf0c89630fcc06f86f96 122.254.164.2 11839 0
12b0ebaa0b3e17e16e38f7149f899e96 82.52.190.151 5405 0
12cefeb85edc41e33686ec23f707621c 90.27.87.164 5637 0
12dd8d3931c05d9dc7f9fe0fafc54e46 213.103.153.186 11880 0
12e075a67748bd9888a537b1ddfc68bb 75.162.143.84 12100 0
12f298eb89c926b23eef71724794f386 80.97.199.30 7007 0
12f9fb4045af33cb47f5b87ac618b39d 85.140.95.208 6484 0
12fced7a66d90c3c029e2fbb0d27d44e 70.48.189.93 6093 1
13005d05429d43624683fd2c3ce83c65 83.214.38.125 7448 0
13c90dbc29a45b6d8297ce758772c056 58.77.54.12 12291 0
140470e218c7f8184af176e54cecc294 62.94.193.218 5600 0
148a88de9e03129f7e3e15bdeae59fe1 70.48.175.156 10301 0
14d04c790464ad46121934041d6254ec 62.57.36.125 4041 0
14d589f5f766e40c0838fd9a74218f7a 71.56.125.35 7543 0
158889e94d84e71c135935061743d456 200.16.221.180 3432 0
1667353bcc5e4953c9dcb2b025a8e87b 212.76.242.34 9574 1
168d639d6f6b4f87e1bd9b1df8344729 218.162.61.52 12901 0
16c3bcc5ffc4ce92cdfc7db9f8d52184 80.188.8.104 4662 0
182015e86828a195e22ccb2455378e91 220.134.22.185 3315 0
18f43620c84d373a5935eb1cffa4bb96 89.169.146.14 8323 0
1998abaf1be11abe19a2ea5961befa38 75.36.191.184 5002 0
19f0b20dce022dca4ca915b7ce859b17 59.124.237.86 11590 0
19ffaeafef17d524126ed45ff7326c2b 83.2.140.63 3128 0
1a0b0df71afbac06620431e1ddb5f939 212.106.171.142 6711 0
1b6b5245e54d2f68972bfb178b887724 203.49.242.90 6324 0
1c20dc407cfa9b57778e929a7867af8a 87.175.196.166 5713 1
21b3df22b8c563ac18ee4dfe35a155bc 58.232.60.235 4197 0
21d59ad8e70e8e60659638e29eef5c25 80.203.138.183 6350 0
220c4cc811b0511f13ccd0672fe2954a 83.28.247.107 3884 0
287f16f02efd285381d7657ca5cd99d9 87.221.0.217 6672 0
2981223354677a4ddf777902e9225bef 81.179.202.34 4222 0
29a7a5751d92da3ade58ad92a1ed942d 124.8.65.42 4422 0
29be351bbe4318605d535c76b9a76a6d 83.23.38.244 11386 0
29cf29ab2b870b288a292cefed0d94bf 151.44.119.139 7688 0
29d063f9aba16668462ab3edf2f43ab7 61.224.52.103 5687 0
2a0c14e8d6383d9e5bf2730f0d0ec857 82.130.210.82 50020 0
2a11275793d740d102a1348fd3f45909 80.53.196.58 9936 0
2a519604b6a0119c126194063edf4b8c 68.148.121.42 6472 0
2a83ac042d1278798b00d3352aefe98d 24.243.188.178 10301 0
2acf26c3b18173eb4eb6f73622540c6a 86.56.213.115 3558 0
2bf18d609eb338c9697c9e99379fd16a 85.137.81.79 11717 0
3279ca195c2f4ddf598b8a7dbfd670b6 84.125.74.120 23232 0
32ac6a1eeabdcf65f1505d2a95cee6c9 83.24.146.73 11964 1
3304d216ec77e0fa5c18712d53c008f6 85.57.160.211 7721 0
33a550bed46568b18eb91fae70ca0dbe 24.225.232.219 12164 0
33e97bddd82e4d09131b7342acfeb79c 24.132.162.32 3016 0
33e9ca51aa7f521589a2e6a3438b2821 80.180.76.149 12777 0
34085309549df35140c8e27068083a63 212.59.192.220 4029 0
36196c2ea442dd5ae56cd35a7d1f8619 90.10.169.218 12214 0
361cea6dd0d377f200474a2d72ca7ba6 149.135.104.131 8190 0
3625c3d644b80f221568d688f0f135c5 90.7.181.106 12615 0
36317d125a1aff13035bcd3c0dec4978 80.36.124.22 46675 0
3640f164a682b2c5d249bdcd8bf38274 80.35.196.42 4665 0
36a55737e170cc90ef3ebee1c3b0dc72 217.228.164.18 5325 0
36d7979c3328056ab80a53e94588ae9c 87.122.0.101 9902 0
37075f69ca1fe6aabe53567c2ab48a1a 87.227.73.35 7776 0
375615ba9163d8ecc6a5aed410fe4182 81.1.118.25 5667 1
3796255e359f42a5c4fe41976307b5cc 85.141.108.236 4505 0
38b0e0fb572b282ed6a610adf7a90de8 82.232.90.43 12223 0
38b39efee6bf73cdcc5aff57e816d6ea 71.17.52.65 11438 0
38f6091d65b3483cb6f90d670cb3e8fa 151.97.69.209 9997 0
39037677e44d021350494e6f7c055a8b 82.225.33.80 11541 0
39145af608906d68f059d04b64e8a291 84.129.0.36 8940 0
397460b987ff9e9e360f52136618b2c3 83.38.86.240 3378 0
3ab05f4b0cebd8a2ff689ce8bfb55232 82.238.254.166 3868 0
3acac309140ec0f5e906b6c4ad64d4f4 212.241.66.225 10986 0
3b27d9526ef86fbbf0723ae413723c1d 85.16.150.41 9948 0
3ebecd58d1f7263b087d9159664997c3 80.192.21.44 3751 0
3f614043083f37e5c8487d36b237ea78 124.57.75.101 9934 0
3f755464997b43d4d0826fcbbc8b266f 219.84.26.38 7583 0
3fac223d6c8f833c42d2ae248e206f21 220.72.28.213 4105 0
40bbdfb51868764a24fb96ddf1035f33 70.113.90.243 11327 0
40ce92ad1ac65e7290541e2fa1915bdc 148.160.184.5 4669 0
416297dd4a79f9fe526182de7dbb1e4d 88.73.212.252 11139 1
418b6b00550617e913a3f85cb6043aa4 80.33.124.231 7000 0
41d492e47d76f13e4cb76579123a99e7 84.151.121.46 5687 0
48ae47cc410aa2ae05c1b707744301f4 82.55.119.14 5875 0
48d9789199fc1008b36acb095f9fc787 62.43.160.213 12573 0
48e228897865a53b264f4c57db5312d1 71.107.201.77 4864 0
49ad250210a9842cfce8fb6d8b848cc9 70.244.241.16 8155 0
49c0c086162a51a485c8fc579176ba03 84.148.228.169 12762 0
4a6a309f7d179856cffb9e6e47921c6a 88.22.50.75 6955 0
4abd70a4ceeee66563edf074f152d4ce 89.180.5.149 12492 0
4e2006734147d86a4f7f47199014be4c 70.53.44.52 80 0
4e2540fad59bfabd00ff5b28519b1e61 82.7.244.135 4614 0
4f8e9b83504d589c5591d58e81406e18 123.99.82.220 9992 0
4fd92008c42283607a0ce22e90897696 86.139.46.140 8308 0
4fedf465f25cdf48a66e5dec9d1bdd17 83.6.241.127 6882 0
50bb895dd390303527424e828e5b54be 24.202.246.85 8230 0
51ac71921161bcb6d8b7f8880f46eefc 24.232.81.207 7851 0
51b83c36ac4adb9707fbc719f422cbe8 70.80.1.95 10677 0
51f280b2fb3151daee581811edb3460d 172.183.248.32 10456 0
523fcbe15ed90076457197d9e6750f1e 84.60.0.22 12831 0
531d8c87b014bcf993094c420ed08cfe 74.103.42.209 4111 0
53a75112814d14ecca2d80bf4a05304c 195.4.200.62 8750 0
541e2bb43da70411b0ec9e4a2e3aa0bc 84.125.22.187 3867 0
5abf0e1bb97d86db40d4002d4709bf1a 220.70.254.220 5244 0
5dc4f61ca975687da17ad01d7a06285d 211.201.124.116 6059 0
5efb862926700079413f76ab2c3e79e2 84.126.46.156 5444 0
5f27354bfa0ba9ca2bae6106899cc1a3 83.10.113.23 5410 0
5f5774d921ce06f3f12dfcb40dd73a49 213.185.6.53 4665 0
5f5e5d1d9726f0e0149ffaa75751b05d 82.5.42.25 10301 0
6060d6810bc1d07ba691bbe90b95585c 82.56.93.76 4792 0
654bf80221c0dec4c74b0342c045abc6 83.53.130.173 4267 0
68f38041f26ff4625247ccfa6c9645a2 83.27.138.127 3241 0
6928f1993de7d20516fd1dd489213dbc 216.28.31.253 3620 0
6b14fa18fc8b5ed357133b1a2502a094 82.159.13.169 12286 0
6e21525341966500c9900aa17df49bf3 85.53.89.43 4582 0
6e2614fe5389f95f36093d8723536929 58.234.36.88 5225 1
6e4fc1983cc5fe4a310712bd063b9de4 83.192.115.177 6265 0
6e93bca819d46c7c31164938482e276c 82.49.27.239 8463 0
6eb7eb16713cf56f3d8e1ce368bebdab 87.10.218.82 10301 0
6f0083083a91360160326195a59ea476 85.49.253.102 11583 1
6f414f0a142b802b05932ee4fb810b12 62.80.230.79 6000 0
6f548dd7068651c0ee22bfef37080862 172.141.131.116 3003 0
6f66be33cebe99344cfcf328aa702cfc 82.234.247.90 5596 0
70875fedb3fd7b5e49bcf7fb8323caad 211.213.130.221 4152 0
70bbf8199ffef9edd68041ec954dfca0 218.101.206.9 3322 0
70d009412251fd40d46d5475c33b5b4d 213.213.249.47 4662 0
70dff47cbddf76aa58e13b4124076526 83.42.124.195 9256 0
70ecffa5c424f8169d50922cf0de9267 81.60.195.33 47047 0
7102b6d37c71f4bb249b4b6e20ac4c0d 146.115.56.136 3682 1
712d6dc23289c4c269823f5cb6899e25 84.55.206.118 9228 0
7156fd747d07a6865f5b02a8971bc78a 62.235.24.23 17008 0
7186f68b51e03cfb745b65f8612f5619 83.198.187.23 5864 1
71cc7aa04be67418f10bfbe4adb1bacf 87.5.76.116 5569 0
71dbfe600812a1dd9a841951f68edca0 74.78.2.177 4548 0
723b96cefcde27f6394bb312ddb3bc73 62.42.1.125 5783 0
72f43b744b3170537794cde315148361 84.121.109.184 4175 0
7341869dd42cdd9054e2578b68d53029 81.220.168.54 4985 1
7a1956c5b41f66669c4b74c71742a058 88.23.168.112 9433 0
7a1a6c659c387c936fef2666a1912a32 80.132.101.112 3633 0
7a316a90de24721a9733d86d5321e8f0 84.189.143.14 4394 0
7a50edadd981b09ba88b6f06acef3718 62.15.235.127 7095 0
7a552fce17bb88689f601e531a7e572b 61.64.69.133 6719 0
7a753356842ad958e7057a1fcfd2c083 211.201.93.71 10674 0
7aa5334de0f210a741c5f1354104b3b1 70.252.73.94 10504 0
7b0fc9ae76a8a2727ae54e843bfc3977 80.48.142.10 6162 0
7b31f2b3500d8aa49537625afaac52db 24.67.81.50 9469 0
7b441d23d521023f5a42cc9b594dd92a 83.92.40.199 6164 0
7b4ecae988a881b978f7748088d8e051 67.168.85.39 9273 0
7b65226b440f58717ec06ef5d935bc45 86.208.174.157 7253 0
7b870dabafbd3419fe46740a5cd7fdfc 82.121.160.160 5040 0
7b8879cd08a41d3bf18cb6b00b12e61c 88.24.51.189 11127 0
7b8feeeecb097e817fe35416be73fc56 83.6.232.250 5181 0
7bd571d08d784662e96f7bae7f7f17b3 84.57.158.33 7222 0
7bf2513793a5994b5cad8546f6231e89 84.75.199.138 6082 0
7c4e2c83d7417f42afb85c25d903629f 83.26.117.189 4736 0
7db9b910b7a85739740f86b81321c5e1 83.21.71.92 6174 0
7f51b9d5b5e986f212f34274aff7e4c3 90.154.213.232 59800 0
7f9b3a74b692c7bb5b75e450122d6608 84.77.5.138 55000 0
7fd158be4a5f243789e123ef83d3edf0 82.54.224.155 23830 0
84396c8cf1a26258cba101ea007a49d9 89.228.227.215 8654 0
84c97bd4a9fa479440ee7ef35947ce38 70.82.82.220 5290 0
8ae1f2710e59c77f8266a12d028a8aaf 212.241.64.215 4854 0
900ffda15c6702a93b220738f6f6bccb 84.25.7.56 7746 0
90a87e1fe896621f14416995bd3166af 134.109.132.156 16563 0
90a8d8cb9c9af9c2e76dac650c189d00 83.23.155.182 8914 0
90b399ec0fbe1dab3471e208598d2e7e 84.44.231.141 28583 0
90bcf4c6d0620aa9faa928b6da3b1d17 213.47.112.74 3404 0
9200db48b63d6331b747621d73cfd3ef 125.135.73.172 5510 0
923a3ca51d2c173795ea7980fec03fa4 82.61.70.247 8014 0
92de6303460273a43508296b6237c078 124.61.19.247 3348 0
92f2c65e8d8c984ecae982c8f9cad81e 85.16.150.41 9948 0
945f69d2b0fed4d40c501d18ac1ee335 84.255.205.251 6818 0
95f23a606a61d0eedccfc88c671c9504 210.159.160.154 4188 0
960ed75cdf0e8e55d8bdf2122779006b 80.102.115.141 3915 0
96e1ba371333a60439608576f729617e 84.121.87.1 47047 0
98d02d1b5b7ad14dd13535ed11b51c48 85.53.69.99 10003 0
9d9a51252908efca21b7f5940d5c16ae 82.225.38.240 7821 0
9e31d3105d1be1be100c2dbca9c1cedb 84.183.164.47 7204 0
9e53862ce85a043876da4a5784ad1661 85.140.63.22 7516 0
9edc2fc255ebae8396d622cb15957176 83.112.107.20 8180 1
9ee556648ad3baf1f792aad85e470a7c 219.74.80.197 6601 0
9fa9acb2252a2b65b5bfe032cb434281 81.240.140.43 9703 0
a167a1c1a719856704541c0a1c3e03a9 69.241.238.138 11593 0
a82320cb11db5a34d2e692c5b7ad19d8 88.24.214.34 9534 0
a8967880514d80246b2d940d89907976 220.244.126.14 4668 1
a914e917b7c972d0ddb0f5d654e9aadc 84.122.49.158 12769 0
a91b9efdde30841d46de0b12040b948c 85.155.209.92 5707 0
a9b06362d0342d42b24902cb3d71683d 75.46.112.130 9576 0
acaca1572ac1f9cb9953e55b2729249d 83.35.237.97 4665 0
b2ae365b21df68b48988045b63d4d6fc 189.172.29.169 9874 0
b4bddaca531a4f012d4fa46900f69813 71.9.169.115 5775 0
b5c9a247777ddae8fcfa83cee4ac676e 219.68.29.74 6230 1
b74595669f238061c5b30a518ae33fa5 83.25.82.238 5326 0
c12d62c54b9b343874dc7c8366c2cfb6 189.157.29.196 8705 0
c14322f92dc74c67dc0f864d272fcbf7 69.31.93.178 3471 0
c1604c1d202792be1dca16283d8e9d5a 220.124.224.75 9581 0
c1bef91ee0fac09f1a54d827546e6a0a 87.11.206.239 3959 0
c21d96781cc4c3d2b16407d76f02e944 218.163.184.113 8597 0
c23d212ae659766e8e46438fcfd7dc22 172.180.110.81 3086 0
c285e7b2ab22453496522299b15b3801 59.12.208.195 11267 0
c2bd693941ef041db66d2fe5c1692e59 88.9.121.245 9384 1
c30bdae50cb39cba80ba9ac1a5e1a65a 82.58.189.230 10301 0
c3b0f868f4a9abae3eb7007ab9e2e7c8 87.123.217.188 9030 0
c54a4feeb6618bfe854146f560ad4c47 81.214.39.120 10000 0
c57a5e547d138d1f581221f17e0e272e 86.215.168.93 11447 0
c5be09328b367f7702397cae1711f586 83.53.177.127 11315 0
c5bf7360aa07f31c07830a7370431c8a 61.224.78.247 12595 0
c8618647749d12e3e0995e3f0c556a5b 70.111.26.144 6133 0
c8ac99b1bfc68b615e165129f9b182d5 211.233.2.100 12542 0
db19cb61c98529a91384cf06493be556 210.180.124.29 3246 0
db45d9513bbaf7c3c5bf3e2fffd3012c 83.31.233.170 4471 0
db4b83b43f36bc58ac2685743533a389 65.189.237.244 8044 0
db5dc765e684ba9a610a865800de3416 81.198.131.36 12718 0
db8be48ab25ea2ebff67f3f4312dd204 84.48.235.130 5999 1
db9ffaa55e3712f9cee25b805732ee7b 84.9.76.208 10209 0
dbb5697be82496bb0c46c3c0a2df3110 61.247.84.226 12426 0
dbd681193c024ffce547fdb999ae8339 84.177.92.139 7017 0
dbdd57d92f889e6c84a344d862e23826 84.61.146.49 5751 0
dbe7aec6a2535f0ff4172ca2917c853c 89.78.201.185 6787 0
e119f64361e2022eb2f8e16ab704ac79 70.177.168.143 3893 0
e26c5ade9519477fbfb754e142758641 87.123.168.236 5002 0
e32ad67eef113f2788c5e438932968d8 85.216.39.254 8579 0
e36b23d3b0e5c4e653008aa0fe683941 213.216.232.88 11108 0
e38016ff75ecb0de179162256b5afdb1 83.61.12.146 8020 0
e380e102024f2e299e7ed2ed847c0edc 87.103.45.238 10901 0
e39b3800ff70830b5e158f334197cb7b 222.106.229.231 4474 0
e7025c81e4f11bd9595eb5b12635ad88 68.185.86.95 6842 0
e702aab5bf92f3356d3a26590e736def 74.56.202.29 8029 0
e71f3f7252bc12414cd3fa425f9ae8f3 88.17.127.248 10863 0
e75578be101ba7e8a36ae1072682f5f7 122.34.133.174 9592 0
e75f71fd8126965e32e23f1056056141 81.203.63.82 1756 0
edd8190b83b7ed219536320d4ecb7691 67.83.25.1 4662 0
efaff405e405967bae5ea9264229f386 211.187.188.231 3915 0
efbdc05dc73789a0656b091186ee1089 71.100.59.158 7519 0
f0831665903a6b37e4205ace3621a925 74.114.66.20 3420 0
f0a877163f230e7fc690022d564ad4f5 213.46.9.204 9676 0
f0c1976867bfa84bbd0929ebb1ec8028 74.103.127.57 8805 0
f296f17abd4ccb3ad63a99468eb96060 82.232.173.22 8754 0
f5932b7cee522a08ecb627d47f5b60f5 121.124.152.54 4104 0
f66f25c51aa05ea462694b9055b70193 84.143.27.99 7665 0
f7508519f31549d0018f363e58e4646c 125.224.193.111 10729 0
f8aa2bd3d4b288fbc520ad0f121416d7 213.239.205.232 10755 0
f8ca9f346d4ac702695dbddbf5b7f0bb 90.13.150.216 11403 0
[other_stuff]
blah blah
blah
[blacklisted_nodes]

View File

@ -1,6 +1,6 @@
TEMPLATE = lib
#CONFIG += staticlib release
CONFIG += staticlib testnetwork
CONFIG += staticlib testnetwork
CONFIG -= qt
TARGET = retroshare
@ -51,6 +51,15 @@ debug {
QMAKE_CXXFLAGS *= -g -fno-omit-frame-pointer
}
bitdht {
HEADERS += dht/p3bitdht.h
SOURCES += dht/p3bitdht.cc
BITDHT_DIR = ../../libbitdht/src
INCLUDEPATH += . $${BITDHT_DIR}
}
PUBLIC_HEADERS = rsiface/rsblogs.h \
rsiface/rschannels.h \
@ -210,12 +219,7 @@ HEADERS += dbase/cachestrapper.h \
dbase/findex.h \
dbase/fistore.h
HEADERS += dht/b64.h \
dht/dhtclient.h \
dht/dhthandler.h \
dht/opendht.h \
dht/opendhtmgr.h \
dht/opendhtstr.h
#HEADERS += dht/p3bitdht.h \
HEADERS += ft/ftchunkmap.h \
ft/ftcontroller.h \
@ -345,10 +349,7 @@ SOURCES += dbase/cachestrapper.cc \
dbase/fistore.cc \
dbase/rsexpr.cc
SOURCES += dht/b64.cc \
dht/opendhtmgr.cc \
dht/opendht.cc \
dht/opendhtstr.cc
#SOURCES += dht/p3bitdht.cc \
SOURCES += ft/ftchunkmap.cc \
ft/ftcontroller.cc \

View File

@ -122,5 +122,39 @@ virtual bool addStun(std::string id) = 0;
pqiConnectCb *mConnCb;
};
#if 0
class pqiNetAssistConnectBitDht: public pqiNetAssist
{
/*
*/
public:
pqiNetAssistConnectBitDht(std::string id, pqiConnectCb *cb)
:mPeerId(id), mConnCb(cb) { return; }
/********** External DHT Interface ************************
* These Functions are the external interface
* for the DHT, and must be non-blocking and return quickly
*/
/* add / remove peers */
virtual bool findPeer(std::string id) = 0;
virtual bool dropPeer(std::string id) = 0;
/* extract current peer status */
virtual bool getPeerStatus(std::string id, struct sockaddr_in &raddr,
uint32_t &mode) = 0;
virtual bool getExternalInterface(struct sockaddr_in &raddr,
uint32_t &mode) = 0;
protected:
std::string mPeerId;
pqiConnectCb *mConnCb;
};
#endif
#endif /* MRK_PQI_ASSIST_H */

View File

@ -2000,7 +2000,7 @@ RsTurtle *rsTurtle = NULL ;
#include "util/rsdir.h"
#include "upnp/upnphandler.h"
#include "dht/opendhtmgr.h"
//#include "dht/opendhtmgr.h"
#include "services/p3disc.h"
#include "services/p3msgservice.h"