diff --git a/libtorrent/include/libtorrent/session_status.hpp b/libtorrent/include/libtorrent/session_status.hpp index e1417763..0bfa4e95 100644 --- a/libtorrent/include/libtorrent/session_status.hpp +++ b/libtorrent/include/libtorrent/session_status.hpp @@ -204,6 +204,9 @@ namespace libtorrent utp_status utp_stats; int peerlist_size; + + // external ip address + std::string external_addr_v4; }; } diff --git a/libtorrent/src/session_impl.cpp b/libtorrent/src/session_impl.cpp index da067f42..1d3d30e8 100644 --- a/libtorrent/src/session_impl.cpp +++ b/libtorrent/src/session_impl.cpp @@ -5718,6 +5718,9 @@ retry: s.peerlist_size = peerlist_size; + boost::system::error_code ec; + s.external_addr_v4 = external_address().external_address(address_v4()).to_string(ec); + return s; } diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp index caa14ac3..e81be240 100644 --- a/src/rpcwallet.cpp +++ b/src/rpcwallet.cpp @@ -100,6 +100,10 @@ Value getinfo(const Array& params, bool fHelp) obj.push_back(Pair("errors", GetWarnings("statusbar"))); } + const CNetAddr paddrPeer("8.8.8.8"); + CAddress addr( GetLocalAddress(&paddrPeer) ); + obj.push_back(Pair("ext_addr_net1", addr.IsValid() ? addr.ToStringIP() : string()) ); + Object torrent_stats = getLibtorrentSessionStatus(); obj.insert( obj.end(), torrent_stats.begin(), torrent_stats.end() ); diff --git a/src/twister.cpp b/src/twister.cpp index 8a179c05..21a08dfd 100644 --- a/src/twister.cpp +++ b/src/twister.cpp @@ -3066,6 +3066,8 @@ Object getLibtorrentSessionStatus() boost::shared_ptr ses(m_ses); if( ses ) { session_status stats = ses->status(); + + obj.push_back( Pair("ext_addr_net2", stats.external_addr_v4) ); obj.push_back( Pair("dht_torrents", stats.dht_torrents) ); obj.push_back( Pair("num_peers", stats.num_peers) );