diff options
author | michael <michael@82007160-df01-0410-b94d-b575c5fd34c7> | 2013-06-02 20:02:18 +0000 |
---|---|---|
committer | michael <michael@82007160-df01-0410-b94d-b575c5fd34c7> | 2013-06-02 20:02:18 +0000 |
commit | 48ee4fb9a5e373df8a4ce9bd69159f41a0fba81d (patch) | |
tree | 57b6cd7b88b49e487ebacbb83783e24333d3a9f6 /src | |
parent | 0755cfe97ceee6e2377789bf1c85e71620328467 (diff) |
- motd.c, motd.h: add support for ip masks
git-svn-id: svn://svn.ircd-hybrid.org/svnroot/ircd-hybrid/branches/8.1.x@2166 82007160-df01-0410-b94d-b575c5fd34c7
Diffstat (limited to 'src')
-rw-r--r-- | src/motd.c | 30 |
1 files changed, 29 insertions, 1 deletions
@@ -37,6 +37,7 @@ #include "memory.h" #include "log.h" #include "motd.h" +#include "hostmask.h" /** Global list of messages of the day. */ @@ -63,7 +64,22 @@ motd_create(const char *hostmask, const char *path) else if (class_find(hostmask, 1)) tmp->type = MOTD_CLASS; else - tmp->type = MOTD_HOSTMASK; + { + switch (parse_netmask(hostmask, &tmp->address, &tmp->addrbits)) + { + case HM_IPV4: + tmp->type = MOTD_IPMASKV4; + break; +#ifdef IPV6 + case HM_IPV6: + tmp->type = MOTD_IPMASKV6; + break; +#endif + default: /* HM_HOST */ + tmp->type = MOTD_HOSTMASK; + break; + } + } if (hostmask != NULL) tmp->hostmask = xstrdup(hostmask); @@ -231,9 +247,21 @@ motd_lookup(struct Client *client_p) case MOTD_CLASS: if (!match(motd->hostmask, class->name)) return motd; + break; case MOTD_HOSTMASK: if (!match(motd->hostmask, client_p->host)) return motd; + break; + case MOTD_IPMASKV4: + if (client_p->localClient->aftype == AF_INET) + if (match_ipv4(&client_p->localClient->ip, &motd->address, motd->addrbits)) + return motd; + break; + case MOTD_IPMASKV6: + if (client_p->localClient->aftype == AF_INET6) + if (match_ipv6(&client_p->localClient->ip, &motd->address, motd->addrbits)) + return motd; + break; default: break; } } |