divert(-1) # # Copyright (c) 2003, 2004 Victor Ustugov # This hack is under BSD License # Redistributions of source code must retain the above copyright notice # # hacks disscussion's maillist - http://www.mta.org.ua/mailman/listinfo/sendmail-conf # # # Check the syntax of IP addresses # Проверка синтаксима IP адресов # # idea from email-security@ # идея взята из email-security@ # divert(0) ifdef(`_IP_CHECK_', `dnl', `dnl VERSIONID(`$Id: check_ip.m4,v 8.12-0.04 2006/08/23 22:20:05 corvax Exp $')dnl divert(-1) define(`_IP_CHECK_')dnl dnl dnl LOCAL_CONFIG dnl dnl Kippat regex -a@MATCH -n [0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3} dnl dnl LOCAL_RULESETS dnl dnl SCheckIPsyntax R $* $: $1 R $-.$-.$-.$- $: <4> $1.$2.$3.$4 R $* $@ FAILED R <4> $-.$-.$-.$- $: $1.$2.$3.$4 R $-.$-.$-.$- $: $(ippat $1.$2.$3.$4 $ $: $1.$2.$3.$4 $) R @MATCH $@ FAILED R $-.$-.$-.$- $: TRUE $1.$2.$3.$4 R TRUE $-.$-.$-.$- $: $(arith l $@ $1 $@ 256 $) $1.$2.$3.$4 R TRUE $-.$-.$-.$- $: $(arith l $@ $2 $@ 256 $) $1.$2.$3.$4 R TRUE $-.$-.$-.$- $: $(arith l $@ $3 $@ 256 $) $1.$2.$3.$4 R TRUE $-.$-.$-.$- $: $(arith l $@ $4 $@ 256 $) $1.$2.$3.$4 R TRUE $-.$-.$-.$- $: $(arith l $@ 0 $@ $1 $) $1.$2.$3.$4 R FALSE $+ $@ FAILED R TRUE $+ $: $1 SCheckIP R $* [$-.$-.$-.$-] $* $: $>CheckIPsyntax $2.$3.$4.$5 R FAILED $#error $@ 5.7.1 $: "550 Forged header" R $-.$-.$-.$- $: $1.$2.$3.$4 ifdef(`confCHECK_IP_OPEN_PROXY', ` R $-.$-.$-.$- $: $1.$2.$3.$4 $| $(dnsbl $4.$3.$2.$1.list.dsbl.org. $: OK $) R $-.$-.$-.$- $| OK $: $1.$2.$3.$4 R $-.$-.$-.$- $| $+ $: $1.$2.$3.$4 R $-.$-.$-.$- $| $+ $#error $@ 5.7.1 $: "550 Open proxy found in backtrace" ') R <$*> $-.$-.$-.$- $| $* $: $2.$3.$4.$5 dnl ')