From bde446bcc08483707dc20a0bbf85ad70bc9d1496 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Thu, 12 Jan 2023 23:24:29 +0100 Subject: Test and fix IPv6 FCGI support --- debian/changelog | 1 + plugins/fcgi/socket.cpp | 2 +- tests/test-webserver.cpp | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index b16b192..0ebbed9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,7 @@ webserver (1.18~pre1) UNRELEASED; urgency=medium * Added websockets support (configurable forwarding proxy) * CGI bugfix: Executable execute bits check * Added example configurations + * FCGI bugfix: IPv6 support -- Roland Reichwein Sun, 08 Jan 2023 15:26:48 +0100 diff --git a/plugins/fcgi/socket.cpp b/plugins/fcgi/socket.cpp index 82bb06b..2b34bc3 100644 --- a/plugins/fcgi/socket.cpp +++ b/plugins/fcgi/socket.cpp @@ -22,7 +22,7 @@ SocketFactory::SocketFactory() std::shared_ptr SocketFactory::create(const std::string& app_addr) { - size_t pos { app_addr.find(':') }; + size_t pos { app_addr.find_last_of(':') }; if (pos != app_addr.npos) { // tcp socket: host:port return std::make_shared(app_addr.substr(0, pos), app_addr.substr(pos + 1), m_io_context); diff --git a/tests/test-webserver.cpp b/tests/test-webserver.cpp index 714cdf2..bd89aab 100644 --- a/tests/test-webserver.cpp +++ b/tests/test-webserver.cpp @@ -604,7 +604,7 @@ BOOST_FIXTURE_TEST_CASE(http_redirect, Fixture) BOOST_CHECK_EQUAL(result.second, "301 Redirecting to reichwein.it ..."); } -BOOST_FIXTURE_TEST_CASE(http_fcgi, Fixture) +BOOST_FIXTURE_TEST_CASE(http_fcgi_ip4, Fixture) { std::string webserver_config{R"CONFIG( www-data @@ -649,3 +649,48 @@ BOOST_FIXTURE_TEST_CASE(http_fcgi, Fixture) BOOST_CHECK_EQUAL(result.second, "returning data of : "); } +BOOST_FIXTURE_TEST_CASE(http_fcgi_ip6, Fixture) +{ + std::string webserver_config{R"CONFIG( + www-data + www-data + 10 + stats.db + ../plugins + + + localhost + localhost + [::1] + + fcgi + ::1:8765 + + + + + +
::1
+ 8080 + http + localhost +
+
+
)CONFIG"}; + WebserverProcess serverProcess{webserver_config}; + BOOST_REQUIRE(serverProcess.is_running()); + + FastCGIProcess fcgiProcess("./fcgi1", "::1", 8765); + BOOST_REQUIRE(fcgiProcess.is_running()); + + auto result {HTTP("/fcgi/abc")}; + BOOST_CHECK_EQUAL(result.first, fmt::format( +"HTTP/1.1 200 OK\r\n" +"Server: Reichwein.IT Webserver {}\r\n" +"Content-Type: text/plain\r\n" +"Content-Length: {}\r\n" +"\r\n" + , VERSION, result.second.size())); + BOOST_CHECK_EQUAL(result.second, "returning data of : "); +} + -- cgit v1.2.3