hive-p2p 1.0.113 → 1.0.114
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/core/arbiter.mjs
CHANGED
|
@@ -69,7 +69,7 @@ export class Arbiter {
|
|
|
69
69
|
if (peerId === this.id) return; // self
|
|
70
70
|
if (delta) this.trustBalances[peerId] = Math.min(MAX_TRUST, (this.trustBalances[peerId] || 0) + delta);
|
|
71
71
|
if (delta && this.verbose > 3) console.log(`%c(Arbiter: ${this.id}) ${peerId} +${delta}ms (${reason}). Updated: ${this.trustBalances[peerId]}ms.`, LOG_CSS.ARBITER);
|
|
72
|
-
if (this.isBanished(peerId) && this.verbose > 1) console.log(`%c(Arbiter: ${this.id}) Peer ${peerId} is now banished
|
|
72
|
+
if (this.isBanished(peerId) && this.verbose > 1) console.log(`%c(Arbiter: ${this.id}) Peer ${peerId} is now banished. (${reason})`, LOG_CSS.ARBITER);
|
|
73
73
|
}
|
|
74
74
|
/** MANUAL BAN (if enabled) @param {string} peerId */
|
|
75
75
|
setBanished(peerId) {
|
|
@@ -134,7 +134,7 @@ export class Arbiter {
|
|
|
134
134
|
}
|
|
135
135
|
/** UNICAST only @param {string} from @param {import('./unicast.mjs').DirectMessage} message */
|
|
136
136
|
#routeLengthControl(from, message) {
|
|
137
|
-
if (message.route.length <= UNICAST.MAX_HOPS) return true;
|
|
137
|
+
if (message.route.length <= UNICAST.MAX_HOPS + 1) return true;
|
|
138
138
|
this.adjustTrust(from, TRUST_VALUES.HOPS_EXCEEDED, 'Unicast HOPS exceeded');
|
|
139
139
|
}
|
|
140
140
|
/** ONLY APPLY AFTER #signatureControl() - @param {string} senderId @param {Uint8Array} pubkey */
|
package/core/crypto-codex.mjs
CHANGED
|
@@ -293,13 +293,13 @@ export class CryptoCodex {
|
|
|
293
293
|
const initialMessageEnd = signatureStart + IDENTITY.SIGNATURE_LENGTH;
|
|
294
294
|
const signature = serialized.slice(signatureStart, initialMessageEnd);
|
|
295
295
|
const isPatched = (serialized.length > initialMessageEnd);
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
const
|
|
300
|
-
const newRoute = this.#bytesToIds(serialized.slice(initialMessageEnd + 32, serialized.length - IDENTITY.SIGNATURE_LENGTH));
|
|
301
|
-
const
|
|
302
|
-
return new DirectMessage(type, timestamp, neighbors, route, pubkey, deserializedData, signature, signatureStart,
|
|
296
|
+
//if (!isPatched) return new DirectMessage(type, timestamp, neighbors, route, pubkey, deserializedData, signature, signatureStart, initialMessageEnd);
|
|
297
|
+
|
|
298
|
+
const expectedEnd = isPatched ? serialized.length : initialMessageEnd;
|
|
299
|
+
const rerouterPk = isPatched ? serialized.slice(initialMessageEnd, initialMessageEnd + 32) : undefined;
|
|
300
|
+
const newRoute = isPatched ? this.#bytesToIds(serialized.slice(initialMessageEnd + 32, serialized.length - IDENTITY.SIGNATURE_LENGTH)) : undefined;
|
|
301
|
+
const rerouterSig = isPatched ? serialized.slice(serialized.length - IDENTITY.SIGNATURE_LENGTH) : undefined;
|
|
302
|
+
return new DirectMessage(type, timestamp, neighbors, route, pubkey, deserializedData, signature, signatureStart, expectedEnd, rerouterPk, newRoute, rerouterSig);
|
|
303
303
|
} catch (/** @type {any} */ error) { if (this.verbose > 1) console.warn(`Error deserializing ${type || 'unknown'} unicast message:`, error.stack); }
|
|
304
304
|
return null;
|
|
305
305
|
}
|