提交 f506e19e authored 作者: Anthony Minessale's avatar Anthony Minessale

FS-3471 making this the new default and patching libdingaling to use it…

FS-3471 making this the new default and patching libdingaling to use it exclusively with openssl, now we actually have single thread for gtalk an no gah noodlez
上级 ead7a682
差异被折叠。
......@@ -50,7 +50,10 @@ AC_SEARCH_LIBS(recv,socket)
AC_CHECK_FUNCS(getopt_long)
AC_CHECK_FUNCS(getaddrinfo)
AX_PATH_LIBGNUTLS(,AC_DEFINE(HAVE_GNUTLS,,"Use libgnutls"))
#AX_PATH_LIBGNUTLS(,AC_DEFINE(HAVE_GNUTLS,,"Use libgnutls"))
m4_include([openssl.m4])
SAC_OPENSSL
dnl Check -Wall flag of GCC
if test "x$GCC" = "xyes"; then
......
dnl ======================================================================
dnl SAC_OPENSSL
dnl ======================================================================
AC_DEFUN([SAC_OPENSSL], [
AC_ARG_WITH(openssl,
[ --with-openssl use OpenSSL [[enabled]]],, with_openssl=pkg-config)
dnl SOSXXX:SAC_ASSERT_DEF([openssl libraries])
if test "$with_openssl" = no ;then
: # No openssl
else
if test "$with_openssl" = "pkg-config" ; then
PKG_CHECK_MODULES(openssl, openssl,
[HAVE_TLS=1 HAVE_SSL=1 LIBS="$openssl_LIBS $LIBS"],
[HAVE_SSL=0])
fi
if test x$HAVE_SSL = x1 ; then
AC_DEFINE([HAVE_LIBCRYPTO], 1, [Define to 1 if you have the `crypto' library (-lcrypto).])
AC_DEFINE([HAVE_LIBSSL], 1, [Define to 1 if you have the `ssl' library (-lssl).])
else
AC_CHECK_HEADERS([openssl/tls1.h], [
HAVE_SSL=1 HAVE_TLS=1
AC_CHECK_LIB(crypto, BIO_new,,
HAVE_SSL=0
AC_MSG_WARN(OpenSSL crypto library was not found))
AC_CHECK_LIB(ssl, TLSv1_method,,
HAVE_TLS=0
AC_MSG_WARN(OpenSSL protocol library was not found))
],[AC_MSG_WARN(OpenSSL include files were not found)])
fi
if test x$HAVE_SSL = x1; then
AC_DEFINE([HAVE_SSL], 1, [Define to 1 if you have OpenSSL])
fi
if test x$HAVE_TLS = x1; then
AC_DEFINE([HAVE_TLS], 1, [Define to 1 if you have TLS])
fi
fi
AM_CONDITIONAL(HAVE_TLS, test x$HAVE_TLS = x1)
])
......@@ -19,6 +19,19 @@
#include <gnutls/gnutls.h>
#endif
#ifdef HAVE_SSL
#include <openssl/ssl.h>
#include <openssl/err.h>
#ifdef WIN32
typedef unsigned __int32 uint32_t;
#else
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
#include <poll.h>
#endif
#endif
#define SF_FOREIGN 1
#define SF_TRY_SECURE 2
#define SF_SECURE 4
......@@ -41,9 +54,63 @@ struct stream_data {
#ifdef HAVE_GNUTLS
gnutls_session sess;
gnutls_certificate_credentials cred;
#elif HAVE_SSL
SSL* ssl;
SSL_CTX* ssl_ctx;
#endif
};
#ifdef HAVE_SSL
#ifdef WIN32
static int sock_read_ready(struct stream_data *data, uint32_t ms)
{
int r = 0;
fd_set fds;
struct timeval tv;
FD_ZERO(&fds);
#ifdef WIN32
#pragma warning( push )
#pragma warning( disable : 4127 )
FD_SET(SSL_get_fd(data->ssl), &fds);
#pragma warning( pop )
#else
FD_SET(SSL_get_fd(data->ssl), &fds);
#endif
tv.tv_sec = ms / 1000;
tv.tv_usec = (ms % 1000) * ms;
r = select (SSL_get_fd(data->ssl) + 1, &fds, NULL, NULL, &tv);
return r;
}
#else
static int sock_read_ready(struct stream_data *data, int ms)
{
struct pollfd pfds[2] = { { 0 } };
int s = 0, r = 0;
pfds[0].fd = SSL_get_fd(data->ssl);
pfds[0].events |= POLLIN;
s = poll(pfds, 1, ms);
if (s < 0) {
r = s;
} else if (s > 0) {
if ((pfds[0].revents & POLLIN)) {
r = 1;
}
}
return r;
}
#endif
#endif
#ifdef HAVE_GNUTLS
#ifndef WIN32
#include <gcrypt.h>
......@@ -120,6 +187,86 @@ handshake (struct stream_data *data)
iks_send_header (data->prs, data->server);
return IKS_OK;
} // HAVE_GNUTLS
#elif HAVE_SSL
static int wait_for_data(struct stream_data *data, int ret, int timeout)
{
struct timeval tv;
fd_set fds;
int err;
int retval = IKS_OK;
err = SSL_get_error(data->ssl, ret);
switch(err)
{
case SSL_ERROR_WANT_READ:
case SSL_ERROR_WANT_WRITE:
ret = sock_read_ready(data, timeout*1000);
if (ret == -1) {
retval = IKS_NET_TLSFAIL;
}
break;
default:
if(data->logHook)
data->logHook(data->user_data, ERR_error_string(err, NULL), strlen(ERR_error_string(err, NULL)), 1);
retval = IKS_NET_TLSFAIL;
break;
}
ERR_clear_error();
return retval;
}
static int
handshake (struct stream_data *data)
{
int ret;
int finished;
SSL_library_init();
SSL_load_error_strings();
data->ssl_ctx = SSL_CTX_new(TLSv1_method());
if(!data->ssl_ctx) return IKS_NOMEM;
data->ssl = SSL_new(data->ssl_ctx);
if(!data->ssl) return IKS_NOMEM;
if( SSL_set_fd(data->ssl, (int)data->sock) != 1 ) return IKS_NOMEM;
/* Set both the read and write BIO's to non-blocking mode */
BIO_set_nbio(SSL_get_rbio(data->ssl), 1);
BIO_set_nbio(SSL_get_wbio(data->ssl), 1);
finished = 0;
do
{
ret = SSL_connect(data->ssl);
if( ret != 1 )
{
if( wait_for_data(data, ret, 1) != IKS_OK )
{
finished = 1;
SSL_free(data->ssl);
}
}
} while( ret != 1 && finished != 1 );
if( ret == 1 )
{
data->flags &= (~SF_TRY_SECURE);
data->flags |= SF_SECURE;
iks_send_header (data->prs, data->server);
}
return ret == 1 ? IKS_OK : IKS_NET_TLSFAIL;
}
#endif
......@@ -295,6 +442,15 @@ tagHook (struct stream_data *data, char *name, char **atts, int type)
return IKS_NET_TLSFAIL;
}
}
#elif HAVE_SSL
if (data->flags & SF_TRY_SECURE) {
if (strcmp (name, "proceed") == 0) {
err = handshake (data);
return err;
} else if (strcmp (name, "failure") == 0){
return IKS_NET_TLSFAIL;
}
}
#endif
if (data->current) {
x = iks_insert (data->current, name);
......@@ -351,6 +507,11 @@ deleteHook (struct stream_data *data)
gnutls_deinit (data->sess);
gnutls_certificate_free_credentials (data->cred);
}
#elif HAVE_SSL
if (data->flags & SF_SECURE) {
if( SSL_shutdown(data->ssl) == 0 ) SSL_shutdown(data->ssl);
SSL_free(data->ssl);
}
#endif
if (data->trans) data->trans->close (data->sock);
data->trans = NULL;
......@@ -507,6 +668,12 @@ iks_recv (iksparser *prs, int timeout)
{
struct stream_data *data = iks_user_data (prs);
int len, ret;
#ifdef HAVE_SSL
int err;
struct timeval tv;
fd_set fds;
#endif
while (1) {
#ifdef HAVE_GNUTLS
......@@ -514,6 +681,34 @@ iks_recv (iksparser *prs, int timeout)
len = gnutls_record_recv (data->sess, data->buf, NET_IO_BUF_SIZE - 1);
if (len == 0) len = -1;
} else
#elif HAVE_SSL
if (data->flags & SF_SECURE) {
ret = sock_read_ready(data, timeout*1000);
if (ret == -1) {
return IKS_NET_TLSFAIL;
} else if( ret == 0 ) {
return IKS_OK;
} else {
len = SSL_read(data->ssl, data->buf, NET_IO_BUF_SIZE - 1);
}
if( len <= 0 )
{
switch( err = SSL_get_error(data->ssl, len) )
{
case SSL_ERROR_WANT_READ:
case SSL_ERROR_WANT_WRITE:
return IKS_OK;
break;
default:
if(data->logHook)
data->logHook(data->user_data, ERR_error_string(err, NULL), strlen(ERR_error_string(err, NULL)), 1);
return IKS_NET_TLSFAIL;
break;
}
}
} else
#endif
{
len = data->trans->recv (data->sock, data->buf, NET_IO_BUF_SIZE - 1, timeout);
......@@ -523,6 +718,7 @@ iks_recv (iksparser *prs, int timeout)
data->buf[len] = '\0';
if (data->logHook) data->logHook (data->user_data, data->buf, len, 1);
ret = iks_parse (prs, data->buf, len, 0);
if (ret != IKS_OK) return ret;
if (!data->trans) {
/* stream hook called iks_disconnect */
......@@ -569,6 +765,10 @@ iks_send_raw (iksparser *prs, const char *xmlstr)
if (data->flags & SF_SECURE) {
if (gnutls_record_send (data->sess, xmlstr, strlen (xmlstr)) < 0) return IKS_NET_RWERR;
} else
#elif HAVE_SSL
if (data->flags & SF_SECURE) {
if (SSL_write(data->ssl, xmlstr, strlen (xmlstr)) < 0) return IKS_NET_RWERR;
} else
#endif
{
ret = data->trans->send (data->sock, xmlstr, strlen (xmlstr));
......@@ -591,6 +791,8 @@ iks_has_tls (void)
{
#ifdef HAVE_GNUTLS
return 1;
#elif HAVE_SSL
return 1;
#else
return 0;
#endif
......@@ -602,6 +804,10 @@ iks_is_secure (iksparser *prs)
#ifdef HAVE_GNUTLS
struct stream_data *data = iks_user_data (prs);
return data->flags & SF_SECURE;
#elif HAVE_SSL
struct stream_data *data = iks_user_data (prs);
return data->flags & SF_SECURE;
#else
return 0;
......@@ -641,6 +847,14 @@ iks_start_tls (iksparser *prs)
int ret;
struct stream_data *data = iks_user_data (prs);
ret = iks_send_raw (prs, "<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>");
if (ret) return ret;
data->flags |= SF_TRY_SECURE;
return IKS_OK;
#elif HAVE_SSL
int ret;
struct stream_data *data = iks_user_data (prs);
ret = iks_send_raw (prs, "<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>");
if (ret) return ret;
data->flags |= SF_TRY_SECURE;
......
......@@ -1498,59 +1498,11 @@ static ldl_queue_t ldl_flush_queue(ldl_handle_t *handle, int done)
}
static void *APR_THREAD_FUNC queue_thread(apr_thread_t *thread, void *obj)
static void xmpp_connect(ldl_handle_t *handle, char *jabber_id, char *pass)
{
ldl_handle_t *handle = (ldl_handle_t *) obj;
int timeout_ka = LDL_KEEPALIVE_TIMEOUT;
int count_ka = timeout_ka;
ldl_set_flag_locked(handle, LDL_FLAG_QUEUE_RUNNING);
while (ldl_test_flag(handle, LDL_FLAG_RUNNING) && !ldl_test_flag(handle, LDL_FLAG_QUEUE_STOP)) {
if (ldl_flush_queue(handle, 0) == LDL_QUEUE_SENT) {
count_ka = timeout_ka;
};
if (handle->loop_callback(handle) != LDL_STATUS_SUCCESS || !ldl_test_flag((&globals), LDL_FLAG_READY)) {
int fd;
if ((fd = iks_fd(handle->parser)) > -1) {
shutdown(fd, 0x02);
}
ldl_set_flag_locked(handle, LDL_FLAG_BREAK);
break;
}
if (count_ka-- <= 0) {
if( iks_send_raw(handle->parser, " ") == IKS_OK) {
count_ka = timeout_ka;
globals.logger(DL_LOG_DEBUG, "Sent keep alive signal\n");
}
}
microsleep(100);
}
ldl_clear_flag_locked(handle, LDL_FLAG_QUEUE_RUNNING);
ldl_clear_flag_locked(handle, LDL_FLAG_QUEUE_STOP);
return NULL;
}
static void launch_queue_thread(ldl_handle_t *handle)
{
apr_thread_t *thread;
apr_threadattr_t *thd_attr;;
apr_threadattr_create(&thd_attr, handle->pool);
apr_threadattr_detach_set(thd_attr, 1);
apr_threadattr_stacksize_set(thd_attr, 512 * 1024);
apr_thread_create(&thread, thd_attr, queue_thread, handle, handle->pool);
}
int count_ka = timeout_ka;
static void xmpp_connect(ldl_handle_t *handle, char *jabber_id, char *pass)
{
while (ldl_test_flag((&globals), LDL_FLAG_READY) && ldl_test_flag(handle, LDL_FLAG_RUNNING)) {
int e;
char tmp[512], *sl;
......@@ -1603,13 +1555,18 @@ static void xmpp_connect(ldl_handle_t *handle, char *jabber_id, char *pass)
}
handle->counter = opt_timeout;
if (ldl_test_flag(handle, LDL_FLAG_TLS)) {
launch_queue_thread(handle);
}
while (ldl_test_flag((&globals), LDL_FLAG_READY) && ldl_test_flag(handle, LDL_FLAG_RUNNING)) {
e = iks_recv(handle->parser, 1);
if (!ldl_test_flag(handle, LDL_FLAG_TLS) && handle->loop_callback) {
if (count_ka-- <= 0) {
if( iks_send_raw(handle->parser, " ") == IKS_OK) {
count_ka = timeout_ka;
globals.logger(DL_LOG_DEBUG, "Sent keep alive signal\n");
}
}
if (handle->loop_callback) {
if (handle->loop_callback(handle) != LDL_STATUS_SUCCESS) {
ldl_clear_flag_locked(handle, LDL_FLAG_RUNNING);
break;
......@@ -1630,7 +1587,7 @@ static void xmpp_connect(ldl_handle_t *handle, char *jabber_id, char *pass)
goto fail;
}
if (!ldl_test_flag(handle, LDL_FLAG_TLS) && ldl_test_flag(handle, LDL_FLAG_RUNNING)) {
if (ldl_test_flag(handle, LDL_FLAG_RUNNING)) {
ldl_flush_queue(handle, 0);
}
......@@ -1648,11 +1605,12 @@ static void xmpp_connect(ldl_handle_t *handle, char *jabber_id, char *pass)
break;
}
}
microsleep(100);
}
fail:
ldl_set_flag_locked(handle, LDL_FLAG_QUEUE_STOP);
ldl_clear_flag_locked(handle, LDL_FLAG_CONNECTED);
ldl_clear_flag_locked(handle, LDL_FLAG_AUTHORIZED);
ldl_clear_flag_locked(handle, LDL_FLAG_BREAK);
......@@ -1662,23 +1620,12 @@ static void xmpp_connect(ldl_handle_t *handle, char *jabber_id, char *pass)
shutdown(fd, 0x02);
}
while(ldl_test_flag(handle, LDL_FLAG_QUEUE_RUNNING)) {
microsleep(100);
}
iks_disconnect(handle->parser);
iks_parser_delete(handle->parser);
}
ldl_clear_flag_locked(handle, LDL_FLAG_RUNNING);
if (!ldl_test_flag(handle, LDL_FLAG_TLS)) {
ldl_flush_queue(handle, 1);
}
while(ldl_test_flag(handle, LDL_FLAG_QUEUE_RUNNING)) {
microsleep(100);
}
ldl_flush_queue(handle, 1);
ldl_set_flag_locked(handle, LDL_FLAG_STOPPED);
......@@ -2529,13 +2476,15 @@ int ldl_handle_authorized(ldl_handle_t *handle)
void ldl_handle_stop(ldl_handle_t *handle)
{
ldl_clear_flag_locked(handle, LDL_FLAG_RUNNING);
#if 0
if (ldl_test_flag(handle, LDL_FLAG_TLS)) {
int fd;
if ((fd = iks_fd(handle->parser)) > -1) {
shutdown(fd, 0x02);
}
}
#endif
while(!ldl_test_flag(handle, LDL_FLAG_STOPPED)) {
microsleep(100);
}
......
......@@ -121,10 +121,8 @@ typedef enum {
LDL_FLAG_AUTHORIZED = (1 << 2),
LDL_FLAG_READY = (1 << 3),
LDL_FLAG_CONNECTED = (1 << 4),
LDL_FLAG_QUEUE_RUNNING = (1 << 5),
LDL_FLAG_STOPPED = (1 << 6),
LDL_FLAG_QUEUE_STOP = (1 << 7),
LDL_FLAG_BREAK = (1 << 8)
LDL_FLAG_STOPPED = (1 << 5),
LDL_FLAG_BREAK = (1 << 6)
} ldl_flag_t;
typedef enum {
......
......@@ -44,8 +44,8 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\iksemel\include;."
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;HAVE_CONFIG_H;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE"
AdditionalIncludeDirectories="..\..\iksemel\include;.;..\..\openssl-1.0.0a\include"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;HAVE_CONFIG_H;HAVE_SSL;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
......@@ -82,12 +82,11 @@
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
Name="Debug|x64"
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
......@@ -103,12 +102,16 @@
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\iksemel\include;."
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;HAVE_CONFIG_H;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE"
RuntimeLibrary="2"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;HAVE_CONFIG_H;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="0"
DebugInformationFormat="3"
......@@ -142,11 +145,12 @@
/>
</Configuration>
<Configuration
Name="Debug|x64"
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
Name="Release|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
......@@ -162,16 +166,12 @@
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\iksemel\include;."
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;HAVE_CONFIG_H;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;HAVE_CONFIG_H;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="0"
DebugInformationFormat="3"
......
......@@ -69,8 +69,8 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\iksemel\include;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;HAVE_CONFIG_H;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\..\iksemel\include;.;..\..\openssl-1.0.0a\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;HAVE_CONFIG_H;HAVE_SSL;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
......@@ -79,8 +79,8 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>..\..\iksemel\include;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;HAVE_CONFIG_H;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\..\iksemel\include;.;..\..\openssl-1.0.0a\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;HAVE_CONFIG_H;HAVE_SSL;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<WarningLevel>TurnOffAllWarnings</WarningLevel>
</ClCompile>
......@@ -91,8 +91,8 @@
</Midl>
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\iksemel\include;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;HAVE_CONFIG_H;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\..\iksemel\include;.;..\..\openssl-1.0.0a\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;HAVE_CONFIG_H;HAVE_SSL;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
......@@ -104,8 +104,8 @@
<TargetEnvironment>X64</TargetEnvironment>
</Midl>
<ClCompile>
<AdditionalIncludeDirectories>..\..\iksemel\include;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;HAVE_CONFIG_H;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\..\iksemel\include;.;..\..\openssl-1.0.0a\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;HAVE_CONFIG_H;HAVE_SSL;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<WarningLevel>TurnOffAllWarnings</WarningLevel>
</ClCompile>
......
......@@ -145,6 +145,12 @@
<Project>{e727e8f6-935d-46fe-8b0e-37834748a0e3}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\..\..\..\libs\win32\openssl\libeay32.2010.vcxproj">
<Project>{d331904d-a00a-4694-a5a3-fcff64ab5dbe}</Project>
</ProjectReference>
<ProjectReference Include="..\..\..\..\libs\win32\openssl\ssleay32.2010.vcxproj">
<Project>{b4b62169-5ad4-4559-8707-3d933ac5db39}</Project>
</ProjectReference>
<ProjectReference Include="..\..\..\..\w32\Library\FreeSwitchCore.2010.vcxproj">
<Project>{202d7a4e-760d-4d0e-afa1-d7459ced30ff}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
......
......@@ -495,18 +495,24 @@ static switch_status_t chat_send(switch_event_t *message_event)
mdl_profile_t *profile = NULL;
const char *proto;
const char *from;
const char *from_full;
const char *to_full;
const char *to;
const char *body;
const char *hint;
const char *profile_name;
proto = switch_event_get_header(message_event, "proto");
from = switch_event_get_header(message_event, "from");
from_full = switch_event_get_header(message_event, "from_full");
to_full = switch_event_get_header(message_event, "to_full");
to = switch_event_get_header(message_event, "to");
body = switch_event_get_body(message_event);
hint = switch_event_get_header(message_event, "hint");
profile_name = switch_event_get_header(message_event, "ldl_profile");
switch_assert(proto != NULL);
if (from && (f_user = strdup(from))) {
if ((f_host = strchr(f_user, '@'))) {
*f_host++ = '\0';
......@@ -516,12 +522,18 @@ static switch_status_t chat_send(switch_event_t *message_event)
}
}
if (to && (user = strdup(to))) {
if ((profile_name && (profile = switch_core_hash_find(globals.profile_hash, profile_name)))) {
from = from_full;
to = to_full;
ldl_handle_send_msg(profile->handle, (char *) from, (char *) to, NULL, switch_str_nil(body));
} else if (to && (user = strdup(to))) {
if ((host = strchr(user, '@'))) {
*host++ = '\0';
}
if (f_host && (profile = switch_core_hash_find(globals.profile_hash, f_host))) {
if (f_host && ((profile_name && (profile = switch_core_hash_find(globals.profile_hash, profile_name)))
|| (profile = switch_core_hash_find(globals.profile_hash, f_host)))) {
if (!strcmp(proto, MDL_CHAT_PROTO)) {
from = hint;
......@@ -2931,6 +2943,8 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "subject", subject);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "type", "text/plain");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "hint", hint);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_full", hint);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "ldl_profile", profile->name);
if (msg) {
switch_event_add_body(event, "%s", msg);
......@@ -2941,12 +2955,14 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
switch_safe_free(from_user);
if (strcasecmp(proto, MDL_CHAT_PROTO)) { /* yes no ! on purpose */
switch_core_chat_send(proto, event);
if (!zstr(msg)) {
if (strcasecmp(proto, MDL_CHAT_PROTO)) { /* yes no ! on purpose */
switch_core_chat_send(proto, event);
}
switch_core_chat_send("GLOBAL", event);
}
switch_core_chat_send("GLOBAL", event);
switch_event_destroy(&event);
switch_safe_free(pproto);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论