mirror of
https://github.com/twisterarmy/twister-core.git
synced 2025-01-24 05:24:34 +00:00
update registration network with the new external IP we learned from DHT peers
This commit is contained in:
parent
a977b88895
commit
06fbea6da9
@ -297,7 +297,7 @@ void ThreadWaitExtIP()
|
|||||||
|
|
||||||
m_ses.reset(new session(*m_swarmDb, fingerprint("TW", LIBTORRENT_VERSION_MAJOR, LIBTORRENT_VERSION_MINOR, 0, 0)
|
m_ses.reset(new session(*m_swarmDb, fingerprint("TW", LIBTORRENT_VERSION_MAJOR, LIBTORRENT_VERSION_MINOR, 0, 0)
|
||||||
, session::add_default_plugins
|
, session::add_default_plugins
|
||||||
, alert::dht_notification
|
, alert::dht_notification | alert::status_notification
|
||||||
, ipStr.size() ? ipStr.c_str() : NULL
|
, ipStr.size() ? ipStr.c_str() : NULL
|
||||||
, !m_usingProxy ? std::make_pair(listen_port, listen_port) : std::make_pair(0, 0) ));
|
, !m_usingProxy ? std::make_pair(listen_port, listen_port) : std::make_pair(0, 0) ));
|
||||||
boost::shared_ptr<session> ses(m_ses);
|
boost::shared_ptr<session> ses(m_ses);
|
||||||
@ -862,6 +862,27 @@ void ThreadSessionAlerts()
|
|||||||
{
|
{
|
||||||
--num_outstanding_resume_data;
|
--num_outstanding_resume_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
external_ip_alert const* ei = alert_cast<external_ip_alert>(*i);
|
||||||
|
if (ei)
|
||||||
|
{
|
||||||
|
boost::system::error_code ec;
|
||||||
|
std::string extip = ei->external_address.to_string(ec);
|
||||||
|
|
||||||
|
printf("Learned new external IP from DHT peers: %s\n", extip.c_str());
|
||||||
|
CNetAddr addrLocalHost(extip);
|
||||||
|
|
||||||
|
// pretend it came from querying http server. try voting up to 10 times
|
||||||
|
// to change current external ip in bitcoin code.
|
||||||
|
for(int i=0; i < 10; i++) {
|
||||||
|
AddLocal(addrLocalHost, LOCAL_HTTP);
|
||||||
|
const CNetAddr paddrPeer("8.8.8.8");
|
||||||
|
CAddress addr( GetLocalAddress(&paddrPeer) );
|
||||||
|
if( addr.IsValid() && addr.ToStringIP() == extip)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user