簡體   English   中英

通過python tor-連接正常,但沒有顯示為tor

[英]tor via python - connection ok, but no showing up as on tor

我正在使用連接到Tor網絡的干示例,這應該將客戶端連接到Tor網絡,似乎正在這樣做,但是當我檢查ip地址時它是錯誤的,而不是Tor IP,關於為什么這樣,更重要的是我該如何解決這個問題:)

import StringIO
import socket
import urllib

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 urllib to fetch a site using SocksiPy for Tor over the SOCKS_PORT.
  """

  try:
    return urllib.urlopen(url).read()
  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,
)

我得到的輸出:

richard@Tornado:~/Documents/Masters Project$ python russiaExample.py 
Starting Tor:

May 26 21:56:49.000 [notice] Bootstrapped 80%: Connecting to the Tor network.
May 26 21:56:50.000 [notice] Bootstrapped 85%: Finishing handshake with first hop.
May 26 21:56:50.000 [notice] Bootstrapped 90%: Establishing a Tor circuit.
May 26 21:56:50.000 [notice] Bootstrapped 100%: Done.

但是,當我訪問https://check.torproject.org/來檢查我是否在使用tor時,它說我現在在,並且顯示了我的常規IP,

是什么引起了這個問題,因為上面顯示的輸出似乎表明它已經建立了對Tor完全可以的電路,但似乎好像沒有使用它?

我在這里正確嗎?

多謝你們

您必須將瀏覽器設置為使用Tor作為代理。

如果您使用的是Firefox

  1. 轉到“ 編輯” ,“ 首選項” ,“ 高級 ”,然后選擇“配置firefox如何連接到互聯網” 設置

  2. 襪子主機中輸入127.0.0.1 ,在端口下輸入7000

轉到whatismyip.com ,您將看到一個新的IP。 檢查tor,project以查看您正在成功使用Tor

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM