Documentation |
Documentation.Script-Tran-3-6 HistoryHide minor edits - Show changes to markup June 13, 2024, at 03:52 PM
by
- Changed line 390 from:
Assumes the input is an RFC-1123 SIP "Date" header value, parses it accordingly and returns the equivalent UNIX timestamp. to:
Assumes the input is an RFC-3261 SIP "Date" header value, parses it accordingly and returns the equivalent UNIX timestamp. June 13, 2024, at 03:51 PM
by
- Added lines 384-394:
@] {s.date2unix} 🔗Assumes the input is an RFC-1123 SIP "Date" header value, parses it accordingly and returns the equivalent UNIX timestamp. [@ $var(date) = "Thu, 13 Jun 2024 12:48:00 GMT"; $(var(date){s.date2unix}) => "1718282880"; December 22, 2022, at 02:40 PM
by
- Added lines 690-699:
Each transformation supports an optional 'index'. This can be used when passing a list of nameaddr specs, and represents the spec index that should be considered when extracting the value. Indexes start with 0 (the default value when missing), and can accept negative values (-1 represents the last nameaddr spec). Example: '"first" <first@opensips.org>, "second" <second@opensips.org>' {nameaddr.0.name} = "first" '"first" <first@opensips.org>, "second" <second@opensips.org>' {nameaddr.1.name} = "second" '"first" <first@opensips.org>, "second" <second@opensips.org>' {nameaddr.-1.name} = "second" December 22, 2021, at 03:42 PM
by
- Added lines 386-466:
{s.sha1} 🔗Returns the SHA1 hash of the given input. xlog("SHA1 over From username: $(fU{s.sha1})\n"); {s.sha224} 🔗Returns the SHA224 hash of the given input. xlog("SHA224 over From username: $(fU{s.sha224})\n"); {s.sha256} 🔗Returns the SHA256 hash of the given input. xlog("SHA256 over From username: $(fU{s.sha256})\n"); {s.sha384} 🔗Returns the SHA384 hash of the given input. xlog("SHA384 over From username: $(fU{s.sha384})\n"); {s.sha512} 🔗Returns the SHA512 hash of the given input. xlog("SHA512 over From username: $(fU{s.sha512})\n"); {s.sha1_hmac,key} 🔗Returns the SHA1 HMAC hash of the given input using key. xlog("SHA1 HMAC over From username using key 'secret': $(fU{s.sha1_hmac,secret})\n"); {s.sha224_hmac,key} 🔗Returns the SHA224 HMAC hash of the given input using key. xlog("SHA224 HMAC over From username using key 'secret': $(fU{s.sha224_hmac,secret})\n"); {s.sha256_hmac,key} 🔗Returns the SHA256 HMAC hash of the given input using key. xlog("SHA256 HMAC over From username using key 'secret': $(fU{s.sha256_hmac,secret})\n"); {s.sha384_hmac,key} 🔗Returns the SHA384 HMAC hash of the given input using key. xlog("SHA384 HMAC over From username using key 'secret': $(fU{s.sha384_hmac,secret})\n"); {s.sha512_hmac,key} 🔗Returns the SHA512 HMAC hash of the given input using key. xlog("SHA512 HMAC over From username using key 'secret': $(fU{s.sha512_hmac,secret})\n"); September 17, 2021, at 08:22 PM
by
- Changed line 134 from:
Return the substring starting at offset having size of length. If offset is negative, then it is counted from the end of the value, -1 being the last char. In case of a positive value, 0 is the first char. The length must be positive and in case of both 0 and greater-than-string-length values, the substring to the end of the input string is returned. Both offset and length may be specified using variables. to:
Return the substring starting at offset having size of length. If offset is negative, then it is counted from the end of the value, -1 being the last char. In case of a positive value, 0 is the first char. The length must be positive and in case of both 0 and greater-than-string-length values, the substring to the end of the input string is returned. Both offset and length may be specified using variables. September 17, 2021, at 08:21 PM
by
- Changed line 134 from:
Return substring starting at offset having size of 'length'. If offset is negative, then it is counted from the end of the value, -1 being the last char. In case of positive value, 0 is first char. Length must be positive, in case of 0, substring to the end of variable value is returned. offset and length can be a varibale as well. to:
Return the substring starting at offset having size of length. If offset is negative, then it is counted from the end of the value, -1 being the last char. In case of a positive value, 0 is the first char. The length must be positive and in case of both 0 and greater-than-string-length values, the substring to the end of the input string is returned. Both offset and length may be specified using variables. February 02, 2021, at 11:47 AM
by
- Added lines 373-383:
@] {s.eval} 🔗Interprets the string as a variable formatted string, evaluating all the variables declared in it. [@ $var(in) = "client"; $var(format) = "Hello, $var(in)!"; $(var(format){s.eval}) => "Hello, client!" September 27, 2019, at 09:14 AM
by
- Changed lines 15-17 from:
Intuitively, a Transformation is a function that is applied to a variable(script variable, pseudo-variables, AVPS, static strings) to get a special value from it. The value of the original variable is not altered. Example of using different kind of variables in OpenSIPS script: to:
Intuitively, a Transformation is a function that is applied to a variable(script variable, pseudo-variable, AVP, static string) to get a special value from it. The input value is not altered. Examples of using different kinds of variables in OpenSIPS script: June 28, 2019, at 05:13 PM
by
- Added lines 677-696:
June 14, 2019, at 06:52 PM
by
- Changed lines 99-100 from:
{s.int}to:
{s.int} 🔗Changed lines 111-112 from:
{s.md5}to:
{s.md5} 🔗Changed lines 120-121 from:
{s.reverse}to:
{s.reverse} 🔗Changed lines 131-132 from:
{s.substr,offset,length}to:
{s.substr,offset,length} 🔗Changed lines 142-143 from:
{s.select,index,separator}to:
{s.select,index,separator} 🔗Changed lines 156-157 from:
{s.encode.hexa}to:
{s.encode.hexa} 🔗Changed lines 161-162 from:
{s.decode.hexa}to:
{s.decode.hexa} 🔗Changed lines 167-168 from:
{s.escape.common}to:
{s.escape.common} 🔗Changed lines 173-174 from:
{s.unescape.common}to:
{s.unescape.common} 🔗Changed lines 179-180 from:
{s.escape.user}to:
{s.escape.user} 🔗Changed lines 184-185 from:
{s.unescape.user}to:
{s.unescape.user} 🔗Changed lines 190-191 from:
{s.escape.param}to:
{s.escape.param} 🔗Changed lines 196-197 from:
{s.unescape.param}to:
{s.unescape.param} 🔗Changed lines 201-202 from:
{s.tolower}to:
{s.tolower} 🔗Changed lines 207-208 from:
{s.toupper}to:
{s.toupper} 🔗Changed lines 212-213 from:
{s.index}to:
{s.index} 🔗Changed lines 240-241 from:
{s.rindex}to:
{s.rindex} 🔗Changed lines 255-256 from:
{s.fill.left, tok, len}to:
{s.fill.left, tok, len} 🔗Changed lines 273-274 from:
{s.fill.right, tok, len}to:
{s.fill.right, tok, len} 🔗Changed lines 287-288 from:
{s.width, len}to:
{s.width, len} 🔗Changed lines 302-303 from:
{s.trim}to:
{s.trim} 🔗Changed lines 313-314 from:
{s.trimr}to:
{s.trimr} 🔗Changed lines 324-325 from:
{s.triml}to:
{s.triml} 🔗Changed lines 335-336 from:
{s.dec2hex}to:
{s.dec2hex} 🔗Changed lines 340-341 from:
{s.hex2dec}to:
{s.hex2dec} 🔗Changed lines 345-346 from:
{s.b64encode}to:
{s.b64encode} 🔗Changed lines 355-356 from:
{s.b64decode}to:
{s.b64decode} 🔗Changed lines 365-366 from:
{s.xor,secret}to:
{s.xor,secret} 🔗Changed lines 382-383 from:
{uri.user}to:
{uri.user} 🔗Changed lines 387-388 from:
{uri.host}to:
{uri.host} 🔗Changed lines 394-395 from:
{uri.passwd}to:
{uri.passwd} 🔗Changed lines 399-400 from:
{uri.port}to:
{uri.port} 🔗Changed lines 404-405 from:
{uri.params}to:
{uri.params} 🔗Changed lines 409-410 from:
{uri.param,name}to:
{uri.param,name} 🔗Changed lines 414-415 from:
{uri.headers}to:
{uri.headers} 🔗Changed lines 419-420 from:
{uri.transport}to:
{uri.transport} 🔗Changed lines 424-425 from:
{uri.ttl}to:
{uri.ttl} 🔗Changed lines 429-430 from:
{uri.uparam}to:
{uri.uparam} 🔗Changed lines 434-435 from:
{uri.maddr}to:
{uri.maddr} 🔗Changed lines 439-440 from:
{uri.method}to:
{uri.method} 🔗Changed lines 444-445 from:
{uri.lr}to:
{uri.lr} 🔗Changed lines 449-450 from:
{uri.r2}to:
{uri.r2} 🔗Changed lines 454-455 from:
{uri.schema}to:
{uri.schema} 🔗Changed lines 471-472 from:
{via.name}to:
{via.name} 🔗Changed lines 476-477 from:
{via.version}to:
{via.version} 🔗Changed lines 481-482 from:
{via.transport}to:
{via.transport} 🔗Changed lines 486-487 from:
{via.host}to:
{via.host} 🔗Changed lines 493-494 from:
{via.port}to:
{via.port} 🔗Changed lines 498-499 from:
{via.comment}to:
{via.comment} 🔗Changed lines 503-504 from:
{via.params}to:
{via.params} 🔗Changed lines 508-509 from:
{via.param,name}to:
{via.param,name} 🔗Changed lines 513-514 from:
{via.branch}to:
{via.branch} 🔗Changed lines 518-519 from:
{via.received}to:
{via.received} 🔗Changed lines 523-524 from:
{via.rport}to:
{via.rport} 🔗Changed lines 535-536 from:
{param.value,name}to:
{param.value,name} 🔗Changed lines 547-548 from:
{param.exist,name}to:
{param.exist,name} 🔗Changed lines 559-560 from:
{param.valueat,index}to:
{param.valueat,index} 🔗Changed lines 571-572 from:
{param.name,index}to:
{param.name,index} 🔗Changed lines 583-584 from:
{param.count}to:
{param.count} 🔗Changed lines 602-603 from:
{nameaddr.name}to:
{nameaddr.name} 🔗Changed lines 612-613 from:
{nameaddr.uri}to:
{nameaddr.uri} 🔗Changed lines 622-623 from:
{nameaddr.len}to:
{nameaddr.len} 🔗Changed lines 628-629 from:
{nameaddr.param,param_name}to:
{nameaddr.param,param_name} 🔗Changed lines 637-638 from:
{nameaddr.params}to:
{nameaddr.params} 🔗Changed lines 650-651 from:
{ip.pton}to:
{ip.pton} 🔗Changed lines 659-660 from:
{ip.ntop}to:
{ip.ntop} 🔗Changed lines 668-669 from:
{ip.isip}to:
{ip.isip} 🔗Changed lines 678-679 from:
{ip.family}to:
{ip.family} 🔗Changed lines 686-687 from:
{ip.resolve}to:
{ip.resolve} 🔗Changed lines 694-695 from:
{ip.matches}to:
{ip.matches} 🔗Changed lines 705-706 from:
{ip.isprivate}to:
{ip.isprivate} 🔗Changed lines 724-725 from:
{csv.count}to:
{csv.count} 🔗Changed lines 732-733 from:
{csv.value}to:
{csv.value} 🔗Changed lines 746-747 from:
{sdp.line}to:
{sdp.line} 🔗Changed lines 764-765 from:
{sdp.stream}to:
{sdp.stream} 🔗Changed lines 783-784 from:
{sdp.stream-delete}to:
{sdp.stream-delete} 🔗Changed lines 806-807 from:
{re.subst,reg_exp}to:
{re.subst,reg_exp} 🔗Changed line 846 from:
@] to:
@] June 14, 2019, at 06:34 PM
by
- Added lines 634-644:
{ip.isprivate}Checks if the input IP address is an IPv4 private IP, according to RFC 1918 and RFC 6598. It returns 1 if the IP is private, 0 if not. Example: if ( $(si{ip.isprivate})==1 ) xlog("source ip is private\n"); else xlog("source ip is not private\n"); April 24, 2019, at 01:13 PM
by
- Changed line 21 from:
if($fU==$tU) { to:
if ($fU == $tU) { April 24, 2019, at 01:09 PM
by
- Changed lines 25-26 from:
switch($ruri.user) { to:
switch ($rU) { Changed lines 37-45 from:
$avp(i:11) = 1;
$avp(i:22) = "opensips";
$avp(i:33) = $ruri; to:
$var(gw_count) = 1;
$avp(server) = "opensips";
$var(ru_backup) = $ru; Changed line 47 from:
$var(x) = "sip:" + $fU +"@" + $td; to:
$var(x) = "sip:" + $fU + "@" + $td; April 23, 2019, at 06:44 PM
by
- Changed line 604 from:
Returns 1 or 0, if the string provided is a valid IP or not. to:
Returns March 13, 2019, at 06:25 PM
by
- Changed line 619 from:
Returns the resolved IP address coresponding to the string domain provided. Transformation has no effect if a string IP is provided. to:
Returns the resolved IP address corresponding to the string domain provided. Transformation has no effect if a string IP is provided. Added lines 624-634:
{ip.matches}Checks if the input IP address matches a net mask given as IP/masklen (short format). It returns 1 if matches, 0 if not. NULL is returned on error (invalid input, invalid parameter, AF mismatch). Variables are supported for the parameter. Example: if ( $(si{ip.matches,10.10.0.1/24})==1 ) xlog("It DOES match \n"); else xlog("It DOES NOT match \n"); March 12, 2019, at 09:39 AM
by
- Added lines 117-126:
{s.reverse}Returns the input string in revers order. $var(forward) = "onetwothree"; $var(reverse) = $(var(forward){s.reverse}); //Contains "eerhtowteno"; October 30, 2018, at 05:52 PM
by
- Added lines 655-672:
} @] {sdp.stream}Returns a specific stream (starting with the m= line) from an SDP body. The stream to be returned can be specified using its index within the body, or using on its media type. If specified as index, it starts at Example: [@ if (is_method("INVITE")) { $var(first_stream) = $(rb{sdp.stream,0}); xlog("First stream is $var(first_stream)\n"); } if (is_method("INVITE")) { $var(audio_stream) = $(rb{sdp.stream,audio}); xlog("Audio stream is $var(audio_stream)\n"); October 30, 2018, at 12:11 PM
by
- Added lines 655-672:
} @] {sdp.stream-delete}Returns the specified SDP body with some of its streams deleted. The stream to be deleted can be specified using its index, or using on its media type. If specified as index, it starts at Example: [@ if (is_method("INVITE")) { $var(new_body) = $(rb{sdp.stream-delete,0}); xlog("SDP body without first stream is $var(new_body)\n"); } if (is_method("INVITE")) { $var(new_body) = $(rb{sdp.stream-delete,video}); xlog("SDP body without video stream is $var(new_body)\n"); August 04, 2018, at 08:57 PM
by
- Changed line 115 from:
xlog("MD5 over From username: $(fU{s.md5})"); to:
xlog("MD5 over From username: $(fU{s.md5})\n"); Changed lines 210-211 from:
xlog("found $var(sstr) in $var(strtosearch)"); to:
xlog("found $var(sstr) in $var(strtosearch)\n"); Changed line 700 from:
xlog("This is an un-registration"); to:
xlog("This is a de-registration\n"); August 04, 2018, at 08:56 PM
by
- Changed lines 112-113 from:
Return md5 over variable value to:
Returns the MD5 hash of the given input. Changed line 115 from:
xlog("MD4 over From username: $(fU{s.md5})"); to:
xlog("MD5 over From username: $(fU{s.md5})"); April 03, 2018, at 05:05 PM
by
- Changed line 15 from:
A Transformation is basically a function that is applied to a variable(script variable, pseudo-variables, AVPS, static strings) to get a special value from it. The value of the original variable is not altered. to:
Intuitively, a Transformation is a function that is applied to a variable(script variable, pseudo-variables, AVPS, static strings) to get a special value from it. The value of the original variable is not altered. July 04, 2017, at 04:46 PM
by
- Changed line 64 from:
Many transformations can be applied in the same time to a variable. to:
Multiple transformations can be applied to a variable at the same time. July 03, 2017, at 05:23 PM
by
- Added lines 72-73:
All transformations, unless otherwise specified, will return NULL in case of error or unsuccessful operation (e.g looking for an nonexistent parameter in an URI with the "{uri.param,name}" transformation). Also, NULL is accepted as input for transformations in order to support chaining with a previous one that would return NULL. Changed lines 130-131 from:
Return a field from the value of a variable. The field is selected based on separator and index. The separator must be a character used to identify the fields. Index must be a integer value or a variable. If index is negative, the count of fields starts from end of value, -1 being last field. If index is positive, 0 is the first field. to:
Return a field from the value of a variable. The field is selected based on separator and index. The separator must be a character used to identify the fields. Index must be a integer value or a variable. If index is negative, the count of fields starts from end of value, -1 being last field. If index is positive, 0 is the first field. Note that if a field is empty, an empty string will be returned and not NULL. Changed line 189 from:
Searches for one string within another starting at the beginning of the first string. Returns starting index of the string found or -1 if not found. to:
Searches for one string within another starting at the beginning of the first string. Returns starting index of the string found or NULL if not found. Changed line 209 from:
if ($(var(strtosearch){s.index, $var(str)}) >=0) to:
if ($(var(strtosearch){s.index, $var(str)}) != NULL) Changed line 216 from:
Searches for one string within another starting at the end of the first string. Returns starting index of the string found or -1 if not found. to:
Searches for one string within another starting at the end of the first string. Returns starting index of the string found or NULL if not found. June 21, 2016, at 03:56 PM
by
- Changed line 314 from:
$(var(in){s.base64encode}) => "AgMEBSFAIyVeJio=" to:
$(var(in){s.b64encode}) => "AgMEBSFAIyVeJio=" Changed line 323 from:
$(var(in){s.base64encode}) => "\x2\x3\x4\x5!@#%^&*" to:
$(var(in){s.b64decode}) => "\x2\x3\x4\x5!@#%^&*" June 21, 2016, at 02:26 PM
by
- Changed lines 308-309 from:
{s.base64encode}to:
{s.b64encode}Changed line 317 from:
{s.base64decode}to:
{s.b64decode}March 29, 2016, at 01:54 PM
by
- Changed lines 102-103 from:
$var(x) = "1234"; if($(var(x){s.int})==1234) { to:
$var(dur) = "2868.12 sec"; if ($(var(dur){s.int}) < 3600) { March 29, 2016, at 01:52 PM
by
- Changed line 99 from:
Return integer value of a string-represented number to:
Converts the initial part of the given string to an integer value. Returns 0 if there were no digits at all. March 28, 2016, at 05:35 PM
by
- Added lines 324-332:
@] {s.xor,secret}Performs one or more logical XOR operations with (a part of) the "secret" string parameter and the input string, depending on the lengths of the two strings. [@ $var(in) = "aaaaaabbbbbb"; $(var(in){s.xor,x}) => "!/>^P!/>^P!^U2^Q!^U2^Q" March 28, 2016, at 05:28 PM
by - March 28, 2016, at 05:28 PM
by
- Deleted lines 184-191:
{s.dec2hex}Converts a decimal(base 10) number to hexadecimal (in base 16), represented as string. {s.hex2dec}Converts a hexadecimal number (base 16) represented as string to decimal (base 10). Added lines 298-323:
@] {s.dec2hex}Converts a decimal(base 10) number to hexadecimal (in base 16), represented as string. {s.hex2dec}Converts a hexadecimal number (base 16) represented as string to decimal (base 10). {s.base64encode}Represents binary input data in an ASCII string format. $var(in) = "\x2\x3\x4\x5!@#%^&*"; $(var(in){s.base64encode}) => "AgMEBSFAIyVeJio=" {s.base64decode}Assumes input is a Base64 string and decodes as many characters as possible. [@ $var(in) = "AgMEBSFAIyVeJio="; $(var(in){s.base64encode}) => "\x2\x3\x4\x5!@#%^&*" July 28, 2015, at 01:01 PM
by
- Added lines 276-305:
@] {s.trim}Strips any leading or trailing whitespace from the input string. Trimmed characters are " " (space), \t (tab), \n (newline) and \r (carriage return). $var(in) = "\t \n input string \r "; $(var(in){s.trim}) => "input string" {s.trimr}Strips any trailing whitespace from the input string. Trimmed characters are " " (space), \t (tab), \n (newline) and \r (carriage return). $var(in) = "\t \n input string \r "; $(var(in){s.trimr}) => "\t \n input string" {s.triml}Strips any leading whitespace from the input string. Trimmed characters are " " (space), \t (tab), \n (newline) and \r (carriage return). [@ $var(in) = "\t \n input string \r "; $(var(in){s.triml}) => "input string \r " June 02, 2015, at 04:56 PM
by
- Changed line 273 from:
$(var(in){s.width, 0}) => "transformation" to:
$(var(in){s.width, 14}) => "transformation" June 02, 2015, at 04:56 PM
by
- Changed lines 234-235 from:
{s.fill.left}to:
{s.fill.left, tok, len}Changed lines 251-252 from:
{s.fill.right}to:
{s.fill.right, tok, len}Changed lines 264-265 from:
Note: currently optimized for speed. Does not support pseudo-variable parameters or successive "s.fill" cascading. to:
{s.width, len}Truncates or expands the input to the given len. Expanding is done to the right with the space character ' '. Truncating is done in a similar manner, from the right. Examples: Fills a string to the right with a char/string until the given final length is reached. The initial string is returned if its length is greater or equal to the given final length. If used on pseudo-variables containing integers, it will convert them to strings. $var(in) = "transformation"; $(var(in){s.width, 0}) => "transformation" $(var(in){s.width, 16}) => "transformation " $(var(in){s.width, 9}) => "transform" March 13, 2015, at 07:08 PM
by
- Added lines 331-334:
{uri.schema}Returns the schema part of the given URI. October 10, 2014, at 01:26 PM
by
- Changed line 2 from:
(:title Script Transformations - ver 1.12 :) to:
(:title Script Transformations - 3.6:) October 10, 2014, at 01:23 PM
by
- Changed lines 615-616 from:
to:
Changed line 626 from:
xlog("This is an un-registrationn"); to:
xlog("This is an un-registration"); October 10, 2014, at 01:16 PM
by
- Changed line 4 from:
(:allVersions Script-Tran 3.6:) to:
(:allVersions Script-Tran 3.6:) September 30, 2014, at 04:17 PM
by
- Deleted lines 237-238:
Note: currently optimized for speed. Does not support pseudo-variable parameters or successive "s.fill" cascading. Added lines 247-250:
Note: currently optimized for speed. Does not support pseudo-variable parameters or successive "s.fill" cascading. Deleted lines 254-255:
Note: currently optimized for speed. Does not support pseudo-variable parameters or successive "s.fill" cascading. Added lines 263-266:
Note: currently optimized for speed. Does not support pseudo-variable parameters or successive "s.fill" cascading. September 30, 2014, at 04:16 PM
by
- Added lines 238-239:
Note: currently optimized for speed. Does not support pseudo-variable parameters or successive "s.fill" cascading. Added lines 252-253:
Note: currently optimized for speed. Does not support pseudo-variable parameters or successive "s.fill" cascading. September 30, 2014, at 04:08 PM
by
- Added lines 231-256:
@] {s.fill.left}Fills a string to the left with a char/string until the given final length is reached. The initial string is returned if its length is greater or equal to the given final length. $var(in) = "485"; (also works for integer PVs) $(var(in){s.fill.left, 0, 3}) => 485 $(var(in){s.fill.left, 0, 6}) => 000485 $(var(in){s.fill.left, abc, 8}) => bcabc485 {s.fill.right}Fills a string to the right with a char/string until the given final length is reached. The initial string is returned if its length is greater or equal to the given final length. [@ $var(in) = 485; (also works for string PVs) $(var(in){s.fill.right, 0, 3}) => 485 $(var(in){s.fill.right, 0, 6}) => 485000 $(var(in){s.fill.right, abc, 8}) => 485abcab |