how does DC++ to get isp Internet IP in active mode ?

Problems compiling? Don't understand the source code? Don't know how to code your feature? Post here.

Moderator: Moderators

Locked
dahwoud
Posts: 3
Joined: 2004-04-13 09:22

how does DC++ to get isp Internet IP in active mode ?

Post by dahwoud » 2004-04-13 09:26

Thanks

GargoyleMT
DC++ Contributor
Posts: 3212
Joined: 2003-01-07 21:46
Location: .pa.us

Post by GargoyleMT » 2004-04-13 20:05

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;
}

dahwoud
Posts: 3
Joined: 2004-04-13 09:22

Post by dahwoud » 2004-04-18 04:21

OK :cry:

Qbert
Posts: 73
Joined: 2003-06-07 03:12

Post by Qbert » 2004-04-18 15:43

You can still manually set it in the connection settings. Why the sad face?
My Visual Studio .NET 2003 is licensed under my name, and the same for my operating system... What about you?
I surf on an OC3 without limitations, two to be exact, and I'm not joking.

gbickford
Posts: 5
Joined: 2004-06-05 03:05
Location: Buenos Aires, Argentina
Contact:

Post by gbickford » 2004-06-05 04:10

perhaps they don't have an OC3 or a static ip address and they don't want to have to manually set their external ip address every time they open dc++.

at least thats why i'm here. :)

GargoyleMT
DC++ Contributor
Posts: 3212
Joined: 2003-01-07 21:46
Location: .pa.us

Post by GargoyleMT » 2004-06-05 08:03

gbickford wrote:perhaps they don't have an OC3 or a static ip address and they don't want to have to manually set their external ip address every time they open dc++.
One such existing option is to use a dynamic DNS name instead of an IP address.

PseudonympH
Forum Moderator
Posts: 366
Joined: 2004-03-06 02:46

Post by PseudonympH » 2004-06-05 21:21

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.

Sedulus
Forum Moderator
Posts: 687
Joined: 2003-01-04 09:32
Contact:

Post by Sedulus » 2004-06-06 06:03

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.
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)

gbickford
Posts: 5
Joined: 2004-06-05 03:05
Location: Buenos Aires, Argentina
Contact:

Post by gbickford » 2004-06-06 08:39

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?

g

GargoyleMT
DC++ Contributor
Posts: 3212
Joined: 2003-01-07 21:46
Location: .pa.us

Post by GargoyleMT » 2004-06-06 09:35

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?
0.0.0.0 (for non-existent ADC hubs): yes.
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).

PseudonympH
Forum Moderator
Posts: 366
Joined: 2004-03-06 02:46

Post by PseudonympH » 2004-06-07 14:57

Sedulus wrote:1) DC++ resolves the hostname before sending it out
Ah... I didn't know that was how it worked.

Locked