diff options
-rw-r--r-- | include/motd.h | 3 | ||||
-rw-r--r-- | src/motd.c | 30 |
2 files changed, 31 insertions, 2 deletions
diff --git a/include/motd.h b/include/motd.h index 898b9af..37c770d 100644 --- a/include/motd.h +++ b/include/motd.h @@ -34,7 +34,8 @@ enum MotdType { MOTD_UNIVERSAL, /**< MOTD for all users */ MOTD_HOSTMASK, /**< MOTD selected by hostmask */ - MOTD_IPMASK, /**< MOTD selected by IP mask */ + MOTD_IPMASKV4, /**< MOTD selected by IP mask */ + MOTD_IPMASKV6, /**< MOTD selected by IP mask */ MOTD_CLASS /**< MOTD selected by connection class */ }; @@ -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; } } |