Jump to content
Phishing - Beware of identity theft... ×
  • 0

Internal ip from source


alejogz

Question

previously I was using game 34k with dif internal_ip and my friends could connect normally, I am now working with the source and obviously no dif serves in that game, I would like to know how to do what makes internal_ip dif but at source, which know thank you very much.

Link to comment
Share on other sites

14 answers to this question

Recommended Posts

  • 0

Open config.cpp search 192.168 replace with 999.999

you can give me your config.cpp? my bool GetIPInfo() not have the 192.168

if you give me your config.cpp i copy your code bool GetIPInfo() and replace for the mine thanks!

  • Love 1
Link to comment
Share on other sites

  • 0

up, any can give me your config.cpp? or the code of GetIPInfo(), my GetIPInfo() is incomplete :C

bool GetIPInfo()
{
#ifndef __WIN32__
	struct ifaddrs* ifaddrp = NULL;

	if (0 != getifaddrs(&ifaddrp))
		return false;

	for( struct ifaddrs* ifap=ifaddrp ; NULL != ifap ; ifap = ifap->ifa_next )
	{
		struct sockaddr_in * sai = (struct sockaddr_in *) ifap->ifa_addr;

		if (!ifap->ifa_netmask ||  // ignore if no netmask
				sai->sin_addr.s_addr == 0 || // ignore if address is 0.0.0.0
				sai->sin_addr.s_addr == 16777343) // ignore if address is 127.0.0.1
			continue;
#else
	WSADATA wsa_data;
	char host_name[100];
	HOSTENT* host_ent;
	int n = 0;

	if (WSAStartup(0x0101, &wsa_data)) {
		return false;
	}

	gethostname(host_name, sizeof(host_name));
	host_ent = gethostbyname(host_name);
	if (host_ent == NULL) {
		return false;
	}
	for ( ; host_ent->h_addr_list[n] != NULL; ++n) {
		struct sockaddr_in addr;
		struct sockaddr_in* sai = &addr;
		memcpy(&sai->sin_addr.s_addr, host_ent->h_addr_list[n], host_ent->h_length);
#endif

		char * netip = inet_ntoa(sai->sin_addr);

		if (!strncmp(netip, "192.168", 7)) // ignore if address is starting with 192
		{
			strlcpy(g_szInternalIP, netip, sizeof(g_szInternalIP));
#ifndef __WIN32__
			fprintf(stderr, "INTERNAL_IP: %s interface %sn", netip, ifap->ifa_name);
#else
			fprintf(stderr, "INTERNAL_IP: %sn", netip);
#endif
		}
		else if (!strncmp(netip, "10.", 3))
		{
			strlcpy(g_szInternalIP, netip, sizeof(g_szInternalIP));
#ifndef __WIN32__
			fprintf(stderr, "INTERNAL_IP: %s interface %sn", netip, ifap->ifa_name);
#else
			fprintf(stderr, "INTERNAL_IP: %sn", netip);
#endif
		}
		else if (g_szPublicIP[0] == '0')
		{
			strlcpy(g_szPublicIP, netip, sizeof(g_szPublicIP));
#ifndef __WIN32__
			fprintf(stderr, "PUBLIC_IP: %s interface %sn", netip, ifap->ifa_name);
#else
			fprintf(stderr, "PUBLIC_IP: %sn", netip);
#endif
		}
	}

#ifndef __WIN32__
	freeifaddrs( ifaddrp );
#else
	WSACleanup();
#endif

	if (g_szPublicIP[0] != '0')
		return true;
	else
		return false;
}
Link to comment
Share on other sites

  • 0

 

up, any can give me your config.cpp? or the code of GetIPInfo(), my GetIPInfo() is incomplete :C

bool GetIPInfo()
{
#ifndef __WIN32__
	struct ifaddrs* ifaddrp = NULL;

	if (0 != getifaddrs(&ifaddrp))
		return false;

	for( struct ifaddrs* ifap=ifaddrp ; NULL != ifap ; ifap = ifap->ifa_next )
	{
		struct sockaddr_in * sai = (struct sockaddr_in *) ifap->ifa_addr;

		if (!ifap->ifa_netmask ||  // ignore if no netmask
				sai->sin_addr.s_addr == 0 || // ignore if address is 0.0.0.0
				sai->sin_addr.s_addr == 16777343) // ignore if address is 127.0.0.1
			continue;
#else
	WSADATA wsa_data;
	char host_name[100];
	HOSTENT* host_ent;
	int n = 0;

	if (WSAStartup(0x0101, &wsa_data)) {
		return false;
	}

	gethostname(host_name, sizeof(host_name));
	host_ent = gethostbyname(host_name);
	if (host_ent == NULL) {
		return false;
	}
	for ( ; host_ent->h_addr_list[n] != NULL; ++n) {
		struct sockaddr_in addr;
		struct sockaddr_in* sai = &addr;
		memcpy(&sai->sin_addr.s_addr, host_ent->h_addr_list[n], host_ent->h_length);
#endif

		char * netip = inet_ntoa(sai->sin_addr);

		if (!strncmp(netip, "192.168", 7)) // ignore if address is starting with 192
		{
			strlcpy(g_szInternalIP, netip, sizeof(g_szInternalIP));
#ifndef __WIN32__
			fprintf(stderr, "INTERNAL_IP: %s interface %sn", netip, ifap->ifa_name);
#else
			fprintf(stderr, "INTERNAL_IP: %sn", netip);
#endif
		}
		else if (!strncmp(netip, "10.", 3))
		{
			strlcpy(g_szInternalIP, netip, sizeof(g_szInternalIP));
#ifndef __WIN32__
			fprintf(stderr, "INTERNAL_IP: %s interface %sn", netip, ifap->ifa_name);
#else
			fprintf(stderr, "INTERNAL_IP: %sn", netip);
#endif
		}
		else if (g_szPublicIP[0] == '0')
		{
			strlcpy(g_szPublicIP, netip, sizeof(g_szPublicIP));
#ifndef __WIN32__
			fprintf(stderr, "PUBLIC_IP: %s interface %sn", netip, ifap->ifa_name);
#else
			fprintf(stderr, "PUBLIC_IP: %sn", netip);
#endif
		}
	}

#ifndef __WIN32__
	freeifaddrs( ifaddrp );
#else
	WSACleanup();
#endif

	if (g_szPublicIP[0] != '0')
		return true;
	else
		return false;
}

Thanks #Reboot but i put this code with 999.999 and my friends not can pass of the selection of character.

when i try put in the start.sh -I 25.151.38.92 in the chs and ch99, but the server not start, when put 999.999 I have to do something else?

Link to comment
Share on other sites

  • 0

 

 

up, any can give me your config.cpp? or the code of GetIPInfo(), my GetIPInfo() is incomplete :C

bool GetIPInfo()
{
#ifndef __WIN32__
	struct ifaddrs* ifaddrp = NULL;

	if (0 != getifaddrs(&ifaddrp))
		return false;

	for( struct ifaddrs* ifap=ifaddrp ; NULL != ifap ; ifap = ifap->ifa_next )
	{
		struct sockaddr_in * sai = (struct sockaddr_in *) ifap->ifa_addr;

		if (!ifap->ifa_netmask ||  // ignore if no netmask
				sai->sin_addr.s_addr == 0 || // ignore if address is 0.0.0.0
				sai->sin_addr.s_addr == 16777343) // ignore if address is 127.0.0.1
			continue;
#else
	WSADATA wsa_data;
	char host_name[100];
	HOSTENT* host_ent;
	int n = 0;

	if (WSAStartup(0x0101, &wsa_data)) {
		return false;
	}

	gethostname(host_name, sizeof(host_name));
	host_ent = gethostbyname(host_name);
	if (host_ent == NULL) {
		return false;
	}
	for ( ; host_ent->h_addr_list[n] != NULL; ++n) {
		struct sockaddr_in addr;
		struct sockaddr_in* sai = &addr;
		memcpy(&sai->sin_addr.s_addr, host_ent->h_addr_list[n], host_ent->h_length);
#endif

		char * netip = inet_ntoa(sai->sin_addr);

		if (!strncmp(netip, "192.168", 7)) // ignore if address is starting with 192
		{
			strlcpy(g_szInternalIP, netip, sizeof(g_szInternalIP));
#ifndef __WIN32__
			fprintf(stderr, "INTERNAL_IP: %s interface %sn", netip, ifap->ifa_name);
#else
			fprintf(stderr, "INTERNAL_IP: %sn", netip);
#endif
		}
		else if (!strncmp(netip, "10.", 3))
		{
			strlcpy(g_szInternalIP, netip, sizeof(g_szInternalIP));
#ifndef __WIN32__
			fprintf(stderr, "INTERNAL_IP: %s interface %sn", netip, ifap->ifa_name);
#else
			fprintf(stderr, "INTERNAL_IP: %sn", netip);
#endif
		}
		else if (g_szPublicIP[0] == '0')
		{
			strlcpy(g_szPublicIP, netip, sizeof(g_szPublicIP));
#ifndef __WIN32__
			fprintf(stderr, "PUBLIC_IP: %s interface %sn", netip, ifap->ifa_name);
#else
			fprintf(stderr, "PUBLIC_IP: %sn", netip);
#endif
		}
	}

#ifndef __WIN32__
	freeifaddrs( ifaddrp );
#else
	WSACleanup();
#endif

	if (g_szPublicIP[0] != '0')
		return true;
	else
		return false;
}

Thanks #Reboot but i put this code with 999.999 and my friends not can pass of the selection of character.

when i try put in the start.sh -I 25.151.38.92 in the chs and ch99, but the server not start, when put 999.999 I have to do something else?

 

 

clean your object dir, then compile again.

gmake clean && gmake -j20
Link to comment
Share on other sites

  • 0

 

 

 

up, any can give me your config.cpp? or the code of GetIPInfo(), my GetIPInfo() is incomplete :C

bool GetIPInfo()
{
#ifndef __WIN32__
	struct ifaddrs* ifaddrp = NULL;

	if (0 != getifaddrs(&ifaddrp))
		return false;

	for( struct ifaddrs* ifap=ifaddrp ; NULL != ifap ; ifap = ifap->ifa_next )
	{
		struct sockaddr_in * sai = (struct sockaddr_in *) ifap->ifa_addr;

		if (!ifap->ifa_netmask ||  // ignore if no netmask
				sai->sin_addr.s_addr == 0 || // ignore if address is 0.0.0.0
				sai->sin_addr.s_addr == 16777343) // ignore if address is 127.0.0.1
			continue;
#else
	WSADATA wsa_data;
	char host_name[100];
	HOSTENT* host_ent;
	int n = 0;

	if (WSAStartup(0x0101, &wsa_data)) {
		return false;
	}

	gethostname(host_name, sizeof(host_name));
	host_ent = gethostbyname(host_name);
	if (host_ent == NULL) {
		return false;
	}
	for ( ; host_ent->h_addr_list[n] != NULL; ++n) {
		struct sockaddr_in addr;
		struct sockaddr_in* sai = &addr;
		memcpy(&sai->sin_addr.s_addr, host_ent->h_addr_list[n], host_ent->h_length);
#endif

		char * netip = inet_ntoa(sai->sin_addr);

		if (!strncmp(netip, "192.168", 7)) // ignore if address is starting with 192
		{
			strlcpy(g_szInternalIP, netip, sizeof(g_szInternalIP));
#ifndef __WIN32__
			fprintf(stderr, "INTERNAL_IP: %s interface %sn", netip, ifap->ifa_name);
#else
			fprintf(stderr, "INTERNAL_IP: %sn", netip);
#endif
		}
		else if (!strncmp(netip, "10.", 3))
		{
			strlcpy(g_szInternalIP, netip, sizeof(g_szInternalIP));
#ifndef __WIN32__
			fprintf(stderr, "INTERNAL_IP: %s interface %sn", netip, ifap->ifa_name);
#else
			fprintf(stderr, "INTERNAL_IP: %sn", netip);
#endif
		}
		else if (g_szPublicIP[0] == '0')
		{
			strlcpy(g_szPublicIP, netip, sizeof(g_szPublicIP));
#ifndef __WIN32__
			fprintf(stderr, "PUBLIC_IP: %s interface %sn", netip, ifap->ifa_name);
#else
			fprintf(stderr, "PUBLIC_IP: %sn", netip);
#endif
		}
	}

#ifndef __WIN32__
	freeifaddrs( ifaddrp );
#else
	WSACleanup();
#endif

	if (g_szPublicIP[0] != '0')
		return true;
	else
		return false;
}

Thanks #Reboot but i put this code with 999.999 and my friends not can pass of the selection of character.

when i try put in the start.sh -I 25.151.38.92 in the chs and ch99, but the server not start, when put 999.999 I have to do something else?

 

 

clean your object dir, then compile again.

gmake clean && gmake -j20

yeah, Likewise I do but the problem persist

Link to comment
Share on other sites

  • 0

 

 

 

and my friends not can pass of the selection of character

Add this line in config each CH :

BIND_IP: XXX.XXX.XXX.XXX (You ip adress)

If I add in config that is not going to get kicked in character.

 

my ip adress of hamachi?

Link to comment
Share on other sites

  • 0

i put my ip of hamachi and now i not can connect to the server

https://metin2.download/picture/pV7gQppvj78I3DZCb19g29Kc62lI6kbA/.png

and now see this new error

socket_tcp_bind: tcp_socket: Can't assign requested address

Why you use hamachi ?

Use direct IP router

Edited by Metin2 Dev
Core X - External 2 Internal
Link to comment
Share on other sites

  • 0

try this: configure your ip on freebsd with your internet connection (switch the adaptador to lan) and your local ip (like a ip-server) then put your hamachi ip on portmap and try! Skype: live:caes95

 

The problem is that FreeBSD and the game can't obtain your external ip because you're using hamachi and hamachi doesn't have a real external ip.

Link to comment
Share on other sites

  • 0

 

i put my ip of hamachi and now i not can connect to the server

https://metin2.download/picture/pV7gQppvj78I3DZCb19g29Kc62lI6kbA/.png

and now see this new error

socket_tcp_bind: tcp_socket: Can't assign requested address

Why you use hamachi ?

Use direct IP router

 

https://metin2.download/picture/3Bho7oXEKjCQz8v78C7f6duzn5Mp7ZgY/.png

the same problem

Edited by Metin2 Dev
Core X - External 2 Internal
Link to comment
Share on other sites

  • 0

 

 

i put my ip of hamachi and now i not can connect to the server

https://metin2.download/picture/pV7gQppvj78I3DZCb19g29Kc62lI6kbA/.png

and now see this new error

socket_tcp_bind: tcp_socket: Can't assign requested address

Why you use hamachi ?

Use direct IP router

 

https://metin2.download/picture/3Bho7oXEKjCQz8v78C7f6duzn5Mp7ZgY/.png

the same problem

 

Remove the bind ip on your CONFIG

Edited by Metin2 Dev
Core X - External 2 Internal
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.