Пример #1
0
def checkTor():
	if not controller.isAlive():
		print "tor controller was dead, now trying to restart it"
		try:
			controller = Controller.from_port()
			controller.authenticate()
		except Exception as e:
			print e
			print "tor is not letting us authenticate, is it configured correctly and running?" 
			exit()

		print "successfully opened control connection to tor"
#TODO here and elsewhere we should change from the get_conf/set_options
#interface to the create_ephemeral_hidden_service/
#remove_ephemeral_hidden_service/list_ephemeral_hidden_services
#that way we can also put the key and hostname in config and not have to
#worry about setting up /var/lib/tor/hidden_service

	if controller.get_conf("HiddenServiceDir") is None:
		print "tor was not configure to provide a hidden service, now configuring"
		try:
			controller.set_options([
			("HiddenServiceDir", get_hidden_svc_dir()),
			("HiddenServicePort", "80 %s:%s" % (host, str(port)))
			])
		except Exception as e:
			print "unable to create hidden service"
			print e
			quit()
Пример #2
0
def graceful():
	try:
		cron.shutdown()
	except Exception as e:
		print "Could not shut down background scheduler, got the following exception:"
		print e

	try:
		cur.close()
	except Exception as e:
		print "Could not close database cursor, got the following exception:"
		print e

	try:
		conn.close()
	except Exception as e:
		print "Could not close database connection, got the following exception:"
		print e

	try:
		controller.remove_hidden_service(get_hidden_svc_dir(), 80)
	except Exception as e:
		print "Could not remove hidden service"
		print e

	try:
		controller.close()
	except Exception as e:
		print "Could not close control connection to hidden service"
		print e 
Пример #3
0
def checkTor():
	if not controller.isAlive():
		print "tor controller was dead, now trying to restart it"
		try:
			controller = Controller.from_port()
			controller.authenticate()
		except Exception as e:
			print e
			print "tor is not letting us authenticate, is it configured correctly and running?" 
			exit()

		print "successfully opened control connection to tor"
#TODO here and elsewhere we should change from the get_conf/set_options
#interface to the create_ephemeral_hidden_service/
#remove_ephemeral_hidden_service/list_ephemeral_hidden_services
#that way we can also put the key and hostname in config and not have to
#worry about setting up /var/lib/tor/hidden_service

	if controller.get_conf("HiddenServiceDir") is None:
		print "tor was not configure to provide a hidden service, now configuring"
		try:
			controller.set_options([
			("HiddenServiceDir", get_hidden_svc_dir()),
			("HiddenServicePort", "80 %s:%s" % (host, str(port)))
			])
		except Exception as e:
			print "unable to create hidden service"
			print e
			quit()
Пример #4
0
def graceful():
	try:
		cron.shutdown()
	except Exception as e:
		print "Could not shut down background scheduler, got the following exception:"
		print e

	try:
		cur.close()
	except Exception as e:
		print "Could not close database cursor, got the following exception:"
		print e

	try:
		conn.close()
	except Exception as e:
		print "Could not close database connection, got the following exception:"
		print e

	try:
		controller.remove_hidden_service(get_hidden_svc_dir(), 80)
	except Exception as e:
		print "Could not remove hidden service"
		print e

	try:
		controller.close()
	except Exception as e:
		print "Could not close control connection to hidden service"
		print e 
Пример #5
0
	#for the pretty site this will likely turn into a fancy html5 download link
	return '<meta HTTP-EQUIV="REFRESH" content="5; url=%s"><h1> you will be redirected to your download in 5 seconds</h1>'% key.generate_url(expires_in=360, query_auth=False)
	#TODO make super double sure it plays nice with tor, also make sure 
	#it consistently downloads as attachment, otherwise we'll do the custom header thing to make sure it does

app.add_url_rule("/<hs>/", 'msgPage', msgPage)

############################
##Resume Main Control Flow##
############################

print "about to try creating hidden service"
try:
	controller.set_options([
	("HiddenServiceDir", get_hidden_svc_dir()),
	("HiddenServicePort", "80 %s:%s" % (host, str(port)))
	])
except Exception as e:
	print "unable to create hidden service"
	print e
	quit()

print "about to start flask"


app.config['SECRET_KEY'] = get_devKey()


#never enable on a production server
#app.debug = True
Пример #6
0
	#for the pretty site this will likely turn into a fancy html5 download link
	return '<meta HTTP-EQUIV="REFRESH" content="5; url=%s"><h1> you will be redirected to your download in 5 seconds</h1>'% key.generate_url(expires_in=360, query_auth=False)
	#TODO make super double sure it plays nice with tor, also make sure 
	#it consistently downloads as attachment, otherwise we'll do the custom header thing to make sure it does

app.add_url_rule("/<hs>/", 'msgPage', msgPage)

############################
##Resume Main Control Flow##
############################

print "about to try creating hidden service"
try:
	controller.set_options([
	("HiddenServiceDir", get_hidden_svc_dir()),
	("HiddenServicePort", "80 %s:%s" % (host, str(port)))
	])
except Exception as e:
	print "unable to create hidden service"
	print e
	quit()

print "about to start flask"


app.config['SECRET_KEY'] = get_devKey()


#never enable on a production server
#app.debug = True