fix "hello" for authenticated peers

This commit is contained in:
Matias Alejo Garcia 2014-04-30 14:28:33 -03:00
parent 8c72476857
commit 6cf8988eae
2 changed files with 10 additions and 7 deletions

View File

@ -174,13 +174,15 @@ Network.prototype._onData = function(encStr, isInbound, peerId) {
console.log('### RECEIVED INBOUND?:%s TYPE: %s FROM %s',
isInbound, payload.type, peerId, payload);
if(payload.type === 'hello' && !this.authenticatedPeers[peerId]) {
var payloadStr = JSON.stringify(payload);
if (this.allowedCopayerIds && !this.allowedCopayerIds[payload.copayerId]) {
console.log('#### Peer is not on the allowedCopayerIds. Closing connection',
this.allowedCopayerIds, payload.copayerId);
this._deletePeer(peerId);
return;
if(payload.type === 'hello' ) {
if (!this.authenticatedPeers[peerId]) {
var payloadStr = JSON.stringify(payload);
if (this.allowedCopayerIds && !this.allowedCopayerIds[payload.copayerId]) {
console.log('#### Peer is not on the allowedCopayerIds. Closing connection',
this.allowedCopayerIds, payload.copayerId);
this._deletePeer(peerId);
return;
}
}
console.log('#### Peer sent hello. Setting it up.'); //TODO
this._setPeerAuthenticated(peerId);

View File

@ -88,6 +88,7 @@ angular.module('copay.controllerUtils')
root.setSocketHandlers = function() {
Socket.removeAllListeners();
if (!$rootScope.wallet) return;
var addrs = $rootScope.wallet.getAddressesStr();
for (var i = 0; i < addrs.length; i++) {