diff options
author | Jonas Smedegaard <dr@jones.dk> | 2010-07-08 10:48:38 +0200 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2010-07-08 10:48:38 +0200 |
commit | 9b490526b28f9e3d0077cca1a8d536983e0c3fdb (patch) | |
tree | d5af8a0cf09e39f93a54b02d6f4cb71fd583596f /localkannel-dispatch | |
parent | 86c5496de82282bcb2f9ed8f1fc5e74687324871 (diff) |
When redirecting, lookup and use same service phone as recently used by target phone - and refuse redirect if lookup fails.
Diffstat (limited to 'localkannel-dispatch')
-rwxr-xr-x | localkannel-dispatch | 12 |
1 files changed, 10 insertions, 2 deletions
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 |