Git Product home page Git Product logo

tcp-unix-socket-proxy's Introduction

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.

tcp-unix-socket-proxy's People

Contributors

rnorth avatar

Stargazers

PEP 8 Speaks avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.