|
|
@ -52,9 +52,10 @@ static const set<bi::address> c_rejectAddresses = { |
|
|
|
{bi::address_v6::from_string("::")} |
|
|
|
}; |
|
|
|
|
|
|
|
PeerHost::PeerHost(std::string const& _clientVersion, unsigned short _port, string const& _publicAddress, bool _upnp): |
|
|
|
PeerHost::PeerHost(std::string const& _clientVersion, unsigned short _port, string const& _publicAddress, bool _upnp, bool _localNetworking): |
|
|
|
m_clientVersion(_clientVersion), |
|
|
|
m_listenPort(_port), |
|
|
|
m_localNetworking(_localNetworking), |
|
|
|
m_acceptor(m_ioService, bi::tcp::endpoint(bi::tcp::v4(), _port)), |
|
|
|
m_socket(m_ioService), |
|
|
|
m_key(KeyPair::create()) |
|
|
@ -63,12 +64,13 @@ PeerHost::PeerHost(std::string const& _clientVersion, unsigned short _port, stri |
|
|
|
determinePublic(_publicAddress, _upnp); |
|
|
|
ensureAccepting(); |
|
|
|
m_lastPeersRequest = chrono::steady_clock::time_point::min(); |
|
|
|
clog(NetNote) << "Id:" << toHex(m_key.address().ref().cropped(0, 4)); |
|
|
|
clog(NetNote) << "Id:" << m_key.address().abridged(); |
|
|
|
} |
|
|
|
|
|
|
|
PeerHost::PeerHost(std::string const& _clientVersion, string const& _publicAddress, bool _upnp): |
|
|
|
PeerHost::PeerHost(std::string const& _clientVersion, string const& _publicAddress, bool _upnp, bool _localNetworking): |
|
|
|
m_clientVersion(_clientVersion), |
|
|
|
m_listenPort(0), |
|
|
|
m_localNetworking(_localNetworking), |
|
|
|
m_acceptor(m_ioService, bi::tcp::endpoint(bi::tcp::v4(), 0)), |
|
|
|
m_socket(m_ioService), |
|
|
|
m_key(KeyPair::create()) |
|
|
@ -80,7 +82,7 @@ PeerHost::PeerHost(std::string const& _clientVersion, string const& _publicAddre |
|
|
|
determinePublic(_publicAddress, _upnp); |
|
|
|
ensureAccepting(); |
|
|
|
m_lastPeersRequest = chrono::steady_clock::time_point::min(); |
|
|
|
clog(NetNote) << "Id:" << toHex(m_key.address().ref().cropped(0, 4)); |
|
|
|
clog(NetNote) << "Id:" << m_key.address().abridged(); |
|
|
|
} |
|
|
|
|
|
|
|
PeerHost::PeerHost(std::string const& _clientVersion): |
|
|
@ -93,7 +95,7 @@ PeerHost::PeerHost(std::string const& _clientVersion): |
|
|
|
// populate addresses.
|
|
|
|
populateAddresses(); |
|
|
|
m_lastPeersRequest = chrono::steady_clock::time_point::min(); |
|
|
|
clog(NetNote) << "Id:" << toHex(m_key.address().ref().cropped(0, 4)); |
|
|
|
clog(NetNote) << "Id:" << m_key.address().abridged(); |
|
|
|
} |
|
|
|
|
|
|
|
PeerHost::~PeerHost() |
|
|
@ -280,7 +282,7 @@ std::map<Public, bi::tcp::endpoint> PeerHost::potentialPeers() |
|
|
|
{ |
|
|
|
auto ep = j->endpoint(); |
|
|
|
// Skip peers with a listen port of zero or are on a private network
|
|
|
|
bool peerOnNet = (j->m_listenPort != 0 && !isPrivateAddress(ep.address())); |
|
|
|
bool peerOnNet = (j->m_listenPort != 0 && (!isPrivateAddress(ep.address()) || m_localNetworking)); |
|
|
|
if (peerOnNet && ep.port() && j->m_id) |
|
|
|
ret.insert(make_pair(i.first, ep)); |
|
|
|
} |
|
|
|