TCP to Unix Socket Proxy

Listens on a TCP port and proxies connections to a UNIX domain socket.

License

License

MIT
GroupId

GroupId

org.rnorth
ArtifactId

ArtifactId

tcp-unix-socket-proxy
Last Version

Last Version

1.0.2
Release Date

Release Date

Type

Type

jar
Description

Description

TCP to Unix Socket Proxy
Listens on a TCP port and proxies connections to a UNIX domain socket.
Project URL

Project URL

https://github.com/rnorth/tcp-unix-socket-proxy
Source Code Management

Source Code Management

https://github.com/rnorth/tcp-unix-socket-proxy

Download tcp-unix-socket-proxy

How to add to project

<!-- https://jarcasting.com/artifacts/org.rnorth/tcp-unix-socket-proxy/ -->
<dependency>
    <groupId>org.rnorth</groupId>
    <artifactId>tcp-unix-socket-proxy</artifactId>
    <version>1.0.2</version>
</dependency>
// https://jarcasting.com/artifacts/org.rnorth/tcp-unix-socket-proxy/
implementation 'org.rnorth:tcp-unix-socket-proxy:1.0.2'
// https://jarcasting.com/artifacts/org.rnorth/tcp-unix-socket-proxy/
implementation ("org.rnorth:tcp-unix-socket-proxy:1.0.2")
'org.rnorth:tcp-unix-socket-proxy:jar:1.0.2'
<dependency org="org.rnorth" name="tcp-unix-socket-proxy" rev="1.0.2">
  <artifact name="tcp-unix-socket-proxy" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.rnorth', module='tcp-unix-socket-proxy', version='1.0.2')
)
libraryDependencies += "org.rnorth" % "tcp-unix-socket-proxy" % "1.0.2"
[org.rnorth/tcp-unix-socket-proxy "1.0.2"]

Dependencies

compile (3)

Group / Artifact Type Version
com.kohlschutter.junixsocket : junixsocket-native-common jar 2.0.4
com.kohlschutter.junixsocket : junixsocket-common jar 2.0.4
org.slf4j : slf4j-api jar 1.7.21

test (1)

Group / Artifact Type Version
org.slf4j : slf4j-simple jar 1.7.21

Project Modules

There are no modules declared in this project.

TcpToUnixSocketProxy

Listens on a TCP port and proxies connections to a UNIX domain socket.

Like socat TCP-LISTEN:2375,fork UNIX-CONNECT:/var/tmp/docker.sock, except this is literally the only thing this program does.

Purposefully simplistic in implementation, potentially buggy or suboptimal in performance, may contain nuts.

This proxy uses Christian Kohlschütter's junixsocket library for interaction with Unix sockets.

Rationale

This was implemented as a short term workaround for incompatibility between netty and Docker for Mac beta's use of unix domain sockets on OS X - described here.

Caveats

This proxy uses a deliberately simple blocking I/O with threads model, purely for simplicity. This clearly eliminates the performance advantages of using netty in docker-java. However, I feel that in most cases the performance of the docker API is not a critical factor, and a working but slow solution is preferable in the short term. Still, once kqueue support for netty is in place, that will become the better solution.

This library is only useful on OS X; Linux unix socket support through epoll is well supported by netty.

Usage

Instantiate a proxy instance:

TcpToUnixSocketProxy proxy = new TcpToUnixSocketProxy(new File("/var/run/docker.sock"));

Start it, and obtain the listening address (localhost with a random port by default):

InetSocketAddress address = proxy.start();

Use the proxy by connecting to localhost on the port given by address.getPort().

Then when the proxy is no longer needed:

proxy.stop();

License

See LICENSE.

Copyright

Copyright (c) 2016 Richard North.

Versions

Version
1.0.2
1.0.1