diff options
author | thilo <thilo@edf5b092-35ff-0310-97b2-ce42778d08ea> | 2009-05-24 16:58:08 +0000 |
---|---|---|
committer | thilo <thilo@edf5b092-35ff-0310-97b2-ce42778d08ea> | 2009-05-24 16:58:08 +0000 |
commit | ddadef7a3cd39c13627e849b9bbf9cc7d52b866f (patch) | |
tree | 190bb1f8a5625a8870100729bd1f9bfc7d40b187 /code/server/sv_client.c | |
parent | 19234f2b7a3acccab061b6814868602e7c58d843 (diff) | |
download | ioquake3-aero-ddadef7a3cd39c13627e849b9bbf9cc7d52b866f.tar.gz ioquake3-aero-ddadef7a3cd39c13627e849b9bbf9cc7d52b866f.zip |
- Introduce new NET_CompareBaseAdrMask for easy comparison of ip address ranges
- Overhaul of the new banning functions:
* basic check for redundant bans/exceptions
* introduction of sv_banFile to make it possible to configure the file where to read bans and exceptions from
* bans can now be deleted by giving address ranges, too.
git-svn-id: svn://svn.icculus.org/quake3/trunk@1557 edf5b092-35ff-0310-97b2-ce42778d08ea
Diffstat (limited to 'code/server/sv_client.c')
-rw-r--r-- | code/server/sv_client.c | 52 |
1 files changed, 3 insertions, 49 deletions
diff --git a/code/server/sv_client.c b/code/server/sv_client.c index 5ef1336..e208a5b 100644 --- a/code/server/sv_client.c +++ b/code/server/sv_client.c @@ -234,18 +234,9 @@ Check whether a certain address is banned static qboolean SV_IsBanned(netadr_t *from, qboolean isexception) { - int index, addrlen, curbyte, netmask, cmpmask; + int index; serverBan_t *curban; - byte *addrfrom, *addrban; - qboolean differed; - if(from->type == NA_IP) - addrlen = sizeof(from->ip); - else if(from->type == NA_IP6) - addrlen = sizeof(from->ip6); - else - return qfalse; - if(!isexception) { // If this is a query for a ban, first check whether the client is excepted @@ -257,47 +248,10 @@ static qboolean SV_IsBanned(netadr_t *from, qboolean isexception) { curban = &serverBans[index]; - if(curban->isexception == isexception && from->type == curban->ip.type) + if(curban->isexception == isexception) { - if(from->type == NA_IP) - { - addrfrom = from->ip; - addrban = curban->ip.ip; - } - else - { - addrfrom = from->ip6; - addrban = curban->ip.ip6; - } - - differed = qfalse; - curbyte = 0; - - for(netmask = curban->subnet; netmask > 7; netmask -= 8) - { - if(addrfrom[curbyte] != addrban[curbyte]) - { - differed = qtrue; - break; - } - - curbyte++; - } - - if(differed) - continue; - - if(netmask) - { - cmpmask = (1 << netmask) - 1; - cmpmask <<= 8 - netmask; - - if((addrfrom[curbyte] & cmpmask) == (addrban[curbyte] & cmpmask)) - return qtrue; - } - else + if(NET_CompareBaseAdrMask(curban->ip, *from, curban->subnet)) return qtrue; - } } |