Skip to content
/ i2pd Public
forked from PurpleI2P/i2pd

Commit

Permalink
integer uptime
Browse files Browse the repository at this point in the history
  • Loading branch information
orignal committed Jan 10, 2022
1 parent dc45c13 commit 843a968
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
19 changes: 16 additions & 3 deletions daemon/I2PControl.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/*
* Copyright (c) 2013-2022, The PurpleI2P Project
*
* This file is part of Purple i2pd project and licensed under BSD3
*
* See full license text in LICENSE file at top of project tree
*/

#include <stdio.h>
#include <sstream>
#include <openssl/x509.h>
Expand Down Expand Up @@ -278,11 +286,16 @@ namespace client
ss << "\"" << name << "\":" << value;
}

void I2PControlService::InsertParam (std::ostringstream& ss, const std::string& name, const std::string& value) const
void I2PControlService::InsertParam (std::ostringstream& ss, const std::string& name, const std::string& value, bool quotes) const
{
ss << "\"" << name << "\":";
if (value.length () > 0)
ss << "\"" << value << "\"";
{
if (quotes)
ss << "\"" << value << "\"";
else
ss << value;
}
else
ss << "null";
}
Expand Down Expand Up @@ -406,7 +419,7 @@ namespace client

void I2PControlService::UptimeHandler (std::ostringstream& results)
{
InsertParam (results, "i2p.router.uptime", std::to_string (i2p::context.GetUptime ()*1000LL));
InsertParam (results, "i2p.router.uptime", std::to_string (i2p::context.GetUptime ()*1000LL), false);
}

void I2PControlService::VersionHandler (std::ostringstream& results)
Expand Down
4 changes: 2 additions & 2 deletions daemon/I2PControl.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-2020, The PurpleI2P Project
* Copyright (c) 2013-2022, The PurpleI2P Project
*
* This file is part of Purple i2pd project and licensed under BSD3
*
Expand Down Expand Up @@ -65,7 +65,7 @@ namespace client

void InsertParam (std::ostringstream& ss, const std::string& name, int value) const;
void InsertParam (std::ostringstream& ss, const std::string& name, double value) const;
void InsertParam (std::ostringstream& ss, const std::string& name, const std::string& value) const;
void InsertParam (std::ostringstream& ss, const std::string& name, const std::string& value, bool quotes = true) const;
void InsertParam (std::ostringstream& ss, const std::string& name, const boost::property_tree::ptree& value) const;

// methods
Expand Down

0 comments on commit 843a968

Please sign in to comment.