本文整理汇总了C++中IPList::clearAndLoadFromFile方法的典型用法代码示例。如果您正苦于以下问题:C++ IPList::clearAndLoadFromFile方法的具体用法?C++ IPList::clearAndLoadFromFile怎么用?C++ IPList::clearAndLoadFromFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPList
的用法示例。
在下文中一共展示了IPList::clearAndLoadFromFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MASTERSERVER_InitializeBans
//*****************************************************************************
//
void MASTERSERVER_InitializeBans( void )
{
const bool BannedIPsChanged = MASTERSERVER_RefreshIPList ( g_BannedIPs, "banlist.txt" );
const bool BannedIPExemptionsChanged = MASTERSERVER_RefreshIPList ( g_BannedIPExemptions, "whitelist.txt" );
if ( !(g_MultiServerExceptions.clearAndLoadFromFile( "multiserver_whitelist.txt" )) )
std::cerr << g_MultiServerExceptions.getErrorMessage();
if ( !(g_BlockedIPs.clearAndLoadFromFile( "blocklist.txt" )) )
std::cerr << g_BlockedIPs.getErrorMessage();
std::cerr << "\nBan list: " << g_BannedIPs.size() << " banned IPs, " << g_BlockedIPs.size( ) << " blocked IPs, " << g_BannedIPExemptions.size() << " exemptions." << std::endl;
std::cerr << "Multi-server exceptions: " << g_MultiServerExceptions.size() << "." << std::endl;
if ( BannedIPsChanged || BannedIPExemptionsChanged )
{
// [BB] The ban list was changed, so no server has the latest list anymore.
for( std::set<SERVER_s, SERVERCompFunc>::iterator it = g_Servers.begin(); it != g_Servers.end(); ++it )
{
it->bHasLatestBanList = false;
it->bVerifiedLatestBanList = false;
}
std::cerr << "Ban lists were changed since last refresh\n";
}
/*
// [BB] Print all banned IPs, to make sure the IP list has been parsed successfully.
std::cerr << "Entries in blacklist:\n";
for ( ULONG ulIdx = 0; ulIdx < g_BannedIPs.size(); ulIdx++ )
std::cerr << g_BannedIPs.getEntryAsString(ulIdx).c_str();
// [BB] Print all exemption-IPs, to make sure the IP list has been parsed successfully.
std::cerr << "Entries in whitelist:\n";
for ( ULONG ulIdx = 0; ulIdx < g_BannedIPExemptions.size(); ulIdx++ )
std::cerr << g_BannedIPExemptions.getEntryAsString(ulIdx).c_str();
*/
}
示例2: 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 );
}