5

私はこの例を試しました:

import getpass
import sys

import stem
import stem.connection

from stem.control import Controller

if __name__ == '__main__':
  try:
    controller = Controller.from_port()
  except stem.SocketError as exc:
    print("Unable to connect to tor on port 9051: %s" % exc)
    sys.exit(1)

  try:
    controller.authenticate()
  except stem.connection.MissingPassword:
    pw = getpass.getpass("Controller password: ")

    try:
      controller.authenticate(password = pw)
    except stem.connection.PasswordAuthFailed:
      print("Unable to authenticate, password is incorrect")
      sys.exit(1)
  except stem.connection.AuthenticationFailure as exc:
    print("Unable to authenticate: %s" % exc)
    sys.exit(1)

  print("Tor is running version %s" % controller.get_version())
  controller.close()

Torのコントローラーがどのように機能するかを確認するためにStemで。しかし、それは私にエラーを与えています:

ポート 9051 に接続できません ([Errno 111] 接続が拒否されました)

/etc/tor/ 内の torrc ファイルで ControlPort を 9051 に設定しましたが、それでも同じエラーが発生します。誰でも助けてもらえますか?(VirtualBoxでUbuntu 14.04を使用しています)

編集:また、端末で tor --controlport 9051 を実行すると、エラーが発生します:

Feb 29 17:50:17.842 [notice] Tor v0.2.4.27 (git-412e3f7dc9c6c01a) running on Linux with Libevent 2.0.21-stable and OpenSSL 1.0.1f.
Feb 29 17:50:17.842 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning
Feb 29 17:50:17.842 [notice] Read configuration file "/etc/tor/torrc".
Feb 29 17:50:17.854 [notice] Opening Socks listener on 127.0.0.1:9050
Feb 29 17:50:17.854 [warn] Could not bind to 127.0.0.1:9050: Address already in use. Is Tor already running?
Feb 29 17:50:17.854 [notice] Opening Control listener on 127.0.0.1:9051
Feb 29 17:50:17.854 [notice] Closing partially-constructed Control listener on 127.0.0.1:9051
Feb 29 17:50:17.854 [warn] Failed to parse/validate config: Failed to bind one of the listener ports.
Feb 29 17:50:17.854 [err] Reading config failed--see warnings above.

しかし、私が走るとき

ps

実行中の tor のインスタンスはありません。編集2:コマンドを試してsudo killall torからチェックしたところsudo /etc/init.d/tor status、認証エラーが発生しました:

 File "circuitPage.py", line 82, in printCircuitInfo
    controller.authenticate()
  File "/usr/local/lib/python2.7/dist-packages/stem/control.py", line 991, in authenticate
    stem.connection.authenticate(self, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/stem/connection.py", line 520, in authenticate
    raise AuthenticationFailure('socket connection failed (%s)' % exc)
stem.connection.AuthenticationFailure: socket connection failed ([Errno 111] Connection refused)
4

1 に答える 1