Socket
Socket
Sign inDemoInstall

coin-hive-stratum

Package Overview
Dependencies
Maintainers
1
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

coin-hive-stratum - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

2

package.json
{
"name": "coin-hive-stratum",
"version": "1.1.1",
"version": "1.1.2",
"description": "proxy to use CoinHive miner on any stratum pool",

@@ -5,0 +5,0 @@ "main": "src/proxy.js",

@@ -54,3 +54,3 @@ CoinHive Stratum Proxy

- `createServer`: Creates a `proxy` server. It may take an `options` object with the following optional properties:
- `createProxy`: Creates a `proxy` server. It may take an `options` object with the following optional properties:

@@ -57,0 +57,0 @@ - `host`: the pool's host.

@@ -62,3 +62,8 @@ const WebSocket = require("ws");

log("\nmessage from miner to pool:\n\n", message);
const data = JSON.parse(message);
let data = null;
try {
data = JSON.parse(message);
} catch (e) {
return log("\ncan't parse message as JSON from miner:\n\n", message);
}
switch (data.type) {

@@ -106,4 +111,9 @@ case "auth": {

if (connection.online) {
connection.ws.send(coinHiveMessage);
log("\nmessage sent to miner:\n\n", coinHiveMessage);
try {
connection.ws.send(coinHiveMessage);
log("\nmessage sent to miner:\n\n", coinHiveMessage);
} catch (e) {
log("\nsocket seems to be already closed.");
killConnection(connection);
}
} else {

@@ -138,4 +148,22 @@ log(

log("\nmessage from pool to miner:\n\n", stratumMessage);
const data = JSON.parse(stratumMessage);
let data = null;
try {
data = JSON.parse(stratumMessage);
} catch (e) {
return sendToMiner(connection, {
type: "error",
params: {
error: "parse_pool_response"
}
});
}
if (data.id === 1) {
if (data.error && data.error.code === -1) {
return sendToMiner(connection, {
type: "error",
params: {
error: "invalid_site_key"
}
});
}
connection.workerId = data.result.id;

@@ -211,11 +239,12 @@ sendToMiner(connection, {

return {
listen: function listen(port = 8892) {
let wss;
listen: function listen(wssOptions) {
if (wssOptions !== Object(wssOptions)) {
wssOptions = { port: +wssOptions };
}
if (options.path) {
wss = new WebSocket.Server({ path: options.path, port: +port });
} else {
wss = new WebSocket.Server({ port: +port });
wssOptions.path = options.path;
}
const wss = new WebSocket.Server(wssOptions);
log("websocket server created");
log("listening on port", port);
log("listening on port", wssOptions.port);
wss.on("connection", ws => {

@@ -222,0 +251,0 @@ const connection = getConnection(ws);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc