Skip to content

Commit

Permalink
Merge pull request #260 from zelcash/development
Browse files Browse the repository at this point in the history
v1.14.0
  • Loading branch information
TheTrunk authored Apr 7, 2021
2 parents 5f5c962 + f4cb3c6 commit efef0b6
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 20 deletions.
9 changes: 9 additions & 0 deletions ZelBack/src/services/benchmarkService.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,14 @@ async function getInfo(req, res) {
return res ? res.json(response) : response;
}

async function getPublicIp(req, res) {
const rpccall = 'getpublicip';

response = await executeCall(rpccall);

return res ? res.json(response) : response;
}

module.exports = {
// == Benchmarks ==
getStatus,
Expand All @@ -163,4 +171,5 @@ module.exports = {
// == Zelnode ==
getBenchmarks,
getInfo,
getPublicIp,
};
27 changes: 25 additions & 2 deletions ZelBack/src/services/fluxCommunication.js
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,7 @@ async function checkMyFluxAvailability(nodelist) {
// run if at least 10 available nodes
if (nodelist.length > 10) {
let askingIP = await getRandomConnection();
if (typeof askingIP !== 'string' || typeof myFluxIP !== 'string') {
if (typeof askingIP !== 'string' || typeof myFluxIP !== 'string' || myFluxIP === askingIP) {
return;
}
if (askingIP.includes(':')) {
Expand All @@ -1081,7 +1081,24 @@ async function checkMyFluxAvailability(nodelist) {
}
if (resMyAvailability.data.status === 'error' || resMyAvailability.data.data.message.includes('not')) {
log.error(`My Flux unavailability detected from ${askingIP}`);
// Asked Flux cannot reach me
// Asked Flux cannot reach me lets check if ip changed
const benchIpResponse = await daemonService.getPublicIp();
if (benchIpResponse.status === 'success') {
const benchMyIP = benchIpResponse.data.length > 5 ? benchIpResponse.data : null;
if (benchMyIP && benchMyIP !== myIP) {
myIP = benchMyIP;
const restartNodeResponse = await daemonService.restartNodeBenchmarks();
if (restartNodeResponse.status !== 'success') {
dosMessage = benchIpResponse.data;
dosState += 10;
}
await serviceHelper.delay(2 * 60 * 1000); // lets wait two minutes
return;
}
} else {
dosMessage = benchIpResponse.data;
dosState += 10;
}
dosState += 1.5;
if (dosState > 10) {
dosMessage = dosMessage || 'Flux is not available for outside communication';
Expand Down Expand Up @@ -1179,8 +1196,14 @@ async function checkDeterministicNodesCollisions() {
log.error(dosMessage);
}
}
setTimeout(() => {
checkDeterministicNodesCollisions();
}, 60 * 1000);
} catch (error) {
log.error(error);
setTimeout(() => {
checkDeterministicNodesCollisions();
}, 120 * 1000);
}
}

Expand Down
11 changes: 6 additions & 5 deletions ZelBack/src/services/fluxService.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ const cmd = require('node-cmd');
const path = require('path');
const config = require('config');
const fullnode = require('fullnode');
const fs = require('fs').promises;
const fs = require('fs');
const fsPromises = fs.promises;

const log = require('../lib/log');
const packageJson = require('../../../package.json');
Expand Down Expand Up @@ -266,7 +267,7 @@ async function daemonDebug(req, res) {
return res.json(errMessage);
}
// check daemon datadir
const defaultDir = new fullnode.Config().defaultFolderPath();
const defaultDir = new fullnode.Config().defaultFolder();
const datadir = daemonService.getConfigValue('datadir') || defaultDir;
const filepath = `${datadir}/debug.log`;

Expand All @@ -293,7 +294,7 @@ async function benchmarkDebug(req, res) {
async function tailDaemonDebug(req, res) {
const authorized = await serviceHelper.verifyAdminAndFluxTeamSession(req.headers);
if (authorized === true) {
const defaultDir = new fullnode.Config().defaultFolderPath();
const defaultDir = new fullnode.Config().defaultFolder();
const datadir = daemonService.getConfigValue('datadir') || defaultDir;
const filepath = `${datadir}/debug.log`;
const exec = `tail -n 100 ${filepath}`;
Expand Down Expand Up @@ -613,7 +614,7 @@ async function adjustCruxID(req, res) {
}
}`;

await fs.writeFile(fluxDirPath, dataToWrite);
await fsPromises.writeFile(fluxDirPath, dataToWrite);

const successMessage = serviceHelper.createSuccessMessage('CruxID adjusted');
res.json(successMessage);
Expand Down Expand Up @@ -658,7 +659,7 @@ async function adjustKadenaAccount(req, res) {
}
}`;

await fs.writeFile(fluxDirPath, dataToWrite);
await fsPromises.writeFile(fluxDirPath, dataToWrite);

const successMessage = serviceHelper.createSuccessMessage('Kadena account adjusted');
res.json(successMessage);
Expand Down
8 changes: 6 additions & 2 deletions ZelBack/src/services/serviceHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,10 @@ function verifyZelID(address) {
throw new Error('Missing parameters for message verification');
}

if (!address.startsWith('1')) {
throw new Error('Invalid zelID');
}

if (address.length > 36) {
const btcPubKeyHash = '00';
zeltrezjs.address.pubKeyToAddr(address, btcPubKeyHash);
Expand All @@ -491,7 +495,7 @@ function verifyZelID(address) {
return isValid;
}

function verifyMessage(message, address, signature) {
function verifyMessage(message, address, signature, strMessageMagic, checkSegwitAlways) {
let isValid = false;
let signingAddress = address;
try {
Expand All @@ -507,7 +511,7 @@ function verifyMessage(message, address, signature) {
// const sigAddress = bitcoinjs.payments.p2pkh({ pubkey: publicKeyBuffer }).address);
signingAddress = sigAddress;
}
isValid = bitcoinMessage.verify(message, signingAddress, signature);
isValid = bitcoinMessage.verify(message, signingAddress, signature, strMessageMagic, checkSegwitAlways);
} catch (e) {
log.error(e);
isValid = e;
Expand Down
3 changes: 0 additions & 3 deletions ZelBack/src/services/serviceManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ async function startFluxFunctions() {
daemonService.daemonBlockchainInfoService();
log.info('Flux Daemon Info Service Started');
fluxCommunication.checkDeterministicNodesCollisions();
setInterval(() => {
fluxCommunication.checkDeterministicNodesCollisions();
}, 60000);
log.info('Flux checks operational');
fluxCommunication.fluxDiscovery();
log.info('Flux Discovery started');
Expand Down
2 changes: 1 addition & 1 deletion ZelFront/src/components/Apps.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1610,7 +1610,7 @@
<div>
Note: Only verified developers and images can currently run on Flux. To become a verified developer with whitelisted images, please contact Flux Team via
<el-link
href="https://discord.io/zel"
href="https://discord.io/runonflux"
target="_blank"
type="primary"
>
Expand Down
2 changes: 1 addition & 1 deletion ZelFront/src/components/Daemon.vue
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@
Benchmarking: {{ callResponse.data.benchmarking }}
</p>
<p>
Flux: {{ callResponse.data.zelback }}
Flux: {{ callResponse.data.zelback || callResponse.data.flux }}
</p>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion helpers/benchmarkinfo.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": "2.0.0",
"version": "2.1.1",
"rpcport": 16224
}
4 changes: 2 additions & 2 deletions lib/daemonrpc/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ let zelcashMethods = [
'rescanblockchain',
'startzelbenchd',
'stopzelbenchd',
'getbenchmarks',
'getbenchstatus',
'getdoslist',
'getstartlist',
// zelbench
'getstatus',
'restartnodebenchmarks',
'signzelnodetransaction',
'getbenchmarks'
'getbenchmarks',
'getpublicip'
]
// ===----------------------------------------------------------------------===//
// callRpc
Expand Down
4 changes: 2 additions & 2 deletions lib/zelcashrpc/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ let zelcashMethods = [
'rescanblockchain',
'startzelbenchd',
'stopzelbenchd',
'getbenchmarks',
'getbenchstatus',
'getdoslist',
'getstartlist',
// zelbench
'getstatus',
'restartnodebenchmarks',
'signzelnodetransaction',
'getbenchmarks'
'getbenchmarks',
'getpublicip'
]
// ===----------------------------------------------------------------------===//
// callRpc
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "flux",
"version": "1.13.3",
"version": "1.14.0",
"description": "Flux, Your Gateway to a Decentralized World",
"repository": {
"type": "git",
Expand Down

0 comments on commit efef0b6

Please sign in to comment.