how does DC++ to get isp Internet IP in active mode ?
Moderator: Moderators
-
- DC++ Contributor
- Posts: 3212
- Joined: 2003-01-07 21:46
- Location: .pa.us
It doesn't get it from outside the network, it pulls trom the local network interfaces:
Code: Select all
string Client::getLocalIp() const {
if(!SETTING(SERVER).empty()) {
return Socket::resolve(SETTING(SERVER));
}
if(getMe() && !getMe()->getIp().empty())
return getMe()->getIp();
if(socket == NULL)
return Util::getLocalIp();
string tmp = socket->getLocalIp();
if(tmp.empty())
return Util::getLocalIp();
return tmp;
}
Code: Select all
string Util::getLocalIp() {
string tmp;
char buf[256];
gethostname(buf, 255);
hostent* he = gethostbyname(buf);
if(he == NULL || he->h_addr_list[0] == 0)
return Util::emptyString;
sockaddr_in dest;
int i = 0;
// We take the first ip as default, but if we can find a better one, use it instead...
memcpy(&(dest.sin_addr), he->h_addr_list[i++], he->h_length);
tmp = inet_ntoa(dest.sin_addr);
if( strncmp(tmp.c_str(), "192", 3) == 0 ||
strncmp(tmp.c_str(), "169", 3) == 0 ||
strncmp(tmp.c_str(), "127", 3) == 0 ||
strncmp(tmp.c_str(), "10.", 3) == 0 ) {
while(he->h_addr_list[i]) {
memcpy(&(dest.sin_addr), he->h_addr_list[i], he->h_length);
string tmp2 = inet_ntoa(dest.sin_addr);
if( strncmp(tmp2.c_str(), "192", 3) != 0 &&
strncmp(tmp2.c_str(), "169", 3) != 0 &&
strncmp(tmp2.c_str(), "127", 3) != 0 &&
strncmp(tmp2.c_str(), "10.", 3) != 0) {
tmp = tmp2;
}
i++;
}
}
return tmp;
}
-
- DC++ Contributor
- Posts: 3212
- Joined: 2003-01-07 21:46
- Location: .pa.us
-
- Forum Moderator
- Posts: 366
- Joined: 2004-03-06 02:46
Unfortunately, that won't be an option under ADC, and I think that's something that will make a fair amount of people angry about it. That and the UTF-8 thing are the only things the average end user could possibly notice, and it's sad that one of them is a big negative, and the other will not be noticed by many.
hm?
1) DC++ resolves the hostname before sending it out --> ADC clients can still do that. at no point does the hub see a hostname.
2) ADC clients don't need to. by sending the null IP (0.0.0.0) you do a request for your own IP as the hub sees it.
1) DC++ resolves the hostname before sending it out --> ADC clients can still do that. at no point does the hub see a hostname.
2) ADC clients don't need to. by sending the null IP (0.0.0.0) you do a request for your own IP as the hub sees it.
http://dc.selwerd.nl/hublist.xml.bz2
http://www.b.ali.btinternet.co.uk/DCPlusPlus/index.html (TheParanoidOne's DC++ Guide)
http://www.dslreports.com/faq/dc (BSOD2600's Direct Connect FAQ)
http://www.b.ali.btinternet.co.uk/DCPlusPlus/index.html (TheParanoidOne's DC++ Guide)
http://www.dslreports.com/faq/dc (BSOD2600's Direct Connect FAQ)
-
- DC++ Contributor
- Posts: 3212
- Joined: 2003-01-07 21:46
- Location: .pa.us
0.0.0.0 (for non-existent ADC hubs): yes.gbickford wrote:So I can just throw a hostname, 0.0.0.0, or nothing at all in there and I will still be in active mode?
hostname: yes.
You only need for force the IP when your local machine's IP is different from your external IP (and you have control over port forwarding at the router).
-
- Forum Moderator
- Posts: 366
- Joined: 2004-03-06 02:46