diff --git a/libi2pd_client/ClientContext.cpp b/libi2pd_client/ClientContext.cpp index 407cc6cd..9cc6c9bb 100644 --- a/libi2pd_client/ClientContext.cpp +++ b/libi2pd_client/ClientContext.cpp @@ -1026,7 +1026,8 @@ namespace client uint16_t port = section.second.get (TORRENTS_TUNNEL_RPC_PORT, 0); if (port) { - auto server = CreateTorrentsRPCServer (port); + auto address = section.second.get (TORRENTS_TUNNEL_RPC_ADDRESS, "127.0.0.1"); + auto server = CreateTorrentsRPCServer (address, port); if (server) { auto path = section.second.get (TORRENTS_TUNNEL_RPC_PATH, ""); @@ -1234,12 +1235,13 @@ namespace client } } - std::shared_ptr ClientContext::CreateTorrentsRPCServer (uint16_t port) + std::shared_ptr ClientContext::CreateTorrentsRPCServer ( + std::string_view address, uint16_t port) { std::shared_ptr server; try { - server = std::make_shared(port); + server = std::make_shared(address, port); } catch(std::exception& ex) { diff --git a/libi2pd_client/ClientContext.h b/libi2pd_client/ClientContext.h index a8d8489e..a5943f45 100644 --- a/libi2pd_client/ClientContext.h +++ b/libi2pd_client/ClientContext.h @@ -77,6 +77,7 @@ namespace client const char TORRENTS_TUNNEL_TRACKERS[] = "trackers"; const char TORRENTS_TUNNEL_RPC_PORT[] = "rpcport"; const char TORRENTS_TUNNEL_RPC_PATH[] = "rpcpath"; + const char TORRENTS_TUNNEL_RPC_ADDRESS[] = "rpcaddress"; class ClientContext { @@ -151,7 +152,7 @@ namespace client void CreateNewSharedLocalDestination (); void AddLocalDestination (std::shared_ptr localDestination); - std::shared_ptr CreateTorrentsRPCServer (uint16_t port); + std::shared_ptr CreateTorrentsRPCServer (std::string_view address, uint16_t port); private: diff --git a/libi2pd_client/TorrentsRPC.cpp b/libi2pd_client/TorrentsRPC.cpp index 5de5e0ab..f8f8a064 100644 --- a/libi2pd_client/TorrentsRPC.cpp +++ b/libi2pd_client/TorrentsRPC.cpp @@ -185,9 +185,9 @@ namespace torrents }); } - TorrentsRPCServer::TorrentsRPCServer (uint16_t port): + TorrentsRPCServer::TorrentsRPCServer (std::string_view address, uint16_t port): RunnableServiceWithWork ("TRPC"), m_Acceptor (GetService (), - boost::asio::ip::tcp::endpoint (boost::asio::ip::make_address ("127.0.0.1"), port)) + boost::asio::ip::tcp::endpoint (boost::asio::ip::make_address (address), port)) { } diff --git a/libi2pd_client/TorrentsRPC.h b/libi2pd_client/TorrentsRPC.h index b6538fda..3215ae35 100644 --- a/libi2pd_client/TorrentsRPC.h +++ b/libi2pd_client/TorrentsRPC.h @@ -50,7 +50,7 @@ namespace torrents { public: - TorrentsRPCServer (uint16_t port); + TorrentsRPCServer (std::string_view address, uint16_t port); auto& GetService () { return GetIOService (); } void Start ();