def setUpPostSession(self): """ override TestAsServer """ TestAsServer.setUpPostSession(self) self.mypermid = str(self.my_keypair.pub().get_der()) self.hispermid = str(self.his_keypair.pub().get_der()) # Calculating the infohash for proxyservice.test.torrent self.torrentfile = os.path.join('extend_hs_dir','proxyservice.test.torrent') # Read torrentfile to calculate the infohash torrentfile_content = open(self.torrentfile, "rb") # Decode all the file metainfo = bdecode(torrentfile_content.read()) # Re-encode only the info section self.infohash = hashlib.sha1(bencode(metainfo['info'])).digest() # Close the torrentfile torrentfile_content.close() # Add us as friend, so he will accept the ASK_FOR_HELP if False: # TEMP friendsdb = FriendDBHandler.getInstance() friendsdb.addFriend(self.mypermid) else: self.session.set_overlay_request_policy(AllowAllRequestPolicy()) self.session.set_download_states_callback(self.states_callback)
def __init__(self): if FriendshipMsgHandler.__singleton: raise RuntimeError, "FriendshipMsgHandler is singleton" self.overlay_bridge = None self.currmsgs = {} self.online_fsext_peers = Set() # online peers that speak FRIENDSHIP ext self.peerdb = PeerDBHandler.getInstance() self.frienddb = FriendDBHandler.getInstance() self.friendshipStatistics_db = FriendshipStatisticsDBHandler.getInstance() self.list_no_of_conn_attempts_per_target= {} self.usercallback = None
def __init__(self): if FriendshipMsgHandler.__singleton: raise RuntimeError, "FriendshipMsgHandler is singleton" self.overlay_bridge = None self.currmsgs = {} self.online_fsext_peers = Set( ) # online peers that speak FRIENDSHIP ext self.peerdb = PeerDBHandler.getInstance() self.frienddb = FriendDBHandler.getInstance() self.friendshipStatistics_db = FriendshipStatisticsDBHandler.getInstance( ) self.list_no_of_conn_attempts_per_target = {} self.usercallback = None
def setUpPostSession(self): """ override TestAsServer """ TestAsServer.setUpPostSession(self) self.mypermid = str(self.my_keypair.pub().get_der()) self.hispermid = str(self.his_keypair.pub().get_der()) # This is the infohash of the torrent in test/extend_hs_dir self.infohash = '\xccg\x07\xe2\x9e!]\x16\xae{\xb8\x10?\xf9\xa5\xf9\x07\xfdBk' self.torrentfile = os.path.join('extend_hs_dir','dummydata.merkle.torrent') # Add us as friend, so he will accept the DOWNLOAD_HELP if False: # TEMP friendsdb = FriendDBHandler.getInstance() friendsdb.addFriend(self.mypermid) else: self.session.set_overlay_request_policy(AllowAllRequestPolicy()) self.session.set_download_states_callback(self.states_callback)
def setUpPostSession(self): """ override TestAsServer """ TestAsServer.setUpPostSession(self) self.mypermid = str(self.my_keypair.pub().get_der()) self.hispermid = str(self.his_keypair.pub().get_der()) # This is the infohash of the torrent in test/extend_hs_dir self.infohash = '\xccg\x07\xe2\x9e!]\x16\xae{\xb8\x10?\xf9\xa5\xf9\x07\xfdBk' self.torrentfile = os.path.join('extend_hs_dir', 'dummydata.merkle.torrent') # Add us as friend, so he will accept the DOWNLOAD_HELP if False: # TEMP friendsdb = FriendDBHandler.getInstance() friendsdb.addFriend(self.mypermid) else: self.session.set_overlay_request_policy(AllowAllRequestPolicy()) self.session.set_download_states_callback(self.states_callback)