本文整理汇总了C++中IPList::getEntryAsString方法的典型用法代码示例。如果您正苦于以下问题:C++ IPList::getEntryAsString方法的具体用法?C++ IPList::getEntryAsString怎么用?C++ IPList::getEntryAsString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPList
的用法示例。
在下文中一共展示了IPList::getEntryAsString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MASTERSERVER_RefreshIPList
//*****************************************************************************
//
bool MASTERSERVER_RefreshIPList( IPList &List, const char *FileName )
{
std::stringstream oldIPs;
for ( ULONG ulIdx = 0; ulIdx < List.size(); ulIdx++ )
oldIPs << List.getEntryAsString ( ulIdx, false ).c_str() << "-";
if ( !(List.clearAndLoadFromFile( FileName )) )
std::cerr << List.getErrorMessage();
std::stringstream newIPs;
for ( ULONG ulIdx = 0; ulIdx < List.size(); ulIdx++ )
newIPs << List.getEntryAsString ( ulIdx, false ).c_str() << "-";
return ( strcmp ( newIPs.str().c_str(), oldIPs.str().c_str() ) != 0 );
}
示例2: MASTERSERVER_SendBanlistToServer
//*****************************************************************************
//
void MASTERSERVER_SendBanlistToServer( const SERVER_s &Server )
{
// [BB] If the server supports it, potentially split the ban list over multiple packets.
if ( Server.iServerRevision >= 2907 )
{
BanlistPacketSender sender ( Server );
sender.start();
// Write all the bans.
for ( unsigned int i = 0; i < g_BannedIPs.size( ); ++i )
sender.writeBanEntry ( g_BannedIPs.getEntryAsString( i, false, false, false ).c_str( ), MSB_BAN );
// Write all the exceptions.
for ( unsigned int i = 0; i < g_BannedIPExemptions.size( ); ++i )
sender.writeBanEntry ( g_BannedIPExemptions.getEntryAsString( i, false, false, false ).c_str( ), MSB_BANEXEMPTION );
sender.end();
}
else
{
NETWORK_ClearBuffer( &g_MessageBuffer );
NETWORK_WriteByte( &g_MessageBuffer.ByteStream, MASTER_SERVER_BANLIST );
// [BB] If the server sent us a verification string, send it along with the ban list.
// This allows the server to verify that the list actually was sent from our master
// (and is not just a packet with forged source IP).
if ( Server.MasterBanlistVerificationString.size() )
NETWORK_WriteString( &g_MessageBuffer.ByteStream, Server.MasterBanlistVerificationString.c_str() );
// Write all the bans.
NETWORK_WriteLong( &g_MessageBuffer.ByteStream, g_BannedIPs.size( ));
for ( ULONG i = 0; i < g_BannedIPs.size( ); i++ )
NETWORK_WriteString( &g_MessageBuffer.ByteStream, g_BannedIPs.getEntryAsString( i, false, false, false ).c_str( ));
// Write all the exceptions.
NETWORK_WriteLong( &g_MessageBuffer.ByteStream, g_BannedIPExemptions.size( ));
for ( ULONG i = 0; i < g_BannedIPExemptions.size( ); i++ )
NETWORK_WriteString( &g_MessageBuffer.ByteStream, g_BannedIPExemptions.getEntryAsString( i, false, false, false ).c_str( ));
NETWORK_LaunchPacket( &g_MessageBuffer, Server.Address );
}
Server.bHasLatestBanList = true;
Server.bVerifiedLatestBanList = false;
printf( "-> Banlist sent to %s.\n", NETWORK_AddressToString( Server.Address ));
}