|
|
|
@ -184,7 +184,7 @@ let VarDiff = (function () {
|
|
|
|
|
};
|
|
|
|
|
})();
|
|
|
|
|
|
|
|
|
|
function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVersion, portType, port) {
|
|
|
|
|
function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVersion, portType, port, agent) {
|
|
|
|
|
// Username Layout - <address in BTC or XMR>.<Difficulty>
|
|
|
|
|
// Password Layout - <password>.<miner identifier>.<payment ID for XMR>
|
|
|
|
|
// Default function is to use the password so they can login. Identifiers can be unique, payment ID is last.
|
|
|
|
@ -195,6 +195,9 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer
|
|
|
|
|
let pass_split = pass.split(":");
|
|
|
|
|
this.error = "";
|
|
|
|
|
this.identifier = pass_split[0];
|
|
|
|
|
if (agent.includes('MinerGate')){
|
|
|
|
|
this.identifier = "MinerGate";
|
|
|
|
|
}
|
|
|
|
|
this.paymentID = null;
|
|
|
|
|
this.valid_miner = true;
|
|
|
|
|
this.port = port;
|
|
|
|
@ -220,6 +223,10 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer
|
|
|
|
|
this.fixed_diff = false;
|
|
|
|
|
this.difficulty = startingDiff;
|
|
|
|
|
this.connectTime = Date.now();
|
|
|
|
|
if (agent.includes('NiceHash')){
|
|
|
|
|
this.fixed_diff = true;
|
|
|
|
|
this.difficulty = global.coinFuncs.niceHashDiff;
|
|
|
|
|
}
|
|
|
|
|
if (diffSplit.length === 2) {
|
|
|
|
|
this.fixed_diff = true;
|
|
|
|
|
this.difficulty = Number(diffSplit[1]);
|
|
|
|
@ -568,13 +575,13 @@ function handleMinerData(method, params, ip, portData, sendReply, pushMessage) {
|
|
|
|
|
}
|
|
|
|
|
switch (method) {
|
|
|
|
|
case 'login':
|
|
|
|
|
if (!params.login || !params.pass) {
|
|
|
|
|
if (!params.login || (!params.pass && !params.agent.includes('MinerGate'))) {
|
|
|
|
|
sendReply("No login/password specified");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
let difficulty = portData.difficulty;
|
|
|
|
|
let minerId = uuidV4();
|
|
|
|
|
miner = new Miner(minerId, params.login, params.pass, ip, difficulty, pushMessage, 1, portData.portType, portData.port);
|
|
|
|
|
miner = new Miner(minerId, params.login, params.pass, ip, difficulty, pushMessage, 1, portData.portType, portData.port, params.agent);
|
|
|
|
|
if (!miner.valid_miner) {
|
|
|
|
|
console.log("Invalid miner, disconnecting due to: " + miner.error);
|
|
|
|
|
sendReply(miner.error);
|
|
|
|
|