Added option --user-agent.

This commit is contained in:
XMRig 2017-08-16 13:19:14 +03:00
parent 79ffb95f05
commit 27f02d5f9f
7 changed files with 20 additions and 9 deletions

View file

@ -81,7 +81,7 @@ App::App(int argc, char **argv) :
} }
# endif # endif
Platform::init(); Platform::init(m_options->userAgent());
Platform::setProcessPriority(m_options->priority()); Platform::setProcessPriority(m_options->priority());
m_network = new Network(m_options); m_network = new Network(m_options);

View file

@ -67,6 +67,7 @@ Options:\n\
--cpu-priority set process priority (0 idle, 2 normal to 5 highest)\n\ --cpu-priority set process priority (0 idle, 2 normal to 5 highest)\n\
--no-color disable colored output\n\ --no-color disable colored output\n\
--donate-level=N donate level, default 5%% (5 minutes in 100 minutes)\n\ --donate-level=N donate level, default 5%% (5 minutes in 100 minutes)\n\
--user-agent set custom user-agent string for pool\n\
-B, --background run the miner in the background\n\ -B, --background run the miner in the background\n\
-c, --config=FILE load a JSON-format configuration file\n\ -c, --config=FILE load a JSON-format configuration file\n\
-l, --log-file=FILE log all output to a file\n" -l, --log-file=FILE log all output to a file\n"
@ -110,6 +111,7 @@ static struct option const options[] = {
{ "threads", 1, nullptr, 't' }, { "threads", 1, nullptr, 't' },
{ "url", 1, nullptr, 'o' }, { "url", 1, nullptr, 'o' },
{ "user", 1, nullptr, 'u' }, { "user", 1, nullptr, 'u' },
{ "user-agent", 1, nullptr, 1008 },
{ "userpass", 1, nullptr, 'O' }, { "userpass", 1, nullptr, 'O' },
{ "version", 0, nullptr, 'V' }, { "version", 0, nullptr, 'V' },
{ 0, 0, 0, 0 } { 0, 0, 0, 0 }
@ -120,6 +122,7 @@ static struct option const config_options[] = {
{ "algo", 1, nullptr, 'a' }, { "algo", 1, nullptr, 'a' },
{ "av", 1, nullptr, 'v' }, { "av", 1, nullptr, 'v' },
{ "background", 0, nullptr, 'B' }, { "background", 0, nullptr, 'B' },
{ "colors", 0, nullptr, 2000 },
{ "cpu-affinity", 1, nullptr, 1020 }, { "cpu-affinity", 1, nullptr, 1020 },
{ "cpu-priority", 1, nullptr, 1021 }, { "cpu-priority", 1, nullptr, 1021 },
{ "donate-level", 1, nullptr, 1003 }, { "donate-level", 1, nullptr, 1003 },
@ -131,7 +134,7 @@ static struct option const config_options[] = {
{ "safe", 0, nullptr, 1005 }, { "safe", 0, nullptr, 1005 },
{ "syslog", 0, nullptr, 'S' }, { "syslog", 0, nullptr, 'S' },
{ "threads", 1, nullptr, 't' }, { "threads", 1, nullptr, 't' },
{ "colors", 0, nullptr, 2000 }, { "user-agent", 1, nullptr, 1008 },
{ 0, 0, 0, 0 } { 0, 0, 0, 0 }
}; };
@ -182,6 +185,7 @@ Options::Options(int argc, char **argv) :
m_safe(false), m_safe(false),
m_syslog(false), m_syslog(false),
m_logFile(nullptr), m_logFile(nullptr),
m_userAgent(nullptr),
m_algo(0), m_algo(0),
m_algoVariant(0), m_algoVariant(0),
m_donateLevel(kDonateLevel), m_donateLevel(kDonateLevel),
@ -329,6 +333,11 @@ bool Options::parseArg(int key, const char *arg)
return parseArg(key, p ? strtoull(p, nullptr, 16) : strtoull(arg, nullptr, 10)); return parseArg(key, p ? strtoull(p, nullptr, 16) : strtoull(arg, nullptr, 10));
} }
case 1008: /* --user-agent */
free(m_userAgent);
m_userAgent = strdup(arg);
break;
default: default:
showUsage(1); showUsage(1);
return false; return false;

View file

@ -59,6 +59,7 @@ public:
inline bool doubleHash() const { return m_doubleHash; } inline bool doubleHash() const { return m_doubleHash; }
inline bool syslog() const { return m_syslog; } inline bool syslog() const { return m_syslog; }
inline const char *logFile() const { return m_logFile; } inline const char *logFile() const { return m_logFile; }
inline const char *userAgent() const { return m_userAgent; }
inline const std::vector<Url*> &pools() const { return m_pools; } inline const std::vector<Url*> &pools() const { return m_pools; }
inline int algo() const { return m_algo; } inline int algo() const { return m_algo; }
inline int algoVariant() const { return m_algoVariant; } inline int algoVariant() const { return m_algoVariant; }
@ -105,6 +106,7 @@ private:
bool m_safe; bool m_safe;
bool m_syslog; bool m_syslog;
char *m_logFile; char *m_logFile;
char *m_userAgent;
int m_algo; int m_algo;
int m_algoVariant; int m_algoVariant;
int m_donateLevel; int m_donateLevel;

View file

@ -29,7 +29,7 @@ class Platform
{ {
public: public:
static const char *defaultConfigName(); static const char *defaultConfigName();
static void init(); static void init(const char *userAgent);
static void release(); static void release();
static void setProcessPriority(int priority); static void setProcessPriority(int priority);
static void setThreadPriority(int priority); static void setThreadPriority(int priority);

View file

@ -42,9 +42,9 @@ static inline char *createUserAgent()
} }
void Platform::init() void Platform::init(const char *userAgent)
{ {
m_userAgent = createUserAgent(); m_userAgent = userAgent ? strdup(userAgent) : createUserAgent();
} }

View file

@ -53,9 +53,9 @@ static inline char *createUserAgent()
} }
void Platform::init() void Platform::init(const char *userAgent)
{ {
m_userAgent = createUserAgent(); m_userAgent = userAgent ? strdup(userAgent) : createUserAgent();
} }

View file

@ -73,9 +73,9 @@ static inline char *createUserAgent()
} }
void Platform::init() void Platform::init(const char *userAgent)
{ {
m_userAgent = createUserAgent(); m_userAgent = userAgent ? strdup(userAgent) : createUserAgent();
} }