Skip to content

Commit 29f8a4a

Browse files
authored
Merge pull request #2516 from wipedlifepotato/JS_CLIENT_TORRENT
fix: fix overflow to auto (torrent-js client)
2 parents 47363b8 + 992de49 commit 29f8a4a

3 files changed

Lines changed: 36 additions & 4 deletions

File tree

contrib/webconsole/torrent_client.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
background: var(--bg-color);
103103
border-radius: 4px;
104104
height: 6px;
105-
overflow: hidden;
105+
overflow: scroll;
106106
border: 1px solid var(--border-color);
107107
}
108108

@@ -139,6 +139,10 @@
139139
background-color: var(--danger);
140140
color: white;
141141
}
142+
143+
.content {
144+
max-width: 100em; /*fix for torrent interface*/
145+
}
142146
</style>
143147

144148
<div class="torrent-wrapper">
@@ -236,6 +240,7 @@ <h1>TORRENT_DAEMON_INTERFACE</h1>
236240
} catch (err) {
237241
statusIndicator.textContent = 'STATUS: CONNECTION_REFUSED';
238242
statusIndicator.style.color = '#ef4444';
243+
console.log(err)
239244
}
240245
}, 1000);
241246

daemon/HTTPServer.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,16 +1406,20 @@ namespace http {
14061406
// todo: to an another method with return;
14071407
std::string tunnelname = params["tunnelname"];
14081408
auto findTunnelEndpoint = [](const std::string& tunnelname) -> std::pair<uint16_t, std::string> {
1409+
LogPrint(eLogDebug,"GetTorrentsRPC");
14091410
for (auto& [port, server] : i2p::client::context.GetTorrentsRPCServers())
14101411
{
1411-
if (!server) continue;
1412+
if (!server) {
1413+
LogPrint(eLogError,"GetTorrentsRPCServers return nothing");
1414+
continue;
1415+
}
14121416
for (const auto& [rpcPath, weakTunnel] : server->GetTunnels())
14131417
{
14141418
if (auto tunnel = weakTunnel.lock())
14151419
{
1420+
LogPrint(eLogDebug, "TUNNEL_OPENJS", tunnel->GetName());
14161421
if (tunnel->GetName() == tunnelname)
14171422
{
1418-
14191423
uint16_t rpcPort = server->GetAcceptor().local_endpoint().port();
14201424
return std::pair<uint16_t, std::string>(rpcPort, rpcPath);
14211425
}

libi2pd_client/TorrentsRPC.cpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,31 @@ namespace torrents
431431
{
432432
if (!ecode)
433433
{
434-
if (m_Request.method() == boost::beast::http::verb::post)
434+
if (m_Request.method() == boost::beast::http::verb::options)
435435
{
436+
m_Response.version (11); // HTTP/1.1
437+
m_Response.result (204);
438+
m_Response.set (boost::beast::http::field::access_control_allow_origin, "*");
439+
m_Response.set (boost::beast::http::field::access_control_allow_methods, "GET, POST, OPTIONS");
440+
m_Response.set (boost::beast::http::field::access_control_allow_headers, "Content-Type, Authorization");
441+
442+
m_Response.keep_alive(m_Request.keep_alive());
443+
m_Response.prepare_payload ();
444+
boost::beast::http::async_write (m_Socket, m_Response,
445+
[s = shared_from_this ()](const boost::system::error_code& ecode, size_t bytes_transferred)
446+
{
447+
if (ecode)
448+
LogPrint (eLogWarning, "TorrentsRPC: Failed to send response: ", ecode.message ());
449+
});
450+
}
451+
else if (m_Request.method() == boost::beast::http::verb::post)
452+
{
453+
m_Response.set(
454+
boost::beast::http::field::access_control_allow_origin,
455+
"*");
456+
m_Response.set(
457+
boost::beast::http::field::access_control_allow_headers,
458+
"Content-Type, Authorization");
436459
auto path = m_Request.target ();
437460
auto tunnel = m_Server.GetTunnel ( {path.data (), path.size ()}); // boost::beast::string_view to std::string_view
438461
if (tunnel)

0 commit comments

Comments
 (0)