z-nomp/scripts/coinSwitch.js

38 lines
956 B
JavaScript
Raw Normal View History

2014-04-06 20:11:53 -07:00
/*
This script demonstrates sending a coin switch request and can be invoked from the command line
with:
2014-04-06 20:11:53 -07:00
"node coinSwitch.js 127.0.0.1:8118 password %s"
2014-04-06 20:11:53 -07:00
where <%s> is the name of the coin proxy miners will be switched onto.
2014-04-06 20:11:53 -07:00
If the coin name is not configured, disabled or matches the existing proxy setting, no action
will be taken by NOMP on receipt of the message.
*/
2014-04-06 20:11:53 -07:00
var net = require('net');
var config = process.argv[2];
var parts = config.split(':');
var host = parts[0];
var port = parts[1];
var password = process.argv[3];
var coin = process.argv[4];
2014-04-06 20:11:53 -07:00
var client = net.connect(port, host, function () {
2014-04-06 20:11:53 -07:00
console.log('client connected');
client.write(JSON.stringify({
password: password,
coin: coin
2014-04-06 20:11:53 -07:00
}) + '\n');
});
client.on('data', function (data) {
2014-04-06 20:11:53 -07:00
console.log(data.toString());
//client.end();
});
client.on('end', function () {
2014-04-06 20:11:53 -07:00
console.log('client disconnected');
//process.exit();
});