feat: add number library routing and cdr location support
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
MI_URL=${LISGLOSIPS_MI_URL:-http://127.0.0.1:8888/mi}
|
||||
ORIGINAL=${SSH_ORIGINAL_COMMAND:-}
|
||||
|
||||
if [ "$#" -eq 0 ] && [ -n "$ORIGINAL" ]; then
|
||||
set -- $ORIGINAL
|
||||
fi
|
||||
|
||||
while [ "$#" -gt 0 ]; do
|
||||
token=${1:-}
|
||||
token=${token#\"}
|
||||
token=${token%\"}
|
||||
token=${token#\'}
|
||||
token=${token%\'}
|
||||
|
||||
case "$token" in
|
||||
/usr/local/sbin/lisglosips-call-control|lisglosips-call-control|'')
|
||||
shift
|
||||
;;
|
||||
dlg_list|dlg_end_dlg)
|
||||
set -- "$token" "${2:-}"
|
||||
break
|
||||
;;
|
||||
*)
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
method=${1:-}
|
||||
case "$method" in
|
||||
dlg_list)
|
||||
payload='{"jsonrpc":"2.0","method":"dlg_list","params":[],"id":1}'
|
||||
;;
|
||||
dlg_end_dlg)
|
||||
dialog_id=${2:-}
|
||||
dialog_id=${dialog_id#\"}
|
||||
dialog_id=${dialog_id%\"}
|
||||
dialog_id=${dialog_id#\'}
|
||||
dialog_id=${dialog_id%\'}
|
||||
if ! printf '%s' "$dialog_id" | grep -Eq '^[A-Za-z0-9@._:%+=-]{1,220}$'; then
|
||||
printf '{"jsonrpc":"2.0","error":{"code":-32602,"message":"invalid dialog id"},"id":1}\n'
|
||||
exit 0
|
||||
fi
|
||||
payload='{"jsonrpc":"2.0","method":"dlg_end_dlg","params":["'"$dialog_id"'"],"id":1}'
|
||||
;;
|
||||
*)
|
||||
printf '{"jsonrpc":"2.0","error":{"code":-32601,"message":"method not allowed"},"id":1}\n'
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
exec curl -fsS -X POST "$MI_URL" -H 'Content-Type: application/json' --data-binary "$payload"
|
||||
Reference in New Issue
Block a user