def _get_poa(self, tdef): """Try to load a POA - possibly trigger a GUI-thing or should the plugin handle getting it if none is already available?""" from BaseLib.Core.ClosedSwarm import ClosedSwarm, PaymentIntegration try: poa = ClosedSwarm.trivial_get_poa(self.s.get_default_state_dir(), self.s.get_permid(), tdef.infohash) poa.verify() if not poa.torrent_id == tdef.infohash: raise Exception("Bad POA - wrong infohash") print >> sys.stderr, "Loaded poa from ", self.s.get_default_state_dir( ) except: # Try to get it or just let the plugin handle it? swarm_id = encodestring(tdef.infohash).replace("\n", "") my_id = encodestring(self.s.get_permid()).replace("\n", "") poa = PaymentIntegration.wx_get_poa( "http://seer2.itek.norut.no:9090", swarm_id, my_id, swarm_title=tdef.get_name()) try: ClosedSwarm.trivial_save_poa(self.s.get_default_state_dir(), self.s.get_permid(), tdef.infohash, poa) except Exception, e: print >> sys.stderr, "Failed to save POA", e
def create_poa(torrent, torrent_keypair, node_id, target_file): # Sanity - check that this key matches the torrent pubkey = torrent_keypair.pub() good_key = False for key in torrent.get_cs_keys(): if pubkey.get_der() == key.get_der(): good_key = True break if not good_key: raise Exception("Bad key given for this torrent") # if the node_id is base64 encoded, decode it try: actual_node_id = decodestring(node_id) print "Node ID was base64 encoded" except: actual_node_id = node_id # Got the right key, now create POA poa = ClosedSwarm.create_poa(t.infohash, torrent_keypair, actual_node_id) # Now we save it if target_file: ClosedSwarm.write_poa_to_file(target_file) tf = target_file else: tf = ClosedSwarm.trivial_save_poa("./", decodestring(node_id), t.infohash, poa) print "Proof of access written to file '%s'"%tf
def _get_poa(self, tdef): """Try to load a POA - possibly trigger a GUI-thing or should the plugin handle getting it if none is already available?""" from BaseLib.Core.ClosedSwarm import ClosedSwarm, PaymentIntegration try: poa = ClosedSwarm.trivial_get_poa(self.s.get_default_state_dir(), self.s.get_permid(), tdef.infohash) poa.verify() if not poa.torrent_id == tdef.infohash: raise Exception("Bad POA - wrong infohash") print >>sys.stderr, "Loaded poa from ", self.s.get_default_state_dir() except: # Try to get it or just let the plugin handle it? swarm_id = encodestring(tdef.infohash).replace("\n", "") my_id = encodestring(self.s.get_permid()).replace("\n", "") poa = PaymentIntegration.wx_get_poa( "http://seer2.itek.norut.no:9090", swarm_id, my_id, swarm_title=tdef.get_name() ) try: ClosedSwarm.trivial_save_poa(self.s.get_default_state_dir(), self.s.get_permid(), tdef.infohash, poa) except Exception, e: print >>sys.stderr, "Failed to save POA", e