Browse Source

use shared pointers

pull/628/head
Jeff Becker 8 years ago
parent
commit
1015188c4e
No known key found for this signature in database
GPG Key ID: AB950234D6EA286B
  1. 13
      Datagram.h
  2. 6
      HTTPServer.cpp
  3. 4
      I2PTunnel.h

13
Datagram.h

@ -48,24 +48,19 @@ namespace datagram
uint64_t LastSuccess() const { return m_LastSuccess; } uint64_t LastSuccess() const { return m_LastSuccess; }
struct Info struct Info
{ {
const i2p::data::IdentHash * IBGW; std::shared_ptr<const i2p::data::IdentHash> IBGW;
const i2p::data::IdentHash * OBEP; std::shared_ptr<const i2p::data::IdentHash> OBEP;
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 uint8_t * ibgw, const uint8_t * 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) :
activity(a), activity(a),
success(s) { success(s) {
if(ibgw) IBGW = new i2p::data::IdentHash(ibgw); if(ibgw) IBGW = std::make_shared<i2p::data::IdentHash>(ibgw);
else IBGW = nullptr; else IBGW = nullptr;
if(obep) OBEP = new i2p::data::IdentHash(obep); if(obep) OBEP = std::make_shared<i2p::data::IdentHash>(obep);
else OBEP = nullptr; else OBEP = nullptr;
} }
~Info()
{
if(IBGW) delete IBGW;
if(OBEP) delete OBEP;
}
}; };
Info GetSessionInfo() const; Info GetSessionInfo() const;

6
HTTPServer.cpp

@ -346,20 +346,20 @@ namespace http {
s << "<th>Idle Time</th>"; s << "<th>Idle Time</th>";
s << "</th>"; s << "</th>";
auto forward = i2p::client::context.GetForwardInfosFor(dest->GetIdentHash()); auto forward = i2p::client::context.GetForwardInfosFor(dest->GetIdentHash());
for (auto & info : forward) for (auto info : forward)
{ {
s << "<tr>"; s << "<tr>";
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().c_str(); s << std::string(info.CurrentIBGW->ToBase64());
else else
s << "(none)"; s << "(none)";
s << "</td>"; s << "</td>";
s << "<td>"; s << "<td>";
if(info.CurrentOBEP) if(info.CurrentOBEP)
s << info.CurrentOBEP->ToBase64().c_str(); s << std::string(info.CurrentOBEP->ToBase64());
else else
s << "(none)"; s << "(none)";
s << "</td>"; s << "</td>";

4
I2PTunnel.h

@ -148,9 +148,9 @@ namespace client
/** ident hash of remote destination */ /** ident hash of remote destination */
const i2p::data::IdentHash RemoteIdent; const i2p::data::IdentHash RemoteIdent;
/** ident hash of IBGW in use currently in this session or nullptr if none is set */ /** ident hash of IBGW in use currently in this session or nullptr if none is set */
const i2p::data::IdentHash * CurrentIBGW; std::shared_ptr<const i2p::data::IdentHash> CurrentIBGW;
/** ident hash of OBEP in use for this session or nullptr if none is set */ /** ident hash of OBEP in use for this session or nullptr if none is set */
const i2p::data::IdentHash * CurrentOBEP; std::shared_ptr<const i2p::data::IdentHash> CurrentOBEP;
/** i2p router's udp endpoint */ /** i2p router's udp endpoint */
const boost::asio::ip::udp::endpoint LocalEndpoint; const boost::asio::ip::udp::endpoint LocalEndpoint;
/** client's udp endpoint */ /** client's udp endpoint */

Loading…
Cancel
Save