/* XMRig * Copyright 2010 Jeff Garzik * Copyright 2012-2014 pooler * Copyright 2014 Lucas Jones * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , * Copyright 2018-2019 SChernykh * Copyright 2016-2019 XMRig , * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef XMRIG_POOL_H #define XMRIG_POOL_H #include #include "base/tools/String.h" #include "common/crypto/Algorithm.h" #include "rapidjson/fwd.h" namespace xmrig { class Pool { public: static const String kDefaultPassword; static const String kDefaultUser; constexpr static uint16_t kDefaultPort = 3333; constexpr static int kKeepAliveTimeout = 60; Pool(); Pool(const char *url); Pool(const rapidjson::Value &object); Pool(const char *host, uint16_t port, const char *user = nullptr, const char *password = nullptr, int keepAlive = 0, bool nicehash = false, bool tls = false ); inline Algorithm &algorithm() { return m_algorithm; } inline bool isNicehash() const { return m_nicehash; } inline bool isTLS() const { return m_tls; } inline bool isValid() const { return !m_host.isNull() && m_port > 0; } inline const Algorithm &algorithm() const { return m_algorithm; } inline const Algorithms &algorithms() const { return m_algorithms; } inline const String &fingerprint() const { return m_fingerprint; } inline const String &host() const { return m_host; } inline const String &password() const { return !m_password.isNull() ? m_password : kDefaultPassword; } inline const String &rigId() const { return m_rigId; } inline const String &url() const { return m_url; } inline const String &user() const { return !m_user.isNull() ? m_user : kDefaultUser; } inline int keepAlive() const { return m_keepAlive; } inline uint16_t port() const { return m_port; } inline void setFingerprint(const char *fingerprint) { m_fingerprint = fingerprint; } inline void setKeepAlive(bool enable) { setKeepAlive(enable ? kKeepAliveTimeout : 0); } inline void setKeepAlive(int keepAlive) { m_keepAlive = keepAlive >= 0 ? keepAlive : 0; } inline void setNicehash(bool nicehash) { m_nicehash = nicehash; } inline void setPassword(const char *password) { m_password = password; } inline void setRigId(const char *rigId) { m_rigId = rigId; } inline void setTLS(bool tls) { m_tls = tls; } inline void setUser(const char *user) { m_user = user; } inline bool operator!=(const Pool &other) const { return !isEqual(other); } inline bool operator==(const Pool &other) const { return isEqual(other); } bool isCompatible(const Algorithm &algorithm) const; bool isEnabled() const; bool isEqual(const Pool &other) const; bool parse(const char *url); bool setUserpass(const char *userpass); rapidjson::Value toJSON(rapidjson::Document &doc) const; void adjust(const Algorithm &algorithm); void setAlgo(const Algorithm &algorithm); # ifdef APP_DEBUG void print() const; # endif private: bool parseIPv6(const char *addr); void addVariant(Variant variant); void adjustVariant(const Variant variantHint); void rebuild(); Algorithm m_algorithm; Algorithms m_algorithms; bool m_enabled; bool m_nicehash; bool m_tls; int m_keepAlive; String m_fingerprint; String m_host; String m_password; String m_rigId; String m_url; String m_user; uint16_t m_port; }; } /* namespace xmrig */ #endif /* XMRIG_POOL_H */