Include proxy (CONNECT)

The 'config.json' and the '-o' command option allow to include a proxy:
poolHost[:poolPort[@proxyHost[:proxyPort]].
This commit is contained in:
enWILLYado 2018-01-15 23:52:57 +01:00
parent 916cf0ae0d
commit 4dd26f6044
5 changed files with 100 additions and 9 deletions

View file

@ -34,6 +34,7 @@ public:
constexpr static const char *kDefaultPassword = "x";
constexpr static const char *kDefaultUser = "x";
constexpr static uint16_t kDefaultPort = 3333;
constexpr static uint16_t kDefaultProxyPort = 8080;
Url();
Url(const char *url);
@ -43,10 +44,15 @@ public:
inline bool isKeepAlive() const { return m_keepAlive; }
inline bool isNicehash() const { return m_nicehash; }
inline bool isValid() const { return m_host && m_port > 0; }
inline const char *host() const { return m_host; }
inline const char *host() const { return isProxyed() ? proxyHost() : finalHost(); }
inline const char *password() const { return m_password ? m_password : kDefaultPassword; }
inline const char *user() const { return m_user ? m_user : kDefaultUser; }
inline uint16_t port() const { return m_port; }
inline uint16_t port() const { return isProxyed() ? proxyPort() : finalPort(); }
inline bool isProxyed() const { return proxyHost(); }
inline const char* finalHost() const { return m_host; }
inline uint16_t finalPort() const { return m_port;}
inline const char* proxyHost() const { return m_proxy_host; }
inline uint16_t proxyPort() const { return m_proxy_port; }
inline void setKeepAlive(bool keepAlive) { m_keepAlive = keepAlive; }
inline void setNicehash(bool nicehash) { m_nicehash = nicehash; }
@ -65,6 +71,8 @@ private:
char *m_password;
char *m_user;
uint16_t m_port;
char* m_proxy_host;
uint16_t m_proxy_port;
};
#endif /* __URL_H__ */