Only broadcast aloha to self if address is really localhost

This commit is contained in:
Benau 2018-03-15 00:34:59 +08:00
parent 1b8d4c80dc
commit 60d822da50

View File

@ -123,13 +123,16 @@ void ConnectToPeer::asynchronousUpdate()
BareNetworkString aloha(std::string("aloha_stk"));
STKHost::get()->sendRawPacket(aloha, broadcast_address);
Log::info("ConnectToPeer", "Broadcast aloha sent.");
Log::verbose("ConnectToPeer", "Broadcast aloha sent.");
StkTime::sleep(1);
broadcast_address.setIP(0x7f000001); // 127.0.0.1 (localhost)
broadcast_address.setPort(m_peer_address.getPort());
STKHost::get()->sendRawPacket(aloha, broadcast_address);
Log::info("ConnectToPeer", "Broadcast aloha to self.");
if (m_peer_address.isPublicAddressLocalhost())
{
broadcast_address.setIP(0x7f000001); // 127.0.0.1 (localhost)
broadcast_address.setPort(m_peer_address.getPort());
STKHost::get()->sendRawPacket(aloha, broadcast_address);
Log::verbose("ConnectToPeer", "Broadcast aloha to self.");
}
// 20 seconds timeout
if (m_tried_connection++ > 10)