0
0
mirror of https://github.com/darkk/redsocks.git synced 2025-08-26 03:35:30 +00:00
transparent TCP-to-proxy redirector
Go to file
Przemyslaw Pawelczyk c97a9e0c77 Properly handle unsupported qops in digest_authentication_encode().
Auth-int is not supported yet, so the function should return early.
2011-01-28 02:06:17 +01:00
doc add http auth RFC doc 2010-11-11 16:35:46 +08:00
.gitignore added .depend to .gitignore 2010-11-11 16:39:44 +08:00
base64.c add base64 and md5 library for http auth 2010-11-14 14:34:08 +08:00
base64.h minor fixes 2010-11-14 22:35:22 +08:00
base.c Fix dead store bugs. 2011-01-27 22:52:13 +01:00
base.h Whitespace fixes. 2008-07-13 21:36:51 +07:00
COPYING Added README and better configuration example. 2008-08-19 03:27:14 +07:00
http-auth.c Properly handle unsupported qops in digest_authentication_encode(). 2011-01-28 02:06:17 +01:00
http-auth.h remove time limit between consective attempts 2010-11-19 01:03:20 +08:00
http-connect.c remove free_null macro 2011-01-13 15:24:48 +08:00
http-relay.c Hide warnings on unused variables if asserts are off. 2011-01-27 23:22:09 +01:00
list.h Whitespace fixes. 2008-07-13 21:36:51 +07:00
log.c add clang compiler support; clean warnings; remove auth info from log file 2010-11-25 19:11:14 +08:00
log.h Fixed format string bug. 2009-05-21 11:28:54 +07:00
main.c Fix logic error bugs. 2011-01-27 23:05:45 +01:00
main.h Whitespace fixes. 2008-07-13 21:36:51 +07:00
Makefile Improve Makefile. 2011-01-27 22:39:34 +01:00
md5.c add base64 and md5 library for http auth 2010-11-14 14:34:08 +08:00
md5.h add base64 and md5 library for http auth 2010-11-14 14:34:08 +08:00
parser.c Fix logic error bugs. 2011-01-27 23:05:45 +01:00
parser.h Added ability to create many redsocks config sections to have many redirectors. 2008-08-18 17:46:27 +07:00
README merge commits from upstream 2010-12-03 22:02:40 +08:00
reddns.c Added GPLv3 copyright notice to every source file. 2008-12-13 15:40:52 +06:00
redsocks.c Hide warnings on unused variables if asserts are off. 2011-01-27 23:22:09 +01:00
redsocks.conf.example Initial UDP over Socks5 support. 2010-12-03 02:18:14 +02:00
redsocks.h merge commits from upstream 2010-12-03 22:02:40 +08:00
redudp.c Fix dead store bugs. 2011-01-27 22:52:13 +01:00
redudp.h Initial UDP over Socks5 support. 2010-12-03 02:18:14 +02:00
socks4.c add clang compiler support; clean warnings; remove auth info from log file 2010-11-25 19:11:14 +08:00
socks5.c Fix logic error bugs. 2011-01-27 23:05:45 +01:00
socks5.h Cleanup: make socks5 structures reusable. 2010-12-02 23:39:03 +02:00
utils.c getsockopt wants optlen to be socklen_t. 2011-01-27 22:14:58 +01:00
utils.h Hide warnings on unused variables if asserts are off. 2011-01-27 23:22:09 +01:00

This tool allows you to redirect any TCP connection to SOCKS or HTTPS
proxy using your firewall, so redirection is system-wide.

Why is that useful? I can suggest following reasons:
* you use tor[1] and don't want any TCP connection to leak.
* you use DVB ISP and this ISP provides internet connectivity with some
  special daemon that may be also called "Internet accelerator" and this
  accelerator acts as proxy. Globax[2] is example of such an accelerator.

Linux/iptables, OpenBSD/pf and FreeBSD/ipfw are supported.
Linux/iptables is well-tested, other implementations may have bugs,
your bugreports are welcome.

Transocks[3] is alike project but it has noticable performance penality.

Transsocks_ev[4] is alike project too, but it has no HTTPS-proxy support
and does not support authentication.

[1] http://www.torproject.org
[2] http://www.globax.biz
[3] http://transocks.sourceforge.net/
[4] http://oss.tiggerswelt.net/transocks_ev/


Features
========

Redirect any TCP connection to SOCKS4, SOCKS5 or HTTPS (HTTP/CONNECT)
proxy server.

Login/password authentication is supported for SOCKS5/HTTPS connections.
SOCKS4 supports only username, password is ignored. for HTTPS, currently
only Basic and Digest scheme is supported.

Redirect UDP packets via SOCKS5 proxy server.

Redirect any HTTP connection to proxy that does not support transparent
proxying (e.g. old SQUID had broken `acl myport' for such connections).


License
=======

All source code is licensed under GPLv3 or later. Contact the author
if you want to use the code and GPLv3 (or later) does not permit you to
do so.

Text of GPLv3 is included in file `COPYING'.


Compilation
===========

libevent[5] is required.

gcc and clang are supported right now, other compilers can be used
but may require some code changes.

Compilation is as easy as running `make', there is no `./configure' magic.

GNU Make works, other implementations of make were not tested.

[5] http://www.monkey.org/~provos/libevent/


Running
=======

Program has only two command-line options:
 -c   sets proper path to config file ("./redsocks.conf" is default one)
 -t   tests config file syntax
 -p   set a file to write the getpid() into

Following signals are understood:
SIGUSR1 dumps list of connected clients to log
SIGTERM and SIGINT terminates daemon, all active connections are closed

You can see configuration file example in redsocks.conf.example


iptables example
================

You have to build iptables with connection tracking and REDIRECT target.

# Create new chain
iptables -t nat -N REDSOCKS

# Ignore LANs and some other reserved addresses.
iptables -t nat -A REDSOCKS -d 0.0.0.0/8 -j RETURN
iptables -t nat -A REDSOCKS -d 10.0.0.0/8 -j RETURN
iptables -t nat -A REDSOCKS -d 127.0.0.0/8 -j RETURN
iptables -t nat -A REDSOCKS -d 169.254.0.0/16 -j RETURN
iptables -t nat -A REDSOCKS -d 172.16.0.0/12 -j RETURN
iptables -t nat -A REDSOCKS -d 192.168.0.0/16 -j RETURN
iptables -t nat -A REDSOCKS -d 224.0.0.0/4 -j RETURN
iptables -t nat -A REDSOCKS -d 240.0.0.0/4 -j RETURN

# Anything else should be redirected to port 12345
iptables -t nat -A REDSOCKS -p tcp -j REDIRECT --to-ports 12345

# Any tcp connection made by `darkk' should be redirected.
iptables -t nat -A OUTPUT -p tcp -m owner --uid-owner darkk -j REDSOCKS


Homepage
========

http://darkk.net.ru/redsocks/


TODO
====

Test OpenBSD (pf) and FreeBSD (ipfw) and write setup examples for those
firewall types.

Allow redirecting of UDP and/or DNS packets.


Author
======
This program was written by Leonid Evdokimov <leon@darkk.net.ru>