Git Product home page Git Product logo

ttu's Introduction

ttu

Tcp To Unix (sockets). A small wrapper program which switches TCP (actually, any AF_INET) sockets to Unix sockets transparently.

Usage

ttu is provided in two forms:

  • libttu.so -- the injection library (overrides bind, connect, etc) which does the magic
  • ttu -- small wrapper program to make using libttu.so easier

libttu.so

ttu use LD_PRELOAD to inject the library into a program, silently overriding several socket-related system calls.

Basically, use libttu.so like this:

$ LD_PRELOAD="/path/to/libttu.so" TTU_BIND="..." TTU_CONNECT="..." program [args]...

Where:

  • /path/to/libttu.so is the absolute path to the libttu.so binary.
  • TTU_BIND and TTU_CONNECT are optional and described here.
  • program [args] are the usual command-line arguments to run the program.

ttu

ttu automates the above process, making it much easier to use:

$ ttu [-l "/path/to/libttu.so"] [-b bind-map] [-c connect-map] -- program [args]

Where:

  • /path/to/libttu.so is the absolute path to the libttu.so binary.
  • -b bind-map and -c connect-map are optional and described here.
  • program [args] are the usual command-line arguments to run the program.

Parameters

The paramaters to ttu are the following:

  • TTU_BIND: A mapping of bindings (inet listening sockets) to unix sockets (aka a bind-map).
  • TTU_CONNECT: A mapping of connections (inet connecting sockets) to unix sockets (aka a connect-map).

Socket mappings are in this format:

[ip-addr]:[port]=/path/to/socket.sock,[ip-addr]:[port]=/path/to/socket.sock, ...

Where:

  • ip-addr is the ip address of the inet socket (optional, defaults to *).
  • port is the port of the inet socket (optional, defaults to *).
  • /path/to/socket.sock is the path to the socket (mandatory, the path is recommended to be an absolute path [to avoid chdir(2) problems])

In the above options, * acts as a wildcard. The order of preference in finding a socket to bind to is as follows:

  1. The exact match of ip:port in the parameters.
  2. The wildcard match of *:port in the parameters.
  3. The wildcard match of ip:* in the parameters.
  4. The wilcard match of *:* in the parameters.
  5. Passthrough and allow the socket to bind normally (no remapping).

If several different paramaters have the same mapping (such as 0.0.0.0:80=/tmp/a,0.0.0.0:80=/tmp/b or *:*=/tmp/a,*:*=/tmp/b), the last mapping in the option is obeyed.

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.