Created
April 21, 2015 10:35
-
-
Save dangowrt/37d956fc2f54fd59e7db to your computer and use it in GitHub Desktop.
kad164: pseudo-e164 dialplan helper script using kadnode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
NUM="$1" | |
uri="" | |
num2name() { | |
l=${#NUM} | |
i=$l | |
while [ $i -gt 0 ]; do | |
n="$( echo "$NUM" | cut -b ${i} )" | |
echo -n "$n." | |
i=$(( $i - 1 )) | |
done | |
echo "e164.p2p" | |
} | |
qs="$( num2name "$1" )" | |
kadnode-ctl lookup $qs 2>/dev/null | while read res; do | |
ip="$( echo $res | cut -d':' -f1 )" | |
port="$( echo $res | cut -d':' -f2 )" | |
proto="" | |
case "$port" in | |
5060) | |
proto="" | |
;; | |
5061) | |
proto=";proto=tls" | |
;; | |
esac | |
[ "$m" ] && echo -n "&" | |
echo -n "SIP/${1}@$ip$proto" | |
m=1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment