mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
6290d8fed9
In preparation for making RS support IPv6. NB: This breaks the build of retroshare-gui, as the sockaddr_storage_xxx fns are only defined as prototypes for now. All the aux libraries like udp / stun / tcponudp / dht have still to be converted. These changes will probably break various things and need to be tested thoroughly. git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.6-initdev@6735 b45a01b8-16f6-495d-af2f-9b41ad6348cc
41 lines
761 B
C++
41 lines
761 B
C++
#pragma once
|
|
|
|
#include "pqi/pqinetwork.h"
|
|
|
|
#ifndef WIN32
|
|
#include <netdb.h>
|
|
#endif
|
|
|
|
#include <map>
|
|
#include <string>
|
|
#include "util/rsthreads.h"
|
|
|
|
struct sockaddr ;
|
|
|
|
class DNSResolver
|
|
{
|
|
public:
|
|
DNSResolver() ;
|
|
~DNSResolver() ;
|
|
|
|
bool getIPAddressFromString(const std::string& server_name,struct sockaddr_storage &addr) ;
|
|
|
|
void start_request() ;
|
|
void reset() ;
|
|
|
|
private:
|
|
enum { DNS_DONT_HAVE,DNS_SEARCHING, DNS_HAVE, DNS_LOOKUP_ERROR } ;
|
|
|
|
struct AddrInfo
|
|
{
|
|
uint32_t state ; // state: Looked-up, not found, have
|
|
time_t last_lookup_time ; // last lookup time
|
|
struct sockaddr_storage addr ;
|
|
};
|
|
friend void *solveDNSEntries(void *p) ;
|
|
|
|
RsMutex _rdnsMtx ;
|
|
bool *_thread_running ;
|
|
std::map<std::string, AddrInfo> *_addr_map ;
|
|
};
|