当前位置:   article > 正文

磁力mysql搜索_求一份磁力链接搜索网站的源码,最好能来个大神讲一下这个搜索的原理...

求网站

[Python] 纯文本查看 复制代码#!/usr/bin/env python

# encoding: utf-8

import socket

from hashlib import sha1

from random import randint

from struct import unpack

from socket import inet_ntoa

from threading import Timer, Thread

from time import sleep

from collections import deque

from bencode import bencode, bdecode

BOOTSTRAP_NODES = (

("router.bittorrent.com", 6881),

("dht.transmissionbt.com", 6881),

("router.utorrent.com", 6881)

)

TID_LENGTH = 2

RE_JOIN_DHT_INTERVAL = 3

TOKEN_LENGTH = 2

def entropy(length):

return "".join(chr(randint(0, 255)) for _ in xrange(length))

def random_id():

h = sha1()

h.update(entropy(20))

return h.digest()

def decode_nodes(nodes):

n = []

length = len(nodes)

if (length % 26) != 0:

return n

for i in range(0, length, 26):

nid = nodes[i:i+20]

ip = inet_ntoa(nodes[i+20:i+24])

port = unpack("!H", nodes[i+24:i+26])[0]

n.append((nid, ip, port))

return n

def timer(t, f):

Timer(t, f).start()

def get_neighbor(target, nid, end=10):

return target[:end]+nid[end:]

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/blog/article/detail/71552
推荐阅读
相关标签
  

闽ICP备14008679号