mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-10 18:15:18 -04:00
made the DNS calls in a separate thread, using new DNSResolver class. Added test program for that class as well. Moved extaddrfinder to util/
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3980 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
dddc9c383c
commit
40f4009ca7
10 changed files with 328 additions and 53 deletions
|
@ -12,11 +12,11 @@ TESTOBJ = conn_harness.o ppg_harness.o
|
|||
|
||||
TESTOBJ += net_test.o dht_test.o net_test1.o netiface_test.o dht_test.o
|
||||
TESTOBJ += pkt_test.o pqiarchive_test.o pqiperson_test.o
|
||||
TESTOBJ += extaddrfinder_test.o pqiipset_test.o
|
||||
TESTOBJ += extaddrfinder_test.o dnsresolver_test.o pqiipset_test.o
|
||||
TESTOBJ += p3connmgr_reset_test.o p3connmgr_connect_test.o
|
||||
#conn_test.o
|
||||
|
||||
TESTS = net_test net_test1 netiface_test pqiarchive_test pqiperson_test extaddrfinder_test
|
||||
TESTS = net_test net_test1 netiface_test pqiarchive_test pqiperson_test dnsresolver_test extaddrfinder_test
|
||||
TESTS += pqiipset_test
|
||||
TESTS += p3connmgr_reset_test p3connmgr_connect_test
|
||||
#TESTS = p3connmgr_test1
|
||||
|
@ -56,6 +56,9 @@ pqiperson_test: pqiperson_test.o testconnect.o
|
|||
extaddrfinder_test: extaddrfinder_test.o
|
||||
$(CC) $(CFLAGS) -o extaddrfinder_test extaddrfinder_test.o $(LIBS)
|
||||
|
||||
dnsresolver_test: dnsresolver_test.o
|
||||
$(CC) $(CFLAGS) -o dnsresolver_test dnsresolver_test.o $(LIBS)
|
||||
|
||||
pqiipset_test: pqiipset_test.o
|
||||
$(CC) $(CFLAGS) -o pqiipset_test pqiipset_test.o $(LIBS)
|
||||
|
||||
|
|
83
libretroshare/src/tests/pqi/dnsresolver_test.cc
Normal file
83
libretroshare/src/tests/pqi/dnsresolver_test.cc
Normal file
|
@ -0,0 +1,83 @@
|
|||
|
||||
/*
|
||||
* "$Id:$"
|
||||
*
|
||||
* RetroShare C++ Interface.
|
||||
*
|
||||
* Copyright 2010-2011 by Cyril Soler
|
||||
*
|
||||
* 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 "util/dnsresolver.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::list<std::string> names;
|
||||
|
||||
DNSResolver *r = new DNSResolver ;
|
||||
|
||||
names.push_back("cortinaire.inrialpes.fr") ;
|
||||
names.push_back("www.google.com") ;
|
||||
names.push_back("www.ego.cn") ;
|
||||
names.push_back("free.fr") ;
|
||||
|
||||
for(int i=0;i<5;++i)
|
||||
{
|
||||
for(std::list<std::string>::const_iterator it = names.begin(); it != names.end(); it++)
|
||||
{
|
||||
in_addr addr ;
|
||||
bool res = r->getIPAddressFromString(*it,addr) ;
|
||||
|
||||
if(res)
|
||||
std::cerr << "Lookup of " << *it << ": " << (res?"done":"pending") << ": addr = " << (void*)addr.s_addr << std::endl;
|
||||
else
|
||||
std::cerr << "Lookup of " << *it << ": " << (res?"done":"pending") << std::endl;
|
||||
}
|
||||
|
||||
std::cerr << std::endl;
|
||||
usleep(200000) ;
|
||||
}
|
||||
|
||||
r->reset() ;
|
||||
|
||||
for(int i=0;i<5;++i)
|
||||
{
|
||||
for(std::list<std::string>::const_iterator it = names.begin(); it != names.end(); it++)
|
||||
{
|
||||
in_addr addr ;
|
||||
bool res = r->getIPAddressFromString(*it,addr) ;
|
||||
|
||||
if(res)
|
||||
std::cerr << "Lookup of " << *it << ": " << (res?"done":"pending") << ": addr = " << (void*)addr.s_addr << std::endl;
|
||||
else
|
||||
std::cerr << "Lookup of " << *it << ": " << (res?"done":"pending") << std::endl ;
|
||||
}
|
||||
std::cerr << std::endl;
|
||||
usleep(200000) ;
|
||||
}
|
||||
|
||||
delete r ;
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue