Sign inSign up

simkim/tcpdam

By simkim

•Updated over 9 years ago

A parking proxy for tcp connections

Image
1

202

simkim/tcpdam repository overview

⁠tcpdam

⁠Overview

tcpdam is a parking proxy for your tcp connection. When your upstream server is ready, send SIGUSR1 to flush connection to the server.

⁠Compilation

make

⁠Usage

tcpdam -l LISTEN-HOST:LISTEN-PORT -r REMOTE-HOST:REMOTE-PORT

will setup a listening tcp server, when something connect it is parked in a waiting list

killall -USR1 tcpdam

will lookup REMOTE-HOST once, and open the dam : the parked and new connections are proxified to REMOTE-HOST.

killall -USR2 tcpdam

will re-close the dam and start to park new connections,

⁠Configuration

EnvCommand lineDescription
TCPDAM_LISTEN_ADDRESS-lListen address for incoming connections
TCPDAM_REMOTE_ADDRESS-hRemote address where the connections will be flushed
TCPDAM_DEBUG-dShow all information
TCPDAM_VERBOSE-vShow some information
TCPDAM_PIDFILE-pFile which will contain the pid of the dam
TCPDAM_CTRLSOCKET-ctrl-socketUnix socket to control the dam
TCPDAM_MAX_FLUSHING-max-flushingMax number of open remote connections
TCPDAM_MAX_PARKED-max-parkedMax number of connections in the queue
TCPDAM_OPEN-openStart the dam open
 -ccommand to send to a running dam
⁠Remote Commands
CommandDescription
openopen the dam unless already open
closeclose the dam unless already closed
set-remote HOST:PORTswitch the remote address, will be used at the next open

⁠Limits

⁠Open file descriptors

You need to configure your maximum number of file descriptor to allow a high number of parked connections

  • debian : configure /etc/security/limits.conf
  • docker : docker run --ulimit nofile=100000:100000
  • compose : see docker-compose.yml
⁠netfilter conntrack size

TODO

⁠tcp TIME_WAIT

TODO

⁠Docker

⁠From the hub

To run the dam

docker run -p 9999:9999 --rm -ti --name tcpdam_test  simkim/tcpdam tcpdam -r google.com:80

To open the dam

docker exec tcpdam_test killall -USR1 tcpdam

To open the dam, wait for connections to terminate and quit

docker stop tcpdam_test
⁠From local build
Edit docker-compose.yml

docker run -v `pwd`/build:/go/bin -v `pwd`:/go/src/github.com/simkim/tcpdam --rm golang go get github.com/simkim/tcpdam/...
docker-compose build
docker-compose up

Tag summary

Content type

Image

Digest

Size

244.9 MB

Last updated

over 9 years ago

docker pull simkim/tcpdam