mirror of https://github.com/aria2/aria2
2010-02-23 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added aiFlags argument to getInterfaceAddress(). Use AI_NUMERICHOST to find interface specified using --bt-lpd-interface option to avoid time-consuming address lookup. * src/BtSetup.cc * src/SocketCore.cc * src/SocketCore.hpull/1/head
parent
232deb47b5
commit
fa6fd758af
|
@ -1,3 +1,12 @@
|
||||||
|
2010-02-23 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
|
Added aiFlags argument to getInterfaceAddress(). Use
|
||||||
|
AI_NUMERICHOST to find interface specified using
|
||||||
|
--bt-lpd-interface option to avoid time-consuming address lookup.
|
||||||
|
* src/BtSetup.cc
|
||||||
|
* src/SocketCore.cc
|
||||||
|
* src/SocketCore.h
|
||||||
|
|
||||||
2010-02-23 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
2010-02-23 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
Return SharedHandle<LpdMessage>(new LpdMessage()) if received data
|
Return SharedHandle<LpdMessage>(new LpdMessage()) if received data
|
||||||
|
|
|
@ -188,7 +188,7 @@ void BtSetup::setup(std::deque<Command*>& commands,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
std::vector<std::pair<sockaddr_storage, socklen_t> > ifAddrs;
|
std::vector<std::pair<sockaddr_storage, socklen_t> > ifAddrs;
|
||||||
getInterfaceAddress(ifAddrs, lpdInterface, AF_INET);
|
getInterfaceAddress(ifAddrs, lpdInterface, AF_INET, AI_NUMERICHOST);
|
||||||
for(std::vector<std::pair<sockaddr_storage, socklen_t> >::const_iterator
|
for(std::vector<std::pair<sockaddr_storage, socklen_t> >::const_iterator
|
||||||
i = ifAddrs.begin(); i != ifAddrs.end(); ++i) {
|
i = ifAddrs.begin(); i != ifAddrs.end(); ++i) {
|
||||||
sockaddr_in addr;
|
sockaddr_in addr;
|
||||||
|
|
|
@ -1267,7 +1267,7 @@ void SocketCore::bindAddress(const std::string& iface)
|
||||||
|
|
||||||
void getInterfaceAddress
|
void getInterfaceAddress
|
||||||
(std::vector<std::pair<struct sockaddr_storage, socklen_t> >& ifAddrs,
|
(std::vector<std::pair<struct sockaddr_storage, socklen_t> >& ifAddrs,
|
||||||
const std::string& iface, int family)
|
const std::string& iface, int family, int aiFlags)
|
||||||
{
|
{
|
||||||
Logger* logger = LogFactory::getInstance();
|
Logger* logger = LogFactory::getInstance();
|
||||||
if(logger->debug()) {
|
if(logger->debug()) {
|
||||||
|
@ -1314,11 +1314,9 @@ void getInterfaceAddress
|
||||||
if(ifAddrs.empty()) {
|
if(ifAddrs.empty()) {
|
||||||
struct addrinfo* res;
|
struct addrinfo* res;
|
||||||
int s;
|
int s;
|
||||||
s = callGetaddrinfo(&res, iface.c_str(), 0, family,
|
s = callGetaddrinfo(&res, iface.c_str(), 0, family, SOCK_STREAM, aiFlags,0);
|
||||||
SOCK_STREAM, 0, 0);
|
|
||||||
if(s) {
|
if(s) {
|
||||||
logger->info(MSG_INTERFACE_NOT_FOUND,
|
logger->info(MSG_INTERFACE_NOT_FOUND, iface.c_str(), gai_strerror(s));
|
||||||
iface.c_str(), gai_strerror(s));
|
|
||||||
} else {
|
} else {
|
||||||
WSAAPI_AUTO_DELETE<struct addrinfo*> resDeleter(res, freeaddrinfo);
|
WSAAPI_AUTO_DELETE<struct addrinfo*> resDeleter(res, freeaddrinfo);
|
||||||
struct addrinfo* rp;
|
struct addrinfo* rp;
|
||||||
|
|
|
@ -381,7 +381,7 @@ public:
|
||||||
|
|
||||||
friend void getInterfaceAddress
|
friend void getInterfaceAddress
|
||||||
(std::vector<std::pair<struct sockaddr_storage, socklen_t> >& ifAddrs,
|
(std::vector<std::pair<struct sockaddr_storage, socklen_t> >& ifAddrs,
|
||||||
const std::string& iface, int family);
|
const std::string& iface, int family, int aiFlags);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Set default ai_flags. hints.ai_flags is initialized with this
|
// Set default ai_flags. hints.ai_flags is initialized with this
|
||||||
|
@ -399,10 +399,11 @@ int callGetaddrinfo
|
||||||
// Collects IP addresses of given inteface iface and stores in
|
// Collects IP addresses of given inteface iface and stores in
|
||||||
// ifAddres. iface may be specified as a hostname, IP address or
|
// ifAddres. iface may be specified as a hostname, IP address or
|
||||||
// interface name like eth0. You can limit the family of IP addresses
|
// interface name like eth0. You can limit the family of IP addresses
|
||||||
// to collect using family argument. No throw.
|
// to collect using family argument. aiFlags is passed to
|
||||||
|
// getaddrinfo() as hints.ai_flags. No throw.
|
||||||
void getInterfaceAddress
|
void getInterfaceAddress
|
||||||
(std::vector<std::pair<struct sockaddr_storage, socklen_t> >& ifAddrs,
|
(std::vector<std::pair<struct sockaddr_storage, socklen_t> >& ifAddrs,
|
||||||
const std::string& iface, int family = AF_UNSPEC);
|
const std::string& iface, int family = AF_UNSPEC, int aiFlags = 0);
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue