Jump to content
  • 0

INTERNAL_IP FİX HELP?


Tkmt2x11

Question

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;
}
 
 
INTERNAL_IP HOW THE FİX? HELP.
Link to comment
Share on other sites

11 answers to this question

Recommended Posts

  • 0

 

 

Change this line:

        if (!strncmp(netip, "192.168", 7)) // ignore if address is starting with 192

With this :

        if (!strncmp(netip, "999.999", 7))

can not be tried

 

Add this line in config each ch:

BIND_IP: XXX.XXX.XXX.XXX
xxx,xxx,xxx,xxx= Ip used virtualbox or host.
 
If using virtualbox, chicken ip you use to connect to WinSCP
  • Love 1
Link to comment
Share on other sites

  • 0

 

 

 

Change this line:

        if (!strncmp(netip, "192.168", 7)) // ignore if address is starting with 192

With this :

        if (!strncmp(netip, "999.999", 7))

can not be tried

 

Add this line in config each ch:

BIND_IP: XXX.XXX.XXX.XXX
xxx,xxx,xxx,xxx= Ip used virtualbox or host.
 
If using virtualbox, chicken ip you use to connect to WinSCP

 

Channel1,game99,auth ?

Link to comment
Share on other sites

  • 0

Change 

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

to

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 (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;
}
  • Love 1
Link to comment
Share on other sites

  • 0

 

Change 

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

to

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

Thanx

Link to comment
Share on other sites

  • 0

please help I've tried all the solutions like VirtualBox using the network of friends I still apply in the way they say I say I can not enter the gametes config.cpp' the channels are not only opened dB

map does not allow anything blah channels opening single db smoothly.

Link to comment
Share on other sites

  • 0

please help I've tried all the solutions like VirtualBox using the network of friends I still apply in the way they say I say I can not enter the gametes config.cpp' the channels are not only opened dB

map does not allow anything blah channels opening single db smoothly.

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.