socks proxy support, disable udp connections support, http bittorrent tracker support, port opened, external ip to stats, only need zeroname site if dont have, dont try to download file that not in content.json, store external ip even if port closed, recreate uirequest class to avoid unfinished requests in some cases
This commit is contained in:
parent
b414a75885
commit
4f7e048413
36 changed files with 1927 additions and 80 deletions
22
src/util/SocksProxy.py
Normal file
22
src/util/SocksProxy.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
from lib.PySocks import socks
|
||||
import socket
|
||||
|
||||
|
||||
def create_connection(address, timeout=None, source_address=None):
|
||||
sock = socks.socksocket()
|
||||
sock.connect(address)
|
||||
return sock
|
||||
|
||||
|
||||
# Dns queries using the proxy
|
||||
def getaddrinfo(*args):
|
||||
return [(socket.AF_INET, socket.SOCK_STREAM, 6, '', (args[0], args[1]))]
|
||||
|
||||
|
||||
def monkeyPath(proxy_ip, proxy_port):
|
||||
print proxy_ip, proxy_port
|
||||
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, proxy_ip, int(proxy_port))
|
||||
socket.socket = socks.socksocket
|
||||
socket.create_connection = create_connection
|
||||
socket.getaddrinfo = getaddrinfo
|
||||
|
|
@ -1,8 +1,5 @@
|
|||
import gevent
|
||||
from gevent import socket
|
||||
from gevent import monkey
|
||||
|
||||
monkey.patch_socket()
|
||||
|
||||
import re, urllib2, httplib, logging
|
||||
from urlparse import urlparse
|
||||
|
@ -231,5 +228,8 @@ def open_port(port=15441, desc="UpnpPunch"):
|
|||
return False
|
||||
|
||||
if __name__ == "__main__":
|
||||
from gevent import monkey
|
||||
monkey.patch_socket()
|
||||
|
||||
logging.getLogger().setLevel(logging.DEBUG)
|
||||
print open_port(15441, "ZeroNet")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue