Skip to content

Commit 89eef2a

Browse files
authored
Merge pull request #46 from akomelj/master
Fixed IRI negotiation bug #5
2 parents f7384fd + e0176a9 commit 89eef2a

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

dist/node/node.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -537,14 +537,14 @@ var Node = function (_Base) {
537537
UDPPort = head.UDPPort,
538538
remoteKey = head.remoteKey,
539539
name = head.name,
540-
wishedProtocol = head.protocol;
540+
protocol = head.protocol;
541541

542-
var protocol = _this9._negotiateProtocol(wishedProtocol);
543-
_this9.list.update(peer, { port: port, nelsonID: nelsonID, TCPPort: TCPPort, UDPPort: UDPPort, remoteKey: remoteKey, name: name, protocol: protocol }).then(function () {
544-
if (protocol) {
542+
var IRIProtocol = _this9._negotiateProtocol(protocol);
543+
_this9.list.update(peer, { port: port, nelsonID: nelsonID, TCPPort: TCPPort, UDPPort: UDPPort, remoteKey: remoteKey, name: name, IRIProtocol: IRIProtocol }).then(function () {
544+
if (IRIProtocol) {
545545
_this9._ready && _this9.iri.addNeighbors([peer]);
546546
} else {
547-
_this9.log(('Couldn\'t negotiate protocol with ' + peer.data.hostname + ': my ' + _this9.opts.IRIProtocol + ' vs remote ' + wishedProtocol).yellow);
547+
_this9.log(('Couldn\'t negotiate protocol with ' + peer.data.hostname + ': my ' + _this9.opts.IRIProtocol + ' vs remote ' + IRIProtocol).yellow);
548548
removeNeighbor();
549549
}
550550
});

src/node/node.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -399,13 +399,13 @@ class Node extends Base {
399399
this.log('!!', 'wrong headers received', head);
400400
return removeNeighbor();
401401
}
402-
const { port, nelsonID, TCPPort, UDPPort, remoteKey, name, protocol: wishedProtocol } = head;
403-
const protocol = this._negotiateProtocol(wishedProtocol);
404-
this.list.update(peer, { port, nelsonID, TCPPort, UDPPort, remoteKey, name, protocol }).then(() => {
405-
if (protocol) {
402+
const { port, nelsonID, TCPPort, UDPPort, remoteKey, name, protocol } = head;
403+
const IRIProtocol = this._negotiateProtocol(protocol);
404+
this.list.update(peer, { port, nelsonID, TCPPort, UDPPort, remoteKey, name, IRIProtocol }).then(() => {
405+
if (IRIProtocol) {
406406
this._ready && this.iri.addNeighbors([ peer ]);
407407
} else {
408-
this.log(`Couldn't negotiate protocol with ${peer.data.hostname}: my ${this.opts.IRIProtocol} vs remote ${wishedProtocol}`.yellow);
408+
this.log(`Couldn't negotiate protocol with ${peer.data.hostname}: my ${this.opts.IRIProtocol} vs remote ${IRIProtocol}`.yellow);
409409
removeNeighbor();
410410
}
411411
});

0 commit comments

Comments
 (0)