Skip to content

Commit

Permalink
Merge #1035: Set Omni bespoke user agent string
Browse files Browse the repository at this point in the history
2dfc9d8 Set Omni bespoke user agent string (Peter Bushnell)
f607a22 Set Omni bespoke user agent string (Peter Bushnell)

Pull request description:

Tree-SHA512: 25eb33595c5da42cb8d3637c34515d0b3848416ca9d786a91997a4f1f11553ef2385fa76e2003a42e862ce0d6be7bbf7fa0b1daeb927046d5441c5e391df8934
  • Loading branch information
dexX7 committed Oct 24, 2019
2 parents c3875d6 + 2dfc9d8 commit 289f032
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/clientversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const std::string CLIENT_NAME("Satoshi");

const std::string CLIENT_BUILD(BUILD_DESC CLIENT_VERSION_SUFFIX);

static std::string FormatVersion(int nVersion)
std::string FormatVersion(int nVersion)
{
if (nVersion % 100 == 0)
return strprintf("%d.%d.%d", nVersion / 1000000, (nVersion / 10000) % 100, (nVersion / 100) % 100);
Expand Down
1 change: 1 addition & 0 deletions src/clientversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ extern const std::string CLIENT_NAME;
extern const std::string CLIENT_BUILD;


std::string FormatVersion(int nVersion);
std::string FormatFullVersion();
std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector<std::string>& comments);

Expand Down
42 changes: 26 additions & 16 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
#include <stdint.h>
#include <stdio.h>

#include <omnicore/version.h>

#ifndef WIN32
#include <attributes.h>
#include <cerrno>
Expand Down Expand Up @@ -552,21 +554,22 @@ void SetupServerArgs()

// TODO: append help messages somewhere else
// TODO: translation
gArgs.AddArg("-startclean", "Clear all persistence files on startup; triggers reparsing of Omni transactions (default: 0)", false, OptionsCategory::BLOCK_CREATION);
gArgs.AddArg("-omnitxcache", "The maximum number of transactions in the input transaction cache (default: 500000)", false, OptionsCategory::BLOCK_CREATION);
gArgs.AddArg("-omniprogressfrequency", "Time in seconds after which the initial scanning progress is reported (default: 30)", false, OptionsCategory::BLOCK_CREATION);
gArgs.AddArg("-omniseedblockfilter", "Set skipping of blocks without Omni transactions during initial scan (default: 1)", false, OptionsCategory::BLOCK_CREATION);
gArgs.AddArg("-omnilogfile", "The path of the log file (default: omnicore.log)", false, OptionsCategory::BLOCK_CREATION);
gArgs.AddArg("-omnidebug=<category>", "Enable or disable log categories, can be \"all\" or \"none\"", false, OptionsCategory::BLOCK_CREATION);
gArgs.AddArg("-autocommit", "Enable or disable broadcasting of transactions, when creating transactions (default: 1)", false, OptionsCategory::BLOCK_CREATION);
gArgs.AddArg("-overrideforcedshutdown", "Overwrite shutdown, triggered by an alert (default: 0)", false, OptionsCategory::BLOCK_CREATION);
gArgs.AddArg("-omnialertallowsender", "Whitelist senders of alerts, can be \"any\")", false, OptionsCategory::BLOCK_CREATION);
gArgs.AddArg("-omnialertignoresender", "Ignore senders of alerts", false, OptionsCategory::BLOCK_CREATION);
gArgs.AddArg("-omniactivationignoresender", "Ignore senders of activations", false, OptionsCategory::BLOCK_CREATION);
gArgs.AddArg("-omniactivationallowsender", "Whitelist senders of activations", false, OptionsCategory::BLOCK_CREATION);
gArgs.AddArg("-disclaimer", "Explicitly show QT disclaimer on startup (default: 0)", false, OptionsCategory::BLOCK_CREATION);
gArgs.AddArg("-omniuiwalletscope", "Max. transactions to show in trade and transaction history (default: 65535)", false, OptionsCategory::BLOCK_CREATION);
gArgs.AddArg("-omnishowblockconsensushash", "Calculate and log the consensus hash for the specified block", false, OptionsCategory::BLOCK_CREATION);
gArgs.AddArg("-startclean", "Clear all persistence files on startup; triggers reparsing of Omni transactions (default: 0)", false, OptionsCategory::OMNI);
gArgs.AddArg("-omnitxcache", "The maximum number of transactions in the input transaction cache (default: 500000)", false, OptionsCategory::OMNI);
gArgs.AddArg("-omniprogressfrequency", "Time in seconds after which the initial scanning progress is reported (default: 30)", false, OptionsCategory::OMNI);
gArgs.AddArg("-omniseedblockfilter", "Set skipping of blocks without Omni transactions during initial scan (default: 1)", false, OptionsCategory::OMNI);
gArgs.AddArg("-omnilogfile", "The path of the log file (default: omnicore.log)", false, OptionsCategory::OMNI);
gArgs.AddArg("-omnidebug=<category>", "Enable or disable log categories, can be \"all\" or \"none\"", false, OptionsCategory::OMNI);
gArgs.AddArg("-autocommit", "Enable or disable broadcasting of transactions, when creating transactions (default: 1)", false, OptionsCategory::OMNI);
gArgs.AddArg("-overrideforcedshutdown", "Overwrite shutdown, triggered by an alert (default: 0)", false, OptionsCategory::OMNI);
gArgs.AddArg("-omnialertallowsender", "Whitelist senders of alerts, can be \"any\")", false, OptionsCategory::OMNI);
gArgs.AddArg("-omnialertignoresender", "Ignore senders of alerts", false, OptionsCategory::OMNI);
gArgs.AddArg("-omniactivationignoresender", "Ignore senders of activations", false, OptionsCategory::OMNI);
gArgs.AddArg("-omniactivationallowsender", "Whitelist senders of activations", false, OptionsCategory::OMNI);
gArgs.AddArg("-disclaimer", "Explicitly show QT disclaimer on startup (default: 0)", false, OptionsCategory::OMNI);
gArgs.AddArg("-omniuiwalletscope", "Max. transactions to show in trade and transaction history (default: 65535)", false, OptionsCategory::OMNI);
gArgs.AddArg("-omnishowblockconsensushash", "Calculate and log the consensus hash for the specified block", false, OptionsCategory::OMNI);
gArgs.AddArg("-omniuseragent", "Show Omni and Omni version in user agent string (default: 1)", false, OptionsCategory::OMNI);


