Prompt for tor controller password if needed

We use getpass for this (i.e. text mode).
This means that if you have password protection for your
Tor controller (advised) and you want to run onionshare-gui,
you need to do it from a terminal (so that you can enter
the password).
This commit is contained in:
The Dod 2014-10-11 07:56:33 +07:00
parent 381d046a94
commit c250cbeba4

View File

@ -21,6 +21,7 @@ import os, sys, subprocess, time, argparse, inspect, shutil, socket, threading,
import socks
from stem.control import Controller
from stem.connection import MissingPassword, AuthenticationFailure
from stem import SocketError
import strings, helpers, web
@ -101,7 +102,17 @@ class OnionShare(object):
pass
if not controller:
raise NoTor(strings._("cant_connect_ctrlport").format(tor_control_ports))
controller.authenticate()
try:
controller.authenticate()
except MissingPassword: # We need a password for control port
from getpass import getpass
authed = False
while not authed:
try:
controller.authenticate(getpass('Tor control password: '))
authed = True
except AuthenticationFailure:
pass
# set up hidden service
controller.set_options([