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