Skip to content

Commit

Permalink
Rewrite the program and drop support to libevent 1.x.
Browse files Browse the repository at this point in the history
  • Loading branch information
semigodking committed Dec 16, 2014
1 parent 218fca0 commit d950079
Show file tree
Hide file tree
Showing 15 changed files with 1,835 additions and 1,823 deletions.
6 changes: 2 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ SRCS := $(OBJS:.o=.c)
CONF := config.h
DEPS := .depend
OUT := redsocks2
VERSION := 0.51
VERSION := 0.60

LIBS := -levent
CFLAGS +=-fPIC -O2 \
-I ~/openwrt/openwrt/staging_dir/target-mipsel_dsp_uClibc-0.9.33.2/usr/include/ \
-L ~/openwrt/openwrt/staging_dir/target-mipsel_dsp_uClibc-0.9.33.2/usr/lib/
CFLAGS +=-fPIC -O3
override CFLAGS += -std=gnu99 -Wall
#LDFLAGS += -fwhole-program

Expand Down
63 changes: 3 additions & 60 deletions README
Original file line number Diff line number Diff line change
@@ -1,63 +1,6 @@
This is a modified version of original redsocks.
This variant is useful for anti-GFW (Great Fire Wall).

Note:
Method 'autosocks5' and 'autohttp-connect' are removed.
To use the autoproxy feature, please change the redsocks section in
configuration file like this:

redsocks {
local_ip = 192.168.1.1;
local_port = 1081;
ip = 192.168.1.1;
port = 9050;
type = socks5; // I use socks5 proxy for GFW'ed IP
autoproxy = 1; // I want autoproxy feature enabled on this section.
// The two lines above have same effect as
// type = autosocks5;
// in previous release.
//type = http-connect;
//login = username;
//password = passwd;
}

--------------------------------------------------------------------
It provides the following advanced features:
1. new 'direct' mehtod.
This method is intent to direct any TCP connections directly without
going through a proxy. Why this mehtod? Some ISP, like China Mobile (CMCC),
detects numbers of computers in your local network sharing same account by
montioring HTTP/HTTPS traffic. Only one computer has full access to all
websites. Other computers in local network are limited to some websites.
By depolying transparent proxy with this method, all your computers can
access websites without restrictions.
2. new 'autosocks5' method. (REPLACED BY NEW METHOD!!!!)
This mehtod is specially customized for fighting against GFW. By
default, all TCP connections are redirected to connect to target directly
without going through socks5 proxy. But, in case the connection to target
is RESET/CLOSED immediately for some reason (e.g. by GFW), the connection
is redirected via socks5 proxy. The same logic is also applied when the
connection to target fails to establish in certain seconds (13 seconds
currently). For such slow connection, no matter it is really a slow
connection or the handshake packets are dropped by GFW, making such
connections go through proxy is not a bad idea.
REDSOCKS also maintances a cache for addresses that need to be relayed
via proxy. So, whenever an address is identified need to be relayed via
proxy, the subsequent connections to those addresses will be relayed via
proxy immediately unless the addresses are removed from cache by code logic.
The advantage of this method is that you do not need to set thousands
entries in iptables for blocked sites manually. It is especially useful
for proxying Youtube which has so many sub-domains for video content cache.
3. new 'autohttp-connect' method. (REPLACED BY NEW METHOD!!!!)
This method behaves similar as 'autoscoks5' method except the proxy
to be used must support HTTP CONNECT method. This method is useful for
using redsocks together with GoProxy.

HOW TO BUILD:
Since this variant of redsocks is customized for running with Openwrt, please
read documents here (http://wiki.openwrt.org/doc/devel/crosscompile) for how
to compile.

This is a modified version of original redsocks and is useful for
anti-GFW (Great Fire Wall).
The content below is from original redsocks project.
---------------------------------------------------------------------
This tool allows you to redirect any TCP connection to SOCKS or HTTPS
proxy using your firewall, so redirection is system-wide.
Expand Down
215 changes: 0 additions & 215 deletions README.html

This file was deleted.

38 changes: 34 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,17 @@ This variant is useful for anti-GFW (Great Fire Wall).

HOW it works
------------
Who can help me to complete this part? -_-
Anyone can help me to complete this part? -_-

HOW TO BUILD
------------
On general linux, simply run command below to build.

make

Since this variant of redsocks is customized for running with Openwrt, please
read documents here (http://wiki.openwrt.org/doc/devel/crosscompile) for how
to cross compile.

##Note:
Method 'autosocks5' and 'autohttp-connect' are removed.
Expand All @@ -29,12 +38,30 @@ configuration file like this:
// It specified timeout value when trying to connect to destination
// directly. Default is 10 seconds. When it is set to 0, default
// timeout value will be used.
timeout = 10;
// NOTE: decrease the timeout value may lead increase of chance for
// normal IP to be misjudged.
timeout = 13;
//type = http-connect;
//login = username;
//password = passwd;
}


##Redirect Blocked Traffic via VPN Automatically
Suppose you have VPN connection setup with interface tun0. You want all
all blocked traffic pass through via VPN connection while normal traffic
pass through via default internet connection.

redsocks {
local_ip = 192.168.1.1;
local_port = 1080;
interface = tun0; // Outgoing interface for blocked traffic
type = direct;
timeout = 13;
autoproxy = 1;
}


##Work with GoAgent
To make redsocks2 works with GoAgent proxy, you need to set proxy type as
'http-relay' for HTTP protocol and 'http-connect' for HTTPS protocol
Expand All @@ -53,7 +80,7 @@ The configuration for forwarding connections to GoAgent is like below:
// It specified timeout value when trying to connect to destination
// directly. Default is 10 seconds. When it is set to 0, default
// timeout value will be used.
timeout = 10;
timeout = 13;
}
redsocks {
local_ip = 192.168.1.1;
Expand All @@ -66,6 +93,9 @@ The configuration for forwarding connections to GoAgent is like below:
// It specified timeout value when trying to connect to destination
// directly. Default is 10 seconds. When it is set to 0, default
// timeout value will be used.
timeout = 10;
timeout = 13;
}

