Improve raw QUIC dumping (#6287)

* improve raw QUIC dumping

* tests++
This commit is contained in:
Maximilian Hils 2023-08-01 12:13:48 +02:00 committed by GitHub
parent d3af57f13b
commit 47aaec4f74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 4 deletions

View File

@ -345,15 +345,24 @@ class Dumper:
message = f.messages[-1]
direction = "->" if message.from_client else "<-"
if f.client_conn.tls_version == "QUIC":
type_ = f"quic/{f.type}"
if f.type == "tcp":
quic_type = "stream"
else:
quic_type = "dgrams"
# TODO: This should not be metadata, this should be typed attributes.
flow_type = (
f"quic {quic_type} {f.metadata.get('quic_stream_id_client','')} "
f"{direction} mitmproxy {direction} "
f"quic {quic_type} {f.metadata.get('quic_stream_id_server','')}"
)
else:
type_ = f.type
flow_type = f.type
self.echo(
"{client} {direction} {type} {direction} {server}".format(
client=human.format_address(f.client_conn.peername),
server=human.format_address(f.server_conn.address),
direction=direction,
type=type_,
type=flow_type,
)
)
if ctx.options.flow_detail >= 3:

View File

@ -292,8 +292,19 @@ def test_quic():
with taddons.context(d):
f = tflow.ttcpflow()
f.client_conn.tls_version = "QUIC"
# TODO: This should not be metadata, this should be typed attributes.
f.metadata["quic_stream_id_client"] = 1
f.metadata["quic_stream_id_server"] = 1
d.tcp_message(f)
assert "quic/tcp" in sio.getvalue()
assert "quic stream 1" in sio.getvalue()
f2 = tflow.tudpflow()
f2.client_conn.tls_version = "QUIC"
# TODO: This should not be metadata, this should be typed attributes.
f2.metadata["quic_stream_id_client"] = 1
f2.metadata["quic_stream_id_server"] = 1
d.udp_message(f2)
assert "quic stream 1" in sio.getvalue()
def test_styling():

View File

@ -58,6 +58,7 @@ export interface OptionsState {
server_replay_kill_extra: boolean;
server_replay_nopop: boolean;
server_replay_refresh: boolean;
server_replay_reuse: boolean;
server_replay_use_headers: string[];
showhost: boolean;
ssl_insecure: boolean;
@ -151,6 +152,7 @@ export const defaultState: OptionsState = {
server_replay_kill_extra: false,
server_replay_nopop: false,
server_replay_refresh: true,
server_replay_reuse: false,
server_replay_use_headers: [],
showhost: false,
ssl_insecure: false,