diff --git a/contrib/webconsole/torrent_client.html b/contrib/webconsole/torrent_client.html index 7c178638..94e0e097 100644 --- a/contrib/webconsole/torrent_client.html +++ b/contrib/webconsole/torrent_client.html @@ -102,7 +102,7 @@ background: var(--bg-color); border-radius: 4px; height: 6px; - overflow: hidden; + overflow: scroll; border: 1px solid var(--border-color); } @@ -139,6 +139,10 @@ background-color: var(--danger); color: white; } + + .content { + max-width: 100em; /*fix for torrent interface*/ + }
@@ -236,6 +240,7 @@ } catch (err) { statusIndicator.textContent = 'STATUS: CONNECTION_REFUSED'; statusIndicator.style.color = '#ef4444'; + console.log(err) } }, 1000); diff --git a/daemon/HTTPServer.cpp b/daemon/HTTPServer.cpp index 9b6e2140..c66f3eea 100644 --- a/daemon/HTTPServer.cpp +++ b/daemon/HTTPServer.cpp @@ -1406,16 +1406,20 @@ namespace http { // todo: to an another method with return; std::string tunnelname = params["tunnelname"]; auto findTunnelEndpoint = [](const std::string& tunnelname) -> std::pair { + LogPrint(eLogDebug,"GetTorrentsRPC"); for (auto& [port, server] : i2p::client::context.GetTorrentsRPCServers()) { - if (!server) continue; + if (!server) { + LogPrint(eLogError,"GetTorrentsRPCServers return nothing"); + continue; + } for (const auto& [rpcPath, weakTunnel] : server->GetTunnels()) { if (auto tunnel = weakTunnel.lock()) { + LogPrint(eLogDebug, "TUNNEL_OPENJS", tunnel->GetName()); if (tunnel->GetName() == tunnelname) { - uint16_t rpcPort = server->GetAcceptor().local_endpoint().port(); return std::pair(rpcPort, rpcPath); } diff --git a/libi2pd_client/TorrentsRPC.cpp b/libi2pd_client/TorrentsRPC.cpp index 80bbc79d..7d116df4 100644 --- a/libi2pd_client/TorrentsRPC.cpp +++ b/libi2pd_client/TorrentsRPC.cpp @@ -431,8 +431,31 @@ namespace torrents { if (!ecode) { - if (m_Request.method() == boost::beast::http::verb::post) + if (m_Request.method() == boost::beast::http::verb::options) { + m_Response.version (11); // HTTP/1.1 + m_Response.result (204); + m_Response.set (boost::beast::http::field::access_control_allow_origin, "*"); + m_Response.set (boost::beast::http::field::access_control_allow_methods, "GET, POST, OPTIONS"); + m_Response.set (boost::beast::http::field::access_control_allow_headers, "Content-Type, Authorization"); + + m_Response.keep_alive(m_Request.keep_alive()); + m_Response.prepare_payload (); + boost::beast::http::async_write (m_Socket, m_Response, + [s = shared_from_this ()](const boost::system::error_code& ecode, size_t bytes_transferred) + { + if (ecode) + LogPrint (eLogWarning, "TorrentsRPC: Failed to send response: ", ecode.message ()); + }); + } + else if (m_Request.method() == boost::beast::http::verb::post) + { + m_Response.set( + boost::beast::http::field::access_control_allow_origin, + "*"); + m_Response.set( + boost::beast::http::field::access_control_allow_headers, + "Content-Type, Authorization"); auto path = m_Request.target (); auto tunnel = m_Server.GetTunnel ( {path.data (), path.size ()}); // boost::beast::string_view to std::string_view if (tunnel)