From c77547ac45b61f2f3cd49a7f08b9c44e6650142e Mon Sep 17 00:00:00 2001 From: drbob Date: Sun, 28 Oct 2012 14:10:56 +0000 Subject: [PATCH 1/3] Tweaks to bitdht library for standalone single search option. - Added flag to disable local Network search. - Fixed DHT Msg Rate bug (ported from trunk). git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5731 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- src/bitdht/bdmanager.cc | 47 +++++++++++++++++++++++------------------ src/bitdht/bdmanager.h | 2 ++ src/bitdht/bdnode.cc | 6 +++--- 3 files changed, 32 insertions(+), 23 deletions(-) diff --git a/src/bitdht/bdmanager.cc b/src/bitdht/bdmanager.cc index 16874eb..719ade5 100644 --- a/src/bitdht/bdmanager.cc +++ b/src/bitdht/bdmanager.cc @@ -87,6 +87,8 @@ bdNodeManager::bdNodeManager(bdNodeId *id, std::string dhtVersion, std::string b mFns->bdPrintNodeId(std::cerr, id); std::cerr << std::endl; #endif + + mLocalNetEnhancements = true; } int bdNodeManager::stopDht() @@ -400,34 +402,39 @@ void bdNodeManager::iteration() std::cerr << std::endl; #endif - /* run a random search for ourselves, from own App DHT peer */ - QueryRandomLocalNet(); + /* This stuff is only important for "LocalNet based Features */ + if (mLocalNetEnhancements) + { + /* run a random search for ourselves, from own App DHT peer */ + QueryRandomLocalNet(); + #define SEARCH_MAX_SIZE 10 - if (mBdNetworkSize < SEARCH_MAX_SIZE) - { -#ifdef DEBUG_MGR - std::cerr << "Local Netsize: " << mBdNetworkSize << " to small...searching"; - std::cerr << std::endl; -#endif - - /* if the network size is very small */ - SearchForLocalNet(); - mSearchingDone = false; - } - else - { - if (!mSearchingDone) + if (mBdNetworkSize < SEARCH_MAX_SIZE) { - mSearchingDone = true; - mSearchTS = now; #ifdef DEBUG_MGR - std::cerr << "Completed LocalNet Search in : " << mSearchTS-mStartTS; + std::cerr << "Local Netsize: " << mBdNetworkSize << " to small...searching"; std::cerr << std::endl; #endif + + /* if the network size is very small */ + SearchForLocalNet(); + mSearchingDone = false; + } + else + { + if (!mSearchingDone) + { + mSearchingDone = true; + mSearchTS = now; +#ifdef DEBUG_MGR + std::cerr << "Completed LocalNet Search in : " << mSearchTS-mStartTS; + std::cerr << std::endl; +#endif + } } } - + #ifdef DEBUG_MGR std::cerr << "bdNodeManager::iteration(): REFRESH "; std::cerr << std::endl; diff --git a/src/bitdht/bdmanager.h b/src/bitdht/bdmanager.h index 635a5eb..a43a883 100644 --- a/src/bitdht/bdmanager.h +++ b/src/bitdht/bdmanager.h @@ -187,6 +187,8 @@ void SearchForLocalNet(); bdBloom mBloomFilter; + bool mLocalNetEnhancements; + /* future node functions */ //addPeerPing(foundId); //clearPing(it->first); diff --git a/src/bitdht/bdnode.cc b/src/bitdht/bdnode.cc index 9e024b0..b16a28c 100644 --- a/src/bitdht/bdnode.cc +++ b/src/bitdht/bdnode.cc @@ -134,14 +134,14 @@ uint32_t bdNode::setNodeDhtMode(uint32_t dhtFlags) { default: case BITDHT_MODE_TRAFFIC_LOW: - mMaxAllowedMsgs = BDNODE_HIGH_MSG_RATE; - break; - case BITDHT_MODE_TRAFFIC_HIGH: mMaxAllowedMsgs = BDNODE_LOW_MSG_RATE; break; case BITDHT_MODE_TRAFFIC_MED: mMaxAllowedMsgs = BDNODE_MED_MSG_RATE; break; + case BITDHT_MODE_TRAFFIC_HIGH: + mMaxAllowedMsgs = BDNODE_HIGH_MSG_RATE; + break; case BITDHT_MODE_TRAFFIC_TRICKLE: mMaxAllowedMsgs = BDNODE_TRICKLE_MSG_RATE; break; From 0c78c76da4cd30f84a5f1726958fb542a65b4b66 Mon Sep 17 00:00:00 2001 From: drbob Date: Sun, 28 Oct 2012 14:21:58 +0000 Subject: [PATCH 2/3] Modified previous example into a Single Shot Search for RPC support. Takes 2 - 3 minutes to run at the moment. Got to make it faster! git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5732 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- src/example/Makefile | 12 +- src/example/bdboot.txt | 1000 +++++++++++++++++++------------------- src/example/bdexample.cc | 42 -- src/example/bdhandler.cc | 97 +++- src/example/bdhandler.h | 17 + src/example/bssdht.cc | 59 +++ 6 files changed, 674 insertions(+), 553 deletions(-) delete mode 100644 src/example/bdexample.cc create mode 100644 src/example/bssdht.cc diff --git a/src/example/Makefile b/src/example/Makefile index eeb1c8c..6b13f2b 100644 --- a/src/example/Makefile +++ b/src/example/Makefile @@ -1,16 +1,16 @@ CXXFLAGS = -Wall -g -I.. -CXXFLAGS += -arch i386 # OSX +#CXXFLAGS += -arch i386 # OSX -LIBS = -L../lib -lbitdht +LIBS = -L../lib -lbitdht -lpthread -EXEC : bdexample +EXEC : bssdht -EGOBJ = bdhandler.o bdexample.o +EGOBJ = bdhandler.o bssdht.o -bdexample: $(EGOBJ) - $(CXX) $(CXXFLAGS) -o bdexample $(EGOBJ) $(LIBS) +bssdht: $(EGOBJ) + $(CXX) $(CXXFLAGS) -o bssdht $(EGOBJ) $(LIBS) diff --git a/src/example/bdboot.txt b/src/example/bdboot.txt index 89f27a2..44cf7d1 100644 --- a/src/example/bdboot.txt +++ b/src/example/bdboot.txt @@ -1,500 +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 +213.200.49.94 49729 +78.106.255.53 33010 +176.52.10.54 6881 +178.89.155.147 6881 +125.14.197.62 14856 +218.77.193.68 16001 +86.149.90.0 63079 +24.132.253.237 16107 +85.54.115.28 30782 +79.136.30.100 63177 +89.136.253.72 32789 +109.254.115.106 46229 +89.120.65.238 63900 +79.164.94.231 8093 +109.195.107.54 6881 +109.60.234.178 60562 +182.218.241.146 32308 +188.16.212.171 6881 +213.85.86.61 6881 +117.220.183.198 48158 +125.137.92.58 45682 +122.80.243.249 16001 +123.165.178.125 9371 +85.64.42.90 46866 +91.241.136.195 48137 +178.217.52.84 20801 +46.233.208.225 14158 +37.79.136.74 35691 +109.252.88.7 61862 +119.166.13.162 57726 +95.25.120.195 6881 +109.88.60.207 37375 +77.66.244.147 6881 +176.77.24.252 35691 +78.25.175.94 39012 +109.194.253.133 19755 +195.169.226.124 51413 +90.151.219.90 6881 +93.124.15.169 22826 +90.39.156.179 21066 +89.222.164.65 28505 +91.146.55.126 15984 +46.0.142.177 65116 +188.186.105.35 6881 +212.21.3.78 6881 +94.190.76.151 61998 +90.150.121.152 6881 +188.234.162.195 6881 +212.87.184.183 18025 +95.105.53.122 10022 +109.110.233.223 63596 +46.149.234.13 6881 +92.112.33.50 17016 +188.244.159.76 6881 +109.226.65.214 30220 +89.204.37.237 6881 +81.182.61.244 62762 +31.23.11.165 23690 +92.112.227.98 16020 +188.173.249.241 10649 +65.28.74.168 16111 +108.252.61.27 30097 +67.164.44.138 1025 +112.136.180.195 28478 +61.31.128.123 11708 +203.202.219.105 26397 +85.180.71.212 28824 +85.17.30.203 51721 +194.44.93.49 41558 +79.115.140.239 6881 +212.57.143.230 64209 +213.57.220.71 54355 +188.25.152.209 38685 +24.215.90.104 50000 +85.173.79.113 43424 +69.254.137.136 59805 +95.21.157.21 38284 +91.66.234.126 45618 +69.81.91.160 36510 +37.11.69.120 21518 +82.251.167.100 27364 +178.95.174.115 27719 +71.95.96.165 30732 +109.222.228.8 31901 +24.192.64.18 48809 +50.72.178.188 44692 +69.76.203.21 60466 +82.234.232.63 22112 +199.21.113.184 64103 +89.80.119.247 57369 +88.72.174.111 9023 +86.29.84.7 56010 +79.47.210.148 15421 +92.144.216.198 61409 +81.64.209.233 6262 +86.70.194.6 8000 +178.83.6.65 6881 +83.246.219.62 12485 +95.73.12.140 56350 +188.190.58.2 27739 +92.252.210.194 10000 +94.23.49.143 8000 +199.127.250.15 29015 +78.119.199.7 55227 +82.242.173.60 48585 +108.207.210.177 17312 +81.101.178.26 36319 +86.126.203.68 10566 +178.223.153.97 23683 +218.111.12.128 59991 +74.132.175.138 63239 +24.239.251.33 55679 +77.9.88.33 8812 +86.105.83.234 64836 +78.26.200.70 53675 +109.126.218.243 49001 +178.120.24.237 23854 +5.164.220.86 46394 +83.165.232.251 11618 +176.14.184.224 47779 +37.229.58.159 25397 +89.112.45.232 51413 +71.227.228.178 59982 +94.8.63.12 21695 +178.83.119.5 6881 +213.109.4.140 35063 +174.66.162.145 19398 +189.4.72.127 43453 +112.203.4.67 15817 +178.216.101.214 54537 +79.134.52.11 52512 +192.162.43.69 45684 +85.240.205.157 18883 +188.232.238.194 59524 +123.110.8.223 15666 +61.19.218.36 50115 +83.215.168.25 64268 +80.2.83.216 16532 +188.124.72.59 32042 +89.46.178.134 39707 +202.177.248.237 51359 +88.174.176.173 56969 +50.98.183.171 47301 +85.59.136.223 43831 +188.190.69.190 40122 +82.155.56.186 20870 +109.9.102.56 16279 +220.245.18.37 7952 +24.53.148.27 20698 +88.156.186.185 51413 +68.101.70.42 48176 +108.38.11.220 57600 +99.102.20.107 34921 +112.186.84.12 30224 +89.3.61.74 63799 +46.72.18.191 38514 +85.142.195.67 6881 +201.24.196.143 21263 +88.72.174.111 14804 +141.84.252.30 6881 +93.218.175.120 47467 +83.134.21.238 39471 +81.229.168.10 32995 +88.170.61.126 7465 +83.254.77.158 22722 +78.94.71.48 51091 +94.45.103.205 23560 +46.119.32.172 40356 +37.204.127.80 34869 +78.53.125.16 1451 +91.219.249.72 6881 +2.60.134.63 42890 +188.195.233.196 7971 +109.209.82.52 1064 +80.217.87.125 47610 +92.151.189.10 41785 +71.237.6.246 41304 +176.15.199.156 35691 +37.14.117.203 24956 +188.165.245.29 62201 +31.192.204.87 36504 +217.73.165.50 65165 +78.126.57.136 29452 +95.16.39.183 51413 +68.229.157.53 20538 +24.15.208.182 19353 +178.72.76.27 10693 +49.204.188.72 15546 +74.172.229.212 9518 +126.11.175.228 46373 +60.181.173.66 16001 +71.245.169.177 43766 +96.55.113.202 17765 +77.31.69.213 16975 +14.192.149.235 14523 +116.114.184.23 16001 +46.73.180.200 57274 +109.167.205.91 17782 +109.248.165.232 29068 +37.112.101.205 12115 +67.193.153.219 61956 +84.109.194.47 46742 +188.24.75.81 63815 +223.98.124.220 16001 +90.56.104.115 11101 +81.190.219.203 14573 +89.99.220.211 6881 +78.129.47.89 25456 +72.89.174.47 49559 +66.169.55.105 10610 +178.129.164.236 6881 +99.164.69.36 44396 +121.182.147.191 62483 +46.214.22.165 20056 +90.196.26.145 62421 +109.110.147.6 51158 +93.152.154.146 63760 +111.253.207.38 16001 +125.27.214.216 44366 +77.243.107.6 8392 +83.128.123.13 22300 +62.80.235.202 39059 +178.120.2.179 18001 +204.11.130.66 6881 +178.122.94.160 10024 +142.167.185.66 51623 +72.84.241.61 23793 +95.29.249.76 6881 +77.41.8.139 6881 +109.165.86.68 6881 +109.111.3.95 42832 +89.222.164.39 17108 +86.198.46.107 64700 +46.0.195.115 6881 +217.123.236.239 59665 +88.206.83.163 6881 +2.217.94.215 62479 +85.27.36.125 3675 +94.23.55.33 33530 +89.222.164.74 8750 +213.111.210.47 44581 +75.158.101.190 59340 +80.184.122.10 15829 +81.235.246.100 57582 +5.187.78.80 50811 +93.74.114.37 33017 +24.30.83.45 54662 +121.187.196.166 61829 +87.97.70.95 59216 +92.101.49.41 15939 +177.132.219.232 52537 +217.15.129.218 15808 +116.14.132.15 56063 +76.177.90.141 36194 +88.90.45.47 58649 +77.57.165.254 6881 +80.98.76.72 43577 +78.30.207.121 16466 +109.89.22.180 30439 +68.190.74.32 22007 +36.236.16.67 16001 +114.163.214.158 11302 +2.97.93.187 57692 +94.253.39.133 6881 +79.139.88.71 10208 +59.126.161.235 42539 +81.234.255.202 56118 +117.200.86.161 53208 +31.46.125.31 18045 +82.243.71.203 65432 +78.224.185.52 56621 +76.204.112.132 6890 +93.223.130.30 32417 +87.223.168.225 26656 +173.73.46.92 52828 +178.202.38.237 40068 +109.14.228.2 6969 +95.157.142.198 64123 +220.245.1.193 64765 +62.227.10.103 19379 +192.228.212.170 21654 +66.197.135.74 9870 +37.221.132.150 22894 +94.21.58.12 38698 +188.176.186.181 18273 +188.190.155.210 4455 +108.252.160.139 42007 +94.23.204.135 30392 +63.245.169.145 33247 +93.96.38.245 6881 +31.45.22.161 35225 +77.222.31.52 59415 +96.42.167.80 52280 +190.196.105.132 14079 +117.201.208.178 10171 +187.104.231.26 33447 +68.42.14.214 23361 +67.167.214.225 63185 +24.138.59.223 55955 +111.242.33.86 23406 +125.30.116.231 18391 +123.23.70.154 10075 +78.229.90.129 32138 +69.112.56.177 44811 +31.16.41.107 7627 +92.141.209.132 15734 +79.118.37.244 40171 +66.49.128.103 51413 +178.90.62.99 10000 +178.157.237.100 6881 +91.178.167.101 30268 +206.248.183.2 51413 +93.86.246.79 12180 +109.193.181.26 17836 +90.224.116.7 33923 +37.144.199.41 32118 +89.123.71.101 10982 +112.204.163.100 13292 +125.24.197.213 11698 +46.63.180.70 54251 +217.210.112.89 20503 +213.64.227.205 18926 +123.203.151.250 56045 +114.37.64.184 25431 +86.8.232.198 47955 +213.181.202.91 51413 +37.229.225.109 24351 +2.33.68.167 45682 +88.222.217.56 46421 +90.208.116.214 55538 +2.124.113.120 51413 +211.228.97.32 11160 +85.67.228.231 33392 +93.116.242.153 33116 +94.51.121.80 59150 +113.171.86.250 10000 +5.159.110.99 26947 +58.7.253.60 38684 +91.229.20.68 6881 +91.179.116.59 17040 +117.195.47.150 49441 +42.98.29.129 22491 +85.167.147.174 34182 +82.242.149.9 25108 +85.108.197.61 29286 +95.56.72.49 14451 +83.150.118.223 7200 +83.246.191.21 6881 +82.49.66.69 26973 +50.53.84.14 47235 +88.212.37.175 40585 +84.55.102.97 49909 +82.168.130.135 56755 +46.173.90.211 6881 +109.169.54.139 51415 +114.34.93.180 20810 +99.231.123.139 47345 +125.212.120.5 21305 +109.128.196.245 51413 +176.215.30.14 28689 +98.30.187.130 21000 +75.73.136.19 62765 +212.19.133.88 13525 +108.202.164.27 51413 +2.49.208.236 46064 +116.51.131.3 47451 +78.155.189.90 22557 +2.3.154.124 43411 +46.251.69.224 11789 +85.138.161.222 28829 +94.181.133.210 35691 +41.69.137.231 13336 +49.48.231.206 64581 +82.7.153.234 39772 +94.113.125.164 27426 +75.48.224.72 51413 +176.103.81.177 52440 +37.218.152.141 24385 +221.149.52.79 11254 +213.114.77.51 61820 +178.22.225.30 11104 +92.84.81.34 57407 +93.146.94.221 19306 +171.116.86.165 16001 +101.63.130.19 48832 +85.84.221.4 19153 +79.126.54.102 37807 +74.77.92.19 51413 +46.108.138.39 25884 +92.247.220.203 25527 +89.20.124.41 6881 +99.189.14.81 43179 +211.193.20.248 25381 +223.228.164.49 18616 +95.140.222.179 55740 +78.149.21.10 46511 +87.89.35.111 41473 +46.2.98.125 26797 +71.201.85.238 63526 +83.143.127.228 51413 +89.142.117.227 60538 +109.198.205.30 49001 +92.126.225.35 10022 +62.57.253.96 49665 +106.160.49.230 58911 +89.92.176.225 51413 +81.202.66.247 27326 +85.165.20.74 37250 +95.220.228.216 57575 +94.211.208.25 16881 +211.28.147.189 30748 +46.50.162.228 6881 +122.116.89.184 59116 +110.93.91.8 38100 +84.248.75.232 63001 +79.165.148.92 61137 +88.132.54.10 62580 +180.224.43.232 63573 +79.82.223.182 29297 +78.7.87.150 28643 +67.235.141.60 19894 +27.190.132.73 4245 +93.123.197.174 58547 +89.216.145.187 1055 +68.46.237.222 34912 +69.181.68.72 60496 +107.193.240.30 51276 +89.148.6.32 54889 +92.112.84.248 10007 +194.44.21.96 58530 +93.116.77.214 10035 +37.79.42.73 32840 +64.218.114.247 60600 +95.178.198.186 28243 +99.137.237.26 49238 +112.134.68.224 10008 +89.41.56.250 15440 +86.205.207.176 56623 +60.220.85.253 13569 +109.174.114.124 3725 +89.23.163.173 19575 +79.119.183.29 52107 +59.66.110.93 27589 +78.105.105.87 42127 +95.69.207.44 35691 +72.200.187.124 48593 +178.123.203.73 6881 +77.35.153.182 16318 +201.22.70.49 12947 +80.236.120.181 14451 +222.212.42.236 6107 +85.25.110.34 62453 +86.24.133.104 42572 +82.126.184.158 31323 +95.154.177.131 19995 +1.22.41.112 37043 +74.190.24.27 11742 +70.123.139.33 45645 +67.78.205.194 5007 +208.101.109.128 53329 +184.99.81.210 65160 +24.30.119.63 46448 +84.10.80.103 512 +95.58.107.250 58280 +213.113.242.33 11761 +95.58.198.83 19786 +187.34.104.235 23609 +61.51.62.143 43220 +2.122.203.188 34936 +95.29.127.137 9000 +85.176.27.50 60583 +178.185.5.228 10048 +189.110.211.69 52748 +212.231.247.212 18744 +212.253.173.114 57417 +69.157.252.118 63494 +95.108.119.185 46830 +213.112.21.57 27077 +95.79.173.173 42349 +76.121.182.77 54059 +70.177.183.134 62354 +92.124.7.63 26804 +176.43.91.144 55976 +220.135.191.36 13894 +78.230.236.178 51528 +194.213.106.70 49001 +176.110.229.36 13664 +178.88.53.243 19564 +124.169.108.217 34547 +109.104.173.57 19454 +70.179.13.236 40021 +109.209.193.34 37721 +2.90.14.222 21661 +79.131.212.125 16844 +142.68.216.103 20804 +123.238.67.137 16515 +50.13.6.176 23275 +58.170.3.84 34130 +91.122.18.146 49001 +76.116.68.100 53034 diff --git a/src/example/bdexample.cc b/src/example/bdexample.cc deleted file mode 100644 index 0c965ea..0000000 --- a/src/example/bdexample.cc +++ /dev/null @@ -1,42 +0,0 @@ - - -#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/src/example/bdhandler.cc b/src/example/bdhandler.cc index faa6afb..d1b1288 100644 --- a/src/example/bdhandler.cc +++ b/src/example/bdhandler.cc @@ -28,8 +28,24 @@ #include #include +#include + #include "bdhandler.h" + +/**** + * This example bitdht app is designed to perform a single shot DHT search. + * Ww want to minimise the dht work, and number of UDP packets sent. + * + * This means we need to add: + * - don't search for App network. (libbitdht option) + * - don't bother filling up Space. (libbitdht option) + * - Programmatically add bootstrap peers. (libbitdht option) + * + */ + + + /* This is a conversion callback class */ @@ -110,6 +126,11 @@ BitDhtHandler::BitDhtHandler(bdNodeId *ownId, uint16_t port, std::string appId, mUdpBitDht->start(); /* starts up the bitdht thread */ + /* setup best mode for quick search */ + uint32_t dhtFlags = BITDHT_MODE_TRAFFIC_MED | BITDHT_MODE_RELAYSERVERS_IGNORED; + mUdpBitDht->setDhtMode(dhtFlags); + mUdpBitDht->setAttachMode(false); + /* switch on the dht too */ mUdpBitDht->startDht(); } @@ -162,8 +183,19 @@ bool BitDhtHandler::FindNode(bdNodeId *peerId) bdStdPrintNodeId(std::cerr, peerId); std::cerr << ")" << std::endl; + + BssResult res; + res.id.id = *peerId; + res.mode = BSS_SINGLE_SHOT; + res.status = 0; + + { + bdStackMutex stack(resultsMtx); /********** MUTEX LOCKED *************/ + mSearchNodes[*peerId] = res; + } + /* add in peer */ - mUdpBitDht->addFindNode(peerId, BITDHT_QFLAGS_DO_IDLE); + mUdpBitDht->addFindNode(peerId, BITDHT_QFLAGS_DISGUISE); return true ; } @@ -178,10 +210,50 @@ bool BitDhtHandler::DropNode(bdNodeId *peerId) /* remove in peer */ mUdpBitDht->removeFindNode(peerId); + bdStackMutex stack(resultsMtx); /********** MUTEX LOCKED *************/ + + /* find the node from our list */ + std::map::iterator it; + it = mSearchNodes.find(*peerId); + if (it != mSearchNodes.end()) + { + std::cerr << "BitDhtHandler::DropNode() Found NodeId, removing"; + std::cerr << std::endl; + + mSearchNodes.erase(it); + } return true ; } +bool BitDhtHandler::SearchResult(bdId *id, uint32_t &status) +{ + bdStackMutex stack(resultsMtx); /********** MUTEX LOCKED *************/ + + /* find the node from our list */ + std::map::iterator it; + it = mSearchNodes.find(id->id); + if (it != mSearchNodes.end()) + { + if (it->second.status != 0) + { + std::cerr << "BitDhtHandler::SearchResults() Found Results"; + std::cerr << std::endl; + status = it->second.status; + *id = it->second.id; + return true; + } + + std::cerr << "BitDhtHandler::SearchResults() No Results Yet"; + std::cerr << std::endl; + return false; + } + + std::cerr << "BitDhtHandler::SearchResults() ERROR: No Search Entry"; + std::cerr << std::endl; + return false; +} + /********************** Callback Functions **************************/ @@ -203,6 +275,20 @@ int BitDhtHandler::PeerCallback(const bdId *id, uint32_t status) bdStdPrintId(std::cerr, id); std::cerr << std::endl; + bdStackMutex stack(resultsMtx); /********** MUTEX LOCKED *************/ + + /* find the node from our list */ + std::map::iterator it; + it = mSearchNodes.find(id->id); + if (it == mSearchNodes.end()) + { + std::cerr << "BitDhtHandler::PeerCallback() Unknown NodeId !!! "; + std::cerr << std::endl; + + return 1; + } + it->second.status = status; + bool connect = false; switch(status) { @@ -211,6 +297,7 @@ int BitDhtHandler::PeerCallback(const bdId *id, uint32_t status) std::cerr << "BitDhtHandler::PeerCallback() QUERY FAILURE ... do nothin "; std::cerr << std::endl; + break; case BITDHT_MGR_QUERY_PEER_OFFLINE: @@ -224,19 +311,19 @@ int BitDhtHandler::PeerCallback(const bdId *id, uint32_t status) case BITDHT_MGR_QUERY_PEER_UNREACHABLE: /* do nothing */ - std::cerr << "BitDhtHandler::PeerCallback() QUERY PEER UNREACHABLE ... flag? / do nothin "; + std::cerr << "BitDhtHandler::PeerCallback() QUERY PEER UNREACHABLE ... saving address "; std::cerr << std::endl; - + it->second.id = *id; break; case BITDHT_MGR_QUERY_PEER_ONLINE: /* do something */ - std::cerr << "BitDhtHandler::PeerCallback() QUERY PEER ONLINE ... try udp connection"; + std::cerr << "BitDhtHandler::PeerCallback() QUERY PEER ONLINE ... saving address"; std::cerr << std::endl; - connect = true; + it->second.id = *id; break; } return 1; diff --git a/src/example/bdhandler.h b/src/example/bdhandler.h index e2ad55d..c0c942d 100644 --- a/src/example/bdhandler.h +++ b/src/example/bdhandler.h @@ -37,6 +37,18 @@ /*** This class can be overloaded to use the XXXXCallback() Functions *****/ class BitDhtIntCallback; + +class BssResult +{ + public: + bdId id; + uint32_t mode; // single shot + uint32_t status; // SEARCHING, FAILURE, FOUND, MULTIPLE HITS. +}; + +#define BSS_SINGLE_SHOT 0x0001 + + class BitDhtHandler { @@ -58,12 +70,17 @@ virtual int NodeCallback(const bdId *id, uint32_t peerflags); virtual int PeerCallback(const bdId *id, uint32_t status); virtual int ValueCallback(const bdNodeId *id, std::string key, uint32_t status); +bool SearchResult(bdId *id, uint32_t &status); + private: /* real DHT classes */ UdpStack *mStack; UdpBitDht *mUdpBitDht; + bdMutex resultsMtx; /* for all class data (below) */ + + std::map mSearchNodes; }; diff --git a/src/example/bssdht.cc b/src/example/bssdht.cc new file mode 100644 index 0000000..b1d1e7b --- /dev/null +++ b/src/example/bssdht.cc @@ -0,0 +1,59 @@ + + +#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 = "bsId"; + std::string bootstrapfile = "bdboot.txt"; + + BitDhtHandler dht(&ownId, port, appId, bootstrapfile); + + /* install search node */ + bdNodeId searchId; + bdStdRandomNodeId(&searchId); + + std::cerr << "bssdht: searching for Id: "; + bdStdPrintNodeId(std::cerr, &searchId); + std::cerr << std::endl; + + dht.FindNode(&searchId); + + /* run your program */ + bdId resultId; + uint32_t status; + + resultId.id = searchId; + + while(false == dht.SearchResult(&resultId, status)) + { + sleep(10); + } + + std::cerr << "bssdht: Found Result:" << std::endl; + + std::cerr << "\tId: "; + bdStdPrintId(std::cerr, &resultId); + std::cerr << std::endl; + + std::cerr << "\tstatus: " << status; + std::cerr << std::endl; + + return 1; +} + + + + + + + + From 3b69706f01bf9e074f688163a83260304a124814 Mon Sep 17 00:00:00 2001 From: drbob Date: Sun, 9 Dec 2012 13:19:28 +0000 Subject: [PATCH 3/3] added single function to call dht, with thread cleanup. git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5954 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- src/example/Makefile | 2 +- src/example/bdboot.txt | 810 ++++++++++++++++++------------------ src/example/bootstrap_fn.cc | 60 +++ src/example/bootstrap_fn.h | 17 + src/example/bssdht.cc | 48 +-- 5 files changed, 493 insertions(+), 444 deletions(-) create mode 100644 src/example/bootstrap_fn.cc create mode 100644 src/example/bootstrap_fn.h diff --git a/src/example/Makefile b/src/example/Makefile index 6b13f2b..447407b 100644 --- a/src/example/Makefile +++ b/src/example/Makefile @@ -8,7 +8,7 @@ LIBS = -L../lib -lbitdht -lpthread EXEC : bssdht -EGOBJ = bdhandler.o bssdht.o +EGOBJ = bdhandler.o bssdht.o bootstrap_fn.o bssdht: $(EGOBJ) $(CXX) $(CXXFLAGS) -o bssdht $(EGOBJ) $(LIBS) diff --git a/src/example/bdboot.txt b/src/example/bdboot.txt index 44cf7d1..74c3100 100644 --- a/src/example/bdboot.txt +++ b/src/example/bdboot.txt @@ -1,394 +1,5 @@ -213.200.49.94 49729 -78.106.255.53 33010 -176.52.10.54 6881 -178.89.155.147 6881 -125.14.197.62 14856 -218.77.193.68 16001 -86.149.90.0 63079 -24.132.253.237 16107 -85.54.115.28 30782 -79.136.30.100 63177 -89.136.253.72 32789 -109.254.115.106 46229 -89.120.65.238 63900 -79.164.94.231 8093 -109.195.107.54 6881 -109.60.234.178 60562 -182.218.241.146 32308 -188.16.212.171 6881 -213.85.86.61 6881 -117.220.183.198 48158 -125.137.92.58 45682 -122.80.243.249 16001 -123.165.178.125 9371 -85.64.42.90 46866 -91.241.136.195 48137 -178.217.52.84 20801 -46.233.208.225 14158 -37.79.136.74 35691 -109.252.88.7 61862 -119.166.13.162 57726 -95.25.120.195 6881 -109.88.60.207 37375 -77.66.244.147 6881 -176.77.24.252 35691 -78.25.175.94 39012 -109.194.253.133 19755 -195.169.226.124 51413 -90.151.219.90 6881 -93.124.15.169 22826 -90.39.156.179 21066 -89.222.164.65 28505 -91.146.55.126 15984 -46.0.142.177 65116 -188.186.105.35 6881 -212.21.3.78 6881 -94.190.76.151 61998 -90.150.121.152 6881 -188.234.162.195 6881 -212.87.184.183 18025 -95.105.53.122 10022 -109.110.233.223 63596 -46.149.234.13 6881 -92.112.33.50 17016 -188.244.159.76 6881 -109.226.65.214 30220 -89.204.37.237 6881 -81.182.61.244 62762 -31.23.11.165 23690 -92.112.227.98 16020 -188.173.249.241 10649 -65.28.74.168 16111 -108.252.61.27 30097 -67.164.44.138 1025 -112.136.180.195 28478 -61.31.128.123 11708 -203.202.219.105 26397 -85.180.71.212 28824 -85.17.30.203 51721 -194.44.93.49 41558 -79.115.140.239 6881 -212.57.143.230 64209 -213.57.220.71 54355 -188.25.152.209 38685 -24.215.90.104 50000 -85.173.79.113 43424 -69.254.137.136 59805 -95.21.157.21 38284 -91.66.234.126 45618 -69.81.91.160 36510 -37.11.69.120 21518 -82.251.167.100 27364 -178.95.174.115 27719 -71.95.96.165 30732 -109.222.228.8 31901 -24.192.64.18 48809 -50.72.178.188 44692 -69.76.203.21 60466 -82.234.232.63 22112 -199.21.113.184 64103 -89.80.119.247 57369 -88.72.174.111 9023 -86.29.84.7 56010 -79.47.210.148 15421 -92.144.216.198 61409 -81.64.209.233 6262 -86.70.194.6 8000 -178.83.6.65 6881 -83.246.219.62 12485 -95.73.12.140 56350 -188.190.58.2 27739 -92.252.210.194 10000 -94.23.49.143 8000 -199.127.250.15 29015 -78.119.199.7 55227 -82.242.173.60 48585 -108.207.210.177 17312 -81.101.178.26 36319 -86.126.203.68 10566 -178.223.153.97 23683 -218.111.12.128 59991 -74.132.175.138 63239 -24.239.251.33 55679 -77.9.88.33 8812 -86.105.83.234 64836 -78.26.200.70 53675 -109.126.218.243 49001 -178.120.24.237 23854 -5.164.220.86 46394 -83.165.232.251 11618 -176.14.184.224 47779 -37.229.58.159 25397 -89.112.45.232 51413 -71.227.228.178 59982 -94.8.63.12 21695 -178.83.119.5 6881 -213.109.4.140 35063 -174.66.162.145 19398 -189.4.72.127 43453 -112.203.4.67 15817 -178.216.101.214 54537 -79.134.52.11 52512 -192.162.43.69 45684 -85.240.205.157 18883 -188.232.238.194 59524 -123.110.8.223 15666 -61.19.218.36 50115 -83.215.168.25 64268 -80.2.83.216 16532 -188.124.72.59 32042 -89.46.178.134 39707 -202.177.248.237 51359 -88.174.176.173 56969 -50.98.183.171 47301 -85.59.136.223 43831 -188.190.69.190 40122 -82.155.56.186 20870 -109.9.102.56 16279 -220.245.18.37 7952 -24.53.148.27 20698 -88.156.186.185 51413 -68.101.70.42 48176 -108.38.11.220 57600 -99.102.20.107 34921 -112.186.84.12 30224 -89.3.61.74 63799 -46.72.18.191 38514 -85.142.195.67 6881 -201.24.196.143 21263 -88.72.174.111 14804 -141.84.252.30 6881 -93.218.175.120 47467 -83.134.21.238 39471 -81.229.168.10 32995 -88.170.61.126 7465 -83.254.77.158 22722 -78.94.71.48 51091 -94.45.103.205 23560 -46.119.32.172 40356 -37.204.127.80 34869 -78.53.125.16 1451 -91.219.249.72 6881 -2.60.134.63 42890 -188.195.233.196 7971 -109.209.82.52 1064 -80.217.87.125 47610 -92.151.189.10 41785 -71.237.6.246 41304 -176.15.199.156 35691 -37.14.117.203 24956 -188.165.245.29 62201 -31.192.204.87 36504 -217.73.165.50 65165 -78.126.57.136 29452 -95.16.39.183 51413 -68.229.157.53 20538 -24.15.208.182 19353 -178.72.76.27 10693 -49.204.188.72 15546 -74.172.229.212 9518 -126.11.175.228 46373 -60.181.173.66 16001 -71.245.169.177 43766 -96.55.113.202 17765 -77.31.69.213 16975 -14.192.149.235 14523 -116.114.184.23 16001 -46.73.180.200 57274 -109.167.205.91 17782 -109.248.165.232 29068 -37.112.101.205 12115 -67.193.153.219 61956 -84.109.194.47 46742 -188.24.75.81 63815 -223.98.124.220 16001 -90.56.104.115 11101 -81.190.219.203 14573 -89.99.220.211 6881 -78.129.47.89 25456 -72.89.174.47 49559 -66.169.55.105 10610 -178.129.164.236 6881 -99.164.69.36 44396 -121.182.147.191 62483 -46.214.22.165 20056 -90.196.26.145 62421 -109.110.147.6 51158 -93.152.154.146 63760 -111.253.207.38 16001 -125.27.214.216 44366 -77.243.107.6 8392 -83.128.123.13 22300 -62.80.235.202 39059 -178.120.2.179 18001 -204.11.130.66 6881 -178.122.94.160 10024 -142.167.185.66 51623 -72.84.241.61 23793 -95.29.249.76 6881 -77.41.8.139 6881 -109.165.86.68 6881 -109.111.3.95 42832 -89.222.164.39 17108 -86.198.46.107 64700 -46.0.195.115 6881 -217.123.236.239 59665 -88.206.83.163 6881 -2.217.94.215 62479 -85.27.36.125 3675 -94.23.55.33 33530 -89.222.164.74 8750 -213.111.210.47 44581 -75.158.101.190 59340 -80.184.122.10 15829 -81.235.246.100 57582 -5.187.78.80 50811 -93.74.114.37 33017 -24.30.83.45 54662 -121.187.196.166 61829 -87.97.70.95 59216 -92.101.49.41 15939 -177.132.219.232 52537 -217.15.129.218 15808 -116.14.132.15 56063 -76.177.90.141 36194 -88.90.45.47 58649 -77.57.165.254 6881 -80.98.76.72 43577 -78.30.207.121 16466 -109.89.22.180 30439 -68.190.74.32 22007 -36.236.16.67 16001 -114.163.214.158 11302 -2.97.93.187 57692 -94.253.39.133 6881 -79.139.88.71 10208 -59.126.161.235 42539 -81.234.255.202 56118 -117.200.86.161 53208 -31.46.125.31 18045 -82.243.71.203 65432 -78.224.185.52 56621 -76.204.112.132 6890 -93.223.130.30 32417 -87.223.168.225 26656 -173.73.46.92 52828 -178.202.38.237 40068 -109.14.228.2 6969 -95.157.142.198 64123 -220.245.1.193 64765 -62.227.10.103 19379 -192.228.212.170 21654 -66.197.135.74 9870 -37.221.132.150 22894 -94.21.58.12 38698 -188.176.186.181 18273 -188.190.155.210 4455 -108.252.160.139 42007 -94.23.204.135 30392 -63.245.169.145 33247 -93.96.38.245 6881 -31.45.22.161 35225 -77.222.31.52 59415 -96.42.167.80 52280 -190.196.105.132 14079 -117.201.208.178 10171 -187.104.231.26 33447 -68.42.14.214 23361 -67.167.214.225 63185 -24.138.59.223 55955 -111.242.33.86 23406 -125.30.116.231 18391 -123.23.70.154 10075 -78.229.90.129 32138 -69.112.56.177 44811 -31.16.41.107 7627 -92.141.209.132 15734 -79.118.37.244 40171 -66.49.128.103 51413 -178.90.62.99 10000 -178.157.237.100 6881 -91.178.167.101 30268 -206.248.183.2 51413 -93.86.246.79 12180 -109.193.181.26 17836 -90.224.116.7 33923 -37.144.199.41 32118 -89.123.71.101 10982 -112.204.163.100 13292 -125.24.197.213 11698 -46.63.180.70 54251 -217.210.112.89 20503 -213.64.227.205 18926 -123.203.151.250 56045 -114.37.64.184 25431 -86.8.232.198 47955 -213.181.202.91 51413 -37.229.225.109 24351 -2.33.68.167 45682 -88.222.217.56 46421 -90.208.116.214 55538 -2.124.113.120 51413 -211.228.97.32 11160 -85.67.228.231 33392 -93.116.242.153 33116 -94.51.121.80 59150 -113.171.86.250 10000 -5.159.110.99 26947 -58.7.253.60 38684 -91.229.20.68 6881 -91.179.116.59 17040 -117.195.47.150 49441 -42.98.29.129 22491 -85.167.147.174 34182 -82.242.149.9 25108 -85.108.197.61 29286 -95.56.72.49 14451 -83.150.118.223 7200 -83.246.191.21 6881 -82.49.66.69 26973 -50.53.84.14 47235 -88.212.37.175 40585 -84.55.102.97 49909 -82.168.130.135 56755 -46.173.90.211 6881 -109.169.54.139 51415 -114.34.93.180 20810 -99.231.123.139 47345 -125.212.120.5 21305 -109.128.196.245 51413 -176.215.30.14 28689 -98.30.187.130 21000 -75.73.136.19 62765 -212.19.133.88 13525 -108.202.164.27 51413 -2.49.208.236 46064 -116.51.131.3 47451 -78.155.189.90 22557 -2.3.154.124 43411 -46.251.69.224 11789 -85.138.161.222 28829 -94.181.133.210 35691 -41.69.137.231 13336 -49.48.231.206 64581 -82.7.153.234 39772 -94.113.125.164 27426 -75.48.224.72 51413 -176.103.81.177 52440 -37.218.152.141 24385 -221.149.52.79 11254 -213.114.77.51 61820 -178.22.225.30 11104 -92.84.81.34 57407 -93.146.94.221 19306 -171.116.86.165 16001 -101.63.130.19 48832 -85.84.221.4 19153 -79.126.54.102 37807 -74.77.92.19 51413 46.108.138.39 25884 92.247.220.203 25527 -89.20.124.41 6881 99.189.14.81 43179 211.193.20.248 25381 223.228.164.49 18616 @@ -397,7 +8,6 @@ 87.89.35.111 41473 46.2.98.125 26797 71.201.85.238 63526 -83.143.127.228 51413 89.142.117.227 60538 109.198.205.30 49001 92.126.225.35 10022 @@ -410,7 +20,6 @@ 94.211.208.25 16881 211.28.147.189 30748 46.50.162.228 6881 -122.116.89.184 59116 110.93.91.8 38100 84.248.75.232 63001 79.165.148.92 61137 @@ -418,46 +27,36 @@ 180.224.43.232 63573 79.82.223.182 29297 78.7.87.150 28643 -67.235.141.60 19894 27.190.132.73 4245 93.123.197.174 58547 89.216.145.187 1055 68.46.237.222 34912 69.181.68.72 60496 -107.193.240.30 51276 89.148.6.32 54889 92.112.84.248 10007 -194.44.21.96 58530 93.116.77.214 10035 37.79.42.73 32840 64.218.114.247 60600 95.178.198.186 28243 99.137.237.26 49238 112.134.68.224 10008 -89.41.56.250 15440 86.205.207.176 56623 60.220.85.253 13569 109.174.114.124 3725 89.23.163.173 19575 79.119.183.29 52107 59.66.110.93 27589 -78.105.105.87 42127 -95.69.207.44 35691 72.200.187.124 48593 178.123.203.73 6881 77.35.153.182 16318 201.22.70.49 12947 -80.236.120.181 14451 222.212.42.236 6107 85.25.110.34 62453 -86.24.133.104 42572 82.126.184.158 31323 -95.154.177.131 19995 1.22.41.112 37043 74.190.24.27 11742 70.123.139.33 45645 67.78.205.194 5007 -208.101.109.128 53329 184.99.81.210 65160 24.30.119.63 46448 84.10.80.103 512 @@ -474,7 +73,6 @@ 212.231.247.212 18744 212.253.173.114 57417 69.157.252.118 63494 -95.108.119.185 46830 213.112.21.57 27077 95.79.173.173 42349 76.121.182.77 54059 @@ -482,8 +80,6 @@ 92.124.7.63 26804 176.43.91.144 55976 220.135.191.36 13894 -78.230.236.178 51528 -194.213.106.70 49001 176.110.229.36 13664 178.88.53.243 19564 124.169.108.217 34547 @@ -494,7 +90,411 @@ 79.131.212.125 16844 142.68.216.103 20804 123.238.67.137 16515 -50.13.6.176 23275 58.170.3.84 34130 91.122.18.146 49001 76.116.68.100 53034 +188.16.212.171 6881 +91.241.136.195 48137 +46.149.234.13 6881 +109.110.233.223 63596 +194.44.93.49 41558 +65.28.74.168 16111 +203.202.219.105 26397 +24.215.90.104 50000 +83.246.219.62 12485 +86.29.84.7 56010 +24.192.64.18 48809 +81.101.178.26 36319 +83.165.232.251 11618 +199.127.250.15 29015 +178.83.119.5 6881 +178.216.101.214 54537 +89.80.119.247 57369 +188.124.72.59 32042 +61.19.218.36 50115 +188.190.69.190 40122 +99.102.20.107 34921 +88.174.176.173 56969 +91.219.249.72 6881 +68.229.157.53 20538 +96.55.113.202 17765 +67.193.153.219 61956 +66.169.55.105 10610 +46.214.22.165 20056 +83.128.123.13 22300 +77.41.8.139 6881 +213.111.210.47 44581 +24.30.83.45 54662 +94.23.55.33 33530 +85.27.36.125 3675 +88.90.45.47 58649 +78.30.207.121 16466 +76.177.90.141 36194 +82.243.71.203 65432 +37.221.132.150 22894 +78.224.185.52 56621 +141.84.252.30 6881 +173.73.46.92 52828 +94.23.204.135 30392 +187.104.231.26 33447 +86.8.232.198 47955 +85.67.228.231 33392 +82.242.149.9 25108 +83.246.191.21 6881 +84.55.102.97 49909 +109.169.54.139 51415 +85.138.161.222 28829 +98.30.187.130 21000 +108.202.164.27 51413 +94.113.125.164 27426 +83.143.127.228 51413 +89.20.124.41 6881 +122.116.89.184 59116 +194.44.21.96 58530 +89.41.56.250 15440 +86.24.133.104 42572 +95.154.177.131 19995 +107.193.240.30 51276 +78.105.105.87 42127 +220.245.1.193 64765 +95.108.119.185 46830 +208.101.109.128 53329 +78.230.236.178 51528 +194.213.106.70 49001 +70.72.180.170 10512 +50.13.6.176 23275 +37.57.17.197 51413 +208.92.21.235 51413 +65.28.234.9 6881 +75.198.61.145 31237 +105.232.142.153 21451 +67.235.141.60 19894 +142.162.222.55 40058 +95.69.207.44 35691 +83.219.215.44 26998 +50.141.207.46 40489 +106.160.47.184 63666 +60.242.97.209 61577 +105.236.24.75 39427 +79.131.84.242 29367 +114.95.228.227 11935 +69.158.76.219 58971 +74.172.229.212 9518 +176.196.29.72 6881 +50.92.192.233 16212 +176.44.25.96 44441 +87.223.16.63 46512 +95.211.209.162 6881 +89.17.34.66 36894 +81.5.117.20 6881 +31.6.128.147 22276 +95.81.228.126 56110 +101.62.20.221 58576 +83.215.168.25 64268 +78.227.57.127 26565 +93.92.199.52 14785 +70.184.208.133 1664 +85.64.42.90 46866 +159.224.152.53 6881 +81.198.240.120 19131 +109.165.217.191 17096 +82.80.164.128 51640 +173.12.200.5 5996 +67.197.115.77 33457 +24.128.99.196 2008 +93.100.4.123 18048 +178.214.163.7 34442 +24.247.179.164 8929 +217.145.16.253 6881 +63.142.211.249 19399 +50.66.93.232 48452 +91.217.90.22 58541 +89.250.174.38 49001 +75.82.172.220 22018 +134.3.49.58 5291 +87.106.249.208 4281 +78.222.160.139 37995 +217.28.239.38 55049 +79.173.119.29 21694 +178.44.153.14 49001 +119.247.118.205 51413 +190.175.67.129 23239 +2.216.70.171 37033 +128.79.124.229 23057 +142.177.120.18 6881 +210.188.39.160 15231 +78.129.47.89 25456 +217.44.226.98 50660 +46.188.25.222 64762 +78.182.157.168 13141 +109.62.139.85 34753 +86.97.18.110 14117 +122.163.241.196 10060 +124.148.58.177 42765 +88.190.17.198 51413 +37.9.53.15 51413 +94.248.201.81 11772 +2.94.239.104 26341 +72.80.63.47 6881 +69.14.228.42 1078 +76.64.217.54 44401 +98.240.147.38 10544 +95.165.76.74 37744 +74.89.151.131 61137 +78.81.42.64 29105 +46.12.152.63 60689 +89.88.176.161 42176 +92.155.213.221 10760 +99.188.192.23 57738 +182.186.67.163 58144 +189.101.136.201 54470 +80.216.2.3 63177 +89.176.181.183 1087 +178.207.233.208 50370 +70.51.252.250 59696 +178.187.192.77 30634 +124.168.238.135 39529 +221.205.98.141 16001 +81.184.83.43 41535 +151.25.78.87 6881 +188.27.197.94 18544 +86.135.42.108 45193 +71.235.78.32 47377 +98.197.97.188 8080 +118.171.164.182 17029 +78.181.27.239 52402 +95.32.130.29 27924 +95.252.234.95 50817 +23.17.78.202 49692 +50.143.162.189 42846 +1.161.24.188 21927 +222.54.48.68 16001 +112.162.27.161 35550 +126.107.170.119 20880 +83.221.190.99 41062 +86.126.166.8 6881 +31.148.57.186 16186 +5.13.37.159 11670 +213.176.229.38 56810 +96.54.26.71 61490 +110.54.21.50 27407 +86.127.60.231 46314 +5.56.181.94 46671 +1.53.165.182 10003 +60.241.238.77 8770 +80.82.69.214 25390 +70.179.27.230 12225 +88.126.12.12 9913 +87.153.100.103 8812 +130.204.152.216 45685 +77.255.17.211 43635 +24.61.199.37 64784 +84.90.254.199 47998 +68.144.77.17 35420 +219.124.192.58 18146 +94.242.209.168 51583 +95.96.151.231 14919 +89.71.154.95 10001 +62.102.170.64 41780 +213.242.54.224 49001 +50.132.115.253 30465 +115.64.212.244 53921 +90.48.214.148 30108 +99.112.168.210 26608 +218.250.225.144 8106 +213.113.112.93 54916 +89.133.27.246 6881 +89.169.167.250 60000 +90.34.205.80 30677 +63.245.169.145 33247 +31.23.203.196 49663 +195.28.2.158 12120 +109.86.138.84 6881 +24.211.235.136 63005 +123.48.88.21 21943 +220.233.66.245 44474 +202.89.161.121 49122 +124.170.105.167 62750 +88.161.230.36 23991 +79.111.222.93 10223 +208.102.53.151 50934 +78.84.18.116 35625 +50.194.191.60 6881 +70.31.41.207 51413 +105.237.27.137 23483 +50.201.138.122 10228 +188.244.175.193 6881 +128.72.188.87 9089 +123.30.74.10 25520 +18.93.14.55 33270 +66.197.135.74 9870 +75.70.84.67 52856 +112.161.223.134 27497 +151.50.187.42 46187 +69.204.231.202 6881 +95.176.193.130 38527 +2.30.11.167 40530 +89.231.133.106 41153 +178.167.122.78 46139 +87.209.76.83 5867 +178.210.228.105 29112 +95.220.26.219 6881 +85.30.93.63 42042 +74.207.143.127 11098 +37.192.22.115 35691 +124.153.224.247 49237 +37.153.18.111 50627 +95.139.209.35 35691 +82.234.232.63 22112 +109.10.172.35 19332 +31.130.17.162 49001 +92.113.123.121 46094 +108.193.168.193 46057 +211.193.27.61 63664 +203.189.97.152 51413 +92.39.237.243 59899 +80.236.120.181 14451 +178.223.171.122 18225 +86.62.146.229 35500 +90.227.58.41 25523 +46.35.227.173 10048 +2.132.96.20 51413 +174.2.56.170 10010 +2.227.33.181 48652 +79.182.21.2 49965 +184.99.119.173 65160 +90.193.128.203 61929 +89.92.244.72 61340 +90.18.32.30 52308 +90.53.53.66 35604 +91.82.34.163 12345 +89.2.143.46 18263 +50.47.16.36 59940 +75.65.71.119 23100 +94.23.49.143 8000 +82.226.200.209 52277 +109.120.214.119 36064 +95.135.74.56 13267 +146.158.20.181 50776 +82.238.176.52 31771 +72.208.178.104 46970 +69.114.139.178 1362 +217.77.20.134 30948 +83.139.140.222 29412 +178.64.14.32 6881 +187.57.85.11 46431 +122.195.185.77 16001 +14.192.142.81 41286 +95.19.48.206 54069 +46.230.20.171 51413 +95.39.223.81 6881 +79.140.174.180 19461 +195.228.61.152 16866 +67.61.23.36 42086 +14.47.26.94 14485 +112.21.1.31 16001 +122.193.188.86 1898 +188.25.63.152 23937 +90.190.20.83 21848 +95.24.50.40 53036 +180.183.44.124 24982 +123.108.226.150 57551 +109.64.212.115 54142 +89.211.83.21 29166 +189.69.171.229 15917 +111.242.44.151 22774 +114.36.19.36 8355 +14.53.82.76 40210 +46.150.6.40 17728 +84.79.92.79 27171 +83.28.102.138 53960 +83.220.90.91 6881 +89.159.16.254 11685 +176.110.246.47 40629 +122.150.55.60 38882 +188.194.175.190 33778 +89.135.99.47 59207 +94.65.207.68 24008 +46.250.118.60 40701 +31.41.60.45 57526 +151.28.154.129 28802 +78.84.68.154 16279 +176.37.2.4 6881 +37.6.121.100 31426 +178.88.93.202 12040 +14.192.246.113 49890 +193.41.184.234 54938 +83.99.181.118 28483 +66.225.173.246 60004 +31.163.131.173 27658 +65.94.209.166 11472 +112.205.2.4 64962 +176.9.113.77 61059 +93.170.28.181 12881 +79.112.132.33 32289 +92.49.156.87 52656 +188.77.209.54 23530 +116.202.121.222 43976 +95.155.254.176 15578 +97.83.52.73 33541 +98.197.136.107 12520 +90.189.44.100 60868 +123.194.41.195 16001 +183.101.164.6 29659 +200.92.49.217 16001 +124.190.113.47 31938 +94.179.174.22 25607 +95.46.211.49 17436 +188.186.23.213 34609 +86.160.200.122 32684 +92.152.98.221 1064 +71.237.6.246 41304 +83.252.40.219 43038 +24.139.75.159 17025 +108.77.18.29 55320 +79.168.31.62 2622 +182.166.177.138 57349 +94.237.78.107 27652 +95.136.148.114 24567 +188.126.41.103 26312 +46.63.212.84 35792 +177.16.241.106 45271 +178.74.226.9 48498 +79.116.11.221 40618 +128.71.72.219 62133 +109.127.166.38 64454 +86.156.165.112 50381 +78.145.36.188 58753 +176.14.161.86 6881 +109.101.34.240 10902 +31.180.55.227 10034 +85.75.7.212 51413 +87.222.93.176 51820 +59.129.70.216 51214 +59.189.224.35 48952 +37.229.150.137 63483 +95.154.52.203 24703 +88.102.56.243 10016 +213.22.43.68 16088 +91.77.79.161 49001 +46.159.213.98 48679 +37.229.166.186 58189 +118.166.174.251 16001 +94.45.187.36 34921 +109.238.98.207 28281 +62.141.219.76 52790 +186.222.9.89 37524 +180.199.181.162 31573 +109.63.197.122 6881 +88.206.85.61 11789 +109.197.128.119 35691 +109.65.151.224 22686 +24.139.75.159 55215 +68.52.52.15 50017 +124.121.50.231 47353 +27.9.150.248 45913 +178.149.6.45 43642 +80.195.253.210 36134 +112.165.56.205 38376 +62.151.135.200 60153 +122.39.214.154 51539 diff --git a/src/example/bootstrap_fn.cc b/src/example/bootstrap_fn.cc new file mode 100644 index 0000000..e58d9a1 --- /dev/null +++ b/src/example/bootstrap_fn.cc @@ -0,0 +1,60 @@ + + +#include "bitdht/bdiface.h" +#include "bitdht/bdstddht.h" +#include "bdhandler.h" + +#include "bootstrap_fn.h" + +bool bdSingleShotFindPeer(const std::string bootstrapfile, const std::string peerId, std::string &peer_ip, uint16_t &peer_port) +{ + /* startup dht : with a random id! */ + bdNodeId ownId; + bdStdRandomNodeId(&ownId); + + uint16_t port = 6775; + std::string appId = "bsId"; + BitDhtHandler dht(&ownId, port, appId, bootstrapfile); + + /* install search node */ + bdNodeId searchId; + bdStdRandomNodeId(&searchId); + + std::cerr << "bssdht: searching for Id: "; + bdStdPrintNodeId(std::cerr, &searchId); + std::cerr << std::endl; + + dht.FindNode(&searchId); + + /* run your program */ + bdId resultId; + uint32_t status; + + resultId.id = searchId; + + while(false == dht.SearchResult(&resultId, status)) + { + sleep(10); + } + + std::cerr << "bdSingleShotFindPeer(): Found Result:" << std::endl; + + std::cerr << "\tId: "; + bdStdPrintId(std::cerr, &resultId); + std::cerr << std::endl; + + std::cerr << "\tstatus: " << status; + std::cerr << std::endl; + + dht.shutdown(); + + return true; +} + + + + + + + + diff --git a/src/example/bootstrap_fn.h b/src/example/bootstrap_fn.h new file mode 100644 index 0000000..19ff6d7 --- /dev/null +++ b/src/example/bootstrap_fn.h @@ -0,0 +1,17 @@ + +#include +#include + + +/* NOTE. At the moment only the bootstrapfile is actually used. + * peerId is ignored (a random peerId is searched for). ip & port are not filled in either. + * + * This is mainly to finish testing. + * + * Once the best form of the return functions is decided (ipv4 structure, or strings). + * this can be finished off. + * + */ + +bool bdSingleShotFindPeer(const std::string bootstrapfile, const std::string peerId, std::string &ip, uint16_t &port); + diff --git a/src/example/bssdht.cc b/src/example/bssdht.cc index b1d1e7b..9d5f0e4 100644 --- a/src/example/bssdht.cc +++ b/src/example/bssdht.cc @@ -1,50 +1,22 @@ - -#include "bitdht/bdiface.h" -#include "bitdht/bdstddht.h" -#include "bdhandler.h" +#include "bootstrap_fn.h" +#include +#include int main(int argc, char **argv) { - /* startup dht : with a random id! */ - bdNodeId ownId; - bdStdRandomNodeId(&ownId); - - uint16_t port = 6775; - std::string appId = "bsId"; std::string bootstrapfile = "bdboot.txt"; - - BitDhtHandler dht(&ownId, port, appId, bootstrapfile); - - /* install search node */ - bdNodeId searchId; - bdStdRandomNodeId(&searchId); - - std::cerr << "bssdht: searching for Id: "; - bdStdPrintNodeId(std::cerr, &searchId); + std::string peerId; + std::string ip; + uint16_t port; + + std::cerr << "bssdht: starting up"; std::cerr << std::endl; - dht.FindNode(&searchId); + bdSingleShotFindPeer(bootstrapfile, peerId, ip, port); - /* run your program */ - bdId resultId; - uint32_t status; - - resultId.id = searchId; - - while(false == dht.SearchResult(&resultId, status)) - { - sleep(10); - } - - std::cerr << "bssdht: Found Result:" << std::endl; - - std::cerr << "\tId: "; - bdStdPrintId(std::cerr, &resultId); - std::cerr << std::endl; - - std::cerr << "\tstatus: " << status; + std::cerr << "bssdht: finished"; std::cerr << std::endl; return 1;