chan_websocket: Allow additional URI parameters to be added to the outgoing URI.

* Added a new option to the WebSocket dial string to capture the additional
  URI parameters.
* Added a new API ast_uri_verify_encoded() that verifies that a string
  either doesn't need URI encoding or that it has already been encoded.
* Added a new API ast_websocket_client_add_uri_params() to add the params
  to the client websocket session.
* Added XML documentation that will show up with `core show application Dial`
  that shows how to use it.

Resolves: #1352

UserNote: A new WebSocket channel driver option `v` has been added to the
Dial application that allows you to specify additional URI parameters on
outgoing connections. Run `core show application Dial` from the Asterisk CLI
to see how to use it.

(cherry picked from commit 15371efeab)
This commit is contained in:
George Joseph
2025-08-13 13:22:38 -06:00
parent 4bbd94ff15
commit 7cc840ef77
5 changed files with 214 additions and 2 deletions

View File

@@ -778,6 +778,42 @@ void ast_uri_decode(char *s, struct ast_flags spec)
*o = '\0';
}
int ast_uri_verify_encoded(const char *string)
{
const char *ptr = string;
size_t length;
char *endl;
if (!string) {
return 0;
}
length = strlen(string);
endl = (char *)string + length;
while (*ptr) {
if (*ptr == '%') {
unsigned int tmp;
/* Make sure there are at least 2 characters left to decode */
if (ptr + 2 >= endl) {
return 0;
}
/* Try to parse the next two characters as hex */
if (sscanf(ptr + 1, "%2x", &tmp) != 1) {
return 0;
}
/* All good, move past the '%' and the two hex digits */
ptr += 3;
} else if (!isalnum((unsigned char ) *ptr) && !strchr("-_.+", *ptr)) {
return 0;
} else {
ptr++;
}
}
return 1; /* all characters are valid */
}
char *ast_escape_quoted(const char *string, char *outbuf, int buflen)
{
const char *ptr = string;