| 340 | } |
| 341 | |
| 342 | int CNetBan::UnbanByIndex(int Index) |
| 343 | { |
| 344 | int Result; |
| 345 | char aBuf[256]; |
| 346 | CBanAddr *pBan = m_BanAddrPool.Get(Index); |
| 347 | if(pBan) |
| 348 | { |
| 349 | NetToString(&pBan->m_Data, aBuf, sizeof(aBuf)); |
| 350 | Result = m_BanAddrPool.Remove(pBan); |
| 351 | } |
| 352 | else |
| 353 | { |
| 354 | CBanRange *pBanRange = m_BanRangePool.Get(Index - m_BanAddrPool.Num()); |
| 355 | if(pBanRange) |
| 356 | { |
| 357 | NetToString(&pBanRange->m_Data, aBuf, sizeof(aBuf)); |
| 358 | Result = m_BanRangePool.Remove(pBanRange); |
| 359 | } |
| 360 | else |
| 361 | { |
| 362 | Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "net_ban", "unban failed (invalid index)"); |
| 363 | return -1; |
| 364 | } |
| 365 | } |
| 366 | |
| 367 | char aMsg[256]; |
| 368 | str_format(aMsg, sizeof(aMsg), "unbanned index %i (%s)", Index, aBuf); |
| 369 | Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "net_ban", aMsg); |
| 370 | return Result; |
| 371 | } |
| 372 | |
| 373 | bool CNetBan::IsBanned(const NETADDR *pOrigAddr, char *pBuf, unsigned BufferSize) const |
| 374 | { |