-
Notifications
You must be signed in to change notification settings - Fork 381
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
Fix unix domain socket binding for reverse tunnel #362
base: main
Are you sure you want to change the base?
Conversation
Hello, Thank you for the PR. |
@@ -50,9 +50,14 @@ impl Stream for UnixListenerStream { | |||
pub async fn run_server(socket_path: &Path) -> Result<UnixListenerStream, anyhow::Error> { | |||
info!("Starting Unix socket server listening cnx on {:?}", socket_path); | |||
|
|||
let path_to_delete = !socket_path.exists(); | |||
if socket_path.exists() { |
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.
If the unix socket path, already exist we should not delete it. As it is not owned by wstunnel.
#[derive(Hash, Eq, PartialEq, Clone, Debug)] | ||
pub enum BindAddr { | ||
Socket(SocketAddr), | ||
Unix(String), // Unix socket path |
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.
You can use PathBuf instead of a string I think.
@@ -194,9 +194,10 @@ impl WsServer { | |||
let header = ppp::v2::Builder::with_addresses( | |||
ppp::v2::Version::Two | ppp::v2::Command::Proxy, | |||
ppp::v2::Protocol::Stream, | |||
(client_address, tx.local_addr()?), | |||
(client_address, tx.local_addr().unwrap()), |
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.
bad merge
) | ||
.build()?; | ||
.build() |
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.
bad merge
@@ -302,7 +308,6 @@ impl WsServer { | |||
move |req: Request<Incoming>| { | |||
http_server_upgrade(server.clone(), restrictions.clone(), restrict_path.clone(), client_addr, req) | |||
.map::<anyhow::Result<_>, _>(Ok) | |||
.instrument(mk_span()) |
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.
bad merge
@@ -337,7 +342,6 @@ impl WsServer { | |||
.unwrap()) | |||
} | |||
} | |||
.instrument(mk_span()) |
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.
bad merge
@@ -383,12 +387,20 @@ impl WsServer { | |||
} | |||
}; | |||
|
|||
let span = span!(Level::INFO, "cnx", peer = peer_addr.to_string(),); |
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.
bad merge
// https://github.com/erebe/wstunnel/issues/358 | ||
// disabled, to avoid conflict with --connection-min-idle flag, that open idle connections | ||
.header_read_timeout(None) | ||
.header_read_timeout(Duration::from_secs(10)) |
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.
bad merge
I case of unix domain socket, local host:port is always 0.0.0.0:0 and when another client wants to connect with a different unix socket path, it binds it to the existing connection.