Exemple #1
0
BYTEARRAY CPotentialPlayer :: GetExternalIP( )
{
    unsigned char Zeros[] = { 0, 0, 0, 0 };

    if( m_Socket ) {
        if( m_IncomingGarenaUser != NULL )
            return GetGarenaIP( );
        else
            return m_Socket->GetIP( );
    }

    return UTIL_CreateByteArray( Zeros, 4 );
}
Exemple #2
0
string CPotentialPlayer :: GetExternalIPString( )
{
    if( m_Socket ) {
		string IPString = string();
        if( m_IncomingGarenaUser != NULL ) {
            BYTEARRAY GarenaIP = GetGarenaIP( );
			IPString = UTIL_ToString(GarenaIP[0]) + "." + UTIL_ToString(GarenaIP[1]) + "." + UTIL_ToString(GarenaIP[2]) + "." + UTIL_ToString(GarenaIP[3]);
        } else {
			IPString = m_Socket->GetIPString( );
        }

		if (!IPString.empty() && IPString != "0.0.0.0")
			m_CachedIP = IPString;
			return IPString;
    }

	return m_CachedIP;
}
BYTEARRAY CPotentialPlayer :: GetExternalIP( )
{
	unsigned char Zeros[] = { 0, 0, 0, 0 };
	BYTEARRAY IP;

	if( m_Socket )
	{	
		if( m_IncomingGarenaUser != NULL )
			return GetGarenaIP( );
		else {
			bool local=false;
			IP=	m_Socket->GetIP( );
			if (IP.size()>=2)
			{
				if (IP[0]==10)
				local=true;
				else if (IP[0]==192 && IP[1]==168)
				local=true;
				else if (IP[0]==169 && IP[1]==254)
				local=true;
				else if (IP[0]==172 && IP[1]==16)
				local=true;
				else if (IP[0]==172 && IP[1]==17)
				local=true;
				else if (IP[0]==172 && IP[1]==18)
				local=true;
				else if (IP[0]==172 && IP[1]==19)
				local=true;
				else if (IP[0]==172 && IP[1]==20)
				local=true;
				else if (IP[0]==172 && IP[1]==21)
				local=true;
				else if (IP[0]==172 && IP[1]==22)
				local=true;
				else if (IP[0]==172 && IP[1]==23)
				local=true;
				else if (IP[0]==172 && IP[1]==24)
				local=true;
				else if (IP[0]==172 && IP[1]==25)
				local=true;
				else if (IP[0]==172 && IP[1]==26)
				local=true;
				else if (IP[0]==172 && IP[1]==27)
				local=true;
				else if (IP[0]==172 && IP[1]==28)
				local=true;
				else if (IP[0]==172 && IP[1]==29)
				local=true;
				else if (IP[0]==172 && IP[1]==30)
				local=true;
				else if (IP[0]==172 && IP[1]==31)
				local=true;
			}
			if (local && m_Game->m_GHost->m_ExternalIP!="")
			{
				IP=UTIL_CreateByteArray(m_Game->m_GHost->m_ExternalIPL,true);
			}
			return IP;
		}
	}

	return UTIL_CreateByteArray( Zeros, 4 );
}
string CPotentialPlayer :: GetExternalIPString( )
{
	BYTEARRAY IP;
	string EIP;
	if( m_Socket )
	{
		if( m_IncomingGarenaUser != NULL ) 
		{
			BYTEARRAY GarenaIP = GetGarenaIP( );
			return UTIL_ToString(GarenaIP[0]) + "." + UTIL_ToString(GarenaIP[1]) + "." + UTIL_ToString(GarenaIP[2]) + "." + UTIL_ToString(GarenaIP[3]);
		} else {	
			bool local=m_LAN;
			if (!m_LANSet)
			{				
				IP=	m_Socket->GetIP( );
				if (IP.size()>=2)
				{
					if (IP[0]==10)
					local=true;
					else if (IP[0]==192 && IP[1]==168)
					local=true;
					else if (IP[0]==169 && IP[1]==254)
					local=true;
					else if (IP[0]==172 && IP[1]==16)
					local=true;
					else if (IP[0]==172 && IP[1]==17)
					local=true;
					else if (IP[0]==172 && IP[1]==18)
					local=true;
					else if (IP[0]==172 && IP[1]==19)
					local=true;
					else if (IP[0]==172 && IP[1]==20)
					local=true;
					else if (IP[0]==172 && IP[1]==21)
					local=true;
					else if (IP[0]==172 && IP[1]==22)
					local=true;
					else if (IP[0]==172 && IP[1]==23)
					local=true;
					else if (IP[0]==172 && IP[1]==24)
					local=true;
					else if (IP[0]==172 && IP[1]==25)
					local=true;
					else if (IP[0]==172 && IP[1]==26)
					local=true;
					else if (IP[0]==172 && IP[1]==27)
					local=true;
					else if (IP[0]==172 && IP[1]==28)
					local=true;
					else if (IP[0]==172 && IP[1]==29)
					local=true;
					else if (IP[0]==172 && IP[1]==30)
					local=true;
					else if (IP[0]==172 && IP[1]==31)
					local=true;
				}
				if (UTIL_IsLocalIP(IP, m_Game->m_GHost->m_LocalAddresses))
					local = true;
				m_LANSet = true;
				m_LAN = local;
			}
			EIP=m_Socket->GetIPString( );
			if (local && m_Game->m_GHost->m_ExternalIP!="")
			{
			EIP=m_Game->m_GHost->m_ExternalIP;
			}
			if( !EIP.empty( ) && EIP != "0.0.0.0" )
				return EIP;
			else
				return m_CachedIP;
		}
	}
	return m_CachedIP;
}