+int
+check_vhost(char *vhost, struct userNode *user, struct svccmd *cmd)
+{
+ unsigned int y;
+
+ // check for a dot in the vhost
+ if(strchr(vhost, '.') == NULL) {
+ reply("NSMSG_NOT_VALID_FAKEHOST_DOT", vhost);
+ return 0;
+ }
+
+ // check for a @ in the vhost
+ if(strchr(vhost, '@') != NULL) {
+ reply("NSMSG_NOT_VALID_FAKEHOST_AT", vhost);
+ return 0;
+ }
+
+ // check for denied words, inspired by monk at paki.sex
+ for(y = 0; y < nickserv_conf.denied_fakehost_words->used; y++) {
+ if(strstr(vhost, nickserv_conf.denied_fakehost_words->list[y]) != NULL) {
+ reply("NSMSG_DENIED_FAKEHOST_WORD", vhost, nickserv_conf.denied_fakehost_words->list[y]);
+ return 0;
+ }
+ }
+
+ // check for ircu's HOSTLEN length.
+ if(strlen(vhost) >= HOSTLEN) {
+ reply("NSMSG_NOT_VALID_FAKEHOST_LEN", vhost);
+ return 0;
+ }
+
+ /* This can be handled by the regex now if desired.
+ if (vhost[strspn(vhost, "0123456789.")]) {
+ hostname = vhost + strlen(vhost);
+ for (depth = 1; depth && (hostname > vhost); depth--) {
+ hostname--;
+ while ((hostname > vhost) && (*hostname != '.')) hostname--;
+ }
+
+ if (*hostname == '.') hostname++; * advance past last dot we saw *
+ if(strlen(hostname) > 4) {
+ reply("NSMSG_NOT_VALID_FAKEHOST_TLD_LEN", vhost);
+ return 0;
+ }
+ }
+ */
+ /* test either regex or as valid handle */
+ if (nickserv_conf.valid_fakehost_regex_set) {
+ int err = regexec(&nickserv_conf.valid_fakehost_regex, vhost, 0, 0, 0);
+ if (err) {
+ char buff[256];
+ buff[regerror(err, &nickserv_conf.valid_fakehost_regex, buff, sizeof(buff))] = 0;
+ log_module(NS_LOG, LOG_INFO, "regexec error: %s (%d)", buff, err);
+ }
+ if(err == REG_NOMATCH) {
+ reply("NSMSG_NOT_VALID_FAKEHOST_REGEX", vhost);
+ return 0;
+ }
+ }
+
+
+ return 1;
+}
+