free(modeBuf);
}
+int is_ircmask(const char *text) {
+ while (*text && (isalnum((char)*text) || strchr("-_[]|\\`^{}?*", *text)))
+ text++;
+ if (*text++ != '!')
+ return 0;
+ while (*text && *text != '@' && !isspace((char)*text))
+ text++;
+ if (*text++ != '@')
+ return 0;
+ while (*text && !isspace((char)*text))
+ text++;
+ return !*text;
+}
+
+char* generate_banmask(struct UserNode *user, char *buffer) {
+ char *userhost = user->host;
+ char *p1, *p2 = userhost;
+
+ //find the last dot to identify if the hostmask is a hidden host
+ while((p1 = strstr(userhost, "."))) {
+ p2 = p1;
+ }
+ //TLD database: http://www.iana.org/domains/root/db/
+ //the longest TLD i found was 6 chars long (ignoring the stange exotic ones :D)
+ //but we even ignore '.museum' and '.travel' so we can say that the TLD of our mask needs to be less than 4 chars to be a real domain
+ if(strlen(p2+1) > 4) {
+ sprintf(buffer, "*!*@%s", userhost);
+ return buffer;
+ }
+
+ //check if the hostname has more than 4 connections (trusted host)
+ if(countUsersWithHost(userhost) > 4) {
+ sprintf(buffer, "*!%s@%s", user->ident, userhost);
+ return buffer;
+ } else {
+ sprintf(buffer, "*!*@%s", userhost);
+ return buffer;
+ }
+}
+
void init_tools() {
register_default_language_table(msgtab);
}