Ejemplo n.º 1
0
    def __init__(self, data_handler, overlay_bridge, log='', dnsindb=None):

        if DEBUG:
            print >> sys.stderr, "=================Initializing bartercast core"

        self.data_handler = data_handler
        self.dnsindb = dnsindb
        self.log = log
        self.overlay_bridge = overlay_bridge
        self.bartercastdb = BarterCastDBHandler.getInstance()

        self.network_delay = 30
        self.send_block_list = {}
        self.recv_block_list = {}
        self.block_interval = 1 * 60 * 60  # block interval for a peer to barter   cast

        self.topn = self.bartercastdb.getTopNPeers(NO_PEERS_IN_MSG,
                                                   local_only=True)['top']
        self.overlay_bridge.add_task(self.refreshTopN, REFRESH_TOPN_INTERVAL)

        if self.log:
            self.overlay_log = OverlayLogger.getInstance(self.log)

        if LOG:
            self.logfile = '/Users/michel/packages/bartercast_dataset/bartercast42.log'
            if not os.path.exists(self.logfile):
                log = open(self.logfile, 'w')
                log.close()
Ejemplo n.º 2
0
    def __init__(self, data_handler, secure_overlay, session, buddycast_interval_function, log = '', dnsindb = None):
        """ Returns an instance of this class
        """
        #Keep reference to interval-function of BuddycastFactory
        self.interval = buddycast_interval_function
        self.data_handler = data_handler
        self.dnsindb = dnsindb
        self.log = log
        
        self.peerdb = PeerDBHandler.getInstance()
        self.votecastdb = VoteCastDBHandler.getInstance()
        
        self.session = session
        self.my_permid = session.get_permid()
        self.max_length = SINGLE_VOTECAST_LENGTH * (session.get_votecast_random_votes() + session.get_votecast_recent_votes())       

        #Reference to buddycast-core, set by the buddycast-core (as it is created by the
        #buddycast-factory after calling this constructor).
        self.buddycast_core = None
        
        
        self.notifier = Notifier.getInstance()
        
        #Extend logging with VoteCast-messages and status
        if self.log:
            self.overlay_log = OverlayLogger.getInstance(self.log)
Ejemplo n.º 3
0
    def __init__(self, data_handler, overlay_bridge, log = '', dnsindb = None):
    
        if DEBUG:
            print >> sys.stderr, "=================Initializing bartercast core"
    
        self.data_handler = data_handler
        self.dnsindb = dnsindb
        self.log = log
        self.overlay_bridge = overlay_bridge
        self.bartercastdb = BarterCastDBHandler.getInstance()
        
        self.network_delay = 30
        self.send_block_list = {}
        self.recv_block_list = {}
        self.block_interval = 1*60*60   # block interval for a peer to barter   cast

        self.topn = self.bartercastdb.getTopNPeers(NO_PEERS_IN_MSG, local_only = True)['top']
        self.overlay_bridge.add_task(self.refreshTopN, REFRESH_TOPN_INTERVAL)
        
        if self.log:
            self.overlay_log = OverlayLogger.getInstance(self.log)
            
        if LOG:
            self.logfile = '/Users/michel/packages/bartercast_dataset/bartercast42.log'
            if not os.path.exists(self.logfile):
                log = open(self.logfile, 'w')
                log.close()
Ejemplo n.º 4
0
    def __init__(self,
                 data_handler,
                 secure_overlay,
                 session,
                 buddycast_interval_function,
                 log='',
                 dnsindb=None):
        """ Returns an instance of this class
        """
        #Keep reference to interval-function of BuddycastFactory
        self.interval = buddycast_interval_function
        self.data_handler = data_handler
        self.dnsindb = dnsindb
        self.log = log

        self.peerdb = PeerDBHandler.getInstance()
        self.votecastdb = VoteCastDBHandler.getInstance()

        self.session = session
        self.my_permid = session.get_permid()
        self.max_length = SINGLE_VOTECAST_LENGTH * (
            session.get_votecast_random_votes() +
            session.get_votecast_recent_votes())

        #Reference to buddycast-core, set by the buddycast-core (as it is created by the
        #buddycast-factory after calling this constructor).
        self.buddycast_core = None

        self.notifier = Notifier.getInstance()

        #Extend logging with VoteCast-messages and status
        if self.log:
            self.overlay_log = OverlayLogger.getInstance(self.log)
Ejemplo n.º 5
0
    def __init__(self, callback, statedir, port):
        assert isinstance(port, int)
        assert 0 <= port
        super(TrackerDispersy, self).__init__(callback, statedir)

        # non-autoload nodes
        self._non_autoload = set()
        self._non_autoload.update(
            host for host, _ in self._bootstrap_candidates.iterkeys())
        # leaseweb machines, some are running boosters, they never unload a community
        self._non_autoload.update([
            "95.211.105.65", "95.211.105.67", "95.211.105.69", "95.211.105.71",
            "95.211.105.73", "95.211.105.75", "95.211.105.77", "95.211.105.79",
            "95.211.105.81", "85.17.81.36"
        ])

        # logger
        overlaylogpostfix = "dp" + str(port) + ".log"
        self._logger = OverlayLogger.getInstance(overlaylogpostfix, statedir)
        self._candidates_status = {}
        callback.register(self._candidate_logger, priority=-128)

        # generate a new my-member
        ec = ec_generate_key(u"very-low")
        self._my_member = Member(ec_to_public_bin(ec), ec_to_private_bin(ec))

        callback.register(self._unload_communities, priority=-128)
Ejemplo n.º 6
0
    def __init__(self, callback, statedir):
        super(BoosterDispersy, self).__init__(callback, statedir)

        # logger
        session = Session.get_instance()
        port = session.get_listen_port()
        overlaylogpostfix = "bp" + str(port) + ".log"
        self._logger = OverlayLogger.getInstance(overlaylogpostfix, statedir)
Ejemplo n.º 7
0
    def __init__(self, callback, statedir):
        super(BoosterDispersy, self).__init__(callback, statedir)

        # logger
        session = Session.get_instance()
        port = session.get_listen_port()
        overlaylogpostfix = "bp" + str(port) + ".log"
        self._logger = OverlayLogger.getInstance(overlaylogpostfix, statedir)
Ejemplo n.º 8
0
 def register(self, overlay_bridge, launchmany, config, bc_fac, log=''):
     if DEBUG:
         print >> sys.stderr, "rquery: register"
     self.overlay_bridge = overlay_bridge
     self.launchmany = launchmany
     self.search_manager = SearchManager(launchmany.torrent_db)
     self.peer_db = launchmany.peer_db
     self.config = config
     self.bc_fac = bc_fac  # May be None
     if log:
         self.overlay_log = OverlayLogger.getInstance(log)
     self.registered = True
Ejemplo n.º 9
0
    def __init__(self, callback, statedir, port):
        assert isinstance(port, int)
        assert 0 <= port
        super(TrackerDispersy, self).__init__(callback, statedir)

        # logger
        overlaylogpostfix = "dp" + str(port) + ".log"
        self._logger = OverlayLogger.getInstance(overlaylogpostfix, statedir)

        # generate a new my-member
        ec = ec_generate_key(u"very-low")
        self._my_member = Member.get_instance(ec_to_public_bin(ec), ec_to_private_bin(ec))

        callback.register(self._unload_communities, priority=-128)
Ejemplo n.º 10
0
    def __init__(self,
                 data_handler,
                 overlay_bridge,
                 session,
                 buddycast_interval_function,
                 log='',
                 dnsindb=None):
        """ Returns an instance of this class """
        if ChannelCastCore.__single:
            raise RuntimeError, "ChannelCastCore is singleton"
        ChannelCastCore.__single = self

        #Keep reference to interval-function of BuddycastFactory
        self.interval = buddycast_interval_function
        self.data_handler = data_handler
        self.dnsindb = dnsindb
        self.log = log
        self.overlay_bridge = overlay_bridge
        self.channelcastdb = ChannelCastDBHandler.getInstance()
        self.votecastdb = VoteCastDBHandler.getInstance()
        self.rtorrent_handler = RemoteTorrentHandler.getInstance()

        self.session = session
        self.database_thread = session.lm.database_thread

        self.my_permid = session.get_permid()

        self.network_delay = 30
        #Reference to buddycast-core, set by the buddycast-core (as it is created by the
        #buddycast-factory after calling this constructor).
        self.buddycast_core = None

        #Extend logging with ChannelCast-messages and status
        if self.log:
            self.overlay_log = OverlayLogger.getInstance(self.log)
            self.dnsindb = self.data_handler.get_dns_from_peerdb

        self.notifier = Notifier.getInstance()

        self.metadataDbHandler = MetadataDBHandler.getInstance()

        #subtitlesHandler = SubtitlesHandler.getInstance()
        subtitleSupport = SubtitlesSupport.getInstance()
        # better if an instance of RMDInterceptor was provided from the
        # outside
        self.peersHaveManger = PeersHaveManager.getInstance()
        if not self.peersHaveManger.isRegistered():
            self.peersHaveManger.register(self.metadataDbHandler,
                                          self.overlay_bridge)
Ejemplo n.º 11
0
 def register(self,overlay_bridge,launchmany,config,bc_fac,log=''):
     if DEBUG:
         print >> sys.stderr,"rquery: register"
     self.overlay_bridge = overlay_bridge
     self.session =  launchmany.session
     self.torrent_db = launchmany.torrent_db
     self.peer_db = launchmany.peer_db
     self.channelcast_db = launchmany.channelcast_db
     # debug
     # self.superpeer_db = launchmany.superpeer_db
     
     self.config = config
     self.bc_fac = bc_fac # May be None
     if log:
         self.overlay_log = OverlayLogger.getInstance(log)
     self.torrent_dir = os.path.abspath(self.config['torrent_collecting_dir'])
     self.registered = True
Ejemplo n.º 12
0
    def __init__(self, data_handler, secure_overlay, log='', dnsindb=None):

        if DEBUG:
            print >> sys.stderr, "=================Initializing bartercast core"

        self.data_handler = data_handler
        self.dnsindb = dnsindb
        self.log = log
        self.secure_overlay = secure_overlay
        self.bartercastdb = BarterCastDBHandler.getInstance()

        self.network_delay = 30
        self.send_block_list = {}
        self.recv_block_list = {}
        self.block_interval = 1 * 60 * 60  # block interval for a peer to barter   cast

        if self.log:
            self.overlay_log = OverlayLogger(self.log)
Ejemplo n.º 13
0
    def __init__(self, data_handler, overlay_bridge, session, buddycast_interval_function, log = '', dnsindb = None):
        """ Returns an instance of this class """
        if ChannelCastCore.__single:
            raise RuntimeError, "ChannelCastCore is singleton"
        ChannelCastCore.__single = self
        
        #Keep reference to interval-function of BuddycastFactory
        self.interval = buddycast_interval_function
        self.data_handler = data_handler
        self.dnsindb = dnsindb
        self.log = log
        self.overlay_bridge = overlay_bridge
        self.channelcastdb = ChannelCastDBHandler.getInstance()
        self.votecastdb = VoteCastDBHandler.getInstance()
        self.rtorrent_handler = RemoteTorrentHandler.getInstance()
        self.my_permid = self.channelcastdb.my_permid
        self.session = session
        
        self.network_delay = 30
        #Reference to buddycast-core, set by the buddycast-core (as it is created by the
        #buddycast-factory after calling this constructor).
        self.buddycast_core = None
        
        #Extend logging with ChannelCast-messages and status
        if self.log:
            self.overlay_log = OverlayLogger.getInstance(self.log)
            self.dnsindb = self.data_handler.get_dns_from_peerdb

        self.notifier = Notifier.getInstance()

        self.metadataDbHandler = MetadataDBHandler.getInstance()
        
        #subtitlesHandler = SubtitlesHandler.getInstance()
        subtitleSupport = SubtitlesSupport.getInstance()
        # better if an instance of RMDInterceptor was provided from the
        # outside
        self.peersHaveManger = PeersHaveManager.getInstance()
        if not self.peersHaveManger.isRegistered():
                self.peersHaveManger.register(self.metadataDbHandler, self.overlay_bridge)
        self.richMetadataInterceptor = RichMetadataInterceptor(self.metadataDbHandler,self.votecastdb,
                                                               self.my_permid, subtitleSupport, self.peersHaveManger,
                                                               self.notifier)
    def __init__(self, callback, statedir, port):
        assert isinstance(port, int)
        assert 0 <= port
        super(TrackerDispersy, self).__init__(callback, statedir)

        # non-autoload nodes
        self._non_autoload = set()
        self._non_autoload.update(host for host, _ in self._bootstrap_candidates.iterkeys())
        # leaseweb machines, some are running boosters, they never unload a community
        self._non_autoload.update(["95.211.105.65", "95.211.105.67", "95.211.105.69", "95.211.105.71", "95.211.105.73", "95.211.105.75", "95.211.105.77", "95.211.105.79", "95.211.105.81", "85.17.81.36"])

        # logger
        overlaylogpostfix = "dp" + str(port) + ".log"
        self._logger = OverlayLogger.getInstance(overlaylogpostfix, statedir)
        self._candidates_status = {}
        callback.register(self._candidate_logger, priority=-128)

        # generate a new my-member
        ec = ec_generate_key(u"very-low")
        self._my_member = Member(ec_to_public_bin(ec), ec_to_private_bin(ec))

        callback.register(self._unload_communities, priority=-128)
Ejemplo n.º 15
0
 def __init__(self, data_handler, secure_overlay, session, buddycast_interval_function, log = '', dnsindb = None):
     """ Returns an instance of this class """
     #Keep reference to interval-function of BuddycastFactory
     self.interval = buddycast_interval_function
     self.data_handler = data_handler
     self.dnsindb = dnsindb
     self.log = log
     self.secure_overlay = secure_overlay
     self.channelcastdb = ChannelCastDBHandler.getInstance()
     self.rtorrent_handler = RemoteTorrentHandler.getInstance()
     self.my_permid = self.channelcastdb.my_permid
     self.session = session
     
     self.network_delay = 30
     #Reference to buddycast-core, set by the buddycast-core (as it is created by the
     #buddycast-factory after calling this constructor).
     self.buddycast_core = None
     
     #Extend logging with ChannelCast-messages and status
     if self.log:
         self.overlay_log = OverlayLogger.getInstance(self.log)
         self.dnsindb = self.data_handler.get_dns_from_peerdb
     self.hits = []