Skip to content

Commit

Permalink
fix equihash usage, minor test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lilyannehall committed Nov 20, 2024
1 parent 64e1d06 commit d673dce
Show file tree
Hide file tree
Showing 10 changed files with 1,492 additions and 954 deletions.
21 changes: 14 additions & 7 deletions bin/kadence.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,20 @@ async function _init() {
);
// If identity is not solved yet, start trying to solve it
// if (!identity.validate()) {
logger.warn('eclipse plugin is busted , equihash bindings are old and incompatible with gcc-11')
// logger.warn(`identity proof not yet solved, this can take a while`);
// await identity.solve();
// fs.writeFileSync(config.IdentityNoncePath, identity.nonce.toString());
// fs.writeFileSync(config.IdentityProofPath, identity.proof);
// }
let identityHasValidProof = false;
try {
identityHasValidProof = await identity.validate();
} catch (err) {
logger.error(err.message);
}
if (!identityHasValidProof) {
logger.warn(`identity proof not yet solved, this can take a while`);
await identity.solve();
fs.writeFileSync(config.IdentityNoncePath, identity.nonce.toString());
fs.writeFileSync(config.IdentityProofPath, identity.proof);
}
init();
}
Expand Down
5 changes: 0 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ services:
- ./bin:/root/kadence/bin
- ./lib:/root/kadence/lib
- ./index.js:/root/kadence/index.js
- ./node_modules:/root/kadence/node_modules
- ./package.json:/root/kadence/package.json
ports:
- "6274:5274"
Expand All @@ -32,7 +31,6 @@ services:
- ./bin:/root/kadence/bin
- ./lib:/root/kadence/lib
- ./index.js:/root/kadence/index.js
- ./node_modules:/root/kadence/node_modules
- ./package.json:/root/kadence/package.json
kadence-3:
build:
Expand All @@ -47,7 +45,6 @@ services:
- ./bin:/root/kadence/bin
- ./lib:/root/kadence/lib
- ./index.js:/root/kadence/index.js
- ./node_modules:/root/kadence/node_modules
- ./package.json:/root/kadence/package.json
kadence-4:
build:
Expand All @@ -62,7 +59,6 @@ services:
- ./bin:/root/kadence/bin
- ./lib:/root/kadence/lib
- ./index.js:/root/kadence/index.js
- ./node_modules:/root/kadence/node_modules
- ./package.json:/root/kadence/package.json
kadence-5:
build:
Expand All @@ -77,5 +73,4 @@ services:
- ./bin:/root/kadence/bin
- ./lib:/root/kadence/lib
- ./index.js:/root/kadence/index.js
- ./node_modules:/root/kadence/node_modules
- ./package.json:/root/kadence/package.json
2 changes: 1 addition & 1 deletion lib/plugin-eclipse.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class EclipseIdentity extends EventEmitter {

/**
* Validates the
* @returns {boolean}
* @returns {Promise<boolean>}
*/
validate() {
return utils.eqverify(utils.hash256(this.pubkey),
Expand Down
9 changes: 7 additions & 2 deletions lib/plugin-traverse.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,13 @@ class TraversePlugin {
* @private
*/
_testIfReachable(callback) {
if (!ip.isPublic(this.node.contact.hostname)) {
this.node.logger.warn('traversal strategy failed, not reachable');
try {
if (!ip.isPublic(this.node.contact.hostname)) {
this.node.logger.warn('traversal strategy failed, not reachable');
return callback(null, false);
}
} catch (err) {
this.node.logger.warn(err.message);
return callback(null, false);
}

Expand Down
4 changes: 3 additions & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const assert = require('node:assert');
const { randomBytes, createHash } = crypto;
const ms = require('ms');
const equihash = require('@tacticalchihuahua/equihash');
const onionRegex = require('onion-regex');


/**
Expand Down Expand Up @@ -327,7 +328,8 @@ module.exports.isValidContact = function(contact, loopback) {
const [, info] = contact;
const isValidAddr = ip.isV4Format(info.hostname) ||
ip.isV6Format(info.hostname) ||
ip.isPublic(info.hostname);
ip.isPublic(info.hostname) ||
onionRegex.v3({ exact: true }).test(info.hostname);
const isValidPort = info.port > 0;
const isAllowedAddr = ip.isLoopback(info.hostname) ? !!loopback : true;

Expand Down
Loading

0 comments on commit d673dce

Please sign in to comment.