mirror of
https://github.com/jambonz/jambonz-infrastructure.git
synced 2026-10-29 15:24:11 +00:00
add patch for mod_httapi to handle signed AWS URLs
This commit is contained in:
1 parent
a0e354278c
commit
44634e4242
6 files changed
+202
-13
No files matched your search
@@ -0,0 +1,73 @@
|
||||
<configuration name="avmd.conf" description="AVMD config">
|
||||
<settings>
|
||||
|
||||
<!-- Edit these settings to change default behaviour
|
||||
of each avmd session. Settings can be overwritten
|
||||
by values passed dynamically per each session -->
|
||||
|
||||
|
||||
<!-- Global settings -->
|
||||
|
||||
<!-- define/undefine this to enable/disable logging of avmd
|
||||
intermediate computations to log -->
|
||||
<param name="debug" value="0"/>
|
||||
|
||||
<!-- define/undef this to enable/disable verbose logging (and reporting to the console)
|
||||
of detection status and other diagnostics like parameters avmd session has been started with,
|
||||
change of configuration parameters, beep detection status after session ended
|
||||
(stop event is fired independently of this setting and beep status included there) -->
|
||||
<param name="report_status" value="1"/>
|
||||
|
||||
<!-- define/undefine this to enable/disable faster computation
|
||||
of arcus cosine - table will be created mapping floats
|
||||
to integers and returning arc cos values given these integer
|
||||
indices into table -->
|
||||
<param name="fast_math" value="0"/>
|
||||
<!-- Global settings end -->
|
||||
|
||||
|
||||
<!-- Per call (session) settings. These settings can be overwritten
|
||||
with custom/different values per each avmd session -->
|
||||
|
||||
<!-- define/undefine this to classify avmd beep detection as valid
|
||||
only when there is required number of consecutive elements
|
||||
in the SMA buffer without reset -->
|
||||
<param name="require_continuous_streak" value="1"/>
|
||||
|
||||
<!-- required number of consecutive elements in the SMA buffer
|
||||
without reset. This parameter helps to avoid false beeps, bigger this value is
|
||||
smaller the probability of getting false detection -->
|
||||
<param name="sample_n_continuous_streak" value="3"/>
|
||||
|
||||
<!-- define number of samples to skip starting from the beginning
|
||||
of the frame and/or after reset has happened. This serves the purpose of skipping first few
|
||||
estimations on each frame, as these estimations may be inaccurate. This parameter also helps
|
||||
to give more robust detections when it's value is increased (up to scertain limit of about 60). -->
|
||||
<param name="sample_n_to_skip" value="0"/>
|
||||
|
||||
<param name="require_continuous_streak_amp" value="1"/>
|
||||
<param name="sample_n_continuous_streak_amp" value="3"/>
|
||||
|
||||
<!-- define/undefine this to enable/disable simplified estimation
|
||||
of frequency based on approximation of sin(x) with (x)
|
||||
in the range x=[0,PI/2] -->
|
||||
<param name="simplified_estimation" value="1"/>
|
||||
|
||||
<!-- define/undefine to enable/disable avmd on internal channel -->
|
||||
<param name="inbound_channel" value="1"/>
|
||||
|
||||
<!-- define/undefine to enable/disable avmd on external channel -->
|
||||
<param name="outbound_channel" value="0"/>
|
||||
|
||||
<!-- determines the mode of detection, default is both amplitude and frequency -->
|
||||
<param name="detection_mode" value="2"/>
|
||||
|
||||
<!-- number of detection threads running per each avmd session -->
|
||||
<param name="detectors_n" value="36"/>
|
||||
|
||||
<!-- number of lagged detection threads running per each avmd session -->
|
||||
<param name="detectors_lagged_n" value="1"/>
|
||||
|
||||
<!-- Per call settings end -->
|
||||
</settings>
|
||||
</configuration>
|
||||
@@ -0,0 +1,55 @@
|
||||
--- mod_httapi.c 2023-03-01 13:57:28
|
||||
+++ mod_httapi.c.new 2023-03-01 14:19:34
|
||||
@@ -2472,6 +2472,12 @@
|
||||
char *ua = NULL;
|
||||
const char *profile_name = NULL;
|
||||
int tries = 10;
|
||||
+ int awsSignedUrl = strstr(url, "X-Amz-Signature") != NULL &&
|
||||
+ strstr(url, "X-Amz-Algorithm") != NULL &&
|
||||
+ strstr(url, "X-Amz-Credential") != NULL &&
|
||||
+ strstr(url, "X-Amz-Date") != NULL &&
|
||||
+ strstr(url, "X-Amz-Expires") != NULL &&
|
||||
+ strstr(url, "X-Amz-SignedHeaders") != NULL;
|
||||
|
||||
if (context->url_params) {
|
||||
profile_name = switch_event_get_header(context->url_params, "profile_name");
|
||||
@@ -2614,7 +2620,7 @@
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *) client);
|
||||
} else {
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_HEADER, 1);
|
||||
- switch_curl_easy_setopt(curl_handle, CURLOPT_NOBODY, 1);
|
||||
+ if (!awsSignedUrl) switch_curl_easy_setopt(curl_handle, CURLOPT_NOBODY, 1);
|
||||
}
|
||||
|
||||
if (headers) {
|
||||
@@ -2783,6 +2789,12 @@
|
||||
char *metadata;
|
||||
const char *ext = NULL;
|
||||
const char *err_msg = NULL;
|
||||
+ int awsSignedUrl = strstr(url, "X-Amz-Signature") != NULL &&
|
||||
+ strstr(url, "X-Amz-Algorithm") != NULL &&
|
||||
+ strstr(url, "X-Amz-Credential") != NULL &&
|
||||
+ strstr(url, "X-Amz-Date") != NULL &&
|
||||
+ strstr(url, "X-Amz-Expires") != NULL &&
|
||||
+ strstr(url, "X-Amz-SignedHeaders") != NULL;
|
||||
|
||||
load_cache_data(context, url);
|
||||
|
||||
@@ -2831,7 +2843,7 @@
|
||||
|
||||
if (!unreachable && !zstr(context->metadata)) {
|
||||
metadata = switch_core_sprintf(context->pool, "%s:%s:%s:%s:%s",
|
||||
- url,
|
||||
+ awsSignedUrl ? context->cache_file : url,
|
||||
switch_event_get_header_nil(headers, "last-modified"),
|
||||
switch_event_get_header_nil(headers, "etag"),
|
||||
switch_event_get_header_nil(headers, "content-length"),
|
||||
@@ -2855,7 +2867,7 @@
|
||||
|
||||
|
||||
metadata = switch_core_sprintf(context->pool, "%s:%s:%s:%s:%s",
|
||||
- url,
|
||||
+ awsSignedUrl ? context->cache_file : url,
|
||||
switch_event_get_header_nil(headers, "last-modified"),
|
||||
switch_event_get_header_nil(headers, "etag"),
|
||||
switch_event_get_header_nil(headers, "content-length"),
|
||||
@@ -74,7 +74,7 @@ sudo cp -r /usr/local/src/drachtio-freeswitch-modules/modules/mod_dialogflow /us
|
||||
sudo sed -i -r -e 's/(.*AM_CFLAGS\))/\1 -g -O0/g' /usr/local/src/freeswitch/src/mod/applications/mod_audio_fork/Makefile.am
|
||||
sudo sed -i -r -e 's/(.*-std=c++11)/\1 -g -O0/g' /usr/local/src/freeswitch/src/mod/applications/mod_audio_fork/Makefile.am
|
||||
|
||||
# copy Makefiles into place
|
||||
# copy Makefiles and patches into place
|
||||
cp /tmp/configure.ac.extra /usr/local/src/freeswitch/configure.ac
|
||||
cp /tmp/Makefile.am.extra /usr/local/src/freeswitch/Makefile.am
|
||||
cp /tmp/modules.conf.in.extra /usr/local/src/freeswitch/build/modules.conf.in
|
||||
@@ -83,13 +83,16 @@ cp /tmp/avmd.conf.xml /usr/local/src/freeswitch/conf/vanilla/autoload_configs/av
|
||||
cp /tmp/switch_rtp.c.patch /usr/local/src/freeswitch/src
|
||||
cp /tmp/switch_core_media.c.patch /usr/local/src/freeswitch/src
|
||||
cp /tmp/mod_avmd.c.patch /usr/local/src/freeswitch/src/mod/applications/mod_avmd
|
||||
cp /tmp/mod_httapi.c.patch /usr/local/src/freeswitch/src/mod/applications/mod_httapi
|
||||
|
||||
# patch freeswitch
|
||||
cd /usr/local/src/freeswitch/src
|
||||
patch < switch_rtp.c.patch
|
||||
patch < switch_core_media.c.patch
|
||||
cd mod/applications/mod_avmd
|
||||
cd /usr/local/src/freeswitch/src/mod/applications/mod_avmd
|
||||
patch < mod_avmd.c.patch
|
||||
cd /usr/local/src/freeswitch/src/mod/applications/mod_httapi
|
||||
patch < mod_httapi.c.patch
|
||||
|
||||
# build libwebsockets
|
||||
cd /usr/local/src/libwebsockets
|
||||
|
||||
@@ -80,6 +80,15 @@
|
||||
"type": "shell",
|
||||
"script": "scripts/install_os_tuning.sh"
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"environment_vars": [
|
||||
"ARCH={{user `ami_base_image_arch`}}",
|
||||
"MEDIA_SERVER_NAME={{user `mediaserver_name`}}",
|
||||
"PREFERRED_CODEC_LIST={{user `preferred_codec_list`}}"
|
||||
],
|
||||
"script": "scripts/install_freeswitch.sh"
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"script": "scripts/install_nodejs.sh"
|
||||
@@ -98,15 +107,6 @@
|
||||
"execute_command": "chmod +x {{ .Path }}; sudo '{{ .Path }}' {{user `install_telegraf`}}",
|
||||
"script": "scripts/install_telegraf.sh"
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"environment_vars": [
|
||||
"ARCH={{user `ami_base_image_arch`}}",
|
||||
"MEDIA_SERVER_NAME={{user `mediaserver_name`}}",
|
||||
"PREFERRED_CODEC_LIST={{user `preferred_codec_list`}}"
|
||||
],
|
||||
"script": "scripts/install_freeswitch.sh"
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"execute_command": "chmod +x {{ .Path }}; sudo '{{ .Path }}' {{user `drachtio_version`}}",
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
--- mod_httapi.c 2023-03-01 13:57:28
|
||||
+++ mod_httapi.c.new 2023-03-01 14:19:34
|
||||
@@ -2472,6 +2472,12 @@
|
||||
char *ua = NULL;
|
||||
const char *profile_name = NULL;
|
||||
int tries = 10;
|
||||
+ int awsSignedUrl = strstr(url, "X-Amz-Signature") != NULL &&
|
||||
+ strstr(url, "X-Amz-Algorithm") != NULL &&
|
||||
+ strstr(url, "X-Amz-Credential") != NULL &&
|
||||
+ strstr(url, "X-Amz-Date") != NULL &&
|
||||
+ strstr(url, "X-Amz-Expires") != NULL &&
|
||||
+ strstr(url, "X-Amz-SignedHeaders") != NULL;
|
||||
|
||||
if (context->url_params) {
|
||||
profile_name = switch_event_get_header(context->url_params, "profile_name");
|
||||
@@ -2614,7 +2620,7 @@
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *) client);
|
||||
} else {
|
||||
switch_curl_easy_setopt(curl_handle, CURLOPT_HEADER, 1);
|
||||
- switch_curl_easy_setopt(curl_handle, CURLOPT_NOBODY, 1);
|
||||
+ if (!awsSignedUrl) switch_curl_easy_setopt(curl_handle, CURLOPT_NOBODY, 1);
|
||||
}
|
||||
|
||||
if (headers) {
|
||||
@@ -2783,6 +2789,12 @@
|
||||
char *metadata;
|
||||
const char *ext = NULL;
|
||||
const char *err_msg = NULL;
|
||||
+ int awsSignedUrl = strstr(url, "X-Amz-Signature") != NULL &&
|
||||
+ strstr(url, "X-Amz-Algorithm") != NULL &&
|
||||
+ strstr(url, "X-Amz-Credential") != NULL &&
|
||||
+ strstr(url, "X-Amz-Date") != NULL &&
|
||||
+ strstr(url, "X-Amz-Expires") != NULL &&
|
||||
+ strstr(url, "X-Amz-SignedHeaders") != NULL;
|
||||
|
||||
load_cache_data(context, url);
|
||||
|
||||
@@ -2831,7 +2843,7 @@
|
||||
|
||||
if (!unreachable && !zstr(context->metadata)) {
|
||||
metadata = switch_core_sprintf(context->pool, "%s:%s:%s:%s:%s",
|
||||
- url,
|
||||
+ awsSignedUrl ? context->cache_file : url,
|
||||
switch_event_get_header_nil(headers, "last-modified"),
|
||||
switch_event_get_header_nil(headers, "etag"),
|
||||
switch_event_get_header_nil(headers, "content-length"),
|
||||
@@ -2855,7 +2867,7 @@
|
||||
|
||||
|
||||
metadata = switch_core_sprintf(context->pool, "%s:%s:%s:%s:%s",
|
||||
- url,
|
||||
+ awsSignedUrl ? context->cache_file : url,
|
||||
switch_event_get_header_nil(headers, "last-modified"),
|
||||
switch_event_get_header_nil(headers, "etag"),
|
||||
switch_event_get_header_nil(headers, "content-length"),
|
||||
@@ -73,7 +73,7 @@ sudo cp -r /usr/local/src/drachtio-freeswitch-modules/modules/mod_dialogflow /us
|
||||
sudo sed -i -r -e 's/(.*AM_CFLAGS\))/\1 -g -O0/g' /usr/local/src/freeswitch/src/mod/applications/mod_audio_fork/Makefile.am
|
||||
sudo sed -i -r -e 's/(.*-std=c++11)/\1 -g -O0/g' /usr/local/src/freeswitch/src/mod/applications/mod_audio_fork/Makefile.am
|
||||
|
||||
# copy Makefiles into place
|
||||
# copy Makefiles and patches into place
|
||||
cp /tmp/configure.ac.extra /usr/local/src/freeswitch/configure.ac
|
||||
cp /tmp/Makefile.am.extra /usr/local/src/freeswitch/Makefile.am
|
||||
cp /tmp/modules.conf.in.extra /usr/local/src/freeswitch/build/modules.conf.in
|
||||
@@ -82,13 +82,16 @@ cp /tmp/avmd.conf.xml /usr/local/src/freeswitch/conf/vanilla/autoload_configs/av
|
||||
cp /tmp/switch_rtp.c.patch /usr/local/src/freeswitch/src
|
||||
cp /tmp/switch_core_media.c.patch /usr/local/src/freeswitch/src
|
||||
cp /tmp/mod_avmd.c.patch /usr/local/src/freeswitch/src/mod/applications/mod_avmd
|
||||
cp /tmp/mod_httapi.c.patch /usr/local/src/freeswitch/src/mod/applications/mod_httapi
|
||||
|
||||
# patch freeswitch
|
||||
cd /usr/local/src/freeswitch/src
|
||||
patch < switch_rtp.c.patch
|
||||
patch < switch_core_media.c.patch
|
||||
cd mod/applications/mod_avmd
|
||||
cd /usr/local/src/freeswitch/src/mod/applications/mod_avmd
|
||||
patch < mod_avmd.c.patch
|
||||
cd /usr/local/src/freeswitch/src/mod/applications/mod_httapi
|
||||
patch < mod_httapi.c.patch
|
||||
|
||||
# build libwebsockets
|
||||
cd /usr/local/src/libwebsockets
|
||||
|
||||
Reference in new issue
Block a user