| 434 | } |
| 435 | |
| 436 | bool CNetBan::IsBanned(const NETADDR *pAddr, char *pBuf, unsigned BufferSize) const |
| 437 | { |
| 438 | CNetHash aHash[17]; |
| 439 | int Length = CNetHash::MakeHashArray(pAddr, aHash); |
| 440 | |
| 441 | // check ban adresses |
| 442 | CBanAddr *pBan = m_BanAddrPool.Find(pAddr, &aHash[Length]); |
| 443 | if(pBan) |
| 444 | { |
| 445 | MakeBanInfo(pBan, pBuf, BufferSize, MSGTYPE_PLAYER); |
| 446 | return true; |
| 447 | } |
| 448 | |
| 449 | // check ban ranges |
| 450 | for(int i = Length-1; i >= 0; --i) |
| 451 | { |
| 452 | for(CBanRange *pBan = m_BanRangePool.First(&aHash[i]); pBan; pBan = pBan->m_pHashNext) |
| 453 | { |
| 454 | if(NetMatch(&pBan->m_Data, pAddr, i, Length)) |
| 455 | { |
| 456 | MakeBanInfo(pBan, pBuf, BufferSize, MSGTYPE_PLAYER); |
| 457 | return true; |
| 458 | } |
| 459 | } |
| 460 | } |
| 461 | |
| 462 | return false; |
| 463 | } |