#if HAVE_DECL_DAEMON
Expand Down Expand Up @@ -1371,7 +1374,14 @@ bool AppInitMain(InitInterfaces& interfaces)
return InitError(strprintf(_("User Agent comment (%s) contains unsafe characters."), cmt));
uacomments.push_back(cmt);
}
strSubVersion = FormatSubVersion(CLIENT_NAME, CLIENT_VERSION, uacomments);

if (gArgs.GetArg("-omniuseragent", true)) {
uacomments.emplace(uacomments.begin(), OMNI_CLIENT_NAME + ":" + FormatVersion(OMNI_USERAGENT_VERSION));
strSubVersion = FormatSubVersion(CLIENT_NAME, CLIENT_VERSION, uacomments);
} else {
strSubVersion = FormatSubVersion(CLIENT_NAME, CLIENT_VERSION, uacomments);
}

if (strSubVersion.size() > MAX_SUBVERSION_LENGTH) {
return InitError(strprintf(_("Total length of network version string (%i) exceeds maximum length (%i). Reduce the number or size of uacomments."),
strSubVersion.size(), MAX_SUBVERSION_LENGTH));
Expand Down
3 changes: 3 additions & 0 deletions src/omnicore/version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
# define OMNICORE_VERSION_SUFFIX ""
#endif

//! Name of client reported in the user aagent message.
const std::string OMNI_CLIENT_NAME("Omni");

//! Returns formatted Omni Core version, e.g. "1.2.0" or "1.3.4.1"
const std::string OmniCoreVersion()
{
Expand Down
8 changes: 8 additions & 0 deletions src/omnicore/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ static const int OMNICORE_VERSION =
+ 1000 * OMNICORE_VERSION_PATCH
+ 1 * OMNICORE_VERSION_BUILD;

static const int OMNI_USERAGENT_VERSION =
1000000 * OMNICORE_VERSION_MAJOR
+ 10000 * OMNICORE_VERSION_MINOR
+ 100 * OMNICORE_VERSION_PATCH
+ 1 * OMNICORE_VERSION_BUILD;

extern const std::string OMNI_CLIENT_NAME;

//! Returns formatted Omni Core version, e.g. "1.2.0"
const std::string OmniCoreVersion();

Expand Down

0 comments on commit 289f032

Please sign in to comment.