Skip to content

Commit f607a22

Browse files
committed
Set Omni bespoke user agent string
1 parent c3875d6 commit f607a22

File tree

3 files changed

+36
-16
lines changed

3 files changed

+36
-16
lines changed

src/init.cpp

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
#include <stdint.h>
5353
#include <stdio.h>
5454

55+
#include <omnicore/version.h>
56+
5557
#ifndef WIN32
5658
#include <attributes.h>
5759
#include <cerrno>
@@ -552,21 +554,22 @@ void SetupServerArgs()
552554

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

571574

572575
#if HAVE_DECL_DAEMON
@@ -1371,7 +1374,13 @@ bool AppInitMain(InitInterfaces& interfaces)
13711374
return InitError(strprintf(_("User Agent comment (%s) contains unsafe characters."), cmt));
13721375
uacomments.push_back(cmt);
13731376
}
1374-
strSubVersion = FormatSubVersion(CLIENT_NAME, CLIENT_VERSION, uacomments);
1377+
1378+
if (gArgs.GetArg("-omniuseragent", true)) {
1379+
strSubVersion = FormatSubVersion(OMNI_CLIENT_NAME, OMNI_USERAGENT_VERSION, uacomments);
1380+
} else {
1381+
strSubVersion = FormatSubVersion(CLIENT_NAME, CLIENT_VERSION, uacomments);
1382+
}
1383+
13751384
if (strSubVersion.size() > MAX_SUBVERSION_LENGTH) {
13761385
return InitError(strprintf(_("Total length of network version string (%i) exceeds maximum length (%i). Reduce the number or size of uacomments."),
13771386
strSubVersion.size(), MAX_SUBVERSION_LENGTH));

src/omnicore/version.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
# define OMNICORE_VERSION_SUFFIX ""
1616
#endif
1717

18+
//! Name of client reported in the user aagent message.
19+
const std::string OMNI_CLIENT_NAME("Omni");
20+
1821
//! Returns formatted Omni Core version, e.g. "1.2.0" or "1.3.4.1"
1922
const std::string OmniCoreVersion()
2023
{

src/omnicore/version.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ static const int OMNICORE_VERSION =
4242
+ 1000 * OMNICORE_VERSION_PATCH
4343
+ 1 * OMNICORE_VERSION_BUILD;
4444

45+
static const int OMNI_USERAGENT_VERSION =
46+
1000000 * OMNICORE_VERSION_MAJOR
47+
+ 10000 * OMNICORE_VERSION_MINOR
48+
+ 100 * OMNICORE_VERSION_PATCH
49+
+ 1 * OMNICORE_VERSION_BUILD;
50+
51+
extern const std::string OMNI_CLIENT_NAME;
52+
4553
//! Returns formatted Omni Core version, e.g. "1.2.0"
4654
const std::string OmniCoreVersion();
4755

0 commit comments

Comments
 (0)