本文整理汇总了C++中IPList::isIPInList方法的典型用法代码示例。如果您正苦于以下问题:C++ IPList::isIPInList方法的具体用法?C++ IPList::isIPInList怎么用?C++ IPList::isIPInList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPList
的用法示例。
在下文中一共展示了IPList::isIPInList方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MASTERSERVER_ParseCommands
//*****************************************************************************
//
void MASTERSERVER_ParseCommands( BYTESTREAM_s *pByteStream )
{
long lCommand;
NETADDRESS_s AddressFrom;
AddressFrom = NETWORK_GetFromAddress( );
// [RC] If this IP is in our flood queue, ignore it completely.
if ( g_floodProtectionIPQueue.addressInQueue( AddressFrom ) || g_ShortFloodQueue.addressInQueue( AddressFrom ))
{
while ( NETWORK_ReadByte( pByteStream ) != -1 ) // [RC] Is this really necessary?
;
return;
}
// Is this IP banned? Send the user an explanation, and ignore the IP for 30 seconds.
if ( !g_BannedIPExemptions.isIPInList( AddressFrom ) && g_BannedIPs.isIPInList( AddressFrom ))
{
NETWORK_ClearBuffer( &g_MessageBuffer );
NETWORK_WriteLong( &g_MessageBuffer.ByteStream, MSC_IPISBANNED );
NETWORK_LaunchPacket( &g_MessageBuffer, AddressFrom );
printf( "* Received challenge from banned IP (%s). Ignoring for 10 seconds.\n", NETWORK_AddressToString( AddressFrom ));
g_queryIPQueue.addAddress( AddressFrom, g_lCurrentTime, &std::cerr );
return;
}
lCommand = NETWORK_ReadLong( pByteStream );
switch ( lCommand )
{
// Server is telling master server of its existence.
case SERVER_MASTER_CHALLENGE:
{
// Certain IPs can be blocked from just hosting.
if ( !g_BannedIPExemptions.isIPInList( AddressFrom ) && g_BlockedIPs.isIPInList( AddressFrom ))
{
NETWORK_ClearBuffer( &g_MessageBuffer );
NETWORK_WriteLong( &g_MessageBuffer.ByteStream, MSC_IPISBANNED );
NETWORK_LaunchPacket( &g_MessageBuffer, AddressFrom );
printf( "* Received server challenge from blocked IP (%s). Ignoring for 10 seconds.\n", NETWORK_AddressToString( AddressFrom ));
g_queryIPQueue.addAddress( AddressFrom, g_lCurrentTime, &std::cerr );
return;
}
SERVER_s newServer;
newServer.Address = AddressFrom;
// [BB] If no verification string was send, NETWORK_ReadString just returns an empty string.
// Thus, this is still compatible with older servers that don't send the string.
newServer.MasterBanlistVerificationString = NETWORK_ReadString( pByteStream );
// [BB] If no value was send, NETWORK_ReadByte just returns -1.
// Thus, this is still compatible with older servers that don't tell us whether they enforce our bans
// and gives them the benefit of the doubt, i.e. it assumes that they enforce our bans.
const int temp = NETWORK_ReadByte( pByteStream );
newServer.bEnforcesBanList = ( temp != 0 );
newServer.bNewFormatServer = ( temp != -1 );
newServer.iServerRevision = ( ( pByteStream->pbStreamEnd - pByteStream->pbStream ) >= 4 ) ? NETWORK_ReadLong( pByteStream ) : NETWORK_ReadShort( pByteStream );
std::set<SERVER_s, SERVERCompFunc>::iterator currentServer = g_Servers.find ( newServer );
// This is a new server; add it to the list.
if ( currentServer == g_Servers.end() )
{
unsigned int iNumOtherServers = 0;
// First count the number of servers from this IP.
for( std::set<SERVER_s, SERVERCompFunc>::const_iterator it = g_Servers.begin(); it != g_Servers.end(); ++it )
{
if ( NETWORK_CompareAddress( it->Address, AddressFrom, true ))
iNumOtherServers++;
}
if ( iNumOtherServers >= 10 && !g_MultiServerExceptions.isIPInList( AddressFrom ))
printf( "* More than 10 servers received from %s. Ignoring request...\n", NETWORK_AddressToString( AddressFrom ));
else
{
// [BB] 3021 is 98d, don't put those servers on the list.
if ( ( newServer.bNewFormatServer ) && ( newServer.iServerRevision != 3021 ) )
{
std::set<SERVER_s, SERVERCompFunc>::iterator currentUnverifiedServer = g_UnverifiedServers.find ( newServer );
// [BB] This is a new server, but we still need to verify it.
if ( currentUnverifiedServer == g_UnverifiedServers.end() )
{
srand ( time(NULL) );
newServer.ServerVerificationInt = rand() + rand() * rand() + rand() * rand() * rand();
// [BB] We don't send the ban list to unverified servers, so just pretent the server already has the list.
newServer.bHasLatestBanList = true;
MASTERSERVER_RequestServerVerification ( newServer );
MASTERSERVER_AddServer( newServer, g_UnverifiedServers );
}
}
else
{
printf( "* Received server challenge from old server (%s). Ignoring IP for 10 seconds.\n", NETWORK_AddressToString( newServer.Address ));
g_queryIPQueue.addAddress( newServer.Address, g_lCurrentTime, &std::cerr );
}
}
//.........这里部分代码省略.........