report the two local/external addresses we know about (which should be the same)

in 'getinfo' rpc. i believe this should help debugging dht connectivity problems
when we change networks, or router gets a new ip etc.
This commit is contained in:
Miguel Freitas 2015-04-08 22:24:56 -03:00
parent bbfa75dc0a
commit 04384df7c4
4 changed files with 12 additions and 0 deletions

View File

@ -204,6 +204,9 @@ namespace libtorrent
utp_status utp_stats;
int peerlist_size;
// external ip address
std::string external_addr_v4;
};
}

View File

@ -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;
}

View File

@ -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() );

View File

@ -3066,6 +3066,8 @@ Object getLibtorrentSessionStatus()
boost::shared_ptr<session> 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) );