gpt4 book ai didi

python-2.7 - Tor 教程 "speaking to russia"停留在 45 - 50%

转载 作者:行者123 更新时间:2023-12-05 01:00:11 28 4
gpt4 key购买 nike

当我尝试按照教程( https://stem.torproject.org/tutorials/to_russia_with_love.html )关于如何启动 Tor 时,我一直卡在 45% 和 有时 在 50%。我使用的是 windows 8、python 3.4 和 LiClipse ide。

[1mStarting Tor: [0m [34mApr 26 12:47:21.000 [notice] Bootstrapped 0%: Starting[0m [34mApr 26 12:47:21.000 [notice] Bootstrapped 45%: Asking for relay descriptors[0m [34mApr 26 13:04:00.000 [notice] Bootstrapped 50%: Loading relay descriptors[0m



脚本是这样的,我在这里自己做的改变是使用 requests图书馆而不是 urllib从源请求数据,但无论如何我都没有进入代码的那部分。这基本上是使用 SocksiPy 的教程页面上的代码副本。

TorConnector.py:
from io import StringIO
import socket
import requests

import socks # SocksiPy module
import stem.process

from stem.util import term

SOCKS_PORT = 7000

# Set socks proxy and wrap the urllib module

socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, '127.0.0.1', SOCKS_PORT)
socket.socket = socks.socksocket

# Perform DNS resolution through the socket

def getaddrinfo(*args):
return [(socket.AF_INET, socket.SOCK_STREAM, 6, '', (args[0], args[1]))]

socket.getaddrinfo = getaddrinfo

def query(url):
"""
Uses requests to fetch a site using SocksiPy for Tor over the SOCKS_PORT.
"""

try:
result = requests.get(url)
return result
except:
return "Unable to reach %s" % url



# Start an instance of Tor configured to only exit through Russia. This prints
# Tor's bootstrap information as it starts. Note that this likely will not
# work if you have another Tor instance running.

def print_bootstrap_lines(line):
if "Bootstrapped " in line:
print(term.format(line, term.Color.BLUE))


print(term.format("Starting Tor:\n", term.Attr.BOLD))

tor_process = stem.process.launch_tor_with_config(
config = {
'SocksPort': str(SOCKS_PORT),
'ExitNodes': '{ru}',
},
init_msg_handler = print_bootstrap_lines,
)

print(term.format("\nChecking our endpoint:\n", term.Attr.BOLD))
print(term.format(query("https://www.atagar.com/echo.php"), term.Color.BLUE))

tor_process.kill() # stops tor

我还尝试将 TorConnector.py 脚本文件移动到 C:\Python34\Lib\site-packages文件夹并从命令提示符运行它 python TorConnector.py但同样的事情发生了,我仍然停留在 45% 上。

此外,如果我在 Tor.exe 进程停留在 45% 时结束它,它会告诉我:

Traceback (most recent call last): File "C:\Users\gatsu\My Documents\LiClipse Workspace\TorCommunicator\TorConnector.py", line 53, in init_msg_handler = print_bootstrap_lines, File "C:\Python34\lib\site-packages\stem\process.py", line 246, in launch_tor_with_config return launch_tor(tor_cmd, args, torrc_path, completion_percent, init_msg_handler, timeout, take_ownership) File "C:\Python34\lib\site-packages\stem\process.py", line 136, in launch_tor raise OSError('Process terminated: %s' % last_problem) OSError: Process terminated: Failed to open GEOIP file C:\Users\gatsu\AppData\Roaming\tor\geoip6. We've been configured to use (or avoid) nodes in certain countries, and we need GEOIP information to figure out which ones they are.



我希望它有助于弄清楚为什么这让我陷入困境。

我什至没有这个文件:C:\Users\gatsu\AppData\Roaming\tor\geoip6

最佳答案

我找到了 geoipgeoip6 Tor 浏览器文件夹 (D:\Program\Tor Browser\Browser\TorBrowser\Data\Tor) 中的文件并将它们复制到 C:\Users\gatsu\AppData\Roaming\tor ,然后让我达到 100%。

[1mStarting Tor: [0m [34mMay 01 23:28:53.000 [notice] Bootstrapped 0%: Starting[0m [34mMay 01 23:28:53.000 [notice] Bootstrapped 80%: Connecting to the Tor network[0m [34mMay 01 23:28:54.000 [notice] Bootstrapped 85%: Finishing handshake with first hop[0m [34mMay 01 23:28:54.000 [notice] Bootstrapped 90%: Establishing a Tor circuit[0m [34mMay 01 23:28:55.000 [notice] Bootstrapped 100%: Done[0m [1m Checking our endpoint: [0m [34mUnable to reach https://www.atagar.com/echo.php[0m

关于python-2.7 - Tor 教程 "speaking to russia"停留在 45 - 50%,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29876778/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com