Skip to content

Feature: Implement unix socket forwarding#448

Open
Moritz-Schmidt wants to merge 7 commits intorathole-org:devfrom
Moritz-Schmidt:socket-forwarding
Open

Feature: Implement unix socket forwarding#448
Moritz-Schmidt wants to merge 7 commits intorathole-org:devfrom
Moritz-Schmidt:socket-forwarding

Conversation

@Moritz-Schmidt
Copy link

Descriptions

Implement Unix Domain Socket (UDS) forwarding for sockets of type: SOCK_STREAM (comparable to TCP).

All new UDS related code is behinde a #[cfg(unix)] conditional compilation attribute because tokio::net::{UnixSocket, UnixListener, UnixStream} is only available on unix systems.

Related Issues:

Type of change

Non-Breaking change which adds a feature.

Usage

Server:

[server.services.my_socket_service]
type = "socket_stream"
bind_addr = "/var/run/example.sock" # specifies the Unix socket path that exposes `my_socket_service` on the server side

Client:

[client.services.my_socket_service]
type = "socket_stream"
local_addr = "/var/run/example.sock" # The socket path of the service that needs to be exposed

How has this been tested?

Implemented integration tests for type socket_stream which pass on MacOS and debian.

Further Ideas

Currently in this PR only UDS to UDS forwarding is implemented. Theoretically it'd be possible to implement UDS to TCP and TCP to UDS forwarding too. However this would need some (possibly breaking) changes to the configuration structure (e.g. different types for client and server) or different types for all possible combinations (e.g. UdsToTcp, TcpToUds) because of this I didn't implement it in this PR. I can implement it if maintainers decide how it should be configured.

Sockets of type SOCK_DGRAM are currently not supported by this PR and I do not plan to implement support for them.

@Moritz-Schmidt Moritz-Schmidt changed the base branch from main to dev January 18, 2026 20:22
@karlbeecken
Copy link

Hi @sjtrny, any chance we can get this in with the 0.6.0 release? I have tested these changes for a few weeks now, and they run perfectly fine in my setup

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