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) {
+ if(isFakeHost(user->host)) {
sprintf(buffer, "*!*@%s", userhost);
return buffer;
}
}
}
+char* make_banmask(char *input, char* buffer) {
+ char *nick = NULL, *ident = NULL, *host = NULL;
+ char tmp[HOSTLEN];
+ char *p;
+ if((p = strstr(input, "!"))) {
+ nick = input;
+ *p = '\0';
+ ident = p+1;
+ if((p = strstr(ident, "@"))) {
+ *p = '\0';
+ host = p+1;
+ }
+ } else if((p = strstr(input, "@"))) {
+ ident = input;
+ *p = '\0';
+ host = p+1;
+ } else if((p = strstr(input, "."))) {
+ host = input;
+ } else if(*input == '*' && !strstr(input+1, "*")) {
+ //AUTH MASK
+ p = getAuthFakehost(input+1);
+ if(p)
+ host = p;
+ else {
+ sprintf(tmp, "%s.*", input+1);
+ host = tmp;
+ }
+ } else {
+ struct UserNode *user = searchUserByNick(input);
+ if(user)
+ return generate_banmask(user, buffer);
+ else
+ nick = input;
+ }
+ sprintf(buffer, "%s!%s@%s", (nick ? nick : "*"), (ident ? ident : "*"), (host ? host : "*"));
+ return buffer;
+}
+
+int isFakeHost(char *host) {
+ char *p1, *p2 = host;
+
+ //find the last dot to identify if the hostmask is a fake host
+ while((p1 = strstr(p2, "."))) {
+ p2 = p1 + 1;
+ }
+ //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
+ return (strlen(p2+1) > 4);
+}
+
void init_tools() {
register_default_language_table(msgtab);
}