1# CHECK-CIDR.RC 2# 3# Function to check an IP against a list of IP 4# ranges in CIDR format. Based on an earlier, SpamHaus 5# DROP list recipe by Garen Erdiosa. 6# 7# Last updated: 4/02/2010 8# 9 10:0 11* $ ? ${TEST} -f ${TESTCIDR} 12{ 13 :0 14 * ! LOCALIPREGEXP ?? ^^^^ 15 * ! LOCALIPREGEXP ?? ^NULL$ 16 { 17 LOCALBUFFER=` ${EGREP} "${LOCALIPREGEXP}" ${TESTCIDR} ` 18 19 :0 20 * ! LOCALBUFFER ?? ^^^^ 21 { 22 SBLOG="L8-check-cidr.rc: Debug: Positive NETWORK/CIDR match for IP ${LOCALIP} with ${LOCALBUFFER}" 23 INCLUDERC=${SBDIR}/functions/loglevel.rc 24 25 SBLOG="L9-check-cidr.rc: Debug: LOCALIPREGEXP=${LOCALIPREGEXP}" 26 INCLUDERC=${SBDIR}/functions/loglevel.rc 27 LT2=yes 28 } 29 30 :0 E 31 { 32 SBLOG="L8-check-cidr.rc: Debug: Negative NETWORK/CIDR match for ${LOCALIP}" 33 INCLUDERC=${SBDIR}/functions/loglevel.rc 34 35 SBLOG="L9-check-cidr.rc: Debug: LOCALIPREGEXP=${LOCALIPREGEXP}" 36 INCLUDERC=${SBDIR}/functions/loglevel.rc 37 } 38 } 39 40 :0 E 41 * ! LOCALIPREGEXP ?? ^NULL$ 42 { 43 SBLOG="L4-check-cidr.rc: SpamBouncer Internal Error, LOCALIPREGEXP variable is empty." 44 INCLUDERC=${SBDIR}/functions/loglevel.rc 45 } 46} 47 48:0 E 49{ 50 SBLOG="L3-Missing file: ${TESTCIDR}" 51 INCLUDERC=${SBDIR}/functions/loglevel.rc 52} 53