chiark / gitweb /
probes: receive
[modbot-urcm.git] / probes / modrelays-probe
index ef7c639bb2b90365b9e532078924438cf7bd2b8b..a817a85b8c2c8655303007ea9b93f7412cf0a9e9 100755 (executable)
@@ -6,6 +6,14 @@ MODRELAYS=moderators.isc.org
 PROBE_TIMEOUT=$(( 20 * 60 ))
 PROBE_EXPIRE=$(( 32 * 86400 ))
 
+case "$1" in
+received)
+       mode="$1"
+       cd "$2"
+       shift; shift; set "$mode" "$@"
+       ;;
+esac
+
 . ../global-settings
 . ./settings
 
@@ -18,8 +26,8 @@ fail () {
        exit 16
 }
 
-record-probing () {
-       # implicitly uses newsgroup, id, domain
+compute-td () {
+       # implicitly uses GROUP, id, domain
        # caller must "local td", which will be set
        local probeid=$1
 
@@ -29,6 +37,10 @@ record-probing () {
        esac
 
        td="$statedir/$probeid"
+}
+
+record-probing () {
+       compute-td "$@"
        mkdir -p $td
 }
 
@@ -197,7 +209,7 @@ probe-domain () {
 }
 
 no_args () {
-       case $1 in
+       case $# in
        0) return ;;
        *) fail "no arguments to $mode allowed" ;;
        esac
@@ -339,6 +351,20 @@ mode_report () {
        done
 }
 
+mode_received () {
+       no_args
+
+       local hn group id domain mx addr
+       while read hn group id domain mx addr; do
+               if [ x"$hn" != x"X-WebSTUMP-Relay-Probe:" ]; then continue; fi
+               if [ x"$group" != x"$GROUP" ]; then continue; fi
+               local td
+               compute-td "mx=$mx,addr=$addr"
+               >"$td/ok" ||:
+               return
+       done
+}
+
 mode_all () {
        no_args $#
        for domain in $MODRELAYS; do