[Pkg-privacy-commits] [onionshare] 56/66: Fix issue with shutting down Flask server when not using --local-only (#238)
Ulrike Uhlig
u-guest at moszumanska.debian.org
Wed Apr 13 22:17:52 UTC 2016
This is an automated email from the git hooks/post-receive script.
u-guest pushed a commit to branch master
in repository onionshare.
commit db1ed7c6de272a57ce2842fc5dec611fe84b7f70
Author: Micah Lee <micah at micahflee.com>
Date: Tue Apr 12 17:04:19 2016 -0700
Fix issue with shutting down Flask server when not using --local-only (#238)
---
onionshare/web.py | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/onionshare/web.py b/onionshare/web.py
index bba98fd..6aba1c7 100644
--- a/onionshare/web.py
+++ b/onionshare/web.py
@@ -298,12 +298,7 @@ def page_not_found(e):
error404_count += 1
if error404_count == 20:
add_request(REQUEST_RATE_LIMIT, request.path)
-
- # Learn the port the Flask app is running on, to stop it
- # http://stackoverflow.com/questions/5085656/how-to-get-the-current-port-number-in-flask
- port = int(request.host.split(':')[1])
- stop(port)
-
+ force_shutdown()
print(strings._('error_rate_limit'))
return render_template_string(open(helpers.get_resource_path('html/404.html')).read())
@@ -315,18 +310,23 @@ shutdown_slug = helpers.random_string(16)
@app.route("/<slug_candidate>/shutdown")
def shutdown(slug_candidate):
"""
- Stop the flask web server.
+ Stop the flask web server, from the context of an http request.
"""
check_slug_candidate(slug_candidate, shutdown_slug)
+ force_shutdown()
+ return ""
+
+def force_shutdown():
+ """
+ Stop the flask web server, from the context of the flask app.
+ """
# shutdown the flask service
func = request.environ.get('werkzeug.server.shutdown')
if func is None:
raise RuntimeError('Not running with the Werkzeug Server')
func()
- return ""
-
def start(port, stay_open=False, transparent_torification=False):
"""
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/onionshare.git
More information about the Pkg-privacy-commits
mailing list