def __init__(self, transport, address, pub=None, guid=None): self._priv = transport._myself self._pub = pub self._guid = guid self._ip = urlparse(address).hostname self._port = urlparse(address).port self._log = logging.getLogger( '[%s] %s' % (transport._market_id, self.__class__.__name__)) PeerConnection.__init__(self, transport, address) if pub == None or guid == None: msg = self.send_raw( json.dumps({ 'type': 'hello', 'pubkey': transport.pubkey, 'uri': transport._uri, 'senderGUID': transport.guid })) msg = json.loads(msg) self._guid = msg['senderGUID'] self._pub = msg['pubkey'] transport._dht.add_active_peer(self) ip = urlparse(address).hostname port = urlparse(address).port transport._dht.add_known_node((ip, port, self._guid)) self._log.info(transport._dht._activePeers)
def __init__(self, transport, address, pub=None, guid=None): self._priv = transport._myself self._pub = pub self._guid = guid self._transport = transport self._ip = urlparse(address).hostname self._port = urlparse(address).port self._log = logging.getLogger("[%s] %s" % (transport._market_id, self.__class__.__name__)) PeerConnection.__init__(self, transport, address) self._log.debug("New Crypt Peer: %s %s %s" % (address, pub, guid)) if pub is None or guid is None: self._log.debug("Sending Hello") msg = self.send_raw( json.dumps( {"type": "hello", "pubkey": transport.pubkey, "uri": transport._uri, "senderGUID": transport.guid} ) ) self._log.debug("Hello Response: %s" % msg) if msg: msg = json.loads(msg) self._guid = msg["senderGUID"] self._pub = msg["pubkey"]
def __init__(self, transport, address, pub=None, guid=None): self._priv = transport._myself self._pub = pub self._guid = guid self._transport = transport self._ip = urlparse(address).hostname self._port = urlparse(address).port self._log = logging.getLogger('[%s] %s' % (transport._market_id, self.__class__.__name__)) PeerConnection.__init__(self, transport, address) if pub == None or guid == None: self._log.debug('About to say hello') msg = self.send_raw(json.dumps({'type':'hello', 'pubkey':transport.pubkey, 'uri':transport._uri, 'senderGUID':transport.guid })) msg = json.loads(msg) self._guid = msg['senderGUID'] self._pub = msg['pubkey'] transport._dht.add_active_peer(self) ip = urlparse(address).hostname port = urlparse(address).port transport._dht.add_known_node((ip, port, self._guid)) self._log.info(transport._dht._activePeers)
def __init__(self, transport, address, pub=None, guid=None, callback=lambda msg: None): self._priv = transport._myself self._pub = pub self._ip = urlparse(address).hostname self._port = urlparse(address).port PeerConnection.__init__(self, transport, address) self._log = logging.getLogger('[%s] %s' % (transport._market_id, self.__class__.__name__)) if guid is not None: self._guid = guid callback(None) else: def cb(msg): msg = msg[0] msg = json.loads(msg) self._guid = msg['senderGUID'] self._pub = msg['pubkey'] self._log.debug('New Crypt Peer: %s %s %s' % (self._address, self._pub, self._guid)) callback(msg) try: self.send_raw(json.dumps({'type':'hello', 'pubkey':transport.pubkey, 'uri':transport._uri, 'senderGUID':transport.guid }), cb) except: print 'error'
def __init__(self, transport, address, pub=None, guid=None, nickname=None, sin=None, callback=lambda msg: None): # self._priv = transport._myself self.pub = pub self.ip = urlparse(address).hostname self.port = urlparse(address).port self.nickname = nickname self.sin = sin self.connected = False self.guid = guid PeerConnection.__init__(self, transport, address) self.log = logging.getLogger('[%s] %s' % (transport.market_id, self.__class__.__name__))
def __init__(self, transport, address, pub=None, guid=None, callback=lambda msg: None): self._priv = transport._myself self._pub = pub self._ip = urlparse(address).hostname self._port = urlparse(address).port PeerConnection.__init__(self, transport, address) self._log = logging.getLogger('[%s] %s' % (transport._market_id, self.__class__.__name__)) self._peer_alive = False if guid is not None: self._guid = guid self._sin = obelisk.EncodeBase58Check('\x0F\x02%s' + self._guid.decode('hex')) callback(None) else: def cb(msg): if msg: self._peer_alive = True msg = msg[0] msg = json.loads(msg) self._guid = msg['senderGUID'] self._sin = obelisk.EncodeBase58Check('\x0F\x02%s' + self._guid.decode('hex')) self._pub = msg['pubkey'] self._log.debug('New Crypt Peer: %s %s %s' % (self._address, self._pub, self._guid)) callback(msg) try: self.send_raw(json.dumps({'type':'hello', 'pubkey':transport.pubkey, 'uri':transport._uri, 'senderGUID':transport.guid }), cb) except: print 'error' def remove_dead_peer(): if not self._peer_alive: return False # Set timer for checking if peer alive ioloop.IOLoop.instance().add_timeout(time.time() + 3, remove_dead_peer)
def __init__(self, transport, address, pub=None, guid=None, nickname=None, callback=lambda msg: None): self._priv = transport._myself self._pub = pub self._ip = urlparse(address).hostname self._port = urlparse(address).port self._nickname = nickname PeerConnection.__init__(self, transport, address) self._log = logging.getLogger('[%s] %s' % (transport._market_id, self.__class__.__name__)) self._peer_alive = False if guid is not None: self._guid = guid self._sin = obelisk.EncodeBase58Check('\x0F\x02%s' + self._guid.decode('hex')) callback(None) else: def cb(msg): if msg: self._peer_alive = True msg = msg[0] msg = json.loads(msg) self._guid = msg['senderGUID'] self._sin = obelisk.EncodeBase58Check('\x0F\x02%s' + self._guid.decode('hex')) self._pub = msg['pubkey'] self._nickname = msg['senderNick'] self._log.debug('New Crypt Peer: %s %s %s %s' % (self._address, self._pub, self._guid, self._nickname)) if callback != None: callback(msg) try: self.send_raw(json.dumps({'type':'hello', 'pubkey':transport.pubkey, 'uri':transport._uri, 'senderGUID':transport.guid, 'senderNick':transport._nickname}), cb) except: print 'Sending raw message failed'
def __init__(self, transport, address, pub=None, guid=None, nickname=None, sin=None, callback=lambda msg: None): # self._priv = transport._myself self._pub = pub self._ip = urlparse(address).hostname self._port = urlparse(address).port self._nickname = nickname self._sin = sin self._connected = False self._guid = guid PeerConnection.__init__(self, transport, address) self._log = logging.getLogger( '[%s] %s' % (transport._market_id, self.__class__.__name__))
def __init__(self, transport, address, pub=None, guid=None): self._priv = transport._myself self._pub = pub self._guid = guid self._transport = transport self._ip = urlparse(address).hostname self._port = urlparse(address).port self._log = logging.getLogger('[%s] %s' % (transport._market_id, self.__class__.__name__)) PeerConnection.__init__(self, transport, address) self._log.debug('New Crypt Peer: %s %s %s' % (address, pub, guid)) if pub is None or guid is None: self._log.debug('Sending Hello') msg = self.send_raw(json.dumps({'type':'hello', 'pubkey':transport.pubkey, 'uri':transport._uri, 'senderGUID':transport.guid })) self._log.debug('Hello Response: %s' % msg) if msg: msg = json.loads(msg) self._guid = msg['senderGUID'] self._pub = msg['pubkey']
def __init__(self, address, transport, pub): self._transport = transport self._priv = transport._myself self._pub = pub PeerConnection.__init__(self, address)
def __init__(self, transport, address, pub): self._priv = transport._myself self._pub = pub PeerConnection.__init__(self, transport, address)
def __init__(self, transport, address, pub, node_guid): self._priv = transport._myself self._pub = pub self._guid = node_guid PeerConnection.__init__(self, transport, address, node_guid) self._log = logging.getLogger(self.__class__.__name__)