2012-10-28 10:21:58 -04:00
|
|
|
|
2012-12-09 08:19:28 -05:00
|
|
|
#include "bootstrap_fn.h"
|
|
|
|
#include <iostream>
|
|
|
|
#include <inttypes.h>
|
2012-10-28 10:21:58 -04:00
|
|
|
|
2012-12-17 15:19:27 -05:00
|
|
|
void args(char *name)
|
|
|
|
{
|
|
|
|
std::cerr << std::endl;
|
|
|
|
std::cerr << "Dht Single Shot Searcher";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
std::cerr << "Usage:";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
std::cerr << "\t" << name << " -p <peerId> ";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
std::cerr << std::endl;
|
|
|
|
std::cerr << "NB: The PeerId is Required to Run";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
std::cerr << std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-10-28 10:21:58 -04:00
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
|
|
|
|
std::string bootstrapfile = "bdboot.txt";
|
2012-12-09 08:19:28 -05:00
|
|
|
std::string peerId;
|
|
|
|
std::string ip;
|
|
|
|
uint16_t port;
|
2012-12-17 15:19:27 -05:00
|
|
|
int c;
|
|
|
|
bool havePeerId = false;
|
|
|
|
|
|
|
|
|
|
|
|
while((c = getopt(argc, argv,"p:")) != -1)
|
|
|
|
{
|
|
|
|
switch (c)
|
|
|
|
{
|
|
|
|
case 'p':
|
|
|
|
peerId = optarg;
|
|
|
|
havePeerId = true;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
args(argv[0]);
|
|
|
|
return 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!havePeerId)
|
|
|
|
{
|
|
|
|
args(argv[0]);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2012-12-09 08:19:28 -05:00
|
|
|
|
|
|
|
std::cerr << "bssdht: starting up";
|
2012-10-28 10:21:58 -04:00
|
|
|
std::cerr << std::endl;
|
|
|
|
|
2012-12-09 08:19:28 -05:00
|
|
|
bdSingleShotFindPeer(bootstrapfile, peerId, ip, port);
|
2012-10-28 10:21:58 -04:00
|
|
|
|
2012-12-09 08:19:28 -05:00
|
|
|
std::cerr << "bssdht: finished";
|
2012-10-28 10:21:58 -04:00
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|