Merge branch 'signalwire:master' into master

This commit is contained in:
谭映宇 2023-07-25 16:26:26 +08:00 committed by GitHub
commit ab6b1c77d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 274 additions and 39 deletions

View File

@ -1352,7 +1352,21 @@ PKG_CHECK_MODULES([MPG123], [libmpg123 >= 1.16.0],[
AC_MSG_RESULT([no]); AM_CONDITIONAL([HAVE_MPG123],[false])])
PKG_CHECK_MODULES([SHOUT], [shout >= 2.2.2],[
AM_CONDITIONAL([HAVE_SHOUT],[true])],[
AM_CONDITIONAL([HAVE_SHOUT],[true])
SHOUT_VERSION="`$PKG_CONFIG --modversion shout`"
SHOUT_MAJOR_VERSION="`echo $SHOUT_VERSION | cut -d. -f1`"
SHOUT_MINOR_VERSION="`echo $SHOUT_VERSION | cut -d. -f2`"
SHOUT_PATCH_VERSION="`echo $SHOUT_VERSION | cut -d. -f3`"
test -n "$SHOUT_PATCH_VERSION" || SHOUT_PATCH_VERSION=0
AC_MSG_NOTICE([SHOUT version: $SHOUT_VERSION])
AC_MSG_NOTICE([SHOUT major version: $SHOUT_MAJOR_VERSION])
AC_MSG_NOTICE([SHOUT minor version: $SHOUT_MINOR_VERSION])
AC_MSG_NOTICE([SHOUT patch version: $SHOUT_PATCH_VERSION])
AC_SUBST([SHOUT_VERSION])
AC_SUBST([SHOUT_MAJOR_VERSION])
AC_SUBST([SHOUT_MINOR_VERSION])
AC_SUBST([SHOUT_PATCH_VERSION])
],[
AC_MSG_RESULT([no]); AM_CONDITIONAL([HAVE_SHOUT],[false])])
mp3lame=false

View File

@ -40,6 +40,9 @@ typedef int switch_CURLINFO;
typedef int switch_CURLcode;
typedef int switch_CURLoption;
#define HAVE_SWITCH_CURL_MIME
typedef void switch_curl_mime;
SWITCH_DECLARE(switch_CURL *) switch_curl_easy_init(void);
SWITCH_DECLARE(switch_CURLcode) switch_curl_easy_perform(switch_CURL *handle);
SWITCH_DECLARE(switch_CURLcode) switch_curl_easy_getinfo(switch_CURL *curl, switch_CURLINFO info, ... );
@ -50,7 +53,9 @@ SWITCH_DECLARE(switch_CURLcode) switch_curl_easy_setopt(CURL *handle, switch_CUR
SWITCH_DECLARE(const char *) switch_curl_easy_strerror(switch_CURLcode errornum );
SWITCH_DECLARE(void) switch_curl_init(void);
SWITCH_DECLARE(void) switch_curl_destroy(void);
SWITCH_DECLARE(switch_status_t) switch_curl_process_form_post_params(switch_event_t *event, switch_CURL *curl_handle, struct curl_httppost **formpostp);
SWITCH_DECLARE(switch_status_t) switch_curl_process_mime(switch_event_t *event, switch_CURL *curl_handle, switch_curl_mime **mimep);
SWITCH_DECLARE(void) switch_curl_mime_free(switch_curl_mime **mimep);
SWITCH_DECLARE(switch_CURLcode) switch_curl_easy_setopt_mime(switch_CURL *curl_handle, switch_curl_mime *mime);
#define switch_curl_easy_setopt curl_easy_setopt
SWITCH_END_EXTERN_C

View File

@ -255,7 +255,7 @@ fctstr_safe_cpy(char *dst, char const *src, size_t num)
#if defined(WIN32) && _MSC_VER >= 1400
strncpy_s(dst, num, src, _TRUNCATE);
#else
strncpy(dst, src, num);
strncpy(dst, src, num - 1);
#endif
dst[num-1] = '\0';
}
@ -760,6 +760,7 @@ fct_nlist__init2(fct_nlist_t *list, size_t start_sz)
list->itm_list = (void**)malloc(sizeof(void*)*start_sz);
if ( list->itm_list == NULL )
{
list->used_itm_num = 0;
return 0;
}
}

View File

