def run_test(): ctl = get_controller() # get a controller that will die # when we die version = ctl.get_info("version")["version"] # save version output for signal in ["HUP", "NEWNYM"]: ctl.send_signal(signal) # send hup # make sure Tor didn't crash assert(version == ctl.get_info("version")["version"]) ctl.close() return 0
def run_test(): ctl = get_controller() dirport = ctl.get_option("DirPort")[0][1] if dirport == None: ctl.set_option(("DirPort", DEFAULT_DIRPORT)) dirport = DEFAULT_DIRPORT else: dirport = int(dirport) # get_option returns a string url = "http://localhost:%d/%s" % (dirport, CONSENSUS_URL) consensus = urllib2.urlopen(url, None, 10) # we time out here because we're accessing a local service and it # shouldn't take longer than 10 seconds if Tor is working; # however, in some cases a libevent issue can cause this to wait # indefinitely assert(consensus != None) ctl.close() return 0
# Sets up an HTTP hidden service and downloads a file over it. import SimpleHTTPServer import SocketServer SocketServer.TCPServer.allow_reuse = True import os import hashlib import pycurl import StringIO import threading import sys sys.path.append('../torciden/') from torciden import get_controller, get_repo_root ctl = get_controller(1) # get a controller that will die when # we die TESTFILE = "kitsune_test.jpg" def init_hs(): """Set up a hidden service -- configure Tor, and start an HTTP server that we return a handle to.""" options = ctl.get_option("HiddenServiceOptions") if (options[0][1] == None or options[1][1] == None): ctl.set_options((("HiddenServiceDir", get_repo_root() + '/examples/tor/data/hs'), ("HiddenServicePort", str(8888)))) port = int(ctl.get_option("HiddenServiceOptions")[1][1]) serve_path = get_repo_root() + '/examples/tor/test/tests/' os.chdir(serve_path) httpd = SocketServer.TCPServer(("", port),