Skip to content

Commit

Permalink
kamctl: option for rpc command to replace tokens in parameters
Browse files Browse the repository at this point in the history
- supported now: replace '=CRLF=' with '\r\n'
- fix 'kamctl ping' command by replacing '=CRLF=' with '\r\n'
in multi-headers parameter

(cherry picked from commit 1c66f6a)
(cherry picked from commit 9b5eade)
  • Loading branch information
miconda committed Mar 29, 2021
1 parent 8247627 commit 0761382
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion utils/kamctl/kamctl
Expand Up @@ -2036,7 +2036,7 @@ kamailio_stop() {
options_ping() {
myhost=`get_my_host`
require_ctlengine
CMDPARAMS="tm.t_uac_start OPTIONS \"$1\" \".\" \".\" \"From:sip:daemon@$myhost"$'\r\n'"To:<$1>"$'\r\n'"Contact:sip:daemon@$myhost"$'\r\n'"\""
CMDPARAMS="= tm.t_uac_start OPTIONS \"$1\" \".\" \".\" \"From:sip:daemon@$myhost=CRLF=To:<$1>=CRLF=Contact:sip:daemon@$myhost=CRLF=\""
if [ $CTLENGINETYPE -eq 1 ] ; then
ctl_cmd_run $CMDPARAMS
else
Expand Down
13 changes: 12 additions & 1 deletion utils/kamctl/kamctl.rpcfifo
Expand Up @@ -101,6 +101,12 @@ rpc_cmd()
chmod a+w $path
fi

PARAMEVAL="no"
if [ "$1" = "=" ]; then
PARAMEVAL="yes"
shift
fi

# construct the command now
CMD="{\"jsonrpc\": \"2.0\", \"method\": \"$1\"";
shift
Expand All @@ -114,7 +120,12 @@ rpc_cmd()
shift
while [ -n "$1" ] ; do
rpcparamval "${1}"
CMD="${CMD}, ${RPCVAL}"
if [ "$PARAMEVAL" = "yes" ]; then
CMDPARAM=`echo "$RPCVAL" | awk -F'=CRLF=' '{$1=$1}1' OFS='\r\n'`
CMD="${CMD}, ${CMDPARAM}"
else
CMD="${CMD}, ${RPCVAL}"
fi
shift
done
CMD="${CMD}]"
Expand Down

0 comments on commit 0761382

Please sign in to comment.