diff options
| author | drstein drstein@31f1291d-b8d6-0310-a050-a5561fc1590b <drstein drstein@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864> | 2007-08-31 20:40:36 +0000 |
|---|---|---|
| committer | drstein drstein@31f1291d-b8d6-0310-a050-a5561fc1590b <drstein drstein@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864> | 2007-08-31 20:40:36 +0000 |
| commit | 317b3e0c4efa277c29e77f8acd3e8b4b000bdc36 (patch) | |
| tree | 8fb8df7ed5b7f5912ee2fbfc0e4956c5ed152a88 /src/sessions.c | |
| parent | d5a2079085b739a0eb31d1074822a2ecedc0e4fa (diff) | |
BUILD : 1.7.19 (1295) BUGS : N/A NOTES : We now have hostip in user_ struct so we can use it where needed. We wont do host_resolve() unless it is extremely necessary, coz we dont want to flood the nameserver.
git-svn-id: svn://svn.anope.org/anope/trunk@1295 31f1291d-b8d6-0310-a050-a5561fc1590b
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1013 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src/sessions.c')
| -rw-r--r-- | src/sessions.c | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/src/sessions.c b/src/sessions.c index 4b665e1bc..5a37e526b 100644 --- a/src/sessions.c +++ b/src/sessions.c @@ -203,7 +203,7 @@ Session *findsession(const char *host) * Returns 1 if the host was added or 0 if the user was killed. */ -int add_session(char *nick, char *host) +int add_session(char *nick, char *host, char *hostip) { Session *session, **list; Exception *exception; @@ -212,7 +212,8 @@ int add_session(char *nick, char *host) session = findsession(host); if (session) { - exception = find_host_exception(host); + exception = find_hostip_exception(host, hostip); + if (checkDefCon(DEFCON_REDUCE_SESSION)) { sessionlimit = exception ? exception->limit : DefConSessionLimit; @@ -348,30 +349,33 @@ void expire_exceptions(void) } /* Find the first exception this host matches and return it. */ - Exception *find_host_exception(const char *host) { - char *ipbuf = NULL; - char *myhost = NULL; int i; - /* we try to resolve the hostname to an IP in case - * the exception was added by IP instead of hostname - DrStein */ - if (host) - myhost = sstrdup(host); - ipbuf = host_resolve(myhost); + for (i = 0; i < nexceptions; i++) { + if ((match_wild_nocase(exceptions[i].mask, host))) { + return &exceptions[i]; + } + } + + return NULL; +} + +/* Same as find_host_exception() except + * this tries to find the exception by IP also. */ +Exception *find_hostip_exception(const char *host, const char *hostip) +{ + int i; for (i = 0; i < nexceptions; i++) { if ((match_wild_nocase(exceptions[i].mask, host)) - || ((ipbuf != NULL) - && match_wild_nocase(exceptions[i].mask, ipbuf))) { - Anope_Free(myhost); + || ((ircd->nickip && hostip) + && (match_wild_nocase(exceptions[i].mask, hostip)))) { return &exceptions[i]; } } - Anope_Free(myhost); - return NULL; } |
