mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 21:37:17 +01:00
check if we can send HolePunch to partcular address
This commit is contained in:
parent
22f9abc2f1
commit
dda25d431c
|
@ -109,6 +109,21 @@ namespace transport
|
|||
m_AddressV6 = localAddress;
|
||||
}
|
||||
|
||||
bool SSU2Server::IsSupported (const boost::asio::ip::address& addr) const
|
||||
{
|
||||
if (addr.is_v4 ())
|
||||
{
|
||||
if (m_SocketV4.is_open ())
|
||||
return true;
|
||||
}
|
||||
else if (addr.is_v6 ())
|
||||
{
|
||||
if (m_SocketV6.is_open ())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
boost::asio::ip::udp::socket& SSU2Server::OpenSocket (const boost::asio::ip::udp::endpoint& localEndpoint)
|
||||
{
|
||||
boost::asio::ip::udp::socket& socket = localEndpoint.address ().is_v6 () ? m_SocketV6 : m_SocketV4;
|
||||
|
|
|
@ -49,6 +49,7 @@ namespace transport
|
|||
void Stop ();
|
||||
boost::asio::io_service& GetService () { return GetIOService (); };
|
||||
void SetLocalAddress (const boost::asio::ip::address& localAddress);
|
||||
bool IsSupported (const boost::asio::ip::address& addr) const;
|
||||
|
||||
void AddSession (std::shared_ptr<SSU2Session> session);
|
||||
void RemoveSession (uint64_t connID);
|
||||
|
|
|
@ -1344,7 +1344,12 @@ namespace transport
|
|||
{
|
||||
auto addr = ep.address ().is_v6 () ? r->GetSSU2V6Address () : r->GetSSU2V4Address ();
|
||||
if (addr)
|
||||
{
|
||||
if (m_Server.IsSupported (ep.address ()))
|
||||
SendHolePunch (bufbe32toh (buf + 33), ep, addr->i);
|
||||
else
|
||||
code = eSSU2RelayResponseCodeCharlieUnsupportedAddress;
|
||||
}
|
||||
else
|
||||
{
|
||||
LogPrint (eLogWarning, "SSU2: RelayInfo unknown address");
|
||||
|
|
|
@ -108,6 +108,7 @@ namespace transport
|
|||
{
|
||||
eSSU2RelayResponseCodeAccept = 0,
|
||||
eSSU2RelayResponseCodeBobRelayTagNotFound = 5,
|
||||
eSSU2RelayResponseCodeCharlieUnsupportedAddress = 65,
|
||||
eSSU2RelayResponseCodeCharlieSignatureFailure = 67,
|
||||
eSSU2RelayResponseCodeCharlieAliceIsUnknown = 70
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue