Date: Tue, 28 Oct 2025 07:24:17 GMT From: Xavier Beaudouin <kiwi@FreeBSD.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org Subject: git: ef66c204e928 - main - www/domoticz: Update to 2025.2 Message-ID: <202510280724.59S7OHB7091939@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch main has been updated by kiwi: URL: https://cgit.FreeBSD.org/ports/commit/?id=ef66c204e928c62f3be42ccf771233e5bce2aca3 commit ef66c204e928c62f3be42ccf771233e5bce2aca3 Author: Xavier Beaudouin <kiwi@FreeBSD.org> AuthorDate: 2025-10-28 07:19:59 +0000 Commit: Xavier Beaudouin <kiwi@FreeBSD.org> CommitDate: 2025-10-28 07:22:34 +0000 www/domoticz: Update to 2025.2 This update domoticz to 2025.2. Changelog: Version 2025.2 (October 13th 2025) - Implemented: EnergyDashboard, add option for (Outside) Temperature Sensor - Implemented: Enever, Added Pure Energy, removed obsolete providers - Implemented: Enphase, display a error is a IQ inverter has not been received for more then a day - Implemented: Kodi, support for 'tvshow' type - Implemented: MQTT-AD, added support for Climate action_template/state - Implemented: MQTT-AD, added support for IR Blaster (Tuya iH-F8260) - Implemented: MQTT-AD, support for disabling cover stop button - Implemented: New Blinds type "Blinds + Stop" - Implemented: MQTT-AD, handling battery low boolean sensors - Implemented: MQTT-AD, allow publishing messages - Implemented: P1 Chart, Report: Added Total Column (Usage-Return) - Implemented: Rain Rate notification - Implemented: Support for Humidity only graph - Fixed: MQTT-AD, fix issue where brightness and RGB command topic are different - Fixed: MQTT-AD, preserve select options when updating a device - Fixed: Replace device now also copies 'Options' field - Changed: Enphase query Token method - Changed: mDNS, hostname now lowercase - Changed: MQTT-AD, added support for color_temp_command_template - Changed: TADO, Added fixed API endpoint - Changed: TADO, Add poll interval option - Changed: MQTT, not publishing devices that are not used - Changed: Philips Hue now uses HTTPS to be compliant with new Hue Bridge - Fixed: mDNS, possible crash when web server (non) SSL was disabled, or a invalid port was specified - Fixed: Charts, after deleting a datapoint, the browser was not correctly refreshed - Updated: Windows libraries Version 2025.1 (May 5th 2025) - Implemented: Battery level for Setpoint sensors - Implemented: Charts, zoom option for 'Day' view - Implemented: Data Pushers, added P1 actual value - Implemented: EnOcean, now able to choose an optional base_id as sender_id instead of the chip_id (#6213) - Implemented: Floorplan, Add support for stop button (Ventation blinds) - Implemented: RFXCom, Updated SDK - Implemented: Support for Honeywell Series 5/PIR - Implemented: Text sensor, now posible to edit direct from the GUI - Implemented: YouLess, added Water meter - Implemented: More default icons - Implemented: MQTT-AD, added support for Gas device class - Implemented: MQTT-AD, added support for Text device class - Implemented: MQTT-AD, better precision for kWh sensors - Implemented: MQTT-AD, enabled 'device_automation' component to be compatible with upcoming (2025) Zigbee2MQTT version - Implemented: MQTT-AD, handling single onoff color mode as a normal light/switch - Implemented: MQTT-AD, power sensors for the Tuya SPM02 - Implemented: MQTT-AD, support sensors that report humidity but sends 'null' values - Implemented: MQTT-AD, support for string field state objects - Implemented: MQTT Push 'Retained' mode option - Implemented: Rain devices can now be replacement with different types of rain devices - Implemented: RFXCom, Falmec Support - Implemented: RTL433, Support Generic Switch (Door) sensor - Implemented: Tado, oauth2 support - Changed: dzVents, possible to pass a Domoticz device ID in notify() through the extra parameter - Changed: Energy Dashboard now also available for non-admin users - Changed: Energy Dashboard, Text object clipping rectangle - Changed: Google Firebase Cloud Messaging (FCM) alternative way to pass a Domoticz device ID through the extra field ('|Device=<devidx>') - Changed: Internal webserver refactoring - Changed: Netatmo Improved and automated login process for devices (to obtain client ID and Password with user selectable scopes) - Changed: Removed Highcharts 'Download PNG/JPG/SVG' buttons until export server is fixed - Changed: Using OpenStreetMap for Latitude/Longitude query in settings - Changed: Hardware/User/Application/Variables setup page (update/delete/add buttons) - Changed: Smoke Detectors are now able (internally) to use keep-alive timestamps - Fixed: Application shutdown, solved possible crash (#6310) - Fixed: AtagOne, fixed getting device_id and better debuginfo - Fixed: Charts, dynamic title based on selected range - Fixed: Computed Meter summation - Fixed: Custom Icons, making sure they are valid and loaded OK - Fixed: Floorplan, corrected open/close icon behaviour - Fixed: Floorplan, now handles protected selectors - Fixed: MQTT Push, making sure direct push is working - Fixed: Possible mutex lock issue when logging - Fixed: Pushers, corrected Gas value rounding - Fixed: Python framework, invalid sValue when creating a General/kWh sensor - Fixed: RFXCom 868 MHz Weather device - Fixed: RFXCom, WS90 Weather device - Removed: Thermosmart thermostat (Product no longer supported/available by the manufacturer) - Removed: API: Old RType calls have been replaced - Updated: HighCharts - Updated: Self Signed Certificate (Valid till 2035) - Updated: Translations PR: 290321 Approved by: 0mp (mentor) --- www/domoticz/Makefile | 13 +- www/domoticz/distinfo | 6 +- www/domoticz/files/patch-CMakeLists.txt | 54 +- www/domoticz/files/patch-asio-deadline_timer | 20 - www/domoticz/files/patch-pr6252 | 2178 -------------------------- www/domoticz/pkg-plist | 57 +- 6 files changed, 89 insertions(+), 2239 deletions(-) diff --git a/www/domoticz/Makefile b/www/domoticz/Makefile index bfc14a878c90..77660aa2a477 100644 --- a/www/domoticz/Makefile +++ b/www/domoticz/Makefile @@ -1,6 +1,5 @@ PORTNAME= domoticz -DISTVERSION= 2024.7 -PORTREVISION= 4 +DISTVERSION= 2025.2 CATEGORIES= www MAINTAINER= kiwi@FreeBSD.org @@ -10,6 +9,8 @@ WWW= https://www.domoticz.com LICENSE= GPLv3 LICENSE_FILE= ${WRKSRC}/License.txt +BUILD_DEPENDS= ${LOCALBASE}/include/jwt-cpp/jwt.h:devel/jwt-cpp + LIB_DEPENDS= libcurl.so:ftp/curl \ libboost_thread.so:devel/boost-libs \ libjsoncpp.so:devel/jsoncpp \ @@ -27,7 +28,8 @@ CMAKE_OFF+= GIT_SUBMODULE \ USE_BUILTIN_MINIZIP \ USE_BUILTIN_JSONCPP \ USE_BUILTIN_MQTT \ - USE_STATIC_OPENZWAVE + USE_STATIC_OPENZWAVE \ + USE_BUILTIN_JWTCPP CMAKE_INSTALL_PREFIX= ${PREFIX}/domoticz @@ -51,11 +53,6 @@ PRECOMP_CMAKE_BOOL= USE_PRECOMPILED_HEADER PYTHON_USES= python:3.9+ PYTHON_CMAKE_BOOL= USE_PYTHON -post-patch: - @${REINPLACE_CMD} -e '/find_package/s| system||' \ - -e '/target_link_libraries/s| Boost::system||' \ - ${WRKSRC}/CMakeLists.txt - post-install: ${MKDIR} ${STAGEDIR}/var/db/domoticz ${STAGEDIR}/var/run/domoticz diff --git a/www/domoticz/distinfo b/www/domoticz/distinfo index 9df59baa0be1..a6ef79518ca2 100644 --- a/www/domoticz/distinfo +++ b/www/domoticz/distinfo @@ -1,3 +1,3 @@ -TIMESTAMP = 1735584809 -SHA256 (domoticz-domoticz-2024.7_GH0.tar.gz) = 6ceabbfe36ada4b7c2ebb42c523d723c87e6444b87db6bbb1703d92f38ee754d -SIZE (domoticz-domoticz-2024.7_GH0.tar.gz) = 13258596 +TIMESTAMP = 1761213053 +SHA256 (domoticz-domoticz-2025.2_GH0.tar.gz) = fd016f4ffe419e8d559bc0a7f9de5ec4fcaf485fc9d1464c8e8221102b13f589 +SIZE (domoticz-domoticz-2025.2_GH0.tar.gz) = 13418498 diff --git a/www/domoticz/files/patch-CMakeLists.txt b/www/domoticz/files/patch-CMakeLists.txt index 7585d271c86d..09961f6df8c5 100644 --- a/www/domoticz/files/patch-CMakeLists.txt +++ b/www/domoticz/files/patch-CMakeLists.txt @@ -1,6 +1,6 @@ ---- CMakeLists.txt.orig 2023-05-23 11:37:06.693431000 +0200 -+++ CMakeLists.txt 2023-05-23 11:37:14.422198000 +0200 -@@ -395,11 +395,9 @@ +--- CMakeLists.txt.orig 2025-10-13 11:42:57.000000000 +0200 ++++ CMakeLists.txt 2025-10-23 12:10:14.143268000 +0200 +@@ -417,7 +417,6 @@ # Target set( @@ -8,11 +8,7 @@ main/stdafx.cpp main/Helper.cpp main/CmdLine.cpp --main/domoticz_tester.cpp - main/BaroForecastCalculator.cpp - main/HTMLSanitizer.cpp - main/localtime_r.cpp -@@ -412,9 +410,6 @@ +@@ -434,9 +433,6 @@ #main/IFTTT.cpp @@ -22,7 +18,7 @@ # # LUA # -@@ -513,7 +508,6 @@ +@@ -535,7 +531,6 @@ # explicitly say that the executable depends on the revisiontag add_dependencies(domoticz revisiontag) @@ -30,7 +26,7 @@ TEST_BIG_ENDIAN(BIGENDIAN) IF(${BIGENDIAN}) -@@ -533,7 +527,6 @@ +@@ -555,7 +550,6 @@ set(JSONCPP_WITH_PKGCONFIG_SUPPORT OFF CACHE BOOL "Enable jsoncpp pkgconfig support" FORCE) add_subdirectory (extern/jsoncpp EXCLUDE_FROM_ALL) target_link_libraries(domoticz jsoncpp_static) @@ -38,7 +34,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/extern/jsoncpp/include) ELSE(USE_BUILTIN_JSONCPP) find_package(PkgConfig) -@@ -543,9 +536,6 @@ +@@ -565,9 +559,6 @@ target_include_directories(domoticz PRIVATE ${JSONCPP_INCLUDE_DIRS}) target_link_directories(domoticz PRIVATE ${JSONCPP_LIBRARY_DIRS}) target_link_libraries(domoticz ${JSONCPP_LIBRARIES}) @@ -48,7 +44,7 @@ ELSE(JSONCPP_FOUND) MESSAGE(FATAL_ERROR "JSONCPP not found on your system! try 'sudo apt-get install jsoncpp-dev'") ENDIF(JSONCPP_FOUND) -@@ -558,7 +548,6 @@ +@@ -580,7 +571,6 @@ option(DOCUMENTATION "Build documentation?" OFF) add_subdirectory (extern/mosquitto EXCLUDE_FROM_ALL) target_link_libraries(domoticz libmosquitto_static) @@ -56,7 +52,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/extern/mosquitto/include) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/extern/mosquitto/lib) ELSE(USE_BUILTIN_MQTT) -@@ -577,7 +566,6 @@ +@@ -599,7 +589,6 @@ MESSAGE(STATUS "Using builtin SQLite library") add_subdirectory (extern/sqlite-amalgamation EXCLUDE_FROM_ALL) target_link_libraries(domoticz SQLite3) @@ -64,7 +60,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/extern/sqlite-amalgamation) ELSE(USE_BUILTIN_SQLITE) find_package(SQLite3) -@@ -586,7 +574,6 @@ +@@ -608,7 +597,6 @@ MESSAGE(STATUS "SQLite includes found at: ${SQLite3_INCLUDE_DIRS}") INCLUDE_DIRECTORIES(${SQLite3_INCLUDE_DIRS}) target_link_libraries(domoticz ${SQLite3_LIBRARIES}) @@ -72,7 +68,7 @@ ELSE(SQLite3_FOUND) MESSAGE(FATAL_ERROR "SQLite3 not found on your system! try 'sudo apt-get install libsqlite3-dev'") ENDIF(SQLite3_FOUND) -@@ -596,7 +583,6 @@ +@@ -618,7 +606,6 @@ IF(USE_BUILTIN_MINIZIP) add_subdirectory (extern/minizip EXCLUDE_FROM_ALL) target_link_libraries(domoticz minizip) @@ -80,7 +76,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/extern/minizip) ELSE(USE_BUILTIN_MINIZIP) find_package(PkgConfig) -@@ -606,9 +592,6 @@ +@@ -628,9 +615,6 @@ target_include_directories(domoticz PRIVATE ${MINIZIP_INCLUDE_DIRS}) target_link_directories(domoticz PRIVATE ${MINIZIP_LIBRARY_DIRS}) target_link_libraries(domoticz ${MINIZIP_LIBRARIES}) @@ -90,7 +86,7 @@ ELSE(MINIZIP_FOUND) MESSAGE(FATAL_ERROR "MINIZIP not found on your system! try 'sudo apt-get install minizip-dev'") ENDIF(MINIZIP_FOUND) -@@ -630,7 +613,6 @@ +@@ -658,7 +642,6 @@ find_library(MD_LIBRARY NAMES md) IF(MD_LIBRARY) target_link_libraries(domoticz ${MD_LIBRARY}) @@ -98,7 +94,7 @@ ENDIF(MD_LIBRARY) ELSE() message(STATUS "OPENSSL library found at: ${OPENSSL_LIBRARIES}") -@@ -638,7 +620,6 @@ +@@ -666,7 +649,6 @@ add_definitions(-DWITH_TLS) include_directories(${OPENSSL_INCLUDE_DIR}) target_link_libraries(domoticz ${OPENSSL_LIBRARIES}) @@ -106,20 +102,20 @@ ENDIF() # -@@ -779,7 +760,6 @@ - ENDIF(TELLDUSCORE_INCLUDE) +@@ -804,7 +786,6 @@ + endif() - target_link_libraries(domoticz ${Boost_LIBRARIES} ${ZLIB_LIBRARIES} ${MINIZIP_LIBRARIES} ${CURL_LIBRARIES} pthread ${MQTT_LIBRARIES} ${LUA_LIBRARIES} ${CMAKE_DL_LIBS} ${TELLDUS_LIBRARIES}) --target_link_libraries(domoticztester ${Boost_LIBRARIES} ${ZLIB_LIBRARIES} ${MINIZIP_LIBRARIES} ${CURL_LIBRARIES} pthread ${MQTT_LIBRARIES} ${LUA_LIBRARIES} ${CMAKE_DL_LIBS} ${TELLDUS_LIBRARIES}) + target_link_libraries(domoticz ${Boost_LIBRARIES} ${ZLIB_LIBRARIES} ${MINIZIP_LIBRARIES} ${RESOLV_LIBRARIES} ${CURL_LIBRARIES} pthread ${MQTT_LIBRARIES} ${LUA_LIBRARIES} ${CMAKE_DL_LIBS} ${TELLDUS_LIBRARIES}) +-target_link_libraries(domoticztester ${Boost_LIBRARIES} ${ZLIB_LIBRARIES} ${MINIZIP_LIBRARIES} ${RESOLV_LIBRARIES} ${CURL_LIBRARIES} pthread ${MQTT_LIBRARIES} ${LUA_LIBRARIES} ${CMAKE_DL_LIBS} ${TELLDUS_LIBRARIES}) - IF(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - target_link_libraries(domoticz -lresolv) -@@ -789,13 +769,11 @@ + IF(EXECINFO_LIBRARIES) target_link_libraries(domoticz ${EXECINFO_LIBRARIES}) - ELSE() - target_link_libraries(domoticz -lrt -lresolv ${EXECINFO_LIBRARIES}) -- target_link_libraries(domoticztester -lrt -lresolv ${EXECINFO_LIBRARIES}) - ENDIF() +@@ -813,13 +794,11 @@ + find_library(LIBRT rt) + if(LIBRT) + target_link_libraries(domoticz -lrt) +- target_link_libraries(domoticztester -lrt) + endif() IF(USE_PRECOMPILED_HEADER) message(STATUS "Using precompiled headers") diff --git a/www/domoticz/files/patch-asio-deadline_timer b/www/domoticz/files/patch-asio-deadline_timer deleted file mode 100644 index ffb192872cf7..000000000000 --- a/www/domoticz/files/patch-asio-deadline_timer +++ /dev/null @@ -1,20 +0,0 @@ ---- webserver/cWebem.h.orig 2024-07-13 14:59:31 UTC -+++ webserver/cWebem.h -@@ -1,6 +1,7 @@ - #pragma once - - #include <boost/asio.hpp> -+#include <boost/asio/deadline_timer.hpp> - #include <boost/thread.hpp> - #include "server.hpp" - #include "session_store.hpp" ---- webserver/connection.hpp.orig 2024-07-13 14:59:31 UTC -+++ webserver/connection.hpp -@@ -12,6 +12,7 @@ - #define HTTP_CONNECTION_HPP - - #include <boost/asio.hpp> -+#include <boost/asio/deadline_timer.hpp> - #include <deque> - #include <fstream> - #include "reply.hpp" diff --git a/www/domoticz/files/patch-pr6252 b/www/domoticz/files/patch-pr6252 deleted file mode 100644 index 34c4efd3f4e4..000000000000 --- a/www/domoticz/files/patch-pr6252 +++ /dev/null @@ -1,2178 +0,0 @@ -Fix for boost 1.87 - -Removed the diff for the msbuild project files, didn't apply cleanly and not relevant anyway. -This will merged in the next stable of domoticz. - -Pullrequest: https://github.com/domoticz/domoticz/pull/6252 -Patch: https://patch-diff.githubusercontent.com/raw/domoticz/domoticz/pull/6252.patch-diff - -diff --git hardware/ASyncSerial.cpp hardware/ASyncSerial.cpp -index 52c950d..6147cdb 100644 ---- hardware/ASyncSerial.cpp -+++ hardware/ASyncSerial.cpp -@@ -54,7 +54,7 @@ public: - { - } - -- boost::asio::io_service io; ///< Io service object -+ boost::asio::io_context io; ///< Io service object - boost::asio::serial_port port; ///< Serial port object - boost::thread backgroundThread; ///< Thread that runs read/write operations - bool open{ false }; ///< True if port open -@@ -117,10 +117,10 @@ void AsyncSerial::open(const std::string& devname, unsigned int baud_rate, - throw; - } - -- pimpl->io.reset(); -+ pimpl->io.restart(); - -- // This gives some work to the io_service before it is started -- pimpl->io.post([this] { return doRead(); }); -+ // This gives some work to the io_context before it is started -+ boost::asio::post(pimpl->io, [this] { return doRead(); }); - - boost::thread t([p = &pimpl->io] { p->run(); }); - pimpl->backgroundThread.swap(t); -@@ -149,10 +149,10 @@ void AsyncSerial::openOnlyBaud(const std::string& devname, unsigned int baud_rat - throw; - } - -- pimpl->io.reset(); -+ pimpl->io.restart(); - -- //This gives some work to the io_service before it is started -- pimpl->io.post([this] { return doRead(); }); -+ //This gives some work to the io_context before it is started -+ boost::asio::post(pimpl->io, [this] { return doRead(); }); - - boost::thread t([p = &pimpl->io] { p->run(); }); - pimpl->backgroundThread.swap(t); -@@ -176,9 +176,9 @@ void AsyncSerial::close() - if(!isOpen()) return; - - pimpl->open = false; -- pimpl->io.post([this] { doClose(); }); -+ boost::asio::post(pimpl->io, [this] { doClose(); }); - pimpl->backgroundThread.join(); -- pimpl->io.reset(); -+ pimpl->io.restart(); - if(errorStatus()) - { - throw(boost::system::system_error(boost::system::error_code(), -@@ -192,7 +192,7 @@ void AsyncSerial::write(const char *data, size_t size) - std::lock_guard<std::mutex> l(pimpl->writeQueueMutex); - pimpl->writeQueue.insert(pimpl->writeQueue.end(),data,data+size); - } -- pimpl->io.post([this] { doWrite(); }); -+ boost::asio::post(pimpl->io, [this] { doWrite(); }); - } - - void AsyncSerial::write(const std::string &data) -@@ -201,7 +201,7 @@ void AsyncSerial::write(const std::string &data) - std::lock_guard<std::mutex> l(pimpl->writeQueueMutex); - pimpl->writeQueue.insert(pimpl->writeQueue.end(), data.c_str(), data.c_str()+data.size()); - } -- pimpl->io.post([this] { doWrite(); }); -+ boost::asio::post(pimpl->io, [this] { doWrite(); }); - } - - void AsyncSerial::write(const std::vector<char>& data) -@@ -211,7 +211,7 @@ void AsyncSerial::write(const std::vector<char>& data) - pimpl->writeQueue.insert(pimpl->writeQueue.end(),data.begin(), - data.end()); - } -- pimpl->io.post([this] { doWrite(); }); -+ boost::asio::post(pimpl->io, [this] { doWrite(); }); - } - - void AsyncSerial::writeString(const std::string& s) -@@ -220,7 +220,7 @@ void AsyncSerial::writeString(const std::string& s) - std::lock_guard<std::mutex> l(pimpl->writeQueueMutex); - pimpl->writeQueue.insert(pimpl->writeQueue.end(),s.begin(),s.end()); - } -- pimpl->io.post([this] { doWrite(); }); -+ boost::asio::post(pimpl->io, [this] { doWrite(); }); - } - - void AsyncSerial::doRead() -diff --git hardware/ASyncSerial.h hardware/ASyncSerial.h -index 0a51ef0..de83f8a 100644 ---- hardware/ASyncSerial.h -+++ hardware/ASyncSerial.h -@@ -123,27 +123,27 @@ class AsyncSerial : private domoticz::noncopyable - - /** - * Callback called to start an asynchronous read operation. -- * This callback is called by the io_service in the spawned thread. -+ * This callback is called by the io_context in the spawned thread. - */ - void doRead(); - - /** - * Callback called at the end of the asynchronous operation. -- * This callback is called by the io_service in the spawned thread. -+ * This callback is called by the io_context in the spawned thread. - */ - void readEnd(const boost::system::error_code &error, size_t bytes_transferred); - - /** - * Callback called to start an asynchronous write operation. - * If it is already in progress, does nothing. -- * This callback is called by the io_service in the spawned thread. -+ * This callback is called by the io_context in the spawned thread. - */ - void doWrite(); - - /** - * Callback called at the end of an asynchronuous write operation, - * if there is more data to write, restarts a new write operation. -- * This callback is called by the io_service in the spawned thread. -+ * This callback is called by the io_context in the spawned thread. - */ - void writeEnd(const boost::system::error_code &error); - -diff --git hardware/ASyncTCP.cpp hardware/ASyncTCP.cpp -index a375561..7c3b536 100644 ---- hardware/ASyncTCP.cpp -+++ hardware/ASyncTCP.cpp -@@ -4,213 +4,241 @@ - #include <boost/system/error_code.hpp> // for error_code - #include "../main/Logger.h" - --struct hostent; -- - #define MAX_TCP_BUFFER_SIZE 4096 - --#ifndef WIN32 -- #include <unistd.h> //gethostbyname --#endif -- - #define STATUS_OK(err) !err -- --ASyncTCP::ASyncTCP(const bool secure) -+#define STATUS_ERR(err) err -+ -+ASyncTCP::ASyncTCP(const bool secure) : -+ m_Tcpwork(boost::asio::make_work_guard(m_io_context)) -+ , m_Socket(m_io_context) -+ , m_Resolver(m_io_context) -+ , m_ReconnectTimer(m_io_context) -+ , m_TimeoutTimer(m_io_context) -+ , m_SendStrand(m_io_context) - #ifdef WWW_ENABLE_SSL -- : mSecure(secure) -+ , m_bSecure(secure) - #endif - { - m_pRXBuffer = new uint8_t[MAX_TCP_BUFFER_SIZE]; - #ifdef WWW_ENABLE_SSL - mContext.set_verify_mode(boost::asio::ssl::verify_none); -- if (mSecure) -+ if (m_bSecure) - { -- mSslSocket.reset(new boost::asio::ssl::stream<boost::asio::ip::tcp::socket>(mIos, mContext)); -+ m_SslSocket.reset(new boost::asio::ssl::stream<boost::asio::ip::tcp::socket>(m_io_context, mContext)); - } - #endif - } - - ASyncTCP::~ASyncTCP() - { -- assert(mTcpthread == nullptr); -- mIsTerminating = true; -- if (mTcpthread) -+ assert(m_Tcpthread == nullptr); -+ m_bIsTerminating = true; -+ if (m_Tcpthread) - { - //This should never happen. terminate() never called!! -- _log.Log(LOG_ERROR, "ASyncTCP: Workerthread not closed. terminate() never called!!!"); -- mIos.stop(); -- if (mTcpthread) -+ _log.Log(LOG_ERROR, "ASyncTCP: Worker thread not closed. terminate() never called!!!"); -+ m_io_context.stop(); -+ if (m_Tcpthread) - { -- mTcpthread->join(); -- mTcpthread.reset(); -+ m_Tcpthread->join(); -+ m_Tcpthread.reset(); - } - } - if (m_pRXBuffer != nullptr) - delete[] m_pRXBuffer; - } - --void ASyncTCP::SetReconnectDelay(int32_t Delay) -+void ASyncTCP::SetReconnectDelay(const int32_t Delay) - { -- mReconnectDelay = Delay; -+ m_iReconnectDelay = Delay; - } - - void ASyncTCP::connect(const std::string& ip, uint16_t port) - { -- assert(!mSocket.is_open()); -- if (mSocket.is_open()) -+ assert(!m_Socket.is_open()); -+ if (m_Socket.is_open()) - { - _log.Log(LOG_ERROR, "ASyncTCP: connect called while socket is still open. !!!"); - terminate(); - } - -- // RK: We reset mIos here because it might have been stopped in terminate() -- mIos.reset(); -- // RK: After the reset, we need to provide it work anew -- mTcpwork = std::make_shared<boost::asio::io_service::work>(mIos); -- if (!mTcpthread) -- mTcpthread = std::make_shared<std::thread>([p = &mIos] { p->run(); }); -- -- mIp = ip; -- mPort = port; -+ m_IP = ip; -+ m_Port = port; - std::string port_str = std::to_string(port); -- boost::asio::ip::tcp::resolver::query query(ip, port_str); - timeout_start_timer(); -- mResolver.async_resolve(query, [this](auto &&err, auto &&iter) { cb_resolve_done(err, iter); }); -+ -+ m_Resolver.async_resolve( -+ ip, port_str, -+ [this](const boost::system::error_code& error, const boost::asio::ip::tcp::resolver::results_type& endpoints) { -+ handle_resolve(error, endpoints); -+ } -+ ); -+ -+ // RK: We restart m_io_context here because it might have been stopped in terminate() -+ m_io_context.restart(); -+ // RK: After the reset, we need to provide it work anew -+ m_Tcpwork.reset(); -+ m_Tcpwork.emplace(boost::asio::make_work_guard(m_io_context)); -+ if (!m_Tcpthread) -+ m_Tcpthread = std::make_shared<std::thread>([p = &m_io_context] { p->run(); }); - } - --void ASyncTCP::cb_resolve_done(const boost::system::error_code& error, boost::asio::ip::tcp::resolver::iterator endpoint_iterator) -+void ASyncTCP::handle_resolve(const boost::system::error_code& error, const boost::asio::ip::tcp::resolver::results_type &endpoints) - { -- if (mIsTerminating) return; -+ if (m_bIsTerminating) return; - -- if (STATUS_OK(error)) -- { -- connect_start(endpoint_iterator); -- } -- else -+ if (STATUS_ERR(error)) - { - process_error(error); -+ return; - } --} -- --void ASyncTCP::connect_start(boost::asio::ip::tcp::resolver::iterator& endpoint_iterator) --{ -- if (mIsConnected) return; -- -- mEndPoint = *endpoint_iterator++; -+ if (m_bIsConnected) return; - - timeout_start_timer(); -+ - #ifdef WWW_ENABLE_SSL -- if (mSecure) -+ if (m_bSecure) - { - // we reset the ssl socket, because the ssl context needs to be reinitialized after a reconnect -- mSslSocket.reset(new boost::asio::ssl::stream<boost::asio::ip::tcp::socket>(mIos, mContext)); -- mSslSocket->lowest_layer().async_connect(mEndPoint, [this, endpoint_iterator](auto &&err) mutable { cb_connect_done(err, endpoint_iterator); }); -+ m_SslSocket.reset(new boost::asio::ssl::stream<boost::asio::ip::tcp::socket>(m_io_context, mContext)); -+ boost::asio::async_connect(m_SslSocket->lowest_layer(), endpoints, -+ [this](const boost::system::error_code& error, const boost::asio::ip::tcp::endpoint& endpoint) -+ { -+ handle_connect(error, endpoint); -+ } -+ ); - } - else - #endif - { -- mSocket.async_connect(mEndPoint, [this, endpoint_iterator](auto &&err) mutable { cb_connect_done(err, endpoint_iterator); }); -+ boost::asio::async_connect(m_Socket, endpoints, -+ [this](const boost::system::error_code& error, const boost::asio::ip::tcp::endpoint& endpoint) -+ { -+ handle_connect(error, endpoint); -+ } -+ ); - } - } - --void ASyncTCP::cb_connect_done(const boost::system::error_code& error, boost::asio::ip::tcp::resolver::iterator &endpoint_iterator) -+void ASyncTCP::handle_connect(const boost::system::error_code& error, const boost::asio::ip::tcp::endpoint& /*endpoint*/) - { -- if (mIsTerminating) return; -+ if (m_bIsTerminating) return; - -- if (STATUS_OK(error)) -+ if (STATUS_ERR(error)) - { -+ process_error(error); -+ return; -+ } - #ifdef WWW_ENABLE_SSL -- if (mSecure) -- { -- timeout_start_timer(); -- mSslSocket->async_handshake(boost::asio::ssl::stream_base::client, [this](auto &&err) { cb_handshake_done(err); }); -- } -- else --#endif -- { -- process_connection(); -- } -+ if (m_bSecure) -+ { -+ timeout_start_timer(); -+ m_SslSocket->async_handshake(boost::asio::ssl::stream_base::client, -+ [this](const boost::system::error_code& error) { -+ cb_handshake_done(error); -+ } -+ ); - } -- else -+ else -+#endif - { -- if (endpoint_iterator != boost::asio::ip::tcp::resolver::iterator()) -- { -- // The connection failed. Try the next endpoint in the list. -- connect_start(endpoint_iterator); -- return; -- } -- process_error(error); -+ process_connection(); - } - } - - #ifdef WWW_ENABLE_SSL - void ASyncTCP::cb_handshake_done(const boost::system::error_code& error) - { -- if (mIsTerminating) return; -+ if (m_bIsTerminating) return; - -- if (STATUS_OK(error)) -- { -- process_connection(); -- } -- else -+ if (STATUS_ERR(error)) - { - process_error(error); -+ return; - } -+ process_connection(); -+#endif - } -+ -+void ASyncTCP::process_connection() -+{ -+ m_bIsConnected = true; -+#ifdef WWW_ENABLE_SSL -+ -+ if (!m_bSecure) - #endif -+ { -+ // RK: only if non-secure -+ boost::asio::socket_base::keep_alive option(true); -+ m_Socket.set_option(option); -+ } -+ OnConnect(); -+ do_read_start(); -+ do_write_start(); -+} - - void ASyncTCP::reconnect_start_timer() - { -- if (mIsReconnecting) return; -+ if (m_bIsReconnecting) return; - -- if (mReconnectDelay != 0) -+ if (m_iReconnectDelay != 0) - { -- mIsReconnecting = true; -- -- mReconnectTimer.expires_from_now(boost::posix_time::seconds(mReconnectDelay)); -- mReconnectTimer.async_wait([this](auto &&err) { cb_reconnect_start(err); }); -+ m_bIsReconnecting = true; -+ -+ m_ReconnectTimer.expires_from_now(boost::posix_time::seconds(m_iReconnectDelay)); -+ m_ReconnectTimer.async_wait( -+ [this](const boost::system::error_code& error) { -+ cb_reconnect_start(error); -+ } -+ ); - } - } - - void ASyncTCP::cb_reconnect_start(const boost::system::error_code& error) - { -- mIsReconnecting = false; -- mReconnectTimer.cancel(); -- mTimeoutTimer.cancel(); -+ m_bIsReconnecting = false; -+ m_ReconnectTimer.cancel(); -+ m_TimeoutTimer.cancel(); - -- if (mIsConnected) return; -+ if (m_bIsConnected) return; - if (error) return; // timer was cancelled - - do_close(); -- connect(mIp, mPort); -+ connect(m_IP, m_Port); - } - - - void ASyncTCP::terminate(const bool silent) - { -- mIsTerminating = true; -+ m_bIsTerminating = true; - disconnect(silent); -- mTcpwork.reset(); -- mIos.stop(); -- if (mTcpthread) -+ m_Tcpwork.reset(); -+ m_io_context.stop(); -+ if (m_Tcpthread) - { -- mTcpthread->join(); -- mTcpthread.reset(); -+ m_Tcpthread->join(); -+ m_Tcpthread.reset(); - } -- mIsReconnecting = false; -- mIsConnected = false; -- mWriteQ.clear(); -- mIsTerminating = false; -+ m_bIsReconnecting = false; -+ m_bIsConnected = false; -+ m_WriteQ.clear(); -+ m_bIsTerminating = false; - } - - void ASyncTCP::disconnect(const bool silent) - { -- mReconnectTimer.cancel(); -- mTimeoutTimer.cancel(); -- if (!mTcpthread) return; -+ m_ReconnectTimer.cancel(); -+ m_TimeoutTimer.cancel(); -+ if (!m_Tcpthread) return; - - try - { -- mIos.post([this] { do_close(); }); -+ boost::asio::post(m_io_context, -+ [this] { -+ do_close(); -+ } -+ ); - } - catch (...) - { -@@ -223,62 +251,68 @@ void ASyncTCP::disconnect(const bool silent) - - void ASyncTCP::do_close() - { -- if (mIsReconnecting) { -+ if (m_bIsReconnecting) { - return; - } -- mReconnectTimer.cancel(); -- mTimeoutTimer.cancel(); -+ m_ReconnectTimer.cancel(); -+ m_TimeoutTimer.cancel(); - boost::system::error_code ec; - #ifdef WWW_ENABLE_SSL -- if (mSecure) -+ if (m_bSecure) - { -- if (mSslSocket->lowest_layer().is_open()) -+ if (m_SslSocket->lowest_layer().is_open()) - { -- mSslSocket->lowest_layer().shutdown(boost::asio::ip::tcp::socket::shutdown_both, ec); -- mSslSocket->lowest_layer().close(ec); -+ m_SslSocket->lowest_layer().shutdown(boost::asio::ip::tcp::socket::shutdown_both, ec); -+ m_SslSocket->lowest_layer().close(ec); - } - } - else - #endif - { -- if (mSocket.is_open()) -+ if (m_Socket.is_open()) - { -- mSocket.close(ec); -+ m_Socket.close(ec); - } - } - } - - void ASyncTCP::do_read_start() - { -- if (mIsTerminating) return; -- if (!mIsConnected) return; -+ if (m_bIsTerminating) return; -+ if (!m_bIsConnected) return; - - timeout_start_timer(); - #ifdef WWW_ENABLE_SSL -- if (mSecure) -+ if (m_bSecure) - { -- mSslSocket->async_read_some(boost::asio::buffer(m_pRXBuffer, MAX_TCP_BUFFER_SIZE), [this](auto &&err, auto bytes) { cb_read_done(err, bytes); }); -+ m_SslSocket->async_read_some(boost::asio::buffer(m_pRXBuffer, MAX_TCP_BUFFER_SIZE), -+ [this](const boost::system::error_code& error, size_t bytes_transferred) { -+ cb_read_done(error, bytes_transferred); -+ } -+ ); - } - else - #endif - { -- mSocket.async_read_some(boost::asio::buffer(m_pRXBuffer, MAX_TCP_BUFFER_SIZE), [this](auto &&err, auto bytes) { cb_read_done(err, bytes); }); -+ m_Socket.async_read_some(boost::asio::buffer(m_pRXBuffer, MAX_TCP_BUFFER_SIZE), -+ [this](const boost::system::error_code& error, size_t bytes_transferred) { -+ cb_read_done(error, bytes_transferred); -+ } -+ ); - } - } - - void ASyncTCP::cb_read_done(const boost::system::error_code& error, size_t bytes_transferred) - { -- if (mIsTerminating) return; -+ if (m_bIsTerminating) return; - -- if (STATUS_OK(error)) -- { -- OnData(m_pRXBuffer, bytes_transferred); -- do_read_start(); -- } -- else -+ if (STATUS_ERR(error)) - { - process_error(error); -+ return; - } -+ OnData(m_pRXBuffer, bytes_transferred); -+ do_read_start(); - } - - void ASyncTCP::write(const uint8_t* pData, size_t length) -@@ -288,77 +322,66 @@ void ASyncTCP::write(const uint8_t* pData, size_t length) - - void ASyncTCP::write(const std::string& msg) - { -- if (!mTcpthread) return; -+ if (!m_Tcpthread) return; - -- mSendStrand.post([this, msg]() { cb_write_queue(msg); }); -+ boost::asio::post(m_SendStrand, [this, msg]() { cb_write_queue(msg); }); - } - - void ASyncTCP::cb_write_queue(const std::string& msg) - { -- mWriteQ.push_back(msg); -+ m_WriteQ.push_back(msg); - -- if (mWriteQ.size() == 1) -+ if (m_WriteQ.size() == 1) - do_write_start(); - } - - void ASyncTCP::do_write_start() - { -- if (mIsTerminating) return; -- if (!mIsConnected) return; -- if (mWriteQ.empty()) -+ if (m_bIsTerminating) return; -+ if (!m_bIsConnected) return; -+ if (m_WriteQ.empty()) - return; - - timeout_start_timer(); - #ifdef WWW_ENABLE_SSL -- if (mSecure) -+ if (m_bSecure) - { -- boost::asio::async_write(*mSslSocket, boost::asio::buffer(mWriteQ.front()), [this](auto &&err, auto) { cb_write_done(err); }); -+ boost::asio::async_write(*m_SslSocket, boost::asio::buffer(m_WriteQ.front()), -+ [this](const boost::system::error_code& error, std::size_t length) { -+ cb_write_done(error, length); -+ } -+ ); - } - else - #endif - { -- boost::asio::async_write(mSocket, boost::asio::buffer(mWriteQ.front()), [this](auto &&err, auto) { cb_write_done(err); }); -+ boost::asio::async_write(m_Socket, boost::asio::buffer(m_WriteQ.front()), -+ [this](const boost::system::error_code& error, std::size_t length) { -+ cb_write_done(error, length); -+ } -+ ); - } - } - --void ASyncTCP::cb_write_done(const boost::system::error_code& error) -+void ASyncTCP::cb_write_done(const boost::system::error_code& error, std::size_t /*length*/) - { -- if (mIsTerminating) return; -+ if (m_bIsTerminating) return; - -- if (STATUS_OK(error)) -- { -- mWriteQ.pop_front(); -- do_write_start(); -- } -- else -+ if (STATUS_ERR(error)) - { - process_error(error); -+ return; - } *** 1718 LINES SKIPPED ***home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202510280724.59S7OHB7091939>
