summaryrefslogtreecommitdiff
path: root/http
diff options
context:
space:
mode:
authorNinad Palsule <ninad@linux.ibm.com>2023-05-30 19:10:58 +0300
committerEd Tanous <ed@tanous.net>2023-06-06 00:14:00 +0300
commit052bcbf48802da1fa9583c8c0990378304e29903 (patch)
tree3a49a0c10880036e6082e1d90d715dfa73ad484f /http
parent61e349acc34787ad80aebf7809ab73c4f03c7520 (diff)
downloadbmcweb-052bcbf48802da1fa9583c8c0990378304e29903.tar.xz
Add support for multiple consoles
This drop adds support for multiple consoles. The following changes are made to achieve this. - Kept the "/console0" route for backward compatibility - Added a new route "/console/<str>" to support multiple consoles. All new consoles must use this route string. Testing: - Make sure that old console path /console0 is working. [INFO "http_connection.hpp":209] Request: 0x1bc2e60 HTTP/1.1 GET /console0 ::ffff:x.x.xx.xxx [DEBUG "routing.hpp":1240] Matched rule (upgrade) '/console0' 1 / 2 [DEBUG "obmc_console.hpp":212] Connection 0x1bdb67c opened [DEBUG "obmc_console.hpp":241] Console Object path = /xyz/openbmc_project/console/default service = xyz.openbmc_project.Console.default Request target = /console0 [DEBUG "obmc_console.hpp":198] Console web socket path: /console0 Console unix FD: 12 duped FD: 13 [DEBUG "obmc_console.hpp":82] Reading from socket [DEBUG "obmc_console.hpp":162] Remove connection 0x1bdb67c from obmc console - Make sure that new path for default console working [INFO "http_connection.hpp":209] Request: 0x1bd76a8 HTTP/1.1 GET /console/default ::ffff:x.x.xx.xxx [DEBUG "routing.hpp":1240] Matched rule (upgrade) '/console/<str>' 1 / 2 [DEBUG "obmc_console.hpp":212] Connection 0x1baf82c opened [DEBUG "obmc_console.hpp":241] Console Object path = /xyz/openbmc_project/console/default service = xyz.openbmc_project.Console.default Request target = /console/default [DEBUG "obmc_console.hpp":198] Console web socket path: /console/default Console unix FD: 12 duped FD: 13 [DEBUG "obmc_console.hpp":82] Reading from socket [INFO "obmc_console.hpp":154] Closing websocket. Reason: [DEBUG "obmc_console.hpp":162] Remove connection 0x1baf82c from obmc console - Make sure that path for hypervisor console is working. [INFO "http_connection.hpp":209] Request: 0x1bc2e60 HTTP/1.1 GET /console/hypervisor ::ffff:x.x.xx.xxx [DEBUG "routing.hpp":1240] Matched rule (upgrade) '/console/<str>' 1 / 2 [DEBUG "obmc_console.hpp":212] Connection 0x1bc5234 opened [DEBUG "obmc_console.hpp":241] Console Object path = /xyz/openbmc_project/console/hypervisor service = xyz.openbmc_project.Console.hypervisor Request target = /console/hypervisor [DEBUG "obmc_console.hpp":198] Console web socket path: /console/hypervisor Console unix FD: 12 duped FD: 13 [DEBUG "obmc_console.hpp":82] Reading from socket [INFO "obmc_console.hpp":154] Closing websocket. Reason: [DEBUG "obmc_console.hpp":162] Remove connection 0x1bc5234 from obmc console - Make sure that bad console path is failing properly due to DBUS error. [INFO "http_connection.hpp":209] Request: 0x1bd76a8 HTTP/1.1 GET /console/badconsoleid ::ffff:x.x.xx.xxx [DEBUG "routing.hpp":1240] Matched rule (upgrade) '/console/<str>' 1 / 2 [DEBUG "obmc_console.hpp":212] Connection 0x1bdb67c opened [DEBUG "obmc_console.hpp":241] Console Object path = /xyz/openbmc_project/console/badconsoleid service = xyz.openbmc_project.Console.badconsoleid Request target = /console/badconsoleid [ERROR "obmc_console.hpp":174] Failed to call console Connect() method DBUS error: No route to host Change-Id: I9b617bc51e3ddc605dd7f4d213c805d05d2cfead Signed-off-by: Ninad Palsule <ninad@linux.ibm.com> Signed-off-by: Ed Tanous <edtanous@google.com>
Diffstat (limited to 'http')
-rw-r--r--http/routing.hpp4
-rw-r--r--http/websocket.hpp15
2 files changed, 13 insertions, 6 deletions
diff --git a/http/routing.hpp b/http/routing.hpp
index ac1c310ae2..f3bcfbb065 100644
--- a/http/routing.hpp
+++ b/http/routing.hpp
@@ -305,7 +305,7 @@ class WebSocketRule : public BaseRule
crow::websocket::ConnectionImpl<boost::asio::ip::tcp::socket>>
myConnection = std::make_shared<
crow::websocket::ConnectionImpl<boost::asio::ip::tcp::socket>>(
- req, std::move(adaptor), openHandler, messageHandler,
+ req, req.url(), std::move(adaptor), openHandler, messageHandler,
messageExHandler, closeHandler, errorHandler);
myConnection->start();
}
@@ -320,7 +320,7 @@ class WebSocketRule : public BaseRule
boost::beast::ssl_stream<boost::asio::ip::tcp::socket>>>
myConnection = std::make_shared<crow::websocket::ConnectionImpl<
boost::beast::ssl_stream<boost::asio::ip::tcp::socket>>>(
- req, std::move(adaptor), openHandler, messageHandler,
+ req, req.url(), std::move(adaptor), openHandler, messageHandler,
messageExHandler, closeHandler, errorHandler);
myConnection->start();
}
diff --git a/http/websocket.hpp b/http/websocket.hpp
index e61f58b0bd..0faa8c60c7 100644
--- a/http/websocket.hpp
+++ b/http/websocket.hpp
@@ -45,7 +45,7 @@ struct Connection : std::enable_shared_from_this<Connection>
virtual void resumeRead() = 0;
virtual boost::asio::io_context& getIoContext() = 0;
virtual ~Connection() = default;
-
+ virtual boost::urls::url_view url() = 0;
boost::beast::http::request<boost::beast::http::string_body> req;
};
@@ -54,8 +54,8 @@ class ConnectionImpl : public Connection
{
public:
ConnectionImpl(
- const crow::Request& reqIn, Adaptor adaptorIn,
- std::function<void(Connection&)> openHandlerIn,
+ const crow::Request& reqIn, boost::urls::url_view urlViewIn,
+ Adaptor adaptorIn, std::function<void(Connection&)> openHandlerIn,
std::function<void(Connection&, const std::string&, bool)>
messageHandlerIn,
std::function<void(crow::websocket::Connection&, std::string_view,
@@ -65,7 +65,7 @@ class ConnectionImpl : public Connection
std::function<void(Connection&, const std::string&)> closeHandlerIn,
std::function<void(Connection&)> errorHandlerIn) :
Connection(reqIn),
- ws(std::move(adaptorIn)), inBuffer(inString, 131088),
+ uri(urlViewIn), ws(std::move(adaptorIn)), inBuffer(inString, 131088),
openHandler(std::move(openHandlerIn)),
messageHandler(std::move(messageHandlerIn)),
messageExHandler(std::move(messageExHandlerIn)),
@@ -215,6 +215,11 @@ class ConnectionImpl : public Connection
});
}
+ boost::urls::url_view url() override
+ {
+ return uri;
+ }
+
void acceptDone()
{
BMCWEB_LOG_DEBUG << "Websocket accepted connection";
@@ -338,6 +343,8 @@ class ConnectionImpl : public Connection
doRead();
}
+ boost::urls::url uri;
+
boost::beast::websocket::stream<Adaptor, false> ws;
bool readingDefered = false;