-
Notifications
You must be signed in to change notification settings - Fork 133
Passthrough traffic mirroring #3279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Passthrough traffic mirroring #3279
Conversation
9a309eb
to
7707492
Compare
One general thing: does |
/// Handles mirrord's file operations, see [`FileManager`]. | ||
file_manager: FileManager, | ||
connection: ClientConnection, | ||
/// [`None`] when targetless. | ||
tcp_sniffer_api: Option<TcpSnifferApi>, | ||
tcp_mirror_api: Option<Box<dyn TcpMirrorApi>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you help me understand why we need/want dynamic dispatch and can't/don't want to use normal generics, with a trait bounded type variable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have needed to change the way ClientConnectionHandler
is created, and it was a bit messy :V
Are you against dynamic dispatch? We can do an enum as well
if let Some(tcp_stealer_api) = self.tcp_steal_api.as_mut() { | ||
if let Err(error) = tcp_stealer_api.handle_client_message(message).await { | ||
self.respond(DaemonMessage::Close(format!( | ||
"invalid HTTP filter: {error}" | ||
))) | ||
.await?; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"invalid HTTP filter" looks pretty arbitrary in here. Even if it's the only possible reason for an error (is it?) wouldn't it be better to determine that with a match
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error type of handle_client_message
is fancy_regex::Error
. Not sure what you mean by match
. Do you want sth like this?
if let Err(error) = tcp_stealer_api.handle_client_message(message).await {
let error: fancy_regex::Error = error;
self.respond(DaemonMessage::Close(format!(
"invalid HTTP filter: {error}"
)))
.await?;
}
This would work as a reminder to update the error message, when someone changes the error type.
Or should the method return just Result<_, String>
(message for DaemonMessage::Close
) 🤔
I didn't think about it much tbh. I believe I came up with this name when presenting the idea internally. I agree that |
105eea0
to
2339fa0
Compare
5e54163
to
7f28da9
Compare
b731d61
to
15163e2
Compare
e0b72c6
to
13a0b32
Compare
Ok, there's something wrong here, some kind of a race. |
Oh well