Add diagnosis details for issues detected for HTTP exposure

This commit is contained in:
Alexandre Aubin 2019-11-20 17:12:23 +01:00
parent 02d00eece0
commit 4636bd20e1
2 changed files with 8 additions and 2 deletions

View file

@ -31,7 +31,7 @@ class HttpDiagnoser(Diagnoser):
r = requests.post('https://diagnosis.yunohost.org/check-http', json={'domain': domain, "nonce": nonce}, timeout=30).json()
if "status" not in r.keys():
raise Exception("Bad syntax for response ? Raw json: %s" % str(r))
elif r["status"] == "error" and ("code" not in r.keys() or r["code"] not in ["error_http_check_connection_error", "error_http_check_unknown_error"]):
elif r["status"] == "error" and ("code" not in r.keys() or not r["code"].startswith("error_http_check_")):
if "content" in r.keys():
raise Exception(r["content"])
else:
@ -44,9 +44,11 @@ class HttpDiagnoser(Diagnoser):
status="SUCCESS",
summary=("diagnosis_http_ok", {"domain": domain}))
else:
detail = r["code"].replace("error_http_check", "diagnosis_http") if "code" in r else "diagnosis_http_unknown_error"
yield dict(meta={"domain": domain},
status="ERROR",
summary=("diagnosis_http_unreachable", {"domain": domain}))
summary=("diagnosis_http_unreachable", {"domain": domain}),
details=[(detail,())])
# In there or idk where else ...
# try to diagnose hairpinning situation by crafting a request for the

View file

@ -212,6 +212,10 @@
"diagnosis_ports_forwarding_tip": "To fix this issue, most probably you need to configure port forwarding on your internet router as described in https://yunohost.org/port_forwarding",
"diagnosis_http_could_not_diagnose": "Could not diagnose if domain is reachable from outside. Error: {error}",
"diagnosis_http_ok": "Domain {domain} is reachable from outside.",
"diagnosis_http_timeout": "Timed-out while trying to contact your server from outside. It appears to be unreachable. You should check that you're correctly forwarding port 80, that nginx is running, and that a firewall is not interfering.",
"diagnosis_http_connection_error": "Connection error: could not connect to the requested domain, it's very likely unreachable.",
"diagnosis_http_unknown_error": "An error happened while trying to reach your domain, it's very likely unreachable.",
"diagnosis_http_bad_status_code": "Could not reach your server as expected, it returned a bad status code. It might be that another machine answered instead of your server. You should check that you're correctly forwarding port 80, that your nginx configuration is up to date, and that a reverse-proxy is not interfering.",
"diagnosis_http_unreachable": "Domain {domain} is unreachable through HTTP from outside.",
"diagnosis_unknown_categories": "The following categories are unknown : {categories}",
"domain_cannot_remove_main": "You cannot remove '{domain:s}' since it's the main domain, you need first to set another domain as the main domain using 'yunohost domain main-domain -n <another-domain>', here is the list of candidate domains: {other_domains:s}",