Skip to content

Commit

Permalink
fix src -> dst
Browse files Browse the repository at this point in the history
  • Loading branch information
CrapsDorian committed Mar 28, 2024
1 parent 5b5bd2f commit 75747c4
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions flask_app/app.py
Expand Up @@ -19,13 +19,10 @@ def mptcp_status_page():
port = request.environ.get('REMOTE_PORT')

try:
conn_without_header = check_output(["ss", "-MtnH", "src", f"{addr}", "sport", f"{port}"]).decode("ascii")
conn_without_header = "\n".join(conn_without_header.split("\n")[1:])
if (conn_without_header == ""):
conn = check_output(["ss", "-MnH", "dst", f"{addr}", "dport", f"{port}"]).decode("ascii")

This comment has been minimized.

Copy link
@matttbe

matttbe Mar 28, 2024

easier to read with:

check_output(f"ss -MnH dest {addr} dport {port}").decode()

This comment has been minimized.

Copy link
@CrapsDorian

CrapsDorian Mar 28, 2024

Author Collaborator

MPTCP Connection is [error: [Errno 2] No such file or directory: 'ss -MnH dest 130.104.228.49 dport 35530']

this is not working

This comment has been minimized.

Copy link
@matttbe

matttbe Mar 28, 2024

mmh, ok, then with .split():

check_output(f"ss -MnH dest {addr} dport {port}".split()).decode()
if (conn == ""):

This comment has been minimized.

Copy link
@matttbe

matttbe Mar 28, 2024

no longer needed: it can be empty if it is not an MPTCP connection

pass

filtered_list = list(filter(None, conn_without_header.split(' ')))
if filtered_list and filtered_list[0] == "mptcp":
if conn.startswith("ESTAB"):
state_message = 'Established'
state_class = 'success'
else:

This comment has been minimized.

Copy link
@matttbe

matttbe Mar 28, 2024

probably best to change the message that is displayed:

You <strong>{{ state_message }}</strong> using MPTCP!

state_message would then be: are here above and are not in the else below

And depending on the user-agent (if it starts with curl/), either return a render_template or just text:

return f"You {state_message} using MPTCP"
Expand All @@ -50,5 +47,4 @@ def generate_audio():
break
yield audio_chunk

return Response(generate_audio(), mimetype='audio/mpeg')

return Response(generate_audio(), mimetype='audio/mpeg')

0 comments on commit 75747c4

Please sign in to comment.