Skip to content

Commit

Permalink
index: add info message about the browser
Browse files Browse the repository at this point in the history
That's not because the browser is not supporting MPTCP, than the system
is not.

While at it, move the errors (if any) there.

Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
  • Loading branch information
matttbe committed Nov 14, 2024
1 parent a692520 commit cc19ba9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
12 changes: 10 additions & 2 deletions flask_app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,30 @@ def mptcp_status_page():
if ":" in addr:
addr = f"{addr}:{port}"

state_info = ''
try:
conn = check_output(["ss", "-MnH", "dst", f"{addr}", "dport", f"{port}"]).decode("ascii")
if conn.startswith("ESTAB"):
state_message = 'are'
state_class = 'success'
state_info = 'Nice, even your browser is supporting MPTCP!'
else:
state_message = 'are not'
state_class = 'fail'
state_info = 'Your browser <strong>is not</strong> supporting MPTCP, but <strong>maybe your system is</strong>, check the cURL command below.'
except Exception as e:
state_message = '[error: ' + str(e) + ']'
state_message = 'are maybe, or maybe not (internal error)'
state_class = 'error'
state_info = 'Error: ' + str(e)

if user.startswith("curl"):
return "You " + state_message + " using MPTCP.\n"

return render_template('index.html', state_message=state_message, state_class=state_class, host=host)
return render_template('index.html',
state_message=state_message,
state_class=state_class,
state_info=state_info,
host=host)

if __name__ == "__main__":
app.run(host="::", port=80, debug=True)
Expand Down
3 changes: 3 additions & 0 deletions flask_app/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ <h2>MPTCP Connection Status</h2>
<p>You <strong>{{ state_message }}</strong> using MPTCP!</p>
</div>
</div>
<p>
{{ state_info }}
</p>

<h2>cURL</h2>
<p>
Expand Down

0 comments on commit cc19ba9

Please sign in to comment.