我试图将{TOR与set tabstop=4
set softtabstop=4
set shiftwidth=4
set smartindent
set mouse=a
set number
set ai
set nowrap
set viminfo='100,<5000,s1000
一起使用,但由于某些原因,我不断收到所有内容的奇怪回复。我不确定如何解释,所以这里有我的例子:
http.client.HTTPConnection
如果我用以下方式运行:
class Socket(http.client.HTTPConnection):
def __init__(self, url):
super().__init__('127.0.0.1', 8118)
super().set_tunnel(url)
#super().__init__(url)
def get(self, url = '/', params = {}):
params = util.params_to_query(params)
if params:
if url.find('?') == -1: url += '?' + params
else: url += '&' + params
self.request(
'GET',
url,
'',
{'Connection': 'Keep alive'}
)
return self.getresponse().read().decode('utf-8')
我明白了:
sock = Socket('www.google.com')
print(sock.get())
谷歌正在将我重定向到我刚才要求的网址,除了私有端口。它变得更奇怪 - 如果我尝试https://check.torproject.org:
<html><head><meta content="text/html;charset=utf-8" http-equiv="content-type"/>
<title>301 Moved</title></head><body>
<h1>301 Moved</h1>
The document has moved
<a href="http://www.google.com:8118/">here</a>.
</body></html>
如果我不尝试使用privoxy / TOR,我会在http://www.google.com或http://check.torproject.org获得您的浏览器。我不知道这里发生了什么。我怀疑问题出在python上,因为我可以在火狐中使用TOR,但我真的不知道。
Privoxy日志显示:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>Welcome to sergii!</title>
</head>
<body>
<h1>Welcome to sergii!</h1>
This is sergii, a system run by and for the <a href="http://www.torproject.org/">Tor Project</a>.
She does stuff.
What kind of stuff and who our kind sponsors are you might learn on
<a href="http://db.torproject.org/machines.cgi?host=sergii">db.torproject.org</a>.
<p>
</p><hr noshade=""/>
<font size="-1">torproject-admin</font>
</body>
</html>
TOR日志没什么好说的。
答案 0 :(得分:0)
这最后是因为我正在与http://
建立联系而这些网站需要https://
。对于接受正常http://
的网站,它可以正常工作。