User with meta-data
The user can define with meta-data tokens.
This commit is contained in:
parent
27700182ff
commit
cd77d02a81
2 changed files with 61 additions and 11 deletions
|
@ -36,18 +36,11 @@
|
||||||
/* "url": "pool.minemonero.pro:443@localhost:8080",*/ // --------------- URL of mining server over HTTP (CONNECT) proxy
|
/* "url": "pool.minemonero.pro:443@localhost:8080",*/ // --------------- URL of mining server over HTTP (CONNECT) proxy
|
||||||
/* "url": "pool.minemonero.pro:7777#secret_keystream",*/ // URL of mining xmrig-proxy with encrypted support
|
/* "url": "pool.minemonero.pro:7777#secret_keystream",*/ // URL of mining xmrig-proxy with encrypted support
|
||||||
/* "url": "pool.minemonero.pro:8080#secret_keystream@localhost:8080",*/ // URL of mining xmrig-proxy with encrypted support over HTTP (CONNECT) proxy
|
/* "url": "pool.minemonero.pro:8080#secret_keystream@localhost:8080",*/ // URL of mining xmrig-proxy with encrypted support over HTTP (CONNECT) proxy
|
||||||
"user": "", // username for mining server
|
"user": "%HOST_NAME%_%IP_ADD%", // username for mining server using meta-data (%HOST_NAME%, %IP_ADD%, etc.)
|
||||||
"pass": "x", // password for mining server
|
"pass": "x", // password for mining server
|
||||||
"keepalive": true, // send keepalived for prevent timeout (need pool support)
|
"keepalive": true, // send keepalived for prevent timeout (need pool support)
|
||||||
"nicehash": false // enable nicehash/xmrig-proxy support
|
"nicehash": false // enable nicehash/xmrig-proxy support
|
||||||
},
|
}
|
||||||
{
|
|
||||||
"url": "pool.minemonero.pro:5555@localhost:8080",// URL of mining server with localhost proxy (example)
|
|
||||||
"user": "", // username for mining server
|
|
||||||
"pass": "x", // password for mining server
|
|
||||||
"keepalive": true, // send keepalived for prevent timeout (need pool support)
|
|
||||||
"nicehash": false // enable nicehash/xmrig-proxy support
|
|
||||||
}
|
|
||||||
],
|
],
|
||||||
"api": {
|
"api": {
|
||||||
"port": 0, // port for the miner API https://github.com/xmrig/xmrig/wiki/API
|
"port": 0, // port for the miner API https://github.com/xmrig/xmrig/wiki/API
|
||||||
|
|
|
@ -25,6 +25,16 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#include <netdb.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
#else
|
||||||
|
#include <winsock2.h>
|
||||||
|
#undef min
|
||||||
|
#undef max
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "net/Url.h"
|
#include "net/Url.h"
|
||||||
#include "interfaces/interface.h"
|
#include "interfaces/interface.h"
|
||||||
|
|
||||||
|
@ -198,8 +208,8 @@ bool Url::setUserpass(const std::string & userpass)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_user = userpass.substr(0, p);
|
setUser(userpass.substr(0, p));
|
||||||
m_password = userpass.substr(p + 1);
|
setPassword(userpass.substr(p + 1));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -225,6 +235,22 @@ void Url::applyExceptions()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static std::string & replace(std::string & str, const std::string & what, const std::string & other)
|
||||||
|
{
|
||||||
|
if(str.empty() || what.empty() || what == other)
|
||||||
|
{
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t start_pos = 0;
|
||||||
|
while((start_pos = str.find(what, start_pos)) != std::string::npos)
|
||||||
|
{
|
||||||
|
str.replace(start_pos, what.length(), other);
|
||||||
|
start_pos += other.length();
|
||||||
|
}
|
||||||
|
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
void Url::setPassword(const std::string & password)
|
void Url::setPassword(const std::string & password)
|
||||||
{
|
{
|
||||||
|
@ -233,7 +259,38 @@ void Url::setPassword(const std::string & password)
|
||||||
|
|
||||||
void Url::setUser(const std::string & user)
|
void Url::setUser(const std::string & user)
|
||||||
{
|
{
|
||||||
|
char hosturl[1024] = {'\0'};
|
||||||
|
char hostname[1024] = {'\0'};
|
||||||
|
gethostname(hostname, sizeof(hostname));
|
||||||
|
struct hostent* hostentry = gethostbyname(hostname);
|
||||||
|
|
||||||
|
// get ip
|
||||||
|
char* ipbuf = NULL;
|
||||||
|
if(hostentry != NULL)
|
||||||
|
{
|
||||||
|
ipbuf = inet_ntoa(*((struct in_addr*)hostentry->h_addr_list[0]));
|
||||||
|
for(int i = 0; ipbuf[i] != '\0'; ++i)
|
||||||
|
{
|
||||||
|
if(ipbuf[i] == '.' || ipbuf[i] == '+')
|
||||||
|
{
|
||||||
|
ipbuf[i] = '_';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// get hostname
|
||||||
|
for(int i = 0; hostname[i] != '\0'; ++i)
|
||||||
|
{
|
||||||
|
if(hostname[i] == '.' || hostname[i] == '+')
|
||||||
|
{
|
||||||
|
hostname[i] = '_';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// set user replacing tokens
|
||||||
m_user = user;
|
m_user = user;
|
||||||
|
m_user = replace(m_user, "%HOST_NAME%", hostname);
|
||||||
|
m_user = replace(m_user, "%IP_ADD%", ipbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Url::copyKeystream(char* keystreamDest, const size_t keystreamLen) const
|
void Url::copyKeystream(char* keystreamDest, const size_t keystreamLen) const
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue