def generate_announce_response(values, peer): peer_list = current_peers().filter(info_hash=values['info_hash']).exclude(pk=peer.pk).order_by('-state') if peer.state == settings.MAGIC_VALUES['seed']: interval = settings.MAGIC_VALUES['seed_interval'] else: interval = settings.MAGIC_VALUES['peer_interval'] peerset = peerset_to_ip(peer_list[:values['numwant']], values['compact']) return tracker_response({ 'interval': interval, 'complete': num_seeds(values['info_hash']), 'incomplete': num_peers(values['info_hash']), 'peers': peerset, })
def generate_announce_response(values, peer): peer_list = current_peers().filter(info_hash=values['info_hash']).exclude( pk=peer.pk).order_by('-state') if peer.state == settings.MAGIC_VALUES['seed']: interval = settings.MAGIC_VALUES['seed_interval'] else: interval = settings.MAGIC_VALUES['peer_interval'] peerset = peerset_to_ip(peer_list[:values['numwant']], values['compact']) return tracker_response({ 'interval': interval, 'complete': num_seeds(values['info_hash']), 'incomplete': num_peers(values['info_hash']), 'peers': peerset, })
def num_peers(info_hash): return current_peers().filter(info_hash=info_hash).filter( state=settings.MAGIC_VALUES['peer']).count()
def num_peers(info_hash): return current_peers().filter(info_hash=info_hash).filter(state=settings.MAGIC_VALUES['peer']).count()