Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

pavel-orlov
Copy link

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.

@erebe
Copy link
Owner

erebe commented Sep 30, 2024

Hello,

Thank you for the PR.
The fix look good, just some merge request conflict to fix ;)

@@ -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() {
Copy link
Owner

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
Copy link
Owner

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()),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bad merge

)
.build()?;
.build()
Copy link
Owner

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())
Copy link
Owner

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())
Copy link
Owner

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(),);
Copy link
Owner

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))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bad merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants