From 9b490526b28f9e3d0077cca1a8d536983e0c3fdb Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Thu, 8 Jul 2010 10:48:38 +0200 Subject: When redirecting, lookup and use same service phone as recently used by target phone - and refuse redirect if lookup fails. --- localkannel-dispatch | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'localkannel-dispatch') diff --git a/localkannel-dispatch b/localkannel-dispatch index c6b5aa0..59c2c85 100755 --- a/localkannel-dispatch +++ b/localkannel-dispatch @@ -31,6 +31,12 @@ uriunescape() { fi } +lastservicephone() { + logfile=/var/log/kannel/smsbox.log + tac $logfile $logfile.1 \ + | perl -ne "/INFO: Starting to service <.*> from <\+$1> to <([^<>]*)>/ and print \$1 and exit 0" +} + #from=`uriunescape "$1" | sed -e 's/\+/ /g'`; shift from=`uriunescape "$1"`; shift #to=`uriunescape "$1" | sed -e 's/\+/ /g'`; shift @@ -141,9 +147,11 @@ esac case "$app" in @*) # FIXME: Avoid hardcoding national prefix - to="$(echo "$app" | perl -pe 's/^@//;' -e 's/^([^+])/+39\1/')" + targetphone="$(echo "$app" | perl -pe 's/^@//;' -e 's/^([^+])/+39\1/')" # TODO: silence errors - or better: bounce those back to original sender - $sbindir/localmarkdown2sms "$to" "$@" + targetfrom=$(lastservicephone "$targetphone") + [ -n "$targetfrom" ] || exit1 "refusing to redirect: unknown target phone number \"$targetphone\"." + SMS_PHONE="targetfrom" $sbindir/localmarkdown2sms "$targetphone" "$@" exit 0 ;; esac -- cgit v1.2.3