mirror of https://github.com/aria2/aria2
2008-05-11 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Changed method signature: NameResolver::resolve * src/DHTEntryPointNameResolveCommand.cc * src/InitiateConnectionCommand.cc * src/NameResolver.cc * src/NameResolver.hpull/1/head
parent
7ec7b7ea60
commit
5e99846776
|
@ -1,3 +1,12 @@
|
|||
2008-05-11 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||
|
||||
Changed method signature:
|
||||
NameResolver::resolve
|
||||
* src/DHTEntryPointNameResolveCommand.cc
|
||||
* src/InitiateConnectionCommand.cc
|
||||
* src/NameResolver.cc
|
||||
* src/NameResolver.h
|
||||
|
||||
2008-05-11 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||
|
||||
Changed method signature:
|
||||
|
|
|
@ -108,7 +108,8 @@ bool DHTEntryPointNameResolveCommand::execute()
|
|||
while(_entryPoints.size()) {
|
||||
std::string hostname = _entryPoints.front().first;
|
||||
try {
|
||||
std::deque<std::string> addrs(res.resolve(hostname));
|
||||
std::deque<std::string> addrs;
|
||||
res.resolve(addrs, hostname);
|
||||
|
||||
std::pair<std::string, uint16_t> p(addrs.front(),
|
||||
_entryPoints.front().second);
|
||||
|
|
|
@ -85,7 +85,7 @@ bool InitiateConnectionCommand::executeInternal() {
|
|||
{
|
||||
NameResolver res;
|
||||
res.setSocktype(SOCK_STREAM);
|
||||
addrs = res.resolve(hostname);
|
||||
res.resolve(addrs, hostname);
|
||||
}
|
||||
logger->info(MSG_NAME_RESOLUTION_COMPLETE, cuid,
|
||||
hostname.c_str(),
|
||||
|
|
|
@ -43,7 +43,8 @@ namespace aria2 {
|
|||
|
||||
NameResolver::NameResolver():_socktype(0) {}
|
||||
|
||||
std::deque<std::string> NameResolver::resolve(const std::string& hostname)
|
||||
void NameResolver::resolve(std::deque<std::string>& resolvedAddresses,
|
||||
const std::string& hostname)
|
||||
{
|
||||
struct addrinfo hints;
|
||||
struct addrinfo* res;
|
||||
|
@ -58,16 +59,13 @@ std::deque<std::string> NameResolver::resolve(const std::string& hostname)
|
|||
throw DlAbortEx(StringFormat(EX_RESOLVE_HOSTNAME,
|
||||
hostname.c_str(), gai_strerror(s)).str());
|
||||
}
|
||||
std::deque<std::string> addrs;
|
||||
struct addrinfo* rp;
|
||||
for(rp = res; rp; rp = rp->ai_next) {
|
||||
std::pair<std::string, uint16_t> addressPort
|
||||
= Util::getNumericNameInfo(rp->ai_addr, rp->ai_addrlen);
|
||||
addrs.push_back(addressPort.first);
|
||||
resolvedAddresses.push_back(addressPort.first);
|
||||
}
|
||||
freeaddrinfo(res);
|
||||
|
||||
return addrs;
|
||||
}
|
||||
|
||||
void NameResolver::setSocktype(int socktype)
|
||||
|
|
|
@ -47,7 +47,11 @@ private:
|
|||
public:
|
||||
NameResolver();
|
||||
|
||||
std::deque<std::string> resolve(const std::string& hostname);
|
||||
/**
|
||||
* Reolved addresses are pushed into addresses.
|
||||
*/
|
||||
void resolve(std::deque<std::string>& resolvedAddresses,
|
||||
const std::string& hostname);
|
||||
|
||||
// specify SOCK_STREAM or SOCK_DGRAM
|
||||
void setSocktype(int socktype);
|
||||
|
|
Loading…
Reference in New Issue