From cbdd08cd348f323b8a0794968fcefc9c7750b5c8 Mon Sep 17 00:00:00 2001 From: drbob Date: Sun, 31 Oct 2010 18:24:12 +0000 Subject: [PATCH] * Improved udpbitdht tests. * Added Simple example - so others can understand how to interface with bitdht. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3724 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libbitdht/src/example/Makefile | 16 + libbitdht/src/example/bdboot.txt | 500 ++++++++++++ libbitdht/src/example/bdexample.cc | 42 + libbitdht/src/example/bdhandler.cc | 251 ++++++ libbitdht/src/example/bdhandler.h | 71 ++ libbitdht/src/tests/bdboot.txt | 998 +++++++++++------------ libbitdht/src/tests/udpbitdht_nettest.cc | 38 +- 7 files changed, 1401 insertions(+), 515 deletions(-) create mode 100644 libbitdht/src/example/Makefile create mode 100644 libbitdht/src/example/bdboot.txt create mode 100644 libbitdht/src/example/bdexample.cc create mode 100644 libbitdht/src/example/bdhandler.cc create mode 100644 libbitdht/src/example/bdhandler.h diff --git a/libbitdht/src/example/Makefile b/libbitdht/src/example/Makefile new file mode 100644 index 000000000..b71d1f898 --- /dev/null +++ b/libbitdht/src/example/Makefile @@ -0,0 +1,16 @@ + +CXXFLAGS = -Wall -g -I.. +#CXXFLAGS += -arch i386 # OSX + +LIBS = -L../lib -lbitdht + + + +EXEC : bdexample + +EGOBJ = bdhandler.o bdexample.o + +bdexample: $(EGOBJ) + $(CXX) $(CXXFLAGS) -o bdexample $(EGOBJ) $(LIBS) + + diff --git a/libbitdht/src/example/bdboot.txt b/libbitdht/src/example/bdboot.txt new file mode 100644 index 000000000..89f27a247 --- /dev/null +++ b/libbitdht/src/example/bdboot.txt @@ -0,0 +1,500 @@ +64.121.80.63 45642 +84.82.225.139 52002 +200.104.218.244 24447 +116.81.147.106 10014 +76.238.231.136 37770 +68.148.109.134 32815 +78.43.60.243 18973 +62.33.209.243 20600 +84.40.115.5 49669 +93.11.108.82 45078 +90.157.139.222 28487 +79.83.184.114 40139 +109.104.187.16 30000 +87.101.162.223 21364 +99.251.104.111 60382 +130.63.133.216 47451 +64.216.32.37 6881 +75.137.149.242 19860 +208.102.25.182 50675 +75.72.144.15 54485 +68.148.20.202 22025 +69.148.177.153 26961 +121.222.5.240 51932 +88.161.156.9 48251 +88.200.104.216 27784 +109.160.52.2 36630 +74.12.101.58 61864 +174.71.75.121 48749 +186.66.255.5 37580 +24.116.239.194 59147 +95.65.178.164 23715 +220.70.175.83 43726 +182.169.110.245 64684 +119.247.164.154 22132 +77.202.227.150 15621 +79.129.217.171 17248 +98.117.197.195 53478 +71.72.3.201 40665 +72.88.206.217 57170 +95.29.8.61 59559 +142.163.161.23 60957 +70.27.27.105 23047 +90.42.104.194 10595 +114.36.7.29 26051 +78.26.164.132 59437 +70.126.197.41 14207 +187.14.3.249 8753 +62.166.34.78 62133 +82.45.213.218 24740 +213.123.71.145 56050 +93.12.188.2 22070 +203.184.0.161 10295 +69.156.209.139 19165 +83.81.119.121 34439 +109.208.211.98 36278 +84.3.208.199 50001 +85.87.98.187 53911 +93.127.107.157 35691 +188.195.145.172 21827 +184.56.151.190 11951 +98.168.190.247 61279 +83.237.221.242 16613 +75.30.79.175 57107 +90.24.61.26 57262 +125.27.132.48 10018 +94.98.122.161 62266 +81.25.50.209 44962 +94.24.137.191 35691 +74.119.191.181 62498 +46.33.237.37 21135 +183.83.30.78 15822 +109.75.207.23 14085 +92.147.163.123 36706 +110.3.132.18 10149 +90.38.163.86 61080 +77.50.87.114 11399 +76.106.47.230 6881 +24.47.46.185 59822 +118.150.145.87 16553 +98.121.178.252 31353 +95.62.64.40 12174 +85.91.17.78 8644 +98.148.37.251 55774 +122.117.82.108 16293 +200.26.143.117 14013 +187.37.80.22 25095 +95.19.224.225 25446 +79.132.4.131 36094 +109.86.136.248 44281 +85.54.187.59 28890 +99.225.92.6 38080 +178.40.89.75 10018 +189.237.151.135 17643 +189.114.233.119 12308 +93.13.211.51 59788 +80.56.69.253 25685 +83.131.224.235 62622 +201.229.9.69 28159 +201.223.65.4 43804 +77.167.196.115 64788 +71.72.158.196 37961 +86.132.129.242 23071 +93.103.167.242 35298 +212.37.169.128 31631 +74.105.104.186 23922 +173.176.243.27 31393 +86.13.110.77 47020 +76.181.24.116 35553 +94.158.107.234 32516 +99.242.143.80 19034 +201.209.54.201 26726 +109.87.52.11 20186 +98.121.161.117 54068 +75.69.6.91 6881 +98.223.44.215 35998 +123.193.220.215 54157 +95.130.12.23 61546 +84.215.125.229 51413 +77.203.179.13 23145 +217.172.179.78 18692 +85.170.52.161 12310 +98.244.158.38 40311 +71.201.200.183 41435 +99.111.202.61 10341 +84.252.27.201 17253 +210.6.173.193 6887 +74.67.142.125 17874 +94.23.212.70 57174 +77.99.18.29 63852 +91.100.81.198 49999 +82.74.117.94 25000 +78.83.127.162 53345 +95.84.255.201 17122 +85.228.78.9 47500 +217.77.60.189 58847 +67.174.74.95 35000 +95.105.198.233 80 +85.238.105.154 40000 +70.114.173.8 26375 +71.100.182.81 21724 +24.9.187.250 29985 +72.204.16.239 50200 +78.94.104.125 63580 +67.83.132.220 51515 +96.52.145.135 12607 +85.187.24.45 14111 +91.148.128.36 24464 +24.186.53.139 61726 +109.110.3.135 57756 +78.159.108.124 63982 +82.244.72.113 10620 +24.16.216.224 45546 +24.60.118.120 60005 +89.135.149.47 52055 +88.191.117.198 46881 +79.108.19.172 52750 +84.24.37.138 15678 +213.93.83.121 51413 +87.50.207.134 60361 +77.120.182.144 30585 +80.109.42.12 29168 +188.230.38.94 32525 +109.86.246.11 11400 +93.72.108.237 39272 +109.160.201.32 27495 +90.214.93.249 25238 +2.106.159.182 28860 +24.49.43.222 26917 +67.215.242.139 6881 +83.83.52.92 10000 +89.161.85.250 27553 +76.20.230.30 58335 +60.62.38.145 22101 +62.148.159.55 52603 +69.123.52.81 64701 +67.215.242.138 6881 +99.225.194.114 45586 +79.124.27.117 26472 +86.10.209.139 12001 +95.181.30.110 37075 +65.5.225.206 6881 +66.110.140.217 6881 +99.112.96.188 35979 +87.120.113.236 18301 +67.162.118.20 9820 +173.51.87.191 37950 +58.69.218.34 38072 +87.120.78.253 25118 +69.137.192.214 6881 +81.57.50.221 11095 +89.212.93.62 32590 +93.152.176.62 6881 +96.250.206.111 20965 +93.72.132.238 47860 +96.20.161.32 44893 +24.235.41.231 11181 +88.80.49.238 35857 +89.215.103.145 16242 +142.162.65.171 30537 +178.162.184.203 6821 +93.182.0.249 32217 +217.208.59.201 46227 +79.132.182.136 30129 +77.70.96.3 11949 +174.59.144.37 5895 +24.206.168.152 22102 +24.64.233.94 17962 +109.168.162.23 32195 +71.53.119.62 23108 +60.241.156.191 24064 +18.242.7.242 65435 +216.113.97.150 29801 +89.133.173.35 37855 +78.82.124.105 20047 +78.128.57.15 22034 +99.54.50.211 64189 +174.118.36.27 60010 +189.120.102.167 63495 +187.1.109.123 20546 +123.193.205.49 22248 +87.48.15.175 52767 +195.145.124.15 33639 +189.34.175.133 1142 +188.16.249.8 10428 +78.96.153.123 10943 +209.188.19.242 61204 +94.208.99.166 13733 +77.70.32.188 9459 +69.134.71.56 10713 +74.213.69.68 17477 +175.137.140.31 18987 +219.79.191.108 35982 +86.129.7.137 21672 +78.225.25.249 10323 +216.195.251.137 41238 +201.6.19.10 64067 +76.101.164.51 20673 +196.221.130.175 18290 +80.192.63.126 59768 +80.177.109.9 34474 +77.243.211.17 40330 +99.179.5.68 55337 +206.63.116.47 47092 +2.83.53.144 14926 +188.25.174.202 26218 +86.28.149.67 39274 +92.133.136.242 41243 +95.28.8.196 39167 +213.231.136.129 13219 +98.237.145.195 46637 +58.165.71.127 25006 +111.252.45.153 25943 +89.29.15.90 56736 +86.171.44.134 57592 +94.59.26.121 36725 +81.191.88.223 54799 +75.81.195.23 22056 +81.109.38.132 31233 +109.121.220.16 10301 +212.92.246.213 22544 +95.158.10.130 13941 +112.118.166.151 45684 +202.154.59.140 43442 +93.181.215.55 46157 +76.217.106.151 62033 +61.227.125.97 13874 +78.58.201.174 28778 +81.231.229.41 19130 +186.10.23.230 37769 +83.254.77.75 17232 +84.110.59.219 62065 +81.98.22.127 47800 +85.17.5.132 51413 +83.55.120.23 42521 +195.18.28.147 35691 +61.202.78.247 22221 +93.80.153.76 48878 +95.29.196.251 61629 +94.75.148.194 24796 +109.194.167.19 47193 +207.216.26.166 36202 +76.186.158.107 56213 +79.118.112.122 26181 +93.115.48.2 16132 +84.32.80.26 6881 +72.198.44.72 31231 +70.162.57.125 48027 +216.162.201.192 17384 +77.49.95.176 45619 +77.47.185.248 15245 +80.185.186.95 10318 +82.200.130.249 58389 +67.162.140.62 29974 +118.168.172.177 27161 +114.51.38.178 23793 +125.175.146.71 17014 +80.66.213.182 64219 +77.50.234.5 25866 +78.90.218.100 49844 +46.118.135.250 58667 +92.80.58.143 14569 +99.253.186.136 43003 +71.60.40.75 41590 +151.11.145.100 18163 +123.237.49.221 17321 +201.130.198.7 56378 +64.219.119.229 53546 +121.118.219.211 6880 +114.32.171.238 6881 +110.33.112.22 7336 +85.58.8.57 59138 +77.70.70.8 19445 +178.140.72.96 33178 +78.166.69.33 40531 +211.24.149.162 39719 +62.16.162.73 50001 +95.84.244.177 33076 +46.118.71.243 57944 +91.139.194.92 24902 +77.248.205.101 58849 +83.152.236.85 46613 +41.236.189.5 11493 +94.26.63.5 29973 +189.100.145.169 45441 +84.202.146.45 32122 +183.179.108.42 15833 +78.247.112.51 48465 +95.102.42.122 6881 +89.185.199.69 49879 +74.129.254.238 21830 +99.181.161.222 27636 +96.235.14.144 40928 +189.71.180.71 18172 +96.54.129.2 26085 +222.141.53.49 16006 +121.184.217.130 21563 +84.3.111.252 51111 +79.103.174.69 40190 +89.139.35.26 45625 +62.215.144.191 33078 +75.27.19.0 42707 +83.192.127.87 10785 +99.174.215.236 51128 +78.36.180.6 33016 +92.101.222.111 42441 +85.91.17.59 14091 +24.14.120.77 11682 +188.26.55.161 13650 +77.37.133.138 63572 +117.199.5.229 28835 +66.231.126.16 53509 +151.68.147.67 38146 +86.28.168.196 52549 +95.208.206.96 24833 +99.36.177.82 57416 +82.19.43.141 50274 +88.243.226.34 31952 +89.117.4.177 9026 +92.62.81.2 11369 +124.103.179.186 15356 +62.182.72.252 56899 +195.174.137.55 10152 +220.77.252.33 64170 +84.28.164.197 38804 +92.247.230.190 56889 +77.255.188.154 50182 +188.52.90.206 62502 +58.99.68.183 16001 +81.166.131.74 49856 +84.72.160.67 21783 +61.58.164.40 61726 +121.3.76.229 24859 +119.188.12.17 16003 +109.194.148.235 35691 +89.152.22.150 54895 +79.169.181.30 15368 +71.229.7.56 63792 +85.152.185.205 37976 +72.179.54.146 62040 +188.168.19.251 33178 +62.42.136.67 14957 +95.104.224.245 55165 +68.148.68.46 61984 +122.3.9.39 62546 +121.222.50.109 33067 +212.7.27.71 59005 +41.233.123.170 57369 +85.69.170.120 44386 +83.209.26.106 57404 +79.114.213.111 41823 +72.139.120.43 64593 +220.235.102.85 40329 +189.114.35.172 9884 +213.89.205.22 51413 +206.45.53.201 6881 +95.93.140.179 58457 +86.212.236.62 41939 +64.120.217.48 6821 +24.192.141.196 43444 +98.111.205.18 38107 +72.70.248.25 50824 +93.80.95.102 6882 +78.161.215.48 1024 +92.46.27.57 32582 +109.185.14.134 10020 +76.10.184.99 48754 +59.129.24.10 12345 +79.167.72.16 24971 +76.69.58.83 33258 +212.75.11.116 18431 +91.111.73.116 60521 +188.177.32.124 25573 +70.119.124.175 32302 +93.141.74.98 25058 +24.113.236.144 28024 +76.22.33.148 47355 +84.38.176.176 59787 +90.3.48.40 52585 +89.72.89.197 19610 +204.191.41.127 23927 +221.217.45.24 47709 +74.137.200.28 6112 +84.1.255.253 39168 +90.230.207.166 64697 +109.195.179.25 49034 +213.7.173.150 27444 +113.190.35.133 26298 +219.71.14.70 20000 +188.26.238.55 12082 +188.126.90.189 42521 +92.152.222.207 60086 +94.41.126.183 35691 +92.124.18.175 7691 +121.84.53.235 36421 +114.181.232.144 14859 +87.126.166.37 23145 +79.136.38.51 61193 +79.136.29.76 64123 +91.203.188.89 31780 +173.70.56.200 34107 +69.112.65.152 26394 +122.168.6.130 36327 +124.24.226.162 8640 +178.164.171.162 38624 +92.241.245.68 47765 +99.99.66.212 23188 +211.38.161.183 41794 +95.153.168.28 8033 +114.77.55.185 14890 +114.41.140.117 11675 +66.41.250.122 26560 +66.131.96.98 9090 +95.42.148.127 21982 +217.172.183.163 6881 +78.56.249.219 11699 +82.209.126.232 49180 +74.129.176.196 18957 +119.246.185.40 25295 +87.207.245.56 14132 +86.205.109.156 9739 +92.239.247.56 39166 +24.9.173.223 61423 +80.54.16.78 14221 +173.58.23.148 56221 +174.93.222.175 58944 +83.188.251.214 37857 +96.242.15.74 31666 +71.56.126.209 50316 +178.46.224.6 61397 +203.121.129.35 48913 +78.107.255.16 6884 +178.30.150.171 49763 +97.118.36.234 28186 +58.179.125.192 62734 +92.28.78.203 14274 +80.219.210.106 56365 +89.38.197.172 27077 +201.226.156.70 16668 +183.191.171.160 4041 +95.233.192.118 52630 +94.253.81.217 52858 +189.98.226.168 54960 +93.103.210.87 35228 +109.86.255.184 6881 +200.120.232.126 42476 +80.56.123.123 15541 +81.234.102.107 18764 +89.253.109.172 31844 +122.166.49.234 16842 +188.27.102.215 33333 +212.233.236.87 1041 +79.165.176.206 39053 +109.171.12.85 51441 +178.94.111.98 59615 +94.112.39.248 7289 +125.134.85.142 21707 +46.33.245.141 45822 +217.23.176.216 58252 +154.5.172.67 23127 +126.12.49.142 23120 diff --git a/libbitdht/src/example/bdexample.cc b/libbitdht/src/example/bdexample.cc new file mode 100644 index 000000000..0c965eabd --- /dev/null +++ b/libbitdht/src/example/bdexample.cc @@ -0,0 +1,42 @@ + + +#include "bitdht/bdiface.h" +#include "bitdht/bdstddht.h" +#include "bdhandler.h" + +int main(int argc, char **argv) +{ + + /* startup dht : with a random id! */ + bdNodeId ownId; + bdStdRandomNodeId(&ownId); + + uint16_t port = 6775; + std::string appId = "exId"; + std::string bootstrapfile = "bdboot.txt"; + + BitDhtHandler dht(&ownId, port, appId, bootstrapfile); + + /* run your program */ + while(1) + { + bdNodeId searchId; + bdStdRandomNodeId(&searchId); + + dht.FindNode(&searchId); + + sleep(180); + + dht.DropNode(&searchId); + } + + return 1; +} + + + + + + + + diff --git a/libbitdht/src/example/bdhandler.cc b/libbitdht/src/example/bdhandler.cc new file mode 100644 index 000000000..b5f558650 --- /dev/null +++ b/libbitdht/src/example/bdhandler.cc @@ -0,0 +1,251 @@ +/* + * libretroshare/src/dht: bdhandler.h + * + * BitDht example interface + * + * 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 +#include +#include + +#include "bdhandler.h" + +/* This is a conversion callback class + */ + +class BdCallback: public BitDhtCallback +{ + public: + + BdCallback(BitDhtHandler *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: + + BitDhtHandler *mParent; +}; + + +BitDhtHandler::BitDhtHandler(bdNodeId *ownId, uint16_t port, std::string appId, std::string bootstrapfile) +{ + std::cerr << "BitDhtHandler::BitDhtHandler()" << std::endl; + std::cerr << "Using Id: "; + bdStdPrintNodeId(std::cerr, ownId); + std::cerr << std::endl; + + std::cerr << "Using Bootstrap File: " << bootstrapfile; + std::cerr << std::endl; + std::cerr << "Converting OwnId to bdNodeId...."; + std::cerr << std::endl; + + /* standard dht behaviour */ + bdDhtFunctions *stdfns = new bdStdDht(); + + std::cerr << "BitDhtHandler() startup ... creating UdpBitDht"; + std::cerr << std::endl; + + /* create dht */ + struct sockaddr_in local; + memset(&local, 0, sizeof(local)); + local.sin_family = AF_INET; + local.sin_addr.s_addr = 0; + local.sin_port = htons(port); + + mStack = new UdpStack(local); + + mUdpBitDht = new UdpBitDht(mStack, ownId, appId, bootstrapfile, stdfns); + mStack->addReceiver(mUdpBitDht); + + /* setup callback to here */ + BdCallback *bdcb = new BdCallback(this); + mUdpBitDht->addCallback(bdcb); + + std::cerr << "BitDhtHandler() starting threads and dht"; + std::cerr << std::endl; + + mUdpBitDht->start(); /* starts up the bitdht thread */ + + /* switch on the dht too */ + mUdpBitDht->startDht(); +} + + /* pqiNetAssist - external interface functions */ +void BitDhtHandler::enable(bool on) +{ + std::cerr << "p3BitDht::enable(" << on << ")"; + std::cerr << std::endl; + if (on) + { + mUdpBitDht->startDht(); + } + else + { + mUdpBitDht->stopDht(); + } +} + +void BitDhtHandler::shutdown() /* blocking call */ +{ + mUdpBitDht->stopDht(); +} + + +void BitDhtHandler::restart() +{ + mUdpBitDht->stopDht(); + mUdpBitDht->startDht(); +} + +bool BitDhtHandler::getEnabled() +{ + return (mUdpBitDht->stateDht() != 0); +} + +bool BitDhtHandler::getActive() +{ + return (mUdpBitDht->stateDht() >= BITDHT_MGR_STATE_ACTIVE); +} + + + + + /* pqiNetAssistConnect - external interface functions */ + /* add / remove peers */ +bool BitDhtHandler::FindNode(bdNodeId *peerId) +{ + std::cerr << "BitDhtHandler::FindNode("; + bdStdPrintNodeId(std::cerr, peerId); + std::cerr << ")" << std::endl; + + /* add in peer */ + mUdpBitDht->addFindNode(peerId, BITDHT_QFLAGS_DO_IDLE); + + return true ; +} + +bool BitDhtHandler::DropNode(bdNodeId *peerId) +{ + std::cerr << "BitDhtHandler::DropNode("; + bdStdPrintNodeId(std::cerr, peerId); + std::cerr << ")" << std::endl; + std::cerr << std::endl; + + /* remove in peer */ + mUdpBitDht->removeFindNode(peerId); + + return true ; +} + + + +/********************** Callback Functions **************************/ + +int BitDhtHandler::NodeCallback(const bdId *id, uint32_t peerflags) +{ +#ifdef DEBUG_BITDHT + std::cerr << "BitDhtHandler::NodeCallback()"; + bdStdPrintNodeId(std::cerr, &(id->id)); + std::cerr << " flags: " << peerflags; + std::cerr << std::endl; +#endif + + return 0; +} + +int BitDhtHandler::PeerCallback(const bdNodeId *id, uint32_t status) +{ + std::cerr << "BitDhtHandler::PeerCallback() NodeId: "; + bdStdPrintNodeId(std::cerr, id); + std::cerr << std::endl; + + bool connect = false; + switch(status) + { + case BITDHT_MGR_QUERY_FAILURE: + /* do nothing */ + std::cerr << "BitDhtHandler::PeerCallback() QUERY FAILURE ... do nothin "; + std::cerr << std::endl; + + break; + + case BITDHT_MGR_QUERY_PEER_OFFLINE: + /* do nothing */ + + std::cerr << "BitDhtHandler::PeerCallback() QUERY PEER OFFLINE ... do nothin "; + std::cerr << std::endl; + + break; + + case BITDHT_MGR_QUERY_PEER_UNREACHABLE: + /* do nothing */ + + std::cerr << "BitDhtHandler::PeerCallback() QUERY PEER UNREACHABLE ... flag? / do nothin "; + std::cerr << std::endl; + + + break; + + case BITDHT_MGR_QUERY_PEER_ONLINE: + /* do something */ + + std::cerr << "BitDhtHandler::PeerCallback() QUERY PEER ONLINE ... try udp connection"; + std::cerr << std::endl; + + connect = true; + break; + } + return 1; +} + + + +int BitDhtHandler::ValueCallback(const bdNodeId *id, std::string key, uint32_t status) +{ + std::cerr << "BitDhtHandler::ValueCallback() NOOP for NOW"; + std::cerr << std::endl; + + std::cerr << "BitDhtHandler::ValueCallback()"; + bdStdPrintNodeId(std::cerr, id); + std::cerr << " key: " << key; + std::cerr << " status: " << status; + std::cerr << std::endl; + + /* ignore for now */ + return 0; +} + diff --git a/libbitdht/src/example/bdhandler.h b/libbitdht/src/example/bdhandler.h new file mode 100644 index 000000000..88ef8bbee --- /dev/null +++ b/libbitdht/src/example/bdhandler.h @@ -0,0 +1,71 @@ +/* + * libbitdht/src/example/bdhandler.h + * + * BitDht interface example + * + * 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 "bitdht@lunamutt.com". + * + */ + + +#ifndef BITDHT_HANDLER_H +#define BITDHT_HANDLER_H + +#include +#include + +#include "udp/udpstack.h" +#include "udp/udpbitdht.h" +#include "bitdht/bdiface.h" + +/*** This class can be overloaded to use the XXXXCallback() Functions *****/ +class BitDhtIntCallback; + +class BitDhtHandler +{ + + public: + + BitDhtHandler(bdNodeId *ownId, uint16_t port, std::string appId, std::string bootstrapfile); + +void enable(bool on); +void shutdown(); /* blocking call */ +void restart(); + +bool getEnabled(); +bool getActive(); + +bool FindNode(bdNodeId *peerId); +bool DropNode(bdNodeId *peerId); + +virtual int NodeCallback(const bdId *id, uint32_t peerflags); +virtual int PeerCallback(const bdNodeId *id, uint32_t status); +virtual int ValueCallback(const bdNodeId *id, std::string key, uint32_t status); + + private: + + /* real DHT classes */ + UdpStack *mStack; + UdpBitDht *mUdpBitDht; + +}; + + +#endif /* BITDHT_HANDLER_H */ + diff --git a/libbitdht/src/tests/bdboot.txt b/libbitdht/src/tests/bdboot.txt index d8d0aed26..8869d39f6 100644 --- a/libbitdht/src/tests/bdboot.txt +++ b/libbitdht/src/tests/bdboot.txt @@ -1,500 +1,500 @@ -117.207.214.217 54937 -86.110.176.106 30000 -220.134.120.229 6881 -41.228.251.92 47814 -78.62.131.230 50104 -24.150.5.250 51413 -76.110.187.39 14164 -65.184.131.218 6881 -111.119.246.115 22046 -68.96.113.203 14608 -85.99.200.222 27808 -184.56.211.105 52867 -66.31.185.120 10317 -218.145.169.134 3149 -219.161.251.38 31529 -99.101.221.11 11764 -109.192.73.224 52318 -98.242.28.163 26145 -188.81.211.246 8080 -80.254.125.140 34296 -64.53.28.136 10809 -67.149.152.217 41077 -91.86.3.133 32176 -95.221.19.39 12976 -83.83.80.92 6881 -87.252.162.190 56515 -151.66.131.139 46954 -78.58.202.177 59464 -71.199.157.116 30520 -96.254.62.199 8200 -24.14.102.44 44245 -70.127.115.202 38183 -99.189.18.223 41292 -213.213.218.65 60981 -190.50.213.190 36891 -118.171.47.177 16001 -119.83.243.224 16654 -113.190.134.153 20216 -114.42.139.73 16001 -182.88.142.211 37365 -119.6.28.67 18045 -85.241.136.42 60048 -68.40.16.60 11232 -212.122.106.140 31783 -109.173.59.147 12962 -95.27.70.32 35054 -77.37.202.193 36299 -178.82.201.203 12055 -109.161.85.240 44209 -94.24.232.164 1500 -75.73.169.64 22011 -90.142.147.91 51488 -76.92.206.199 14832 -99.57.74.12 50424 -173.60.116.127 55492 -99.90.234.80 54989 -99.192.38.145 50847 -85.240.71.5 32193 -98.219.151.25 33246 -81.236.226.106 6882 -89.88.117.136 50637 -91.117.62.76 34004 -99.230.133.39 9536 -74.69.217.130 36242 -86.23.42.71 50946 -66.249.57.76 57217 -210.89.51.164 52413 -76.226.51.91 12663 -24.64.83.1 45429 -117.198.144.222 21855 -64.166.166.167 22837 -91.202.9.75 35691 -24.158.190.101 30993 -124.144.30.72 34172 -98.220.212.46 13972 -221.86.239.1 11798 -68.190.208.15 50557 -68.203.251.86 18992 -178.92.94.213 56595 -89.212.178.131 64999 -178.140.66.146 47690 -212.2.140.47 35691 -93.100.231.80 33103 -95.25.141.71 60569 -109.87.58.45 36303 -46.0.141.155 11396 -87.97.230.29 21009 -119.56.32.42 32382 -92.124.53.28 46108 -89.134.67.24 14172 -114.38.122.171 40232 -114.41.85.198 59723 -122.148.239.163 6881 -112.205.134.194 55288 -78.147.163.160 14027 -122.104.168.226 13618 -138.217.156.134 63770 -117.254.208.18 40438 -75.3.113.99 6881 -84.29.97.213 15577 -91.211.83.75 61617 -93.2.244.233 43565 -86.139.36.0 12037 -87.59.181.239 62153 -174.112.6.77 6881 -24.60.73.227 45502 -69.137.165.233 6881 -76.30.10.86 6881 -24.79.144.209 34882 -84.127.134.131 25717 -98.193.20.11 58714 -95.165.18.201 17170 -189.12.171.99 13596 -94.128.46.21 8827 -60.34.66.88 25136 -95.130.12.19 61050 -77.250.121.26 51413 -77.70.21.207 64309 -213.133.98.4 6881 -69.137.229.111 8500 -109.184.173.10 10058 -65.6.149.143 63622 -82.194.190.194 36219 -59.99.200.15 50007 -98.180.221.118 37950 -111.243.51.215 17517 -125.27.60.193 55555 -85.142.208.26 18256 -87.120.157.123 6073 -90.155.192.228 59169 -91.103.205.231 30573 -85.12.239.118 64317 -174.64.9.192 25397 -78.100.208.205 39074 -66.229.163.248 41546 -123.204.158.238 6881 -94.6.215.232 35125 -120.144.133.123 41889 -203.218.92.102 13383 -111.250.205.16 16001 -91.179.186.59 12654 -84.234.241.206 62793 -84.211.40.116 26202 -213.66.1.88 31701 -109.93.197.4 15932 -84.238.182.126 18755 -86.107.219.33 29748 -94.251.22.96 6890 -94.28.27.245 10249 -88.167.63.173 17155 -95.160.98.229 19948 -76.230.136.237 51413 -88.160.107.217 33383 -75.1.151.129 42526 -80.99.198.116 51819 -175.144.252.191 1722 -67.140.208.226 44078 -118.157.66.146 15267 -88.89.93.181 6881 -188.195.214.69 9089 -90.214.16.2 10050 -24.47.133.24 27457 -88.186.78.58 53354 -178.128.240.54 33591 +93.113.253.235 10351 +109.195.26.63 35691 +78.84.189.238 16105 +93.149.194.159 10006 +142.165.155.66 54333 +87.2.252.141 32523 +86.28.119.162 65393 +75.141.203.120 9269 +61.219.92.157 26309 +113.197.131.184 39390 +61.202.78.247 22221 +99.192.87.181 63645 +186.14.24.166 53495 +90.191.162.101 56943 +75.9.79.58 49173 +189.79.164.180 51916 +188.2.188.200 15904 +216.137.107.5 42096 +119.82.197.117 14165 +93.142.184.229 30804 +81.230.155.227 49912 +78.3.22.204 12176 +70.53.218.176 48079 +99.138.101.252 45682 +109.96.227.190 17059 +71.72.158.196 37961 +92.80.210.120 10000 +91.146.132.224 12566 +81.182.99.86 58659 +83.217.46.30 59184 +118.173.96.14 15000 +41.107.83.159 10000 +80.189.136.230 51692 +212.142.83.32 48265 +194.220.84.244 22464 +79.219.206.130 57803 +94.179.29.137 9371 +86.132.129.242 23071 +92.101.129.144 59039 +113.77.164.93 31872 +114.149.135.219 7128 +178.90.5.139 14054 +85.67.83.55 18671 +77.121.45.122 26731 +84.202.51.66 52591 +80.9.93.215 16504 +83.82.128.46 62372 +178.167.21.234 6881 +82.243.15.108 64162 +89.241.183.88 11887 +187.1.109.123 20546 +76.104.157.104 13313 +121.190.21.7 23585 +111.184.60.209 8473 +175.137.141.17 4841 +114.47.124.155 16001 +190.9.80.109 60921 +78.53.157.19 61597 +82.22.73.207 39714 +94.227.124.236 51413 +93.86.121.17 23491 +78.8.127.204 49158 +173.21.246.1 28175 +74.105.104.186 23922 +93.106.78.26 62241 +95.52.220.221 46873 +46.41.99.164 41403 +90.3.189.132 27532 +95.24.191.34 37686 +94.158.206.37 47733 +24.192.141.196 43444 +88.114.60.226 14701 +190.233.28.216 10035 +187.59.104.184 38406 +88.241.54.177 6881 +75.169.41.44 23921 +212.231.219.123 30749 +95.111.59.146 31360 +117.20.185.249 34787 +184.15.43.192 25872 +41.236.143.104 18254 +212.37.169.128 31631 +93.103.167.242 35298 +95.208.34.13 28134 +81.184.29.241 60338 +173.176.243.27 31393 +200.30.215.247 53196 +95.27.138.236 32373 +78.181.51.1 56672 +69.113.118.17 43710 +118.15.159.47 14924 +219.78.37.4 17323 +79.179.35.221 8080 +41.233.232.153 28027 +2.40.81.5 39425 +76.181.24.116 35553 +183.37.193.84 21819 +188.2.108.62 62838 +188.2.182.88 12877 +93.150.26.240 19076 +78.60.165.96 46785 +99.242.143.80 19034 +190.166.108.145 57967 +90.15.142.10 20380 +212.139.216.168 28287 +79.173.18.85 16234 +109.122.6.119 35077 +95.70.76.28 39132 +178.206.42.99 35691 +189.110.158.105 52423 +112.195.15.4 1083 +219.79.127.226 20579 +194.102.155.85 30332 +94.158.107.234 32516 +144.85.198.132 55745 +220.132.140.86 16001 +92.14.78.83 15294 +92.147.31.42 14099 +86.13.110.77 47020 +95.8.170.249 34481 +178.166.138.75 33347 +117.195.196.154 53480 +189.159.45.177 27778 +99.228.167.174 18537 +60.34.32.239 64398 +71.103.193.176 50913 +213.156.101.150 47078 +95.72.233.199 13299 +70.70.161.4 37542 +89.252.11.169 39924 +94.21.150.86 20004 +90.206.166.236 30055 +92.45.198.23 56969 +71.190.128.27 8181 +201.209.54.201 26726 +201.254.175.141 1052 +86.22.154.1 34153 +202.212.230.225 62582 +217.210.126.55 6881 +92.242.118.12 59741 +195.18.28.147 35691 +77.105.61.152 10003 +90.157.174.67 64061 +109.184.242.18 19268 +97.95.66.89 37027 +109.212.41.127 46365 +204.182.12.51 56654 +186.205.50.126 54325 +119.247.252.118 13277 +118.20.246.94 7113 +116.3.57.205 19699 +189.101.77.13 52448 +89.178.80.137 40431 +75.69.6.91 6881 +98.121.161.117 54068 +69.153.56.74 13496 +78.62.118.16 47252 +79.46.255.126 26751 +122.169.170.101 10028 +123.193.220.215 54157 +218.218.128.104 49963 +219.106.122.171 55959 +112.210.235.218 27157 +90.60.172.96 6881 +92.17.64.55 10008 +98.223.44.215 35998 +190.28.95.226 41411 +186.206.12.110 9037 +90.218.16.149 40972 +109.87.52.11 20186 +77.101.143.17 37570 +82.34.77.180 41818 +94.41.21.214 36939 +85.127.34.173 10085 +83.4.7.35 19276 +91.200.254.202 12737 +87.121.66.246 12420 +81.198.26.183 39568 +92.132.93.148 23722 +91.77.94.227 14372 +206.45.53.201 6881 +74.95.222.53 60733 +72.19.62.187 21338 +71.201.200.183 41435 +24.98.172.105 61382 +78.92.152.60 12365 +93.87.252.82 21564 +61.228.64.67 38444 +219.79.74.97 43357 +118.173.119.134 10993 +123.254.183.208 36587 +99.111.202.61 10341 +94.194.87.1 31169 +93.23.174.188 39415 +78.70.152.38 30356 +94.251.17.152 35691 +67.175.189.15 16703 +109.242.224.50 45107 +86.196.29.237 28767 +84.252.27.201 17253 +70.162.57.125 48027 +210.6.173.193 6886 +210.6.173.193 6887 +110.132.207.153 29959 +94.25.171.229 40703 +178.53.139.9 13328 +85.170.52.161 12310 +85.17.5.132 51413 +95.130.12.23 61546 +87.106.18.80 21060 +85.69.170.120 44386 +77.203.179.13 23145 +86.125.150.25 59847 +82.130.251.32 54834 +83.139.173.200 56953 +87.11.51.210 8500 +85.70.116.131 19860 +98.244.158.38 40311 +98.143.96.103 21711 +84.215.125.229 51413 +217.172.179.78 18692 +74.67.142.125 17874 +98.195.197.177 32346 +207.216.26.166 36202 +76.29.22.154 37778 +114.220.155.188 7576 +109.8.31.209 16726 +71.100.182.81 21724 +58.85.55.238 14725 +67.174.74.95 35000 +99.194.168.253 29358 +85.228.78.9 47500 +71.187.90.32 50260 +216.113.97.150 29801 +85.49.133.208 27989 +94.208.99.166 13733 +78.83.127.162 53345 +91.121.174.148 55690 +94.3.214.214 56319 +94.23.212.70 57174 +85.217.136.179 47053 +78.94.104.125 63580 +95.105.198.233 80 +95.84.255.201 17122 +91.100.81.198 49999 +78.90.128.10 52518 +95.26.156.134 19486 +82.232.104.187 16807 +79.101.213.250 13121 +75.118.101.142 30141 +93.89.209.227 19280 +82.7.214.190 21876 +217.168.214.39 19766 +70.114.173.8 26375 +72.204.16.239 50200 +24.9.187.250 29985 +76.16.32.242 16278 +74.79.89.24 11697 +200.158.63.125 39637 +82.74.116.4 17223 +96.52.145.135 12607 +77.99.18.29 63852 +217.77.60.189 58847 +82.74.117.94 25000 +85.238.105.154 40000 +67.83.132.220 51515 +82.237.186.158 6881 +188.187.172.48 63699 +90.192.99.87 19903 +74.162.128.111 65432 +109.184.8.183 64619 +77.198.210.34 58320 +89.90.170.230 23442 +97.100.136.205 25942 +98.119.32.149 13434 +68.51.90.191 16878 +142.167.52.20 42904 +118.5.144.222 45043 +98.149.14.52 26659 +79.108.19.172 52750 +79.115.9.172 63866 +79.168.88.72 12883 +91.148.128.36 24464 +85.187.24.45 14111 +82.240.100.118 19906 +89.135.149.47 52055 +71.185.134.201 50771 +77.78.178.156 60852 +24.186.53.139 61726 +74.140.96.199 19420 +109.110.3.135 57756 +24.16.216.224 45546 +85.132.109.108 21838 +118.101.115.37 10395 +24.102.8.251 34774 +85.247.82.191 6882 +59.113.66.184 8473 +220.61.29.35 32776 +82.244.72.113 10620 +124.144.11.76 26144 +59.100.97.236 421 +115.166.24.156 21109 +188.36.71.13 45750 +95.37.35.103 6881 +78.159.108.124 63982 +81.166.43.192 48429 +85.222.55.113 51409 +62.80.183.225 26033 +84.85.23.152 56471 +86.165.244.171 6881 +90.157.165.36 1046 +84.61.147.98 6889 +81.154.201.146 45682 +24.60.118.120 60005 +24.61.141.82 60919 +2.106.159.182 28860 +78.57.176.166 33061 +87.1.182.97 48031 +84.3.249.76 11353 +87.120.64.46 25428 +88.181.152.48 44330 +109.160.201.32 27495 +188.230.38.94 32525 +90.214.93.249 25238 +84.249.175.45 34904 +114.45.181.114 61860 +69.176.179.196 53579 +220.210.178.105 37492 +213.93.83.121 51413 +88.191.117.198 46881 +212.233.241.25 20164 +96.38.226.139 47850 +77.120.182.144 30585 +82.228.54.32 32492 +92.138.66.102 17105 +95.158.179.229 13684 +77.70.20.90 17610 +87.203.114.107 39136 +85.113.48.19 6881 +174.51.65.149 46912 67.215.242.139 6881 -79.110.118.172 17827 -85.17.74.169 6881 -190.150.26.121 23765 -189.5.90.211 16422 -71.110.78.125 50924 -112.104.174.102 25693 -222.145.168.62 64457 -125.25.169.12 46286 -79.84.4.144 16887 -95.52.76.243 27570 -151.32.158.158 10464 -189.4.13.169 60285 -70.189.217.212 39037 -119.117.135.178 13778 -85.24.236.236 60224 -77.110.26.188 19101 -90.199.170.34 10491 -212.187.127.4 42544 -213.167.146.216 62238 -24.36.225.41 13970 -88.162.153.3 45698 -67.167.185.252 36758 -119.234.57.170 42523 -118.93.145.87 27871 -118.19.235.114 22136 -124.244.75.29 50766 -114.26.158.95 20185 -143.238.237.25 14151 -2.85.8.6 53180 -112.105.159.195 21721 -77.249.209.133 41620 -109.230.14.32 30747 -86.101.42.86 27426 -213.149.144.24 23206 -85.226.150.37 17020 -95.42.53.21 50840 -91.146.51.190 52891 -79.139.234.104 16939 -93.0.225.253 15592 -98.254.244.165 56359 -114.44.224.46 24232 -60.50.37.37 63880 -119.56.90.14 6884 -222.134.253.50 25460 -200.82.124.226 11216 -86.124.181.25 41812 -151.71.224.236 26022 -78.128.123.63 22260 -79.44.193.147 46988 -81.88.124.26 25171 -92.140.191.170 10583 -74.192.41.234 12306 -24.11.0.152 6881 -98.162.214.118 6881 -76.112.183.73 16254 -217.217.35.121 32001 -67.175.133.224 32772 -78.36.196.61 59269 -76.234.70.144 63498 -118.165.101.148 25966 -78.29.72.239 10169 -88.203.69.43 20846 -85.230.126.66 59655 -114.33.208.192 6881 -213.137.40.155 28447 -79.40.28.4 22978 -85.220.113.75 44116 -2.85.54.157 26621 -92.82.169.146 10122 -24.191.39.52 13692 -24.92.85.17 41738 -222.164.18.139 6881 -59.156.223.119 58460 -201.24.51.203 18936 -210.207.227.15 54112 -220.135.104.71 6885 -111.166.209.176 16001 -120.83.182.73 44755 -203.219.45.127 56366 -92.27.98.236 42249 -213.107.103.7 26498 -87.194.35.172 19102 -85.155.45.17 26814 -80.190.139.91 6895 -80.202.98.113 24874 -95.143.217.5 26620 -87.121.131.142 18291 -68.37.105.85 18621 -76.125.40.83 36132 -76.83.2.223 51867 -82.130.145.80 10145 -116.49.130.251 42663 -219.95.36.65 22024 -93.138.138.25 36193 -125.198.109.94 25391 -118.166.52.195 7613 -125.214.154.196 14295 -189.93.138.193 30752 -212.116.83.37 48862 -89.178.0.217 51413 -95.95.243.42 63297 -92.63.29.186 35073 -213.100.103.111 59606 -212.40.113.62 19734 -71.206.232.202 46400 -70.119.92.84 32082 -78.101.105.86 17183 -173.58.66.221 26774 -94.28.105.90 37707 -86.26.47.187 20295 -70.52.182.161 20499 -95.111.185.235 48104 -122.94.252.223 21574 -113.20.82.4 11560 -1.23.143.146 24679 -114.40.118.14 21330 -85.181.59.132 34288 -118.154.53.162 16234 -109.174.68.4 51490 -109.201.74.210 20655 -75.62.19.231 37592 -97.85.74.36 14594 -83.233.120.5 51800 -64.231.15.87 45129 -24.85.138.161 26724 -147.32.8.69 6881 -88.216.128.98 32122 -142.167.5.37 29661 -68.4.207.220 63881 -98.237.164.36 52796 -99.109.20.192 16385 -91.105.126.138 33105 -111.255.46.225 26839 -85.10.3.55 58402 -123.243.29.227 37451 -94.153.114.233 34599 -94.75.136.162 31042 -112.204.106.67 48691 -217.120.148.194 51615 -109.121.134.46 64548 -178.150.86.230 63371 -188.153.7.124 29949 -2.55.82.43 18407 -95.58.44.125 11121 -116.74.115.65 32886 -83.131.71.123 39603 -99.148.166.253 49200 -99.179.93.192 26004 -117.200.32.60 33696 -190.193.153.225 26735 -68.103.246.183 62692 -92.23.100.103 20962 -82.48.131.139 6881 -96.50.99.76 40637 -183.83.0.210 55716 -94.156.160.208 1296 -99.240.114.49 60001 -123.238.20.56 11495 -98.164.225.18 51413 -83.248.115.125 48880 -77.50.124.217 45561 -195.13.160.107 40473 -91.185.36.137 16415 -68.189.164.175 35316 -90.163.159.154 48436 -124.8.223.66 16880 -24.161.134.16 23585 -72.12.147.238 48200 -77.99.163.56 14408 -79.165.239.5 41714 -95.34.50.159 33001 -92.150.184.16 57367 -76.120.195.253 52729 -87.238.1.77 20617 -115.134.213.88 22989 -94.59.123.17 45340 -189.6.134.85 16228 -201.198.78.18 24646 -82.244.111.116 50102 -78.159.163.4 16880 -203.214.42.15 35239 -142.177.246.150 41881 -220.253.180.201 51413 -86.16.190.229 51413 -81.89.106.209 51413 -88.207.84.240 34723 -79.108.206.28 16866 -193.11.162.109 40000 -88.222.107.185 23367 -85.73.84.231 52545 -81.249.93.113 53727 -69.119.12.235 16181 -94.97.7.171 21608 -88.194.178.213 36956 -83.10.93.128 17371 -121.166.23.3 19226 -85.136.235.241 10889 -219.69.115.178 21604 -220.136.219.134 19860 -112.118.91.195 25949 -189.74.105.192 1730 -72.53.76.39 55501 -213.64.51.135 35114 -74.105.9.97 62498 -79.56.233.96 37086 -95.84.0.84 20090 -70.75.213.15 20077 -24.21.100.94 28550 -208.118.23.71 56690 -88.109.14.155 34392 -189.236.5.200 26306 -80.184.65.55 12052 -90.151.185.253 49653 -140.136.239.153 51413 -119.77.220.96 22438 -75.11.180.71 21205 -114.76.81.8 20869 -93.81.137.222 59627 -99.249.255.103 21609 -82.207.43.123 12452 -94.72.123.6 16660 -67.168.18.61 46759 -216.8.170.95 44302 -95.59.128.199 30499 -190.159.56.248 60787 -24.15.32.32 32241 -114.249.142.149 23363 -78.86.71.118 23744 -89.160.3.33 10132 -89.152.240.196 32504 -94.244.172.119 28248 -95.245.89.123 7881 -88.87.1.254 20493 -195.182.132.66 64356 -94.64.144.11 7110 -99.240.139.107 6881 -71.91.56.80 19492 -82.245.161.72 29889 -41.201.68.118 15497 -119.239.155.80 55121 -200.104.77.39 15443 -201.34.97.64 61884 -121.221.223.224 12114 -123.192.140.58 17701 -158.193.168.5 21798 -78.86.111.253 23576 -88.106.167.216 28781 -188.94.39.175 15010 -213.111.238.195 56312 -78.56.7.200 21846 -94.41.112.123 23918 -85.117.33.27 19637 -209.20.68.239 62368 -190.11.108.123 35985 -89.34.34.249 24474 -89.79.136.193 51413 -95.27.123.195 34348 -87.126.188.76 25422 -195.214.237.249 15300 -80.80.116.100 55993 -180.2.23.99 24383 -76.27.231.95 11423 -188.51.83.143 56717 -92.47.229.200 10385 -210.6.213.167 26301 -112.119.40.105 62294 -24.108.1.66 63373 -184.36.90.143 37107 -182.48.202.118 28011 -114.26.162.140 24871 -67.149.182.183 17372 -220.255.183.95 10793 -89.243.44.234 23297 -118.173.35.219 19018 -124.13.140.102 38007 -112.118.43.128 27673 -188.87.87.100 45595 -173.33.201.88 34218 -184.91.39.18 20931 -208.103.246.149 61903 -114.41.224.18 19562 -91.121.177.18 53140 -178.94.155.182 60556 -211.74.67.111 14181 -199.74.97.182 29255 -94.9.44.224 52476 -189.91.127.145 20801 -109.87.34.215 51413 -82.69.1.251 5001 -125.3.4.166 51187 -69.203.68.51 11758 -96.22.31.154 43510 -174.65.137.136 48100 -190.228.94.165 26710 -187.104.62.61 19789 -188.82.144.27 52696 -219.237.1.104 52827 -82.1.75.63 13312 -83.94.240.45 30864 -87.89.12.207 37559 -59.101.167.84 20459 -203.217.50.120 56814 -219.79.49.98 23007 -221.140.188.163 58808 -24.87.209.90 9344 -82.40.248.27 16676 -99.32.75.52 14690 -220.137.140.31 26831 -83.9.219.77 48034 -79.97.250.119 19888 -212.142.76.123 53413 -94.180.157.168 35124 -216.245.196.72 54821 -116.72.169.167 14492 -189.47.125.243 36874 -94.112.8.99 29633 -117.207.235.231 25849 -173.183.106.57 58370 -95.93.136.147 21175 -99.247.172.168 22177 -77.95.59.144 34007 -111.167.216.189 6881 -95.77.154.219 27317 -71.7.161.68 12588 -115.164.135.201 56196 -122.100.221.107 24300 -213.60.104.227 22642 -113.151.72.159 16352 -218.103.176.234 10519 -88.247.49.186 11074 -83.6.190.105 26554 -76.181.160.45 23986 -216.252.75.148 51413 -88.162.86.247 8444 -89.215.27.13 9200 +99.111.240.83 54548 +24.54.1.238 60738 +65.13.127.70 56958 +83.83.52.92 10000 +60.62.38.145 22101 +61.22.93.23 35048 +58.152.160.161 51954 +121.7.94.125 23766 +89.161.85.250 27553 +84.24.37.138 15678 +80.109.42.12 29168 +87.50.207.134 60361 +93.72.108.237 39272 +91.117.209.44 17063 +109.86.246.11 11400 +24.49.43.222 26917 +64.121.80.63 45642 +76.20.230.30 58335 +86.10.209.139 12001 +67.215.242.138 6881 +87.120.78.253 25118 +84.82.225.139 52002 +200.104.218.244 24447 +116.81.147.106 10014 +76.238.231.136 37770 +68.148.109.134 32815 +78.43.60.243 18973 +62.33.209.243 20600 +84.40.115.5 49669 +93.11.108.82 45078 +90.157.139.222 28487 +79.124.27.117 26472 +99.225.194.114 45586 +79.83.184.114 40139 +109.104.187.16 30000 +87.101.162.223 21364 +99.251.104.111 60382 +130.63.133.216 47451 +66.110.140.217 6881 +87.120.113.236 18301 +64.216.32.37 6881 +75.137.149.242 19860 +69.137.192.214 6881 +208.102.25.182 50675 +173.51.87.191 37950 +75.72.144.15 54485 +68.148.20.202 22025 +99.112.96.188 35979 +67.162.118.20 9820 +69.148.177.153 26961 +58.69.218.34 38072 +121.222.5.240 51932 +88.161.156.9 48251 +88.200.104.216 27784 +62.148.159.55 52603 +109.160.52.2 36630 +69.123.52.81 64701 +95.181.30.110 37075 +65.5.225.206 6881 +74.12.101.58 61864 +174.71.75.121 48749 +186.66.255.5 37580 +24.116.239.194 59147 +95.65.178.164 23715 +220.70.175.83 43726 +182.169.110.245 64684 +122.166.49.234 16842 +119.247.164.154 22132 +77.202.227.150 15621 +79.129.217.171 17248 +88.80.49.238 35857 +96.250.206.111 20965 +98.117.197.195 53478 +81.57.50.221 11095 +71.72.3.201 40665 +72.88.206.217 57170 +95.29.8.61 59559 +24.235.41.231 11181 +142.163.161.23 60957 +70.27.27.105 23047 +90.42.104.194 10595 +114.36.7.29 26051 +78.26.164.132 59437 +70.126.197.41 14207 +142.162.65.171 30537 +187.14.3.249 8753 +62.166.34.78 62133 +82.45.213.218 24740 +213.123.71.145 56050 +93.12.188.2 22070 +203.184.0.161 10295 +93.152.176.62 6881 +69.156.209.139 19165 +96.20.161.32 44893 +83.81.119.121 34439 +109.208.211.98 36278 +154.5.172.67 23127 +93.72.132.238 47860 +89.215.103.145 16242 +89.212.93.62 32590 +84.3.208.199 50001 +85.87.98.187 53911 +93.127.107.157 35691 +188.195.145.172 21827 +184.56.151.190 11951 +98.168.190.247 61279 +83.237.221.242 16613 +75.30.79.175 57107 +90.24.61.26 57262 +125.27.132.48 10018 +94.98.122.161 62266 +178.162.184.203 6821 +93.182.0.249 32217 +81.25.50.209 44962 +94.24.137.191 35691 +78.82.124.105 20047 +71.53.119.62 23108 +74.119.191.181 62498 +46.33.237.37 21135 +183.83.30.78 15822 +109.75.207.23 14085 +92.147.163.123 36706 +110.3.132.18 10149 +90.38.163.86 61080 +89.133.173.35 37855 +77.50.87.114 11399 +76.106.47.230 6881 +24.206.168.152 22102 +24.47.46.185 59822 +60.241.156.191 24064 +118.150.145.87 16553 +98.121.178.252 31353 +24.64.233.94 17962 +95.62.64.40 12174 +85.91.17.78 8644 +98.148.37.251 55774 +122.117.82.108 16293 +200.26.143.117 14013 +187.37.80.22 25095 +95.19.224.225 25446 +79.132.4.131 36094 +217.208.59.201 46227 +109.86.136.248 44281 +85.54.187.59 28890 +99.225.92.6 38080 +178.40.89.75 10018 +79.132.182.136 30129 +174.59.144.37 5895 +189.237.151.135 17643 +189.114.233.119 12308 +109.168.162.23 32195 +93.13.211.51 59788 +80.56.69.253 25685 +77.70.96.3 11949 +18.242.7.242 65435 +83.131.224.235 62622 +201.229.9.69 28159 +201.223.65.4 43804 +77.167.196.115 64788 diff --git a/libbitdht/src/tests/udpbitdht_nettest.cc b/libbitdht/src/tests/udpbitdht_nettest.cc index 13809fef3..abdf1e2a1 100644 --- a/libbitdht/src/tests/udpbitdht_nettest.cc +++ b/libbitdht/src/tests/udpbitdht_nettest.cc @@ -46,7 +46,9 @@ int args(char *name) std::cerr << " -p "; std::cerr << " -b "; std::cerr << " -u "; - std::cerr << " -r (do random queries) "; + std::cerr << " -q "; + std::cerr << " -r (do dht restarts) "; + std::cerr << " -j (do join test) "; std::cerr << std::endl; return 1; } @@ -68,10 +70,11 @@ int main(int argc, char **argv) bool doRandomQueries = false; bool doRestart = false; bool doThreadJoin = false; + int noQueries = 0; srand(time(NULL)); - while((c = getopt(argc, argv,"rjp:b:u:q")) != -1) + while((c = getopt(argc, argv,"rjp:b:u:q:")) != -1) { switch (c) { @@ -118,6 +121,7 @@ int main(int argc, char **argv) case 'q': { doRandomQueries = true; + noQueries = atoi(optarg); std::cerr << "Doing Random Queries"; std::cerr << std::endl; } @@ -187,8 +191,6 @@ int main(int argc, char **argv) /* do a couple of random continuous searchs. */ uint32_t mode = BITDHT_QFLAGS_DO_IDLE; - mode = 0; - int count = 0; int running = 1; @@ -198,6 +200,22 @@ int main(int argc, char **argv) bitdht->startDht(); + if (doRandomQueries) + { + for(int i = 0; i < noQueries; i++) + { + bdNodeId rndId; + bdStdRandomNodeId(&rndId); + + std::cerr << "BitDht Launching Random Search: "; + bdStdPrintNodeId(std::cerr, &rndId); + std::cerr << std::endl; + + bitdht->addFindNode(&rndId, mode); + + } + } + while(1) { sleep(60); @@ -220,18 +238,6 @@ int main(int argc, char **argv) mode = 0; } - if (doRandomQueries) - { - bdNodeId rndId; - bdStdRandomNodeId(&rndId); - - std::cerr << "BitDht Launching Random Search: "; - bdStdPrintNodeId(std::cerr, &rndId); - std::cerr << std::endl; - - bitdht->addFindNode(&rndId, mode); - } - if (doThreadJoin) { /* change address */