From 90a6ada67c1fe2f7e5a35b4842ccbacaa8f47800 Mon Sep 17 00:00:00 2001 From: Asher Dawes Date: Wed, 11 Oct 2023 11:15:50 -0700 Subject: [PATCH] Update conf file generation --- routes/api/daemonControl.js | 23 +++++++++++++++++++++-- routes/api/native/verusbridge/vethconf.js | 17 +++++++++-------- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/routes/api/daemonControl.js b/routes/api/daemonControl.js index 07d554b8..f2fda772 100644 --- a/routes/api/daemonControl.js +++ b/routes/api/daemonControl.js @@ -58,7 +58,7 @@ module.exports = (api) => { api.writeRpcUser = (confFile) => { return new Promise((resolve, reject) => { api.log(`creating rpcuser for ${confFile}...`, "native.process"); - fs.appendFile(confFile, '\nrpcuser=verusdesktop') + fs.appendFile(confFile, `\nrpcuser=${generateRpcPassword()}`) .then(resolve) .catch(e => reject(e)) }) @@ -72,7 +72,22 @@ module.exports = (api) => { .catch(e => reject(e)) }) } - + api.writeRpcHost = (confFile) => { + return new Promise((resolve, reject) => { + api.log(`setting rpchost for ${confFile}...`, "native.process"); + fs.appendFile(confFile, '\nrpchost=127.0.0.1') + .then(resolve) + .catch(e => reject(e)) + }) + } + api.writeRpcAllowIP = (confFile) => { + return new Promise((resolve, reject) => { + api.log(`setting rpcallowip for ${confFile}...`, "native.process"); + fs.appendFile(confFile, '\nrpcallowip=127.0.0.1') + .then(resolve) + .catch(e => reject(e)) + }) + } api.writeRpcPort = (coin, confFile, fallbackPort) => { return new Promise((resolve, reject) => { api.log(`creating rpcport for ${confFile}...`, "native.process"); @@ -220,6 +235,8 @@ module.exports = (api) => { api.confFileIndex[coin] = confFile; if (coin === 'VRSCTEST') { return Promise.all([ + api.writeRpcHost(confFile), + api.writeRpcAllowIP(confFile), api.writeRpcPort(coin, confFile, fallbackPort), api.writeRpcPassword(confFile), api.writeRpcUser(confFile), @@ -227,6 +244,8 @@ module.exports = (api) => { ]); } else { return Promise.all([ + api.writeRpcHost(confFile), + api.writeRpcAllowIP(confFile), api.writeRpcPort(coin, confFile, fallbackPort), api.writeRpcPassword(confFile), api.writeRpcUser(confFile) diff --git a/routes/api/native/verusbridge/vethconf.js b/routes/api/native/verusbridge/vethconf.js index 20a0ea8a..61e84ab7 100644 --- a/routes/api/native/verusbridge/vethconf.js +++ b/routes/api/native/verusbridge/vethconf.js @@ -3,6 +3,7 @@ const os = require("os"); const path = require("path"); var ini = require("ini"); const fixPath = require("fix-path"); +const {generateRpcPassword} = require("../../utils/auth/rpcAuth"); const INIKeys = { rpcuser: "", @@ -38,24 +39,24 @@ const vethFolder = { const RPCDefault = { VRSCTEST: { - rpcuser: "user", - rpcpassword: "password", - rpcport: 8000, + rpcuser: `${generateRpcPassword()}`, + rpcpassword: `${generateRpcPassword()}`, + rpcport: 8002, rpchost: "127.0.0.1", delegatorcontractaddress: "empty", testnet: true, privatekey: "empty", - ethnode: "empty", + ethnode: "wss://goerli.infura.io/ws/v3/........", }, VRSC: { - rpcuser: "username", - rpcpassword: "password", - rpcport: 8000, + rpcuser: `${generateRpcPassword()}`, + rpcpassword: `${generateRpcPassword()}`, + rpcport: 8002, rpchost: "127.0.0.1", delegatorcontractaddress: "empty", testnet: false, privatekey: "empty", - ethnode: "wss://rinkeby.infura.io/ws/v3/........", + ethnode: "wss://mainnet.infura.io/ws/v3/........", }, };