Sync changes with proxy.

This commit is contained in:
XMRig 2018-11-06 00:50:28 +07:00
parent 3d60b3cc62
commit a76243a65e
9 changed files with 402 additions and 97 deletions

View file

@ -280,16 +280,16 @@ bool xmrig::CommonConfig::parseBoolean(int key, bool enable)
break;
case KeepAliveKey: /* --keepalive */
m_pools.back().setKeepAlive(enable ? Pool::kKeepAliveTimeout : 0);
currentPool().setKeepAlive(enable ? Pool::kKeepAliveTimeout : 0);
break;
case TlsKey: /* --tls */
m_pools.back().setTLS(enable);
currentPool().setTLS(enable);
break;
# ifndef XMRIG_PROXY_PROJECT
case NicehashKey: /* --nicehash */
m_pools.back().setNicehash(enable);
currentPool().setNicehash(enable);
break;
# endif
@ -333,13 +333,15 @@ bool xmrig::CommonConfig::parseString(int key, const char *arg)
break;
case UserpassKey: /* --userpass */
if (!m_pools.back().setUserpass(arg)) {
if (!currentPool().setUserpass(arg)) {
return false;
}
break;
case UrlKey: /* --url */
fixup();
if (m_pools.size() > 1 || m_pools[0].isValid()) {
Pool pool(arg);
@ -358,23 +360,23 @@ bool xmrig::CommonConfig::parseString(int key, const char *arg)
break;
case UserKey: /* --user */
m_pools.back().setUser(arg);
currentPool().setUser(arg);
break;
case PasswordKey: /* --pass */
m_pools.back().setPassword(arg);
currentPool().setPassword(arg);
break;
case RigIdKey: /* --rig-id */
m_pools.back().setRigId(arg);
currentPool().setRigId(arg);
break;
case FingerprintKey: /* --tls-fingerprint */
m_pools.back().setFingerprint(arg);
currentPool().setFingerprint(arg);
break;
case VariantKey: /* --variant */
m_pools.back().algorithm().parseVariant(arg);
currentPool().algorithm().parseVariant(arg);
break;
case LogFileKey: /* --log-file */
@ -462,11 +464,11 @@ bool xmrig::CommonConfig::parseInt(int key, int arg)
break;
case KeepAliveKey: /* --keepalive */
m_pools.back().setKeepAlive(arg);
currentPool().setKeepAlive(arg);
break;
case VariantKey: /* --variant */
m_pools.back().algorithm().parseVariant(arg);
currentPool().algorithm().parseVariant(arg);
break;
case DonateLevelKey: /* --donate-level */
@ -493,3 +495,30 @@ bool xmrig::CommonConfig::parseInt(int key, int arg)
return true;
}
Pool &xmrig::CommonConfig::currentPool()
{
fixup();
return m_pools.back();
}
void xmrig::CommonConfig::fixup()
{
if (m_state == NoneState) {
return;
}
if (m_pools.empty()) {
if (!m_activePools.empty()) {
std::swap(m_pools, m_activePools);
}
else {
m_pools.push_back(Pool());
}
m_state = NoneState;
}
}

View file

@ -112,9 +112,11 @@ protected:
private:
bool parseInt(int key, int arg);
Pool &currentPool();
void fixup();
};
} /* namespace xmrig */
#endif /* __COMMONCONFIG_H__ */
#endif /* XMRIG_COMMONCONFIG_H */

View file

