mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-13 01:20:22 +03:00
add null checks
This commit is contained in:
parent
82f46464f3
commit
f0bc2a3645
12
Datagram.cpp
12
Datagram.cpp
@ -195,24 +195,24 @@ namespace datagram
|
|||||||
DatagramSession::Info DatagramSession::GetSessionInfo() const
|
DatagramSession::Info DatagramSession::GetSessionInfo() const
|
||||||
{
|
{
|
||||||
if(!m_RoutingSession)
|
if(!m_RoutingSession)
|
||||||
return DatagramSession::Info{nullptr, nullptr, m_LastUse, m_LastSuccess};
|
return DatagramSession::Info(nullptr, nullptr, m_LastUse, m_LastSuccess);
|
||||||
|
|
||||||
auto routingPath = m_RoutingSession->GetSharedRoutingPath();
|
auto routingPath = m_RoutingSession->GetSharedRoutingPath();
|
||||||
if (!routingPath)
|
if (!routingPath)
|
||||||
return DatagramSession::Info{nullptr, nullptr, m_LastUse, m_LastSuccess};
|
return DatagramSession::Info(nullptr, nullptr, m_LastUse, m_LastSuccess);
|
||||||
auto lease = routingPath->remoteLease;
|
auto lease = routingPath->remoteLease;
|
||||||
auto tunnel = routingPath->outboundTunnel;
|
auto tunnel = routingPath->outboundTunnel;
|
||||||
if(lease)
|
if(lease)
|
||||||
{
|
{
|
||||||
if(tunnel)
|
if(tunnel)
|
||||||
return DatagramSession::Info{lease->tunnelGateway, tunnel->GetEndpointIdentHash(), m_LastUse, m_LastSuccess};
|
return DatagramSession::Info(lease->tunnelGateway, tunnel->GetEndpointIdentHash(), m_LastUse, m_LastSuccess);
|
||||||
else
|
else
|
||||||
return DatagramSession::Info{lease->tunnelGateway, nullptr, m_LastUse, m_LastSuccess};
|
return DatagramSession::Info(lease->tunnelGateway, nullptr, m_LastUse, m_LastSuccess);
|
||||||
}
|
}
|
||||||
else if(tunnel)
|
else if(tunnel)
|
||||||
return DatagramSession::Info{nullptr, tunnel->GetEndpointIdentHash(), m_LastUse, m_LastSuccess};
|
return DatagramSession::Info(nullptr, tunnel->GetEndpointIdentHash(), m_LastUse, m_LastSuccess);
|
||||||
else
|
else
|
||||||
return DatagramSession::Info{nullptr, nullptr, m_LastUse, m_LastSuccess};
|
return DatagramSession::Info(nullptr, nullptr, m_LastUse, m_LastSuccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatagramSession::HandleSend(std::shared_ptr<I2NPMessage> msg)
|
void DatagramSession::HandleSend(std::shared_ptr<I2NPMessage> msg)
|
||||||
|
11
Datagram.h
11
Datagram.h
@ -53,11 +53,14 @@ namespace datagram
|
|||||||
const uint64_t activity;
|
const uint64_t activity;
|
||||||
const uint64_t success;
|
const uint64_t success;
|
||||||
Info() : IBGW(nullptr), OBEP(nullptr), activity(0), success(0) {}
|
Info() : IBGW(nullptr), OBEP(nullptr), activity(0), success(0) {}
|
||||||
Info(const i2p::data::IdentHash & ibgw, const i2p::data::IdentHash & obep, const uint64_t a, const uint64_t s) :
|
Info(const uint8_t * ibgw, const uint8_t * obep, const uint64_t a, const uint64_t s) :
|
||||||
IBGW(new i2p::data::IdentHash(ibgw.data())),
|
|
||||||
OBEP(new i2p::data::IdentHash(obep.data())),
|
|
||||||
activity(a),
|
activity(a),
|
||||||
success(s) {}
|
success(s) {
|
||||||
|
if(ibgw) IBGW = new i2p::data::IdentHash(ibgw);
|
||||||
|
else IBGW = nullptr;
|
||||||
|
if(obep) OBEP = new i2p::data::IdentHash(obep);
|
||||||
|
else OBEP = nullptr;
|
||||||
|
}
|
||||||
~Info()
|
~Info()
|
||||||
{
|
{
|
||||||
if(IBGW) delete IBGW;
|
if(IBGW) delete IBGW;
|
||||||
|
@ -352,14 +352,14 @@ namespace http {
|
|||||||
s << "<td>" << info.RemoteIdent.ToBase32() << "</td>";
|
s << "<td>" << info.RemoteIdent.ToBase32() << "</td>";
|
||||||
s << "<td>";
|
s << "<td>";
|
||||||
if(info.CurrentIBGW)
|
if(info.CurrentIBGW)
|
||||||
s << info.CurrentIBGW->ToBase64();
|
s << info.CurrentIBGW->ToBase64().c_str();
|
||||||
else
|
else
|
||||||
s << "(none)";
|
s << "(none)";
|
||||||
s << "</td>";
|
s << "</td>";
|
||||||
|
|
||||||
s << "<td>";
|
s << "<td>";
|
||||||
if(info.CurrentOBEP)
|
if(info.CurrentOBEP)
|
||||||
s << info.CurrentOBEP->ToBase64();
|
s << info.CurrentOBEP->ToBase64().c_str();
|
||||||
else
|
else
|
||||||
s << "(none)";
|
s << "(none)";
|
||||||
s << "</td>";
|
s << "</td>";
|
||||||
|
Loading…
Reference in New Issue
Block a user