Adding limit ranges and port blocking on the API.

This commit is contained in:
Alexander Blair
2017-02-15 17:09:38 -08:00
parent 7c79ceede5
commit 67e9a0bde1
2 changed files with 33 additions and 18 deletions
+7 -1
View File
@@ -22,6 +22,7 @@ let httpResponse = ' 200 OK\nContent-Type: text/plain\nContent-Length: 18\n\nMin
let threadName;
let minerCount = [];
let BlockTemplate = global.coinFuncs.BlockTemplate;
let hexMatch = new RegExp("^[0-9a-f]$");
Buffer.prototype.toByteArray = function () {
return Array.prototype.slice.call(this, 0);
@@ -232,9 +233,14 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer
this.error = "Too many options in the login field";
this.valid_miner = false;
}
if (typeof(addressSplit[1]) !== 'undefined' && (addressSplit[1].length === 16 || addressSplit[1].length === 64)) {
if (typeof(addressSplit[1]) !== 'undefined' && addressSplit[1].length === 64 && addressSplit[1].test(hexMatch)) {
this.paymentID = addressSplit[1];
this.payout = this.address + "." + this.paymentID;
} else if (addressSplit[1] !== 'undefined') {
this.identifier = this.identifier === 'x' ? addressSplit[1] : pass_split[0];
}
if (typeof(addressSplit[2]) !== 'undefined') {
this.identifier = this.identifier === 'x' ? addressSplit[2] : pass_split[0];
}
if (pass_split.length === 2) {