@ -97,16 +97,23 @@ public:
OclCompModeKey = 1410,
// xmrig-proxy
AccessLogFileKey = 'A',
BindKey = 'b',
CoinKey = 1104,
CustomDiffKey = 1102,
DebugKey = 1101,
ModeKey = 'm',
PoolCoinKey = 'C',
ReuseTimeoutKey = 1106,
WorkersKey = 1103,
WorkersAdvKey = 1107,
AccessLogFileKey = 'A',
BindKey = 'b',
CoinKey = 1104,
CustomDiffKey = 1102,
DebugKey = 1101,
ModeKey = 'm',
PoolCoinKey = 'C',
ReuseTimeoutKey = 1106,
WorkersKey = 1103,
WorkersAdvKey = 1107,
TlsBindKey = 1108,
TlsCertKey = 1109,
TlsCertKeyKey = 1110,
TlsDHparamKey = 1111,
TlsCiphersKey = 1112,
TlsCipherSuitesKey = 1113,
TlsProtocolsKey = 1114,
// xmrig nvidia
CudaMaxThreadsKey = 1200,

View file

@ -21,8 +21,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __LOG_H__
#define __LOG_H__
#ifndef XMRIG_LOG_H
#define XMRIG_LOG_H
#include <assert.h>
@ -39,7 +39,7 @@ public:
static inline Log* i() { if (!m_self) { defaultInit(); } return m_self; }
static inline void add(ILogBackend *backend) { i()->m_backends.push_back(backend); }
static inline void init() { if (!m_self) { new Log(); } }
static inline void release() { assert(m_self != nullptr); delete m_self; }
static inline void release() { delete m_self; }
void message(ILogBackend::Level level, const char* fmt, ...);
void text(const char* fmt, ...);
@ -98,4 +98,4 @@ private:
# define LOG_DEBUG_WARN(x, ...)
#endif
#endif /* __LOG_H__ */
#endif /* XMRIG_LOG_H */

View file

@ -21,8 +21,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef XMRIG_TLS_H
#define XMRIG_TLS_H
#ifndef XMRIG_CLIENT_TLS_H
#define XMRIG_CLIENT_TLS_H
#include <openssl/ssl.h>
@ -59,4 +59,4 @@ private:
};
#endif /* XMRIG_TLS_H */
#endif /* XMRIG_CLIENT_TLS_H */

View file

@ -21,82 +21,19 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __C_STR_H__
#define __C_STR_H__
#ifndef XMRIG_C_STR_H
#define XMRIG_C_STR_H
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "base/tools/String.h"
namespace xmrig {
/**
* @brief Simple C string wrapper.
*
* 1. I know about std:string.
* 2. For some reason I prefer don't use std:string in miner, eg because of file size of MSYS2 builds.
*/
class c_str
{
public:
inline c_str() : m_data(nullptr) {}
inline c_str(c_str &&other) { m_data = other.m_data; other.m_data = nullptr; }
inline c_str(const c_str &other) : m_data(nullptr) { set(other.data()); }
inline c_str(const char *str) : m_data(nullptr) { set(str); }
inline ~c_str() { free(m_data); }
inline void set(const char *str)
{
free(m_data);
m_data = str != nullptr ? strdup(str) : nullptr;
}
inline void set(char *str)
{
free(m_data);
m_data = str;
}
inline bool isEqual(const char *str) const
{
return (m_data != nullptr && str != nullptr && strcmp(m_data, str) == 0) || (m_data == nullptr && m_data == nullptr);
}
inline bool contains(const char *str) const
{
return strstr(m_data, str) != nullptr;
}
inline bool isNull() const { return m_data == nullptr; }
inline const char *data() const { return m_data; }
inline size_t size() const { return m_data == nullptr ? 0 : strlen(m_data); }
inline bool operator!=(const c_str &str) const { return !isEqual(str.data()); }
inline bool operator!=(const char *str) const { return !isEqual(str); }
inline bool operator==(const c_str &str) const { return isEqual(str.data()); }
inline bool operator==(const char *str) const { return isEqual(str); }
inline c_str &operator=(char *str) { set(str); return *this; }
inline c_str &operator=(const c_str &str) { set(str.data()); return *this; }
inline c_str &operator=(const char *str) { set(str); return *this; }
private:
char *m_data;
};
typedef String c_str;
} /* namespace xmrig */
#endif /* __C_STR_H__ */
#endif /* XMRIG_C_STR_H */