AUTHOR
------
Zhuofei Wang <semigodking@gmail.com>
Loading

28 comments on commit d950079

@qiuzi
Copy link

@qiuzi qiuzi commented on d950079 Dec 17, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我来试试 有需要测试的项目或要求吗 /?

libevent2 需要换掉吗?

@semigodking
Copy link
Owner Author

@semigodking semigodking commented on d950079 Dec 17, 2014 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rampageX
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

貌似上传的问题还是没有解决?我试了下百度网盘,上传还是有问题。

@qiuzi
Copy link

@qiuzi qiuzi commented on d950079 Dec 18, 2014 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rampageX
Copy link

@rampageX rampageX commented on d950079 Dec 18, 2014 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@qiuzi
Copy link

@qiuzi qiuzi commented on d950079 Dec 18, 2014 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rampageX
Copy link

@rampageX rampageX commented on d950079 Dec 18, 2014 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@semigodking
Copy link
Owner Author

@semigodking semigodking commented on d950079 Dec 18, 2014 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rampageX
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@semigodking 公司是移动光纤,我刚仔细看了下可能本身访问百度网盘有问题,115 网盘没有问题的。

我回家会用电信网络再测试。

@rampageX
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@semigodking 确定是网络问题,家里电信 ADSL 无问题,Sorry。

@qiuzi
Copy link

@qiuzi qiuzi commented on d950079 Dec 18, 2014 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@semigodking
Copy link
Owner Author

@semigodking semigodking commented on d950079 Dec 18, 2014 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@qiuzi
Copy link

@qiuzi qiuzi commented on d950079 Dec 18, 2014 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@qiuzi
Copy link

@qiuzi qiuzi commented on d950079 Dec 25, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

最近dns污染严重 里面的dns转发功能可以实现非iptables转发吗?
就是直接127.0.0.1:55 这样建立dns服务?

@semigodking
Copy link
Owner Author

@semigodking semigodking commented on d950079 Dec 25, 2014 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@qiuzi
Copy link

@qiuzi qiuzi commented on d950079 Dec 25, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@semigodking 加这类功能也不行吗?

@semigodking
Copy link
Owner Author

@semigodking semigodking commented on d950079 Dec 25, 2014 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@qiuzi
Copy link

@qiuzi qiuzi commented on d950079 Dec 25, 2014 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@semigodking
Copy link
Owner Author

@semigodking semigodking commented on d950079 Dec 25, 2014 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@qiuzi
Copy link

@qiuzi qiuzi commented on d950079 Dec 25, 2014 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mumchristmas
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我用的是ChinaDNS方案(https://github.com/clowwindy/ChinaDNS)。
特点是易于部署,并且可以实现免维护。

@qiuzi
Copy link

@qiuzi qiuzi commented on d950079 Dec 26, 2014 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mumchristmas
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@qiuzi 第一次ping不正常,解析回211.5.133.18,100%丢包。
再次ping就恢复了,解析回61.54.28.6。

黑洞地址有维护列表的,可以加到黑名单里防止。
另外之前的地址给错了,我路由器用的是这个版本:https://github.com/clowwindy/ChinaDNS-C

@qiuzi
Copy link

@qiuzi qiuzi commented on d950079 Dec 26, 2014 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@semigodking
Copy link
Owner Author

@semigodking semigodking commented on d950079 Dec 26, 2014 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@qiuzi
Copy link

@qiuzi qiuzi commented on d950079 Dec 28, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

近来发现的策略问题,观看googlevideo时会解析很多ip 有些ip不能被redsocks判定走代理
造成视频卡顿严重例如https://www.youtube.com/watch?v=JF8t4ygOZwo
纯代理很快 启动自动判定后无法观看 视频为https加密协议 靠超时和重置不能实现自动代理

@wyf88
Copy link

@wyf88 wyf88 commented on d950079 Dec 29, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感谢作者,新版貌似解决了上传的问题。但我还有个小问题:用 Windows 远程桌面连到学校里另一台电脑 (相当于局域网) 时发现,仍然会出现直连时不会出现的卡顿,尽管似乎比上个版本已经好些了。

@semigodking
Copy link
Owner Author

@semigodking semigodking commented on d950079 Dec 29, 2014 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.