Module: kamailio
Branch: master
Commit: 1c66f6a1a5d04c33f1912609a36729b06b6eebd7
URL:
https://github.com/kamailio/kamailio/commit/1c66f6a1a5d04c33f1912609a36729b…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2021-01-18T10:34:58+01:00
kamctl: option for rpc command to replace tokens in parameters
- supported now: replace '=CRLF=' with '\r\n'
- fix 'kamctl ping' command by replacing '=CRLF=' with '\r\n'
in multi-headers parameter
---
Modified: utils/kamctl/kamctl
Modified: utils/kamctl/kamctl.rpcfifo
---
Diff:
https://github.com/kamailio/kamailio/commit/1c66f6a1a5d04c33f1912609a36729b…
Patch:
https://github.com/kamailio/kamailio/commit/1c66f6a1a5d04c33f1912609a36729b…
---
diff --git a/utils/kamctl/kamctl b/utils/kamctl/kamctl
index 5be26efbc4..3b8ecd6c64 100755
--- a/utils/kamctl/kamctl
+++ b/utils/kamctl/kamctl
@@ -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
diff --git a/utils/kamctl/kamctl.rpcfifo b/utils/kamctl/kamctl.rpcfifo
index 743f15bc4d..c8e5329811 100644
--- a/utils/kamctl/kamctl.rpcfifo
+++ b/utils/kamctl/kamctl.rpcfifo
@@ -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
@@ -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}]"