From 3a9cc78a2102172f1439f7c9767e8c20ce694e06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Fri, 1 Jun 2018 12:29:04 +0200 Subject: Make the global ad-hoc configure command available in fixed mode --- CHANGELOG.rst | 6 ++++ src/xmpp/biboumi_component.cpp | 11 ++++++-- tests/end_to_end/__main__.py | 63 ++++++++++++++++++++++++++++++------------ 3 files changed, 59 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index cd7c4a1..379841c 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,3 +1,9 @@ +Version 8.3 +=========== + +- The global ad-hoc configure command is now available on biboumi’s JID in + fixed_irc_server mode. + Version 8.2 - 2018-05-23 ======================== diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp index dbaf8a4..be34873 100644 --- a/src/xmpp/biboumi_component.cpp +++ b/src/xmpp/biboumi_component.cpp @@ -72,11 +72,16 @@ BiboumiComponent::BiboumiComponent(std::shared_ptr& poller, const std::s AdhocCommand configure_global_command({&ConfigureGlobalStep1, &ConfigureGlobalStep2}, "Configure a few settings", false); if (!Config::get("fixed_irc_server", "").empty()) - this->adhoc_commands_handler.add_command("configure", configure_server_command); + { + this->adhoc_commands_handler.add_command("server-configure", configure_server_command); + this->adhoc_commands_handler.add_command("global-configure", configure_global_command); + } else - this->adhoc_commands_handler.add_command("configure", configure_global_command); + { + this->adhoc_commands_handler.add_command("configure", configure_global_command); + this->irc_server_adhoc_commands_handler.add_command("configure", configure_server_command); + } - this->irc_server_adhoc_commands_handler.add_command("configure", configure_server_command); this->irc_channel_adhoc_commands_handler.add_command("configure", {{&ConfigureIrcChannelStep1, &ConfigureIrcChannelStep2}, "Configure a few settings for that IRC channel", false}); #endif } diff --git a/tests/end_to_end/__main__.py b/tests/end_to_end/__main__.py index f8ef2d4..a029bea 100644 --- a/tests/end_to_end/__main__.py +++ b/tests/end_to_end/__main__.py @@ -891,28 +891,35 @@ if __name__ == '__main__': handshake_sequence(), partial(send_stanza, ""), partial(expect_stanza, ("/iq[@type='result']/disco_items:query[@node='http://jabber.org/protocol/commands']", - "/iq/disco_items:query/disco_items:item[3]")), + "/iq/disco_items:query/disco_items:item[@node='configure']", + "/iq/disco_items:query/disco_items:item[4]", + "!/iq/disco_items:query/disco_items:item[5]")), ]), Scenario("list_admin_adhoc", [ handshake_sequence(), partial(send_stanza, ""), partial(expect_stanza, ("/iq[@type='result']/disco_items:query[@node='http://jabber.org/protocol/commands']", - "/iq/disco_items:query/disco_items:item[5]")), + "/iq/disco_items:query/disco_items:item[6]", + "!/iq/disco_items:query/disco_items:item[7]")), ]), Scenario("list_adhoc_fixed_server", [ handshake_sequence(), partial(send_stanza, ""), partial(expect_stanza, ("/iq[@type='result']/disco_items:query[@node='http://jabber.org/protocol/commands']", - "/iq/disco_items:query/disco_items:item[5]")), + "/iq/disco_items:query/disco_items:item[@node='global-configure']", + "/iq/disco_items:query/disco_items:item[@node='server-configure']", + "/iq/disco_items:query/disco_items:item[6]", + "!/iq/disco_items:query/disco_items:item[7]")), ], conf='fixed_server'), Scenario("list_admin_adhoc_fixed_server", [ handshake_sequence(), partial(send_stanza, ""), partial(expect_stanza, ("/iq[@type='result']/disco_items:query[@node='http://jabber.org/protocol/commands']", - "/iq/disco_items:query/disco_items:item[5]")), + "/iq/disco_items:query/disco_items:item[8]", + "!/iq/disco_items:query/disco_items:item[9]")), ], conf='fixed_server'), Scenario("list_adhoc_irc", [ @@ -921,20 +928,6 @@ if __name__ == '__main__': partial(expect_stanza, ("/iq[@type='result']/disco_items:query[@node='http://jabber.org/protocol/commands']", "/iq/disco_items:query/disco_items:item[2]")), ]), - Scenario("list_adhoc_irc_fixed_server", - [ - handshake_sequence(), - partial(send_stanza, ""), - partial(expect_stanza, ("/iq[@type='result']/disco_items:query[@node='http://jabber.org/protocol/commands']", - "/iq/disco_items:query/disco_items:item[4]")), - ], conf='fixed_server'), - Scenario("list_admin_adhoc_irc_fixed_server", - [ - handshake_sequence(), - partial(send_stanza, ""), - partial(expect_stanza, ("/iq[@type='result']/disco_items:query[@node='http://jabber.org/protocol/commands']", - "/iq/disco_items:query/disco_items:item[6]")), - ], conf='fixed_server'), Scenario("list_muc_user_adhoc", [ handshake_sequence(), @@ -2807,6 +2800,40 @@ if __name__ == '__main__': partial(send_stanza, ""), partial(expect_stanza, "/iq[@type='result']/commands:command[@node='configure'][@status='canceled']"), ]), + Scenario("global_configure_fixed", + [ + handshake_sequence(), + partial(send_stanza, ""), + partial(expect_stanza, ("/iq[@type='result']/commands:command[@node='global-configure'][@sessionid][@status='executing']", + "/iq/commands:command/dataform:x[@type='form']/dataform:title[text()='Configure some global default settings.']", + "/iq/commands:command/dataform:x[@type='form']/dataform:instructions[text()='Edit the form, to configure your global settings for the component.']", + "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='max_history_length']/dataform:value[text()='20']", + "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='boolean'][@var='record_history']/dataform:value[text()='true']", + "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='boolean'][@var='persistent']/dataform:value[text()='false']", + "/iq/commands:command/commands:actions/commands:next", + ), + after = partial(save_value, "sessionid", partial(extract_attribute, "/iq[@type='result']/commands:command[@node='global-configure']", "sessionid")) + ), + partial(send_stanza, "042"), + partial(expect_stanza, "/iq[@type='result']/commands:command[@node='global-configure'][@status='completed']/commands:note[@type='info'][text()='Configuration successfully applied.']"), + + partial(send_stanza, ""), + partial(expect_stanza, ("/iq[@type='result']/commands:command[@node='global-configure'][@sessionid][@status='executing']", + "/iq/commands:command/dataform:x[@type='form']/dataform:title[text()='Configure some global default settings.']", + "/iq/commands:command/dataform:x[@type='form']/dataform:instructions[text()='Edit the form, to configure your global settings for the component.']", + "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='max_history_length']/dataform:value[text()='42']", + "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='boolean'][@var='record_history']/dataform:value[text()='false']", + "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='boolean'][@var='persistent']/dataform:value[text()='false']", + "/iq/commands:command/commands:actions/commands:next", + ), + after = partial(save_value, "sessionid", partial(extract_attribute, "/iq[@type='result']/commands:command[@node='global-configure']", "sessionid")) + ), + partial(send_stanza, ""), + partial(expect_stanza, "/iq[@type='result']/commands:command[@node='global-configure'][@status='canceled']"), + + partial(send_stanza, ""), + partial(expect_stanza, ("/iq[@type='result']/commands:command[@node='server-configure'][@sessionid][@status='executing']",)) + ], conf='fixed_server'), Scenario("global_configure_persistent_by_default", [ handshake_sequence(), -- cgit v1.2.3 From ab7d1bbf02b40b1171d457961d8a082e0b6b5216 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Fri, 1 Jun 2018 12:43:34 +0200 Subject: Release version 8.3 --- CHANGELOG.rst | 4 ++-- CMakeLists.txt | 2 +- packaging/biboumi.spec.cmake | 5 ++++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 379841c..45c13bd 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,5 +1,5 @@ -Version 8.3 -=========== +Version 8.3 - 2018-06-01 +======================== - The global ad-hoc configure command is now available on biboumi’s JID in fixed_irc_server mode. diff --git a/CMakeLists.txt b/CMakeLists.txt index 26f2f11..abfd334 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.0) project(biboumi) set(${PROJECT_NAME}_VERSION_MAJOR 8) -set(${PROJECT_NAME}_VERSION_MINOR 2) +set(${PROJECT_NAME}_VERSION_MINOR 3) set(${PROJECT_NAME}_VERSION_SUFFIX "") if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") diff --git a/packaging/biboumi.spec.cmake b/packaging/biboumi.spec.cmake index d658c55..5950930 100644 --- a/packaging/biboumi.spec.cmake +++ b/packaging/biboumi.spec.cmake @@ -63,8 +63,11 @@ make check %{?_smp_mflags} %changelog +* Wed Jun 1 2018 Le Coz Florent - 8.3-1 + Update to version 8.3 + * Wed May 25 2018 Le Coz Florent - 8.2-1 - Update to version 8.1 + Update to version 8.2 * Wed May 14 2018 Le Coz Florent - 8.1-1 Update to version 8.1 -- cgit v1.2.3 From b18d81ae9faf6adcf4020680bc5d874bf92848c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Tue, 25 Feb 2020 22:52:58 +0100 Subject: Fix a typo in a function name (match_pairt) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It’s totally harmless --- src/identd/identd_socket.cpp | 2 +- src/network/tcp_client_socket_handler.cpp | 2 +- src/network/tcp_client_socket_handler.hpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/identd/identd_socket.cpp b/src/identd/identd_socket.cpp index 92cd80b..422c5c0 100644 --- a/src/identd/identd_socket.cpp +++ b/src/identd/identd_socket.cpp @@ -47,7 +47,7 @@ std::string IdentdSocket::generate_answer(const BiboumiComponent& biboumi, uint1 { for (const auto& pair: bridge->get_irc_clients()) { - if (pair.second->match_port_pairt(local, remote)) + if (pair.second->match_port_pair(local, remote)) { std::ostringstream os; os << local << " , " << remote << " : USERID : OTHER : " << hash_jid(bridge->get_bare_jid()) << "\r\n"; diff --git a/src/network/tcp_client_socket_handler.cpp b/src/network/tcp_client_socket_handler.cpp index 9dda73d..e5b1b75 100644 --- a/src/network/tcp_client_socket_handler.cpp +++ b/src/network/tcp_client_socket_handler.cpp @@ -261,7 +261,7 @@ std::string TCPClientSocketHandler::get_port() const return this->port; } -bool TCPClientSocketHandler::match_port_pairt(const uint16_t local, const uint16_t remote) const +bool TCPClientSocketHandler::match_port_pair(const uint16_t local, const uint16_t remote) const { const auto remote_port = static_cast(std::stoi(this->port)); return this->is_connected() && local == this->local_port && remote == remote_port; diff --git a/src/network/tcp_client_socket_handler.hpp b/src/network/tcp_client_socket_handler.hpp index 74caca9..38d8b84 100644 --- a/src/network/tcp_client_socket_handler.hpp +++ b/src/network/tcp_client_socket_handler.hpp @@ -34,7 +34,7 @@ class TCPClientSocketHandler: public TCPSocketHandler /** * Whether or not this connection is using the two given TCP ports. */ - bool match_port_pairt(const uint16_t local, const uint16_t remote) const; + bool match_port_pair(const uint16_t local, const uint16_t remote) const; protected: bool hostname_resolution_failed; -- cgit v1.2.3 From 23f3f48b4aaca4d933b0fc448482c463dd2f31be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Tue, 25 Feb 2020 22:53:37 +0100 Subject: Only consider sockets that are in valid states as identd candidates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When an identd query happens, we check all the connected sockets for their local and remote ports, to compare them with the query. But we MUST only consider the connected ones because: - It doesn’t make sense to answer for a connection that has just been closed - A non-connected sockets is not in a valid state for this (specifically here: its ::port attribute is empty) fix #3421 --- src/network/tcp_client_socket_handler.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/network/tcp_client_socket_handler.cpp b/src/network/tcp_client_socket_handler.cpp index e5b1b75..dcf38f9 100644 --- a/src/network/tcp_client_socket_handler.cpp +++ b/src/network/tcp_client_socket_handler.cpp @@ -263,6 +263,8 @@ std::string TCPClientSocketHandler::get_port() const bool TCPClientSocketHandler::match_port_pair(const uint16_t local, const uint16_t remote) const { + if (!this->is_connected()) + return false; const auto remote_port = static_cast(std::stoi(this->port)); - return this->is_connected() && local == this->local_port && remote == remote_port; + return local == this->local_port && remote == remote_port; } -- cgit v1.2.3 From 5fbd900fd681a8d907f356ba1085899e4ec0e2c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Tue, 25 Feb 2020 23:07:26 +0100 Subject: Ignore malformed identd queries fix #3422 --- src/identd/identd_socket.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/identd/identd_socket.cpp b/src/identd/identd_socket.cpp index 422c5c0..7688bbe 100644 --- a/src/identd/identd_socket.cpp +++ b/src/identd/identd_socket.cpp @@ -25,10 +25,12 @@ void IdentdSocket::parse_in_buffer(const std::size_t) std::istringstream line(this->in_buf.substr(0, line_end)); this->consume_in_buffer(line_end + 1); - uint16_t local_port; - uint16_t remote_port; + uint16_t local_port{}; + uint16_t remote_port{}; char sep; line >> local_port >> sep >> remote_port; + if (line.fail()) // Data did not match the expected format, ignore the line entirely + continue; const auto& xmpp = this->server.get_biboumi_component(); auto response = this->generate_answer(xmpp, local_port, remote_port); -- cgit v1.2.3 From 9913518178b582abcd5cac69e2f6c96866801f77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Fri, 30 Aug 2019 11:40:42 +0200 Subject: Add an error message for udns error DNS_E_NODATA (cherry-picked from master) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In cases where the DNS server does not respond “domain not found” but “domain found, but no IP for that record type”, we just say “domain not found” too (instead of nothing, previously). --- src/network/resolver.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/network/resolver.cpp b/src/network/resolver.cpp index ef54ba2..ae5cecd 100644 --- a/src/network/resolver.cpp +++ b/src/network/resolver.cpp @@ -21,6 +21,7 @@ static std::map dns_error_messages { {DNS_E_TEMPFAIL, "Timeout while contacting DNS servers"}, {DNS_E_PROTOCOL, "Misformatted DNS reply"}, {DNS_E_NXDOMAIN, "Domain name not found"}, + {DNS_E_NODATA, "Domain name not found"}, {DNS_E_NOMEM, "Out of memory"}, {DNS_E_BADQUERY, "Misformatted domain name"} }; -- cgit v1.2.3 From 4b0fb8b37e5d2ff79da1c568ca38d4c8905dc9eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Tue, 25 Feb 2020 23:20:54 +0100 Subject: Remove all identd sockets on exit signal fix #3420 --- src/identd/identd_server.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/identd/identd_server.hpp b/src/identd/identd_server.hpp index b1c8ec8..55fe225 100644 --- a/src/identd/identd_server.hpp +++ b/src/identd/identd_server.hpp @@ -24,6 +24,7 @@ class IdentdServer: public TcpSocketServer if (this->poller->is_managing_socket(this->socket)) this->poller->remove_socket_handler(this->socket); ::close(this->socket); + this->sockets.clear(); } void clean() { -- cgit v1.2.3