@ -347,7 +347,7 @@ static size_t file_callback(void *ptr, size_t size, size_t nmemb, void *data)
return realsize;
}
static long do_lookup_url(switch_memory_pool_t *pool, switch_event_t *event, char **response, const char *query, struct curl_httppost *post,
static long do_lookup_url(switch_memory_pool_t *pool, switch_event_t *event, char **response, const char *query, switch_curl_mime *post,
switch_curl_slist_t *headers, int timeout)
{
switch_time_t start_time = switch_micro_time_now();
@ -373,7 +373,7 @@ static long do_lookup_url(switch_memory_pool_t *pool, switch_event_t *event, cha
switch_curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0);
}
if (post) {
switch_curl_easy_setopt(curl_handle, CURLOPT_HTTPPOST, post);
switch_curl_easy_setopt_mime(curl_handle, post);
} else {
switch_curl_easy_setopt(curl_handle, CURLOPT_HTTPGET, 1);
}

View File

@ -104,8 +104,13 @@ struct http_sendfile_data_obj {
char *extrapost_elements;
switch_CURL *curl_handle;
char *cacert;
#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800)
curl_mime *mime;
curl_mimepart *part;
#else
struct curl_httppost *formpost;
struct curl_httppost *lastptr;
#endif
uint8_t flags; /* This is for where to send output of the curl_sendfile commands */
switch_stream_handle_t *stream;
char *sendfile_response;
@ -456,8 +461,19 @@ static void http_sendfile_initialize_curl(http_sendfile_data_t *http_data)
curl_easy_setopt(http_data->curl_handle, CURLOPT_WRITEFUNCTION, http_sendfile_response_callback);
curl_easy_setopt(http_data->curl_handle, CURLOPT_WRITEDATA, (void *) http_data);
/* Initial http_data->mime */
#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800)
http_data->mime = curl_mime_init(http_data->curl_handle);
#endif
/* Add the file to upload as a POST form field */
#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800)
http_data->part = curl_mime_addpart(http_data->mime);
curl_mime_name(http_data->part, http_data->filename_element_name);
curl_mime_filedata(http_data->part, http_data->filename_element);
#else
curl_formadd(&http_data->formpost, &http_data->lastptr, CURLFORM_COPYNAME, http_data->filename_element_name, CURLFORM_FILE, http_data->filename_element, CURLFORM_END);
#endif
if(!zstr(http_data->extrapost_elements))
{
@ -476,16 +492,32 @@ static void http_sendfile_initialize_curl(http_sendfile_data_t *http_data)
if(argc2 == 2) {
switch_url_decode(argv2[0]);
switch_url_decode(argv2[1]);
#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800)
http_data->part = curl_mime_addpart(http_data->mime);
curl_mime_name(http_data->part, argv2[0]);
curl_mime_data(http_data->part, argv2[1], CURL_ZERO_TERMINATED);
#else
curl_formadd(&http_data->formpost, &http_data->lastptr, CURLFORM_COPYNAME, argv2[0], CURLFORM_COPYCONTENTS, argv2[1], CURLFORM_END);
#endif
}
}
}
/* Fill in the submit field too, even if this isn't really needed */
#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800)
http_data->part = curl_mime_addpart(http_data->mime);
curl_mime_name(http_data->part, "submit");
curl_mime_data(http_data->part, "or_die", CURL_ZERO_TERMINATED);
#else
curl_formadd(&http_data->formpost, &http_data->lastptr, CURLFORM_COPYNAME, "submit", CURLFORM_COPYCONTENTS, "or_die", CURLFORM_END);
#endif
/* what URL that receives this POST */
#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800)
curl_easy_setopt(http_data->curl_handle, CURLOPT_MIMEPOST, http_data->mime);
#else
curl_easy_setopt(http_data->curl_handle, CURLOPT_HTTPPOST, http_data->formpost);
#endif
// This part actually fires off the curl, captures the HTTP response code, and then frees up the handle.
curl_easy_perform(http_data->curl_handle);
@ -494,7 +526,11 @@ static void http_sendfile_initialize_curl(http_sendfile_data_t *http_data)
curl_easy_cleanup(http_data->curl_handle);
// Clean up the form data from POST
#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800)
curl_mime_free(http_data->mime);
#else
curl_formfree(http_data->formpost);
#endif
}
static switch_status_t http_sendfile_test_file_open(http_sendfile_data_t *http_data, switch_event_t *event)

View File

