Commit c5e74abe authored by Adrien Béraud's avatar Adrien Béraud Committed by Andreas Traczyk

Ringaccount: add support for DHT proxy and push notifications

* Bump restbed for OpenDHT, update patch and add patch to react
  to timeout and socket closed in restbed.
* Bump OpenDHT to support push notifications
* Add DRing APIs to support setting a client push notification token
  and to retransmit push notifications to dring
* Implement proxy support in RingAccount

Change-Id: I8d3a02cf54a9666a94ab992ee3fa2958e82aa7ad
parent 9179735a
......@@ -501,7 +501,7 @@
<SDLCheck>
</SDLCheck>
<AdditionalIncludeDirectories>$(ProjectDir)..\contrib\build\FFmpegInterop\ffmpeg\Build\Windows10\x64\include;$(ProjectDir);$(ProjectDir)..\;$(ProjectDir)..\src;$(ProjectDir)..\src\client;$(ProjectDir)..\src\config;$(ProjectDir)..\src\dring;$(ProjectDir)..\src\hooks;$(ProjectDir)..\src\iax;$(ProjectDir)..\src\im;$(ProjectDir)..\src\media;$(ProjectDir)..\src\ringdht;$(ProjectDir)..\src\security;$(ProjectDir)..\src\sip;$(ProjectDir)..\src\upnp;$(ProjectDir)..\src\ringdht\eth;$(ProjectDir)..\contrib\build;$(ProjectDir)..\contrib\build\include;$(ProjectDir)..\contrib\build\pjproject\pjlib\include;$(ProjectDir)..\contrib\build\pjproject\pjnath\include;$(ProjectDir)..\contrib\build\pjproject\pjlib-util\include;$(ProjectDir)..\contrib\build\pjproject\pjsip\include;$(ProjectDir)..\contrib\build\pjproject\third_party\speex\include;$(ProjectDir)..\contrib\build\pjproject\third_party;$(ProjectDir)..\contrib\build\pjproject\pjmedia\include;$(ProjectDir)..\contrib\build\boost;$(ProjectDir)..\contrib\build\cryptopp;$(ProjectDir)..\contrib\build\restbed\source;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>BOOST_SYSTEM_NO_DEPRECATED;PJ_OS_HAS_CHECK_STACK=1;STATIC_GETOPT;_USE_MATH_DEFINES;PCRE_STATIC;_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;NOMINMAX;HAVE_CONFIG_H;WIN32_LEAN_AND_MEAN;RING_UWP;WIN32_NATIVE;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>BOOST_SYSTEM_NO_DEPRECATED;PJ_OS_HAS_CHECK_STACK=1;STATIC_GETOPT;_USE_MATH_DEFINES;PCRE_STATIC;_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;NOMINMAX;HAVE_CONFIG_H;WIN32_LEAN_AND_MEAN;RING_UWP;WIN32_NATIVE;_MBCS;OPENDHT_PROXY_CLIENT;OPENDHT_PROXY_SERVER;OPENDHT_PUSH_NOTIFICATIONS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DisableSpecificWarnings>4996;4503;4180;4244;4267;</DisableSpecificWarnings>
<SuppressStartupBanner>true</SuppressStartupBanner>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
......@@ -527,7 +527,7 @@
</Command>
</PreBuildEvent>
<Lib>
<AdditionalDependencies>ws2_32.lib;iphlpapi.lib;advapi32.lib;avcodec.lib;avdevice.lib;avfilter.lib;avformat.lib;avutil.lib;swresample.lib;swscale.lib;libsamplerate.lib;libgnutls.lib;lib_json.lib;opendht.lib;Argon2Ref.lib;pcre.lib;yaml-cpp.lib;portaudio-UWP.lib;libupnp.lib;pjsip-core-x86_64-x64-vc14-Release.lib;pjsip-simple-x86_64-x64-vc14-Release.lib;pjsua2-lib-x86_64-x64-vc14-Release.lib;pjsua-lib-x86_64-x64-vc14-Release.lib;pjsip-ua-x86_64-x64-vc14-Release.lib;pjmedia-codec-x86_64-x64-vc14-Release.lib;pjmedia-x86_64-x64-vc14-Release.lib;pjlib-util-x86_64-x64-vc14-Release.lib;libspeex-x86_64-x64-vc14-Release.lib;pjlib-x86_64-x64-vc14-Release.lib;pjnath-x86_64-x64-vc14-Release.lib;restbed.lib;libeay32.lib;ssleay32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>ws2_32.lib;iphlpapi.lib;advapi32.lib;avcodec.lib;avdevice.lib;avfilter.lib;avformat.lib;avutil.lib;swresample.lib;swscale.lib;libsamplerate.lib;libgnutls.lib;lib_json.lib;opendht.lib;Argon2Ref.lib;pcre.lib;yaml-cpp.lib;portaudio-UWP.lib;libupnp.lib;pjsip-core-x86_64-x64-vc14-Release.lib;pjsip-simple-x86_64-x64-vc14-Release.lib;pjsua2-lib-x86_64-x64-vc14-Release.lib;pjsua-lib-x86_64-x64-vc14-Release.lib;pjsip-ua-x86_64-x64-vc14-Release.lib;pjmedia-codec-x86_64-x64-vc14-Release.lib;pjmedia-x86_64-x64-vc14-Release.lib;pjlib-util-x86_64-x64-vc14-Release.lib;libspeex-x86_64-x64-vc14-Release.lib;pjlib-x86_64-x64-vc14-Release.lib;pjnath-x86_64-x64-vc14-Release.lib;restbed.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(ProjectDir)..\contrib\build\FFmpegInterop\ffmpeg\Build\Windows10\x64\bin;$(ProjectDir)..\contrib\build\lib\x64;$(ProjectDir)..\contrib\build\boost\stage\lib;$(ProjectDir)..\contrib\build\pjproject\pjsip\lib;$(ProjectDir)..\contrib\build\pjproject\pjmedia\lib;$(ProjectDir)..\contrib\build\pjproject\pjlib-util\lib;$(ProjectDir)..\contrib\build\pjproject\third_party\lib;$(ProjectDir)..\contrib\build\pjproject\pjlib\lib;$(ProjectDir)..\contrib\build\pjproject\pjnath\lib;$(ProjectDir)..\contrib\build\libnatpmp\msvc\x64\Release;$(ProjectDir)..\contrib\build\restbed\build\Release;$(ProjectDir)..\contrib\build\restbed\dependency\openssl\out32dll</AdditionalLibraryDirectories>
<AdditionalOptions>/ignore:4006 /ignore:4221 %(AdditionalOptions)</AdditionalOptions>
<LinkTimeCodeGeneration>true</LinkTimeCodeGeneration>
......
......@@ -194,6 +194,11 @@ int exportAccounts(std::vector<std::string> accountIDs, std::string toDir, std::
int importAccounts(std::string archivePath, std::string password);
void connectivityChanged();
void enableProxyClient(const std::string& accountID, bool enable);
void setPushNotificationToken(const std::string& pushDeviceToken);
void pushNotificationReceived(const std::string& from, const std::map<std::string, std::string>& data);
}
class ConfigurationCallback {
......
......@@ -223,6 +223,8 @@ AS_IF([test -n "${CONTRIB_DIR}"], [
AC_MSG_RESULT([${CONTRIB_DIR}])
export PATH=${CONTRIB_DIR}/bin:$PATH
CPPFLAGS="${CPPFLAGS} -I${CONTRIB_DIR}/include"
CPPFLAGS+=" -DOPENDHT_PROXY_CLIENT=true -DOPENDHT_PUSH_NOTIFICATIONS=true -DOPENDHT_PROXY_SERVER=true"
CFLAGS="${CFLAGS} -DPJ_AUTOCONF=1 "
CXXFLAGS="${CXXFLAGS} -DPJ_AUTOCONF=1 "
AS_IF([test "${HAVE_WIN64}" = "1"],[
......@@ -230,8 +232,12 @@ AS_IF([test -n "${CONTRIB_DIR}"], [
CXXFLAGS+=" -DPJ_WIN64=1"
])
CFLAGS+=" -I${CONTRIB_DIR}/include"
CFLAGS+=" -DOPENDHT_PROXY_CLIENT=true -DOPENDHT_PUSH_NOTIFICATIONS=true -DOPENDHT_PROXY_SERVER=true"
CXXFLAGS+=" -I${CONTRIB_DIR}/include"
CXXFLAGS+=" -DOPENDHT_PROXY_CLIENT=true -DOPENDHT_PUSH_NOTIFICATIONS=true -DOPENDHT_PROXY_SERVER=true"
OBJCFLAGS="${OBJCFLAGS} -I${CONTRIB_DIR}/include"
OBJCFLAGS+=" -DOPENDHT_PROXY_CLIENT=true -DOPENDHT_PUSH_NOTIFICATIONS=true -DOPENDHT_PROXY_SERVER=true"
AS_IF([test "${SYS}" = "mingw32"],[
PKG_CONFIG_PATH_CUSTOM="${CONTRIB_DIR}/lib/pkgconfig:${CONTRIB_DIR}/lib64/pkgconfig"
AC_SUBST(PKG_CONFIG_PATH_CUSTOM)
......@@ -243,6 +249,10 @@ AS_IF([test -n "${CONTRIB_DIR}"], [
AS_IF([test "${SYS}" = "darwin"], [
export LD_LIBRARY_PATH="${CONTRIB_DIR}/lib:$LD_LIBRARY_PATH"
export DYLD_LIBRARY_PATH="${CONTRIB_DIR}/lib:$DYLD_LIBRARY_PATH"
], [
PKG_CHECK_MODULES([Jsoncpp], [jsoncpp >= 1.6.5])
CPPFLAGS="${CPPFLAGS} ${Jsoncpp_CFLAGS}"
LDFLAGS="${LDFLAGS} ${Jsoncpp_LIBS}"
])
], [
AS_IF([test -n "${with_contrib}" && test "${with_contrib}" != "no"], [
......@@ -413,7 +423,7 @@ AS_IF([test "x$enable_restbed_old_api" = "xyes"], [
])
AS_IF([test "x$enable_ringns" != "xno" || test "x$with_restcpp" = "xyes"],
AC_CHECK_LIB(restbed, exit,, AC_MSG_ERROR([Missing restbed files])));
AC_CHECK_LIB(restbed, exit,, AC_MSG_ERROR([Missing restbed files])));
AS_IF([test "x$with_restcpp" = "xyes"], [
AS_AC_EXPAND(SBINDIR, $sbindir)
......
......@@ -70,20 +70,11 @@ set MSYS2_BIN="C:\msys64\usr\bin\bash.exe"
call BuildFFmpeg.bat win10 x64
cd ..\..
rem * build openssl UWP *
cd build\restbed\dependency\openssl
call perl Configure no-asm no-hw no-dso VC-WINUNIVERSAL
call ms\do_winuniversal
call ms\setVSvars universal10.0x64
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64
call nmake -f ms\ntdll.mak
set PATH=restbed\dependency\openssl\out32dll;%PATH%
rem * build restbed w/asio *
cd ..\..
cd build\restbed
mkdir build
cd build
cmake -G "Visual Studio 14 2015 Win64" ..
cmake -DBUILD_SSL=OFF -G "Visual Studio 14 2015 Win64" ..
cmake --build . --target ALL_BUILD --config Release
cd ..\..
......
eb2ffc2662cd981a552ae19109260a2d675de748906f5e1037b85fe123cfbd2b4a714ef1428444f69828d5cd2405f7cb70cd53ad36c71b298d9930c49fca16ba opendht-1.5.0.tar.gz
ef677a72dfbd59dfa604165ab3be547e1bd52ff2862a86bfed54c7f931d26a8374b30a20ad818ff45fa377bad662d8b9dc9e1db9108cda6422b9c4a8ec90dc4d opendht-4d4ba2be96ae237f21e65acdc3eab24d7d5d0e00.tar.gz
set BUILD=%SRC%..\build
set OPENDHT_VERSION=1.5.0
set OPENDHT_VERSION=4d4ba2be96ae237f21e65acdc3eab24d7d5d0e00
set OPENDHT_URL=https://github.com/savoirfairelinux/opendht/archive/%OPENDHT_VERSION%.tar.gz
mkdir %BUILD%
......@@ -18,5 +18,6 @@ rename %BUILD%\opendht-%OPENDHT_VERSION% opendht
cd %BUILD%\opendht
git apply --reject --whitespace=fix %SRC%\opendht\opendht-uwp.patch
git apply --reject --whitespace=fix %SRC%\opendht\opendht-proxy-uwp.patch
cd %SRC%
--- a/MSVC/opendht.vcxproj
+++ b/MSVC/opendht.vcxproj
@@ -19,11 +19,14 @@
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
+ <ClCompile Include="..\src\base64.cpp" />
<ClCompile Include="..\src\callbacks.cpp" />
<ClCompile Include="..\src\crypto.cpp" />
<ClCompile Include="..\src\default_types.cpp" />
<ClCompile Include="..\src\dht.cpp" />
<ClCompile Include="..\src\dhtrunner.cpp" />
+ <ClCompile Include="..\src\dht_proxy_client.cpp" />
+ <ClCompile Include="..\src\dht_proxy_server.cpp" />
<ClCompile Include="..\src\indexation\pht.cpp" />
<ClCompile Include="..\src\infohash.cpp" />
<ClCompile Include="..\src\log.cpp" />
@@ -36,32 +39,13 @@
<ClCompile Include="..\src\value.cpp" />
</ItemGroup>
<ItemGroup>
- <ClInclude Include="..\include\opendht.h" />
- <ClInclude Include="..\include\opendht\callbacks.h" />
- <ClInclude Include="..\include\opendht\crypto.h" />
<ClInclude Include="..\include\opendht\def.h" />
- <ClInclude Include="..\include\opendht\default_types.h" />
- <ClInclude Include="..\include\opendht\dht.h" />
- <ClInclude Include="..\include\opendht\dhtrunner.h" />
- <ClInclude Include="..\include\opendht\indexation\pht.h" />
- <ClInclude Include="..\include\opendht\infohash.h" />
- <ClInclude Include="..\include\opendht\log.h" />
- <ClInclude Include="..\include\opendht\log_enable.h" />
- <ClInclude Include="..\include\opendht\network_engine.h" />
- <ClInclude Include="..\include\opendht\node.h" />
- <ClInclude Include="..\include\opendht\node_cache.h" />
- <ClInclude Include="..\include\opendht\rate_limiter.h" />
- <ClInclude Include="..\include\opendht\request.h" />
- <ClInclude Include="..\include\opendht\rng.h" />
- <ClInclude Include="..\include\opendht\routing_table.h" />
- <ClInclude Include="..\include\opendht\scheduler.h" />
- <ClInclude Include="..\include\opendht\securedht.h" />
<ClInclude Include="..\include\opendht\sockaddr.h" />
- <ClInclude Include="..\include\opendht\utils.h" />
- <ClInclude Include="..\include\opendht\value.h" />
- <ClInclude Include="..\src\net.h" />
+ <ClInclude Include="..\src\base64.h" />
<ClInclude Include="..\src\listener.h" />
+ <ClInclude Include="..\src\net.h" />
<ClInclude Include="..\src\parsed_message.h" />
+ <ClInclude Include="..\src\request.h" />
<ClInclude Include="..\src\search.h" />
<ClInclude Include="..\src\storage.h" />
</ItemGroup>
@@ -215,8 +199,8 @@ copy ..\include\opendht.h $(OutDir)\include\</Command>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
- <AdditionalIncludeDirectories>$(ProjectDir)contrib\build\include;$(ProjectDir)..\include;$(ProjectDir)..\include\opendht;$(ProjectDir)contrib\build\msgpack-c\include;$(ProjectDir)contrib\build\argon2\include;$(ProjectDir)..\..\include;$(ProjectDir)..\..\argon2\include</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32_NATIVE;WIN32_LEAN_AND_MEAN;_MBCS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>$(ProjectDir)contrib\build\include;$(ProjectDir)..\include;$(ProjectDir)..\include\opendht;$(ProjectDir)contrib\build\msgpack-c\include;$(ProjectDir)contrib\build\argon2\include;$(ProjectDir)..\..\include;$(ProjectDir)..\..\argon2\include;$(ProjectDir)..\..\restbed\source</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32_NATIVE;WIN32_LEAN_AND_MEAN;_MBCS;OPENDHT_PROXY_CLIENT;OPENDHT_PROXY_SERVER;OPENDHT_PUSH_NOTIFICATIONS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DisableSpecificWarnings>4804;4800;4101;4267;4244;4503;</DisableSpecificWarnings>
<AdditionalOptions>-D_SCL_SECURE_NO_WARNINGS %(AdditionalOptions)</AdditionalOptions>
<ProgramDataBaseFileName>$(OutDir)\lib\x64\$(TargetName).pdb</ProgramDataBaseFileName>
diff --git a/MSVC/opendht.vcxproj.filters b/MSVC/opendht.vcxproj.filters
index 9d275f8..885baa0 100644
--- a/MSVC/opendht.vcxproj.filters
+++ b/MSVC/opendht.vcxproj.filters
@@ -31,9 +31,6 @@
<ClCompile Include="..\src\node_cache.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="..\src\indexation\pht.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="..\src\routing_table.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@@ -46,79 +43,38 @@
<ClCompile Include="..\src\value.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="..\src\base64.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\src\dht_proxy_client.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\src\dht_proxy_server.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\src\indexation\pht.cpp">
+ <Filter>Source Files\indexation</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
- <ClInclude Include="..\include\opendht\callbacks.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\include\opendht\crypto.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\include\opendht\default_types.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\include\opendht\dht.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\include\opendht\dhtrunner.h">
- <Filter>Header Files</Filter>
+ <ClInclude Include="..\include\opendht\def.h" />
+ <ClInclude Include="..\include\opendht\sockaddr.h" />
+ <ClInclude Include="..\src\net.h" />
+ <ClInclude Include="..\src\parsed_message.h" />
+ <ClInclude Include="..\src\base64.h">
+ <Filter>Source Files</Filter>
</ClInclude>
- <ClInclude Include="..\include\opendht\infohash.h">
- <Filter>Header Files</Filter>
+ <ClInclude Include="..\src\request.h">
+ <Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\src\listener.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\include\opendht\log.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\include\opendht\log_enable.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\include\opendht\network_engine.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\include\opendht\node.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\include\opendht\node_cache.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\include\opendht.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\include\opendht\indexation\pht.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\include\opendht\rate_limiter.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\include\opendht\request.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\include\opendht\rng.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\include\opendht\routing_table.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\include\opendht\scheduler.h">
- <Filter>Header Files</Filter>
+ <Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\src\search.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\include\opendht\securedht.h">
- <Filter>Header Files</Filter>
+ <Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\src\storage.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\include\opendht\utils.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="..\include\opendht\value.h">
- <Filter>Header Files</Filter>
+ <Filter>Source Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
@@ -128,5 +84,8 @@
<Filter Include="Header Files">
<UniqueIdentifier>{d1ab5bfe-3ab1-45ee-9324-b4b071887668}</UniqueIdentifier>
</Filter>
+ <Filter Include="Source Files\indexation">
+ <UniqueIdentifier>{4f930bd8-2e82-4b16-8db5-8c8dfff25a18}</UniqueIdentifier>
+ </Filter>
</ItemGroup>
</Project>
\ No newline at end of file
--
2.10.2.windows.1
# OPENDHT
OPENDHT_VERSION := 1.5.0
OPENDHT_VERSION := 4d4ba2be96ae237f21e65acdc3eab24d7d5d0e00
OPENDHT_URL := https://github.com/savoirfairelinux/opendht/archive/$(OPENDHT_VERSION).tar.gz
PKGS += opendht
......@@ -14,6 +14,12 @@ endif
ifneq ($(call need_pkg,"libargon2"),)
DEPS_opendht += argon2
endif
ifneq ($(call need_pkg,"restbed"),)
DEPS_opendht += restbed
endif
ifneq ($(call need_pkg,"jsoncpp"),)
DEPS_opendht += jsoncpp
endif
ifneq ($(call need_pkg,"gnutls >= 3.3.0"),)
DEPS_opendht += gnutls
endif
......@@ -30,6 +36,6 @@ opendht: opendht-$(OPENDHT_VERSION).tar.gz
.opendht: opendht .sum-opendht
mkdir -p $</m4 && $(RECONF)
cd $< && $(HOSTVARS) ./configure --disable-tools --disable-python --disable-doc $(HOSTCONF)
cd $< && $(HOSTVARS) ./configure --disable-tools --disable-python --disable-doc --enable-proxy-server --enable-proxy-client --enable-push-notifications $(HOSTCONF)
cd $< && $(MAKE) install
touch $@
81fbc7c90b6690ba9926c7990495bf114d4b4511785cf8ad7d526a119104e6eea0d0945c7e73e94ff7005b996b96ec4ecb067e192da04afa20e854c1f982549d restbed-4.6.tar.gz
\ No newline at end of file
26fa79c08cf9414bb26a0a6d3573e71d4df0facfe1a0d86a5935bdf5203f7d1fb633fa99802bc2c9104eed7ab67e9cef3e1679ca4a12b982bfd49d7f5a1c088c restbed-df867a858dddc4cf6ca8642da02720bd65ba239a.tar.gz
--- a/source/corvusoft/restbed/detail/socket_impl.cpp
+++ b/source/corvusoft/restbed/detail/socket_impl.cpp
@@ -418,20 +418,40 @@ namespace restbed
m_timer->async_wait( bind( &SocketImpl::connection_timeout_handler, this, shared_from_this( ), _1 ) );
size_t size = 0;
+ auto finished = std::make_shared<bool>(false);
+ auto sharedError = std::make_shared<error_code>();
+ auto sharedSize = std::make_shared<size_t>(0);
#ifdef BUILD_SSL
if ( m_socket not_eq nullptr )
{
#endif
size = asio::read( *m_socket, *data, asio::transfer_at_least( length ), error );
+ asio::async_read(*m_socket, *data, asio::transfer_at_least(length),
+ [this, finished, sharedSize, sharedError](const error_code & error, size_t size) {
+ *sharedError = error;
+ *sharedSize = size;
+ *finished = true;
+ });
#ifdef BUILD_SSL
}
else
{
size = asio::read( *m_ssl_socket, *data, asio::transfer_at_least( length ), error );
+ asio::async_read(*m_ssl_socket, *data, asio::transfer_at_least(length),
+ [this, finished, sharedSize, sharedError](const error_code & error, size_t size) {
+ *sharedError = error;
+ *sharedSize = size;
+ *finished = true;
+ });
}
#endif
+ auto& io_service = m_socket->get_io_service();
+ while (!*finished)
+ io_service.run_one();
+ error = *sharedError;
+ size = *sharedSize;
m_timer->cancel( );
if ( error )
@@ -549,21 +569,40 @@ namespace restbed
m_timer->async_wait( bind( &SocketImpl::connection_timeout_handler, this, shared_from_this( ), _1 ) );
size_t length = 0;
-
+ auto finished = std::make_shared<bool>(false);
+ auto sharedError = std::make_shared<error_code>();
+ auto sharedLength = std::make_shared<size_t>(0);
#ifdef BUILD_SSL
if ( m_socket not_eq nullptr )
{
#endif
length = asio::read_until( *m_socket, *data, delimiter, error );
+ asio::async_read_until(*m_socket, *data, delimiter,
+ [this, finished, sharedLength, sharedError](const error_code & error, size_t length) {
+ *sharedError = error;
+ *sharedLength = length;
+ *finished = true;
+ });
#ifdef BUILD_SSL
}
else
{
length = asio::read_until( *m_ssl_socket, *data, delimiter, error );
+ asio::async_read_until(*m_ssl_socket, *data, delimiter,
+ [this, finished, sharedLength, sharedError](const error_code & error, size_t length) {
+ *sharedError = error;
+ *sharedLength = length;
+ *finished = true;
+ });
}
#endif
+ auto& io_service = m_socket->get_io_service();
+ while (!*finished)
+ io_service.run_one();
+ error = *sharedError;
+ length = *sharedLength;
m_timer->cancel( );
if ( error )
--
2.10.2.windows.1
From 09b542eea3fb3038d02ff056d41dea16bfe889bd Mon Sep 17 00:00:00 2001
From: AmarOk <contact@enconn.fr>
Date: Tue, 5 Dec 2017 10:45:53 -0600
Subject: [PATCH]socket_impl: replace read_until by async_read_until
---
source/corvusoft/restbed/detail/socket_impl.cpp | 62 +++++++++++++++++++------
1 file changed, 49 insertions(+), 13 deletions(-)
diff --git a/source/corvusoft/restbed/detail/socket_impl.cpp b/source/corvusoft/restbed/detail/socket_impl.cpp
index 90e8b04..379f1c7 100644
--- a/source/corvusoft/restbed/detail/socket_impl.cpp
+++ b/source/corvusoft/restbed/detail/socket_impl.cpp
@@ -417,28 +417,47 @@ namespace restbed
m_timer->expires_from_now( m_timeout );
m_timer->async_wait( bind( &SocketImpl::connection_timeout_handler, this, shared_from_this( ), _1 ) );
+
size_t size = 0;
+ auto finished = std::make_shared<bool>(false);
+ auto sharedError = std::make_shared<error_code>();
+ auto sharedSize = std::make_shared<size_t>(0);
+
#ifdef BUILD_SSL
-
+
if ( m_socket not_eq nullptr )
{
#endif
- size = asio::read( *m_socket, *data, asio::transfer_at_least( length ), error );
+ asio::async_read( *m_socket, *data, asio::transfer_at_least( length ),
+ [ this, finished, sharedSize, sharedError ]( const error_code & error, size_t size ) {
+ *sharedError = error;
+ *sharedSize = size;
+ *finished = true;
+ });
#ifdef BUILD_SSL
}
else
{
- size = asio::read( *m_ssl_socket, *data, asio::transfer_at_least( length ), error );
+ asio::async_read( *m_ssl_socket, *data, asio::transfer_at_least( length ),
+ [ this, finished, sharedSize, sharedError ]( const error_code & error, size_t size ) {
+ *sharedError = error;
+ *sharedSize = size;
+ *finished = true;
+ });
}
-
#endif
+ auto& io_service = m_socket->get_io_service( );
+ while (!*finished)
+ io_service.run_one();
+ error = *sharedError;
+ size = *sharedSize;
m_timer->cancel( );
-
+
if ( error )
{
m_is_open = false;
}
-
+
return size;
}
@@ -549,28 +568,45 @@ namespace restbed
m_timer->async_wait( bind( &SocketImpl::connection_timeout_handler, this, shared_from_this( ), _1 ) );
size_t length = 0;
-
+ auto finished = std::make_shared<bool>(false);
+ auto sharedError = std::make_shared<error_code>();
+ auto sharedLength = std::make_shared<size_t>(0);
+
#ifdef BUILD_SSL
-
+
if ( m_socket not_eq nullptr )
{
#endif
- length = asio::read_until( *m_socket, *data, delimiter, error );
+ asio::async_read_until( *m_socket, *data, delimiter,
+ [ this, finished, sharedLength, sharedError ]( const error_code & error, size_t length ) {
+ *sharedError = error;
+ *sharedLength = length;
+ *finished = true;
+ });
#ifdef BUILD_SSL
}
else
{
- length = asio::read_until( *m_ssl_socket, *data, delimiter, error );
+ asio::async_read_until( *m_ssl_socket, *data, delimiter,
+ [ this, finished, sharedLength, sharedError ]( const error_code & error, size_t length ) {
+ *sharedError = error;
+ *sharedLength = length;
+ *finished = true;
+ });
}
-
#endif
+ auto& io_service = m_socket->get_io_service( );
+ while (!*finished)
+ io_service.run_one();
+ error = *sharedError;
+ length = *sharedLength;
m_timer->cancel( );
-
+
if ( error )
{
m_is_open = false;
}
-
+
return length;
}
--
2.14.3
--- a/cmake/configuration.cmake
+++ b/cmake/configuration.cmake
@@ -37,13 +37,7 @@ elseif( ${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC )
if ( ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 19.00.23026.0 )
message( WARNING "\nMSVC compiler version < 19.00.23026.0" )
endif ( )
- set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MT /std:c++latest /D_WIN32_WINNT=0x0601 /W4 /wd4068 /wd4702 /wd4996" )
-
- foreach ( flag_var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO )
- if ( ${flag_var} MATCHES "/MD" )
- string( REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}" )
- endif ( ${flag_var} MATCHES "/MD" )
- endforeach ( )
+ set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MD /std:c++latest /D_WIN32_WINNT=0x0601 /W4 /wd4068 /wd4702 /wd4996" )
else ( )
message( FATAL_ERROR "Compiler not supported.")
endif ( )
--
2.10.2.windows.1
set BUILD=%SRC%..\build
set RESTBED_VERSION=34187502642144ab9f749ab40f5cdbd8cb17a54a
set RESTBED_URL=https://github.com/Corvusoft/restbed/archive/%RESTBED_VERSION%.tar.gz
mkdir %BUILD%
if %USE_CACHE%==1 (
copy %CACHE_DIR%\%RESTBED_VERSION%.tar.gz %cd%
) else (
wget %RESTBED_URL%
)
7z -y x %RESTBED_VERSION%.tar.gz && 7z -y x %RESTBED_VERSION%.tar -o%BUILD%
del %RESTBED_VERSION%.tar && del %RESTBED_VERSION%.tar.gz && del %BUILD%\pax_global_header
rename %BUILD%\restbed-%RESTBED_VERSION% restbed
rmdir /s /q %BUILD%\restbed\dependency
mkdir %BUILD%\restbed\dependency
cd %BUILD%\restbed\dependency
set ASIO_VERSION=276846097ab5073b67e772dbdfa12596224a54a5
set ASIO_URL=https://github.com/Corvusoft/asio-dependency/archive/%ASIO_VERSION%.tar.gz
if %USE_CACHE%==1 (
copy %CACHE_DIR%\%ASIO_VERSION%.tar.gz %cd%
) else (
wget %ASIO_URL%
)
7z -y x %ASIO_VERSION%.tar.gz && 7z -y x %ASIO_VERSION%.tar
del %ASIO_VERSION%.tar && del %ASIO_VERSION%.tar.gz && del pax_global_header
rename asio-dependency-%ASIO_VERSION% asio
cd asio
git apply --reject --whitespace=fix %SRC%\restbed\asio-uwp.patch
cd ..
set CATCH_VERSION=35f510545d55a831372d3113747bf1314ff4f2ef
set CATCH_URL=https://github.com/Corvusoft/catch-dependency/archive/%CATCH_VERSION%.tar.gz
if %USE_CACHE%==1 (
copy %CACHE_DIR%\%CATCH_VERSION%.tar.gz %cd%
) else (
wget %CATCH_URL%
)
7z -y x %CATCH_VERSION%.tar.gz && 7z -y x %CATCH_VERSION%.tar
del %CATCH_VERSION%.tar && del %CATCH_VERSION%.tar.gz && del pax_global_header
rename catch-dependency-%CATCH_VERSION% catch
set OPENSSL_VERSION=c7ba244789ce9f9b6675ff88e61dd5d5e5cac53e
set OPENSSL_URL=https://github.com/Microsoft/openssl/archive/%OPENSSL_VERSION%.tar.gz
if %USE_CACHE%==1 (
copy %CACHE_DIR%\%OPENSSL_VERSION%.tar.gz %cd%
) else (
wget %OPENSSL_URL%
)
7z -y x %OPENSSL_VERSION%.tar.gz && 7z -y x %OPENSSL_VERSION%.tar
del %OPENSSL_VERSION%.tar && del %OPENSSL_VERSION%.tar.gz && del pax_global_header
rename openssl-%OPENSSL_VERSION% openssl
set BUILD=%SRC%..\build
set RESTBED_VERSION=df867a858dddc4cf6ca8642da02720bd65ba239a
set RESTBED_URL=https://github.com/Corvusoft/restbed/archive/%RESTBED_VERSION%.tar.gz
mkdir %BUILD%
if %USE_CACHE%==1 (
copy %CACHE_DIR%\%RESTBED_VERSION%.tar.gz %cd%
) else (
wget %RESTBED_URL%
)
7z -y x %RESTBED_VERSION%.tar.gz && 7z -y x %RESTBED_VERSION%.tar -o%BUILD%
del %RESTBED_VERSION%.tar && del %RESTBED_VERSION%.tar.gz && del %BUILD%\pax_global_header
rename %BUILD%\restbed-%RESTBED_VERSION% restbed
cd %BUILD%\restbed
git apply --reject --whitespace=fix %SRC%\restbed\async_read_until-uwp.patch
git apply --reject --whitespace=fix %SRC%\restbed\cmake-uwp.patch
cd ..
rmdir /s /q %BUILD%\restbed\dependency
mkdir %BUILD%\restbed\dependency
cd %BUILD%\restbed\dependency
set ASIO_VERSION=276846097ab5073b67e772dbdfa12596224a54a5
set ASIO_URL=https://github.com/Corvusoft/asio-dependency/archive/%ASIO_VERSION%.tar.gz
if %USE_CACHE%==1 (
copy %CACHE_DIR%\%ASIO_VERSION%.tar.gz %cd%
) else (
wget %ASIO_URL%
)
7z -y x %ASIO_VERSION%.tar.gz && 7z -y x %ASIO_VERSION%.tar
del %ASIO_VERSION%.tar && del %ASIO_VERSION%.tar.gz && del pax_global_header
rename asio-dependency-%ASIO_VERSION% asio
cd asio
git apply --reject --whitespace=fix %SRC%\restbed\asio-uwp.patch
cd ..
set CATCH_VERSION=35f510545d55a831372d3113747bf1314ff4f2ef
set CATCH_URL=https://github.com/Corvusoft/catch-dependency/archive/%CATCH_VERSION%.tar.gz
if %USE_CACHE%==1 (
copy %CACHE_DIR%\%CATCH_VERSION%.tar.gz %cd%
) else (
wget %CATCH_URL%
)
7z -y x %CATCH_VERSION%.tar.gz && 7z -y x %CATCH_VERSION%.tar
del %CATCH_VERSION%.tar && del %CATCH_VERSION%.tar.gz && del pax_global_header
rename catch-dependency-%CATCH_VERSION% catch
set KASHMIR_VERSION=2f3913f49c4ac7f9bff9224db5178f6f8f0ff3ee
set KASHMIR_URL=https://github.com/corvusoft/kashmir-dependency/archive/%KASHMIR_VERSION%.tar.gz
if %USE_CACHE%==1 (
copy %CACHE_DIR%\%KASHMIR_VERSION%.tar.gz %cd%
) else (
wget %KASHMIR_URL%
)
7z -y x %KASHMIR_VERSION%.tar.gz && 7z -y x %KASHMIR_VERSION%.tar
del %KASHMIR_VERSION%.tar && del %KASHMIR_VERSION%.tar.gz && del pax_global_header
rename kashmir-dependency-%KASHMIR_VERSION% kashmir
cd %SRC%
\ No newline at end of file
......@@ -19,8 +19,8 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
RESTBED_VERSION := 4.6
RESTBED_URL := https://github.com/Corvusoft/restbed/archive/$(RESTBED_VERSION).tar.gz
RESTBED_VERSION := df867a858dddc4cf6ca8642da02720bd65ba239a
RESTBED_URL := https://github.com/corvusoft//restbed/archive/$(RESTBED_VERSION).tar.gz
PKGS += restbed
......@@ -49,7 +49,7 @@ restbed: restbed-$(RESTBED_VERSION).tar.gz kashmir.tar.gz .sum-restbed
mv kashmir-dependency-master $(UNPACK_DIR)/dependency/kashmir
$(APPLY) $(SRC)/restbed/findkashmir.patch
$(APPLY) $(SRC)/restbed/strand.patch
$(APPLY) $(SRC)/restbed/locale-fix.patch
$(APPLY) $(SRC)/restbed/async_read_until.patch
$(MOVE)
.restbed: restbed toolchain.cmake
......
--- a/source/corvusoft/restbed/detail/socket_impl.hpp 2016-09-28 12:01:30.415787179 -0400
--- a/source/corvusoft/restbed/detail/socket_impl.hpp 2016-09-28 12:01:33.329120391 -0400
@@ -23,3 +23,3 @@