--- gross-1.0rc4/src/worker.c.orig 2008-04-28 13:17:49.000000000 +0800 +++ gross-1.0rc4/src/worker.c 2008-04-30 18:43:01.000000000 +0800 @@ -187,6 +187,49 @@ } int +check_helo(char *helo) +{ + int match_dot = 0; + int match_bad = 0; + int match_isalpha = 0; + int match_isnum = 0; +// int match_bracket = 0; + char *ptr = helo, *tmp = helo; + int ret = 0; + char c; + + while (tmp && (c = tmp++[0])) + if (c == '/') + ptr = tmp; + + while (ptr && (c = ptr++[0])) { + if (c == '-' || (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')) { + match_isalpha++; + continue; + } else if (c >= '0' && c<= '9') { + match_isnum++; + continue; + } else if (c == '.') { + match_dot++; + continue; +// } else if (c == '[' || c == ']') { +// match_bracket++; +// continue; + } else if (c == '_') { + continue; + } else { + match_bad++; + break; + } + } + if (match_dot == 3 && match_isnum >= 4 && match_isalpha == 0) + ret = 0; + else if (match_dot > 0 && match_bad == 0 && match_isnum + match_isalpha >= 2) + ret = -1; + return ret; +} + +int test_tuple(final_status_t *final, grey_tuple_t *request, tmout_action_t *ta) { char maskedtuple[MSGSZ]; @@ -265,6 +308,8 @@ } else if (0 == checkcount) { /* traditional greylister */ retvalue = STATUS_GREY; + } else if (0 == check_helo(request->helo_name)) { + retvalue = STATUS_GREY; } else { /* build default entry, if timeout not given */ if (!ta) {