@ -1419,7 +1419,7 @@ static switch_status_t httapi_sync(client_t *client)
switch_status_t status = SWITCH_STATUS_FALSE;
int get_style_method = 0;
char *method = NULL;
struct curl_httppost *formpost=NULL;
switch_curl_mime *formpost = NULL;
switch_event_t *save_params = NULL;
const char *put_file;
FILE *fd = NULL;
@ -1476,7 +1476,7 @@ static switch_status_t httapi_sync(client_t *client)
}
if (!put_file) {
switch_curl_process_form_post_params(client->params, curl_handle, &formpost);
switch_curl_process_mime(client->params, curl_handle, &formpost);
}
if (formpost) {
@ -1588,7 +1588,7 @@ static switch_status_t httapi_sync(client_t *client)
curl_easy_setopt(curl_handle, CURLOPT_READFUNCTION, put_file_read);
} else if (formpost) {
curl_easy_setopt(curl_handle, CURLOPT_HTTPPOST, formpost);
switch_curl_easy_setopt_mime(curl_handle, formpost);
} else {
switch_curl_easy_setopt(curl_handle, CURLOPT_POST, !get_style_method);
}
@ -1670,9 +1670,7 @@ static switch_status_t httapi_sync(client_t *client)
switch_curl_easy_cleanup(curl_handle);
switch_curl_slist_free_all(headers);
if (formpost) {
curl_formfree(formpost);
}
switch_curl_mime_free(&formpost);
if (client->err) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error encountered! [%s]\ndata: [%s]\n", client->profile->url, data);

View File

@ -279,7 +279,11 @@ switch_status_t azure_blob_finalise_put(http_profile_t *profile, const char *url
goto done;
}
#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x070c01)
switch_curl_easy_setopt(curl_handle, CURLOPT_UPLOAD, 1);
#else
switch_curl_easy_setopt(curl_handle, CURLOPT_PUT, 1);
#endif
switch_curl_easy_setopt(curl_handle, CURLOPT_NOSIGNAL, 1);
switch_curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, headers);
switch_curl_easy_setopt(curl_handle, CURLOPT_URL, full_url);

View File

@ -393,7 +393,9 @@ static switch_status_t http_put(url_cache_t *cache, http_profile_t *profile, swi
goto done;
}
switch_curl_easy_setopt(curl_handle, CURLOPT_UPLOAD, 1);
#if !defined(LIBCURL_VERSION_NUM) || (LIBCURL_VERSION_NUM < 0x070c01)
switch_curl_easy_setopt(curl_handle, CURLOPT_PUT, 1);
#endif
switch_curl_easy_setopt(curl_handle, CURLOPT_NOSIGNAL, 1);
switch_curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, headers);
switch_curl_easy_setopt(curl_handle, CURLOPT_URL, full_url);

View File

@ -48,7 +48,7 @@ static switch_status_t switch_ilbc_fmtp_parse(const char *fmtp, switch_codec_fmt
memset(codec_fmtp, '\0', sizeof(struct switch_codec_fmtp));
if (fmtp && (mode = strstr(fmtp, "mode=")) && (mode + 5)) {
if (fmtp && (mode = strstr(fmtp, "mode=")) && *(mode + 5)) {
codec_ms = atoi(mode + 5);
}
if (!codec_ms) {

View File

@ -411,7 +411,7 @@ switch_status_t mariadb_finish_results_real(const char* file, const char* func,
if ((status = mysql_next_result(&handle->con))) {
if (status > 0) {
err_str = mariadb_handle_get_error(handle);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "An error occurred trying to get next for query (%s): %s\n", handle->sql, err_str);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "An error occurred trying to get next for query (%s): %s\n", handle->sql, switch_str_nil(err_str));
switch_safe_free(err_str);
break;

View File

@ -42,6 +42,7 @@
#if OPENSSL_VERSION_NUMBER < 0x0090800 || !defined(SHA256_DIGEST_LENGTH)
#error Your OpenSSL is too old, need 0.9.8 or newer with SHA256
#endif
#if OPENSSL_VERSION_NUMBER < 0x30000000L
#if OPENSSL_VERSION_NUMBER < 0x10100000L
#define HMAC_setup(ctx, key, len) HMAC_CTX_init(&ctx); HMAC_Init_ex(&ctx, key, len, EVP_sha256(), 0)
#define HMAC_crunch(ctx, buf, len) HMAC_Update(&ctx, buf, len)
@ -51,6 +52,7 @@
#define HMAC_crunch(ctx, buf, len)HMAC_Update(ctx, buf, len)
#define HMAC_finish(ctx, dig, dlen) HMAC_Final(ctx, dig, &dlen); HMAC_CTX_free(ctx)
#endif
#endif
#define FP10
#define RTMP_SIG_SIZE 1536
@ -155,9 +157,13 @@ static unsigned int GetDigestOffset1(uint8_t *handshake, unsigned int len)
static getoff *digoff[] = {GetDigestOffset1, GetDigestOffset2};
// static getoff *dhoff[] = {GetDHOffset1, GetDHOffset2};
static void HMACsha256(const uint8_t *message, size_t messageLen, const uint8_t *key, size_t keylen, uint8_t *digest)
static void HMACsha256(const uint8_t *message, size_t messageLen, const uint8_t *key, int keylen, uint8_t *digest)
{
unsigned int digestLen;
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
HMAC(EVP_sha256(), key, keylen, (uint8_t *)message, messageLen, digest, &digestLen);
#else
#if OPENSSL_VERSION_NUMBER < 0x10100000L
HMAC_CTX ctx;
#else
@ -167,11 +173,12 @@ static void HMACsha256(const uint8_t *message, size_t messageLen, const uint8_t
HMAC_setup(ctx, key, (int)keylen);
HMAC_crunch(ctx, message, messageLen);
HMAC_finish(ctx, digest, digestLen);
#endif
assert(digestLen == 32);
}
static void CalculateDigest(unsigned int digestPos, uint8_t *handshakeMessage, const uint8_t *key, size_t keyLen, uint8_t *digest)
static void CalculateDigest(unsigned int digestPos, uint8_t *handshakeMessage, const uint8_t *key, int keyLen, uint8_t *digest)
{
const int messageLen = RTMP_SIG_SIZE - SHA256_DIGEST_LENGTH;
uint8_t message[RTMP_SIG_SIZE - SHA256_DIGEST_LENGTH];
@ -184,7 +191,7 @@ static void CalculateDigest(unsigned int digestPos, uint8_t *handshakeMessage, c
HMACsha256(message, messageLen, key, keyLen, digest);
}
static int VerifyDigest(unsigned int digestPos, uint8_t *handshakeMessage, const uint8_t *key, size_t keyLen)
static int VerifyDigest(unsigned int digestPos, uint8_t *handshakeMessage, const uint8_t *key, int keyLen)
{
uint8_t calcDigest[SHA256_DIGEST_LENGTH];

View File

@ -92,14 +92,14 @@ char* skinny_codec2string(skinny_codecs skinnycodec);
/*****************************************************************************/
#define skinny_create_message(message,msgtype,field) \
message = calloc(1, 12 + sizeof(message->data.field)); \
message = calloc(1, sizeof(skinny_message_t)); \
message->type = msgtype; \
message->length = 4 + sizeof(message->data.field)
#define skinny_create_empty_message(message,msgtype) \
message = calloc(1, 12); \
message->type = msgtype; \
message->length = 4
message = calloc(1, sizeof(skinny_empty_message_t)); \
((skinny_empty_message_t *)message)->type = msgtype; \
((skinny_empty_message_t *)message)->length = 4
/* KeepAliveMessage */
@ -937,6 +937,12 @@ union skinny_data {
#pragma pack(push, r1, 1)
#endif
struct PACKED skinny_empty_message {
uint32_t length;
uint32_t version;
uint32_t type;
};
/*
* header is length+version
* body is type+data
@ -954,6 +960,7 @@ struct PACKED skinny_message {
#endif
typedef struct skinny_message skinny_message_t;
typedef struct skinny_empty_message skinny_empty_message_t;

View File

@ -366,7 +366,9 @@ SWITCH_STANDARD_API(kz_http_put)
goto done;
}
switch_curl_easy_setopt(curl_handle, CURLOPT_UPLOAD, 1);
#if !defined(LIBCURL_VERSION_NUM) || (LIBCURL_VERSION_NUM < 0x070c01)
switch_curl_easy_setopt(curl_handle, CURLOPT_PUT, 1);
#endif
switch_curl_easy_setopt(curl_handle, CURLOPT_NOSIGNAL, 1);
switch_curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, headers);
switch_curl_easy_setopt(curl_handle, CURLOPT_URL, url);

View File

@ -7,8 +7,8 @@ if HAVE_MP3LAME
mod_LTLIBRARIES = mod_shout.la
mod_shout_la_SOURCES = mod_shout.c
mod_shout_la_CFLAGS = $(AM_CFLAGS)
mod_shout_la_CPPFLAGS = $(CURL_CFLAGS) $(AM_CPPFLAGS) $(SHOUT_CFLAGS) $(MP3LAME_CFLAGS) $(MPG123_CFLAGS)
mod_shout_la_CFLAGS = $(AM_CFLAGS) -DSHOUT_VERSION=$(SHOUT_VERSION) -DSHOUT_MAJOR_VERSION=$(SHOUT_MAJOR_VERSION) -DSHOUT_MINOR_VERSION=$(SHOUT_MINOR_VERSION) -DSHOUT_PATCH_VERSION=$(SHOUT_PATCH_VERSION)
mod_shout_la_CPPFLAGS = $(CURL_CFLAGS) $(AM_CPPFLAGS) $(SHOUT_CFLAGS) $(MP3LAME_CFLAGS) $(MPG123_CFLAGS) -DSHOUT_VERSION=$(SHOUT_VERSION) -DSHOUT_MAJOR_VERSION=$(SHOUT_MAJOR_VERSION) -DSHOUT_MINOR_VERSION=$(SHOUT_MINOR_VERSION) -DSHOUT_PATCH_VERSION=$(SHOUT_PATCH_VERSION)
mod_shout_la_LIBADD = $(switch_builddir)/libfreeswitch.la
mod_shout_la_LDFLAGS = $(CURL_LIBS) -avoid-version -module -no-undefined -shared $(SHOUT_LIBS) $(MP3LAME_LIBS) $(MPG123_LIBS)

View File

@ -51,6 +51,11 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_shout_load);
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_shout_shutdown);
SWITCH_MODULE_DEFINITION(mod_shout, mod_shout_load, mod_shout_shutdown, NULL);
#define CHECK_SHOUT_MIN_VERSION(major, minor, patch) \
(SHOUT_MAJOR_VERSION > major || \
(SHOUT_MAJOR_VERSION == major && SHOUT_MINOR_VERSION > minor) || \
(SHOUT_MAJOR_VERSION == major && SHOUT_MINOR_VERSION == minor && SHOUT_PATCH_VERSION >= patch))
static char *supported_formats[SWITCH_MAX_CODECS] = { 0 };
static struct {
@ -463,7 +468,11 @@ static size_t stream_callback(void *ptr, size_t size, size_t nmemb, void *data)
return 0;
}
#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x072000)
static int progress_callback(void *clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow)
#else
static int progress_callback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow)
#endif
{
shout_context_t *context = (shout_context_t *) clientp;
return context->err;
@ -496,8 +505,13 @@ static void *SWITCH_THREAD_FUNC read_stream_thread(switch_thread_t *thread, void
switch_mutex_unlock(context->audio_mutex);
curl_handle = switch_curl_easy_init();
switch_curl_easy_setopt(curl_handle, CURLOPT_URL, context->stream_url);
#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x072000)
curl_easy_setopt(curl_handle, CURLOPT_XFERINFOFUNCTION, progress_callback);
curl_easy_setopt(curl_handle, CURLOPT_XFERINFODATA, (void *)context);
#else
curl_easy_setopt(curl_handle, CURLOPT_PROGRESSFUNCTION, progress_callback);
curl_easy_setopt(curl_handle, CURLOPT_PROGRESSDATA, (void *)context);
#endif
switch_curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1);
switch_curl_easy_setopt(curl_handle, CURLOPT_MAXREDIRS, 10);
switch_curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, stream_callback);
@ -862,12 +876,20 @@ static switch_status_t shout_file_open(switch_file_handle_t *handle, const char
goto error;
}
#if (CHECK_SHOUT_MIN_VERSION(2, 4, 6))
if (shout_set_meta(context->shout, SHOUT_META_URL, "http://www.freeswitch.org") != SHOUTERR_SUCCESS) {
#else
if (shout_set_url(context->shout, "http://www.freeswitch.org") != SHOUTERR_SUCCESS) {
#endif
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting name: %s\n", shout_get_error(context->shout));
goto error;
}
#if (CHECK_SHOUT_MIN_VERSION(2, 4, 6))
if (shout_set_meta(context->shout, SHOUT_META_DESCRIPTION, "FreeSWITCH mod_shout Broadcasting Module") != SHOUTERR_SUCCESS) {
#else
if (shout_set_description(context->shout, "FreeSWITCH mod_shout Broadcasting Module") != SHOUTERR_SUCCESS) {
#endif
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting description: %s\n", shout_get_error(context->shout));
goto error;
}
@ -877,7 +899,11 @@ static switch_status_t shout_file_open(switch_file_handle_t *handle, const char
goto error;
}
#if (CHECK_SHOUT_MIN_VERSION(2, 4, 6))
if (shout_set_content_format(context->shout, SHOUT_FORMAT_MP3, SHOUT_USAGE_AUDIO, NULL) != SHOUTERR_SUCCESS) {
#else
if (shout_set_format(context->shout, SHOUT_FORMAT_MP3) != SHOUTERR_SUCCESS) {
#endif
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting format: %s\n", shout_get_error(context->shout));
goto error;
}
@ -1127,21 +1153,33 @@ static switch_status_t shout_file_set_string(switch_file_handle_t *handle, switc
switch (col) {
case SWITCH_AUDIO_COL_STR_TITLE:
#if (CHECK_SHOUT_MIN_VERSION(2, 4, 6))
if (shout_set_meta(context->shout, SHOUT_META_NAME, string) == SHOUTERR_SUCCESS) {
#else
if (shout_set_name(context->shout, string) == SHOUTERR_SUCCESS) {
#endif
status = SWITCH_STATUS_SUCCESS;
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting name: %s\n", shout_get_error(context->shout));
}
break;
case SWITCH_AUDIO_COL_STR_COMMENT:
#if (CHECK_SHOUT_MIN_VERSION(2, 4, 6))
if (shout_set_meta(context->shout, SHOUT_META_URL, string) == SHOUTERR_SUCCESS) {
#else
if (shout_set_url(context->shout, string) == SHOUTERR_SUCCESS) {
#endif
status = SWITCH_STATUS_SUCCESS;
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting name: %s\n", shout_get_error(context->shout));
}
break;
case SWITCH_AUDIO_COL_STR_ARTIST:
#if (CHECK_SHOUT_MIN_VERSION(2, 4, 6))
if (shout_set_meta(context->shout, SHOUT_META_DESCRIPTION, string) == SHOUTERR_SUCCESS) {
#else
if (shout_set_description(context->shout, string) == SHOUTERR_SUCCESS) {
#endif
status = SWITCH_STATUS_SUCCESS;
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting name: %s\n", shout_get_error(context->shout));

View File

@ -74,7 +74,16 @@
#if (defined(HAVE_LIBMD5) || defined(HAVE_LIBMD) || defined(HAVE_MD5INIT))
#include <md5.h>
#elif defined(HAVE_LIBCRYPTO)
#include <openssl/md5.h>
#ifndef OPENSSL_VERSION_NUMBER
#include <openssl/opensslv.h>
#endif
#if OPENSSL_VERSION_NUMBER < 0x30000000
#include <openssl/md5.h>
#else
#include <openssl/evp.h>
#endif
#else
#include <apr_md5.h>
#endif
#ifndef WIN32
@ -1174,11 +1183,24 @@ SWITCH_DECLARE(switch_status_t) switch_md5(unsigned char digest[SWITCH_MD5_DIGES
return SWITCH_STATUS_SUCCESS;
#elif defined(HAVE_LIBCRYPTO)
MD5_CTX md5_context;
#if OPENSSL_VERSION_NUMBER < 0x30000000
MD5_CTX md5_context;
MD5_Init(&md5_context);
MD5_Update(&md5_context, input, inputLen);
MD5_Final(digest, &md5_context);
MD5_Init(&md5_context);
MD5_Update(&md5_context, input, inputLen);
MD5_Final(digest, &md5_context);
#else
EVP_MD_CTX *md5_context;
/* MD5_Init */
md5_context = EVP_MD_CTX_new();
EVP_DigestInit_ex(md5_context, EVP_md5(), NULL);
/* MD5_Update */
EVP_DigestUpdate(md5_context, input, inputLen);
/* MD5_Final */
EVP_DigestFinal_ex(md5_context, digest, NULL);
EVP_MD_CTX_free(md5_context);
#endif
return SWITCH_STATUS_SUCCESS;
#else

View File

@ -287,7 +287,10 @@ SWITCH_DECLARE(int) switch_core_gen_certs(const char *prefix)
//bio_err=BIO_new_fp(stderr, BIO_NOCLOSE);
mkcert(&x509, &pkey, 4096, 0, 36500);
if (!mkcert(&x509, &pkey, 4096, 0, 36500)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Certificate generation failed\n");
goto end;
}
//RSA_print_fp(stdout, pkey->pkey.rsa, 0);
//X509_print_fp(stdout, x509);
@ -410,7 +413,9 @@ static int mkcert(X509 **x509p, EVP_PKEY **pkeyp, int bits, int serial, int days
{
X509 *x;
EVP_PKEY *pk;
#if OPENSSL_VERSION_NUMBER < 0x30000000
RSA *rsa;
#endif
X509_NAME *name=NULL;
switch_assert(pkeyp);
@ -432,7 +437,26 @@ static int mkcert(X509 **x509p, EVP_PKEY **pkeyp, int bits, int serial, int days
x = *x509p;
}
#if OPENSSL_VERSION_NUMBER >= 0x10100000
#if OPENSSL_VERSION_NUMBER >= 0x30000000
{
EVP_PKEY_CTX *ctx;
ctx = EVP_PKEY_CTX_new_id(EVP_PKEY_RSA, NULL);
/* Setup the key context */
if ((!ctx) || (EVP_PKEY_keygen_init(ctx) <= 0) || (EVP_PKEY_CTX_set_rsa_keygen_bits(ctx, bits) <= 0)) {
abort();
goto err;
}
/* Generate key */
if (EVP_PKEY_generate(ctx, &pk) <= 0) {
abort();
goto err;
}
EVP_PKEY_CTX_free(ctx);
}
#elif OPENSSL_VERSION_NUMBER >= 0x10100000
rsa = RSA_new();
{
static const BN_ULONG ULONG_RSA_F4 = RSA_F4;
@ -449,11 +473,13 @@ static int mkcert(X509 **x509p, EVP_PKEY **pkeyp, int bits, int serial, int days
rsa = RSA_generate_key(bits, RSA_F4, NULL, NULL);
#endif
#if OPENSSL_VERSION_NUMBER < 0x30000000
if (!EVP_PKEY_assign_RSA(pk, rsa)) {
abort();
}
rsa = NULL;
#endif
X509_set_version(x, 2);
ASN1_INTEGER_set(X509_get_serialNumber(x), serial);
@ -476,13 +502,21 @@ static int mkcert(X509 **x509p, EVP_PKEY **pkeyp, int bits, int serial, int days
*/
X509_set_issuer_name(x, name);
if (!X509_sign(x, pk, EVP_sha1()))
#if OPENSSL_VERSION_NUMBER >= 0x30000000
if (!X509_sign(x, pk, EVP_sha256())) {
#else
if (!X509_sign(x, pk, EVP_sha1())) {
#endif
goto err;
}
*x509p = x;
*pkeyp = pk;
return(1);
err:
err:
ERR_print_errors_fp(stdout);
return(0);
}

View File

@ -1170,7 +1170,7 @@ static uint32_t parse_lifetime_mki(const char **p, const char *end)
val += ((**p) - '0') * i;
}
res |= (val & 0x000000ff); /* MKI_SIZE */
} else if (isdigit(*(field_begin + 1)) && (field_begin + 2) && (*(field_begin + 2) == '^') && (field_begin + 3) && isdigit(*(field_begin + 3))) {
} else if (isdigit(*(field_begin + 1)) && (*(field_begin + 2) == '^') && isdigit(*(field_begin + 3))) {
res |= (CRYPTO_KEY_MATERIAL_LIFETIME << 24);
val = ((uint32_t) (*(field_begin + 1) - '0')) << 8;
res |= val; /* LIFETIME base. */

View File

@ -58,11 +58,16 @@ SWITCH_DECLARE(void) switch_curl_destroy(void)
curl_global_cleanup();
}
SWITCH_DECLARE(switch_status_t) switch_curl_process_form_post_params(switch_event_t *event, switch_CURL *curl_handle, struct curl_httppost **formpostp)
SWITCH_DECLARE(switch_status_t) switch_curl_process_mime(switch_event_t *event, switch_CURL *curl_handle, switch_curl_mime **mimep)
{
#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800)
curl_mime *mime = NULL;
curl_mimepart *part = NULL;
uint8_t added = 0;
#else
struct curl_httppost *formpost=NULL;
struct curl_httppost *lastptr=NULL;
#endif
switch_event_header_t *hp;
int go = 0;
@ -77,39 +82,87 @@ SWITCH_DECLARE(switch_status_t) switch_curl_process_form_post_params(switch_even
return SWITCH_STATUS_FALSE;
}
for (hp = event->headers; hp; hp = hp->next) {
#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800)
mime = curl_mime_init(curl_handle);
#endif
for (hp = event->headers; hp; hp = hp->next) {
if (!strncasecmp(hp->name, "attach_file:", 12)) {
char *pname = strdup(hp->name + 12);
if (pname) {
char *fname = strchr(pname, ':');
if (fname) {
*fname++ = '\0';
#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800)
part = curl_mime_addpart(mime);
curl_mime_name(part, pname);
curl_mime_filename(part, fname);
curl_mime_filedata(part, hp->value);
added++;
#else
curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, pname,
CURLFORM_FILENAME, fname,
CURLFORM_FILE, hp->value,
CURLFORM_END);
#endif
}
free(pname);
}
} else {
#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800)
part = curl_mime_addpart(mime);
curl_mime_name(part, hp->name);
curl_mime_data(part, hp->value, CURL_ZERO_TERMINATED);
added++;
#else
curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, hp->name,
CURLFORM_COPYCONTENTS, hp->value,
CURLFORM_END);
#endif
}
}
*formpostp = formpost;
#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800)
if (!added) {
curl_mime_free(mime);
mime = NULL;
}
*mimep = mime;
#else
*mimep = formpost;
#endif
return SWITCH_STATUS_SUCCESS;
}
SWITCH_DECLARE(void) switch_curl_mime_free(switch_curl_mime **mimep)
{
if (mimep && *mimep) {
#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800)
curl_mime_free(*mimep);
#else
curl_formfree(*mimep);
#endif
mimep = NULL;
}
}
SWITCH_DECLARE(switch_CURLcode) switch_curl_easy_setopt_mime(switch_CURL *curl_handle, switch_curl_mime *mime)
{
#if defined(LIBCURL_VERSION_NUM) && (LIBCURL_VERSION_NUM >= 0x073800)
return curl_easy_setopt(curl_handle, CURLOPT_MIMEPOST, mime);
#else
return curl_easy_setopt(curl_handle, CURLOPT_HTTPPOST, mime);
#endif
}
/* For Emacs:

View File

@ -3643,7 +3643,11 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_add_dtls(switch_rtp_t *rtp_session, d
const SSL_METHOD *ssl_method;
SSL_CTX *ssl_ctx;
BIO *bio;
#if OPENSSL_VERSION_NUMBER >= 0x30000000
EVP_PKEY *dh_pk;
#else
DH *dh;
#endif
switch_status_t status = SWITCH_STATUS_SUCCESS;
#ifndef OPENSSL_NO_EC
#if OPENSSL_VERSION_NUMBER < 0x10002000L
@ -3723,13 +3727,21 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_add_dtls(switch_rtp_t *rtp_session, d
switch_assert(dtls->ssl_ctx);
bio = BIO_new_file(dtls->pem, "r");
#if OPENSSL_VERSION_NUMBER < 0x30000000
dh = PEM_read_bio_DHparams(bio, NULL, NULL, NULL);
BIO_free(bio);
if (dh) {
SSL_CTX_set_tmp_dh(dtls->ssl_ctx, dh);
DH_free(dh);
}
#else
if((dh_pk = PEM_read_bio_PrivateKey(bio, NULL, NULL, NULL)) != NULL) {
SSL_CTX_set0_tmp_dh_pkey(dtls->ssl_ctx, dh_pk);
EVP_PKEY_free(dh_pk);
}
BIO_free(bio);
#endif
SSL_CTX_set_mode(dtls->ssl_ctx, SSL_MODE_AUTO_RETRY);
//SSL_CTX_set_verify(dtls->ssl_ctx, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, NULL);

View File

@ -2380,7 +2380,7 @@ SWITCH_DECLARE(int) switch_cmp_addr(switch_sockaddr_t *sa1, switch_sockaddr_t *s
return (s1->sin_addr.s_addr == s2->sin_addr.s_addr && s1->sin_port == s2->sin_port);
}
case AF_INET6:
if (s16->sin6_addr.s6_addr && s26->sin6_addr.s6_addr) {
{
int i;
if (!ip_only) {
@ -2434,7 +2434,7 @@ SWITCH_DECLARE(int) switch_cp_addr(switch_sockaddr_t *sa1, switch_sockaddr_t *sa
return 1;
case AF_INET6:
if (s16->sin6_addr.s6_addr && s26->sin6_addr.s6_addr) {
{
int i;
s16->sin6_port = s26->sin6_port;