Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Socks4 support, pls #356

Open
wants to merge 153 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
153 commits
Select commit Hold shift + click to select a range
87baf3f
Update README.md
j67678 Oct 5, 2014
9815078
Delete README-en.md
j67678 Oct 5, 2014
f0bb8d0
Update README.md
j67678 Oct 5, 2014
0a1627e
Update README.md
j67678 Oct 5, 2014
df4b426
rename cow to meow
Oct 5, 2014
dbdd3f1
ignore stat.txt.bak
Oct 5, 2014
a127f8a
fix readme
Oct 5, 2014
7442a53
add direct site
Oct 6, 2014
5eaa82b
now is MEOW
Oct 12, 2014
0f0bde1
now with README
Oct 12, 2014
f24a9d9
readme
Oct 12, 2014
85f8c77
fix pac & log
Oct 12, 2014
aa3e895
add my site
Oct 12, 2014
66bddd9
remove amazonaws.com
Oct 12, 2014
7de5feb
readme
Oct 12, 2014
77b8603
fix client connect method
Oct 12, 2014
bb82e89
add kardianos/service
Oct 12, 2014
6406b68
remove service: failed to implement
Oct 12, 2014
3f5959e
no retry
Oct 12, 2014
96d639b
with icon & now beta
Oct 12, 2014
fd72d41
update direct list
Oct 12, 2014
ade5681
readme
Oct 13, 2014
223b92b
rename install-meow.sh
Oct 13, 2014
38a59d9
remove unused methods
Oct 13, 2014
fd3f626
fix tests & png icon
Oct 14, 2014
18d9b88
fix test
Oct 14, 2014
6dc55b4
update CHANGELOG
Oct 14, 2014
64cb738
readme
Oct 14, 2014
4bba66f
remove useless functions
Oct 14, 2014
a1b265e
fix test
Oct 14, 2014
9a313da
fix test.sh
Oct 14, 2014
a1c382c
optimize output
Oct 14, 2014
0d7d463
change test.sh
Oct 14, 2014
3ff039b
update README
Oct 14, 2014
94d0bbb
minor change
Oct 14, 2014
d3d7f0a
remove co.uk in direct list
Oct 17, 2014
080a00b
remove timeout
Oct 18, 2014
6a487f1
only `ipShouldDirect` to implement
Oct 18, 2014
ceb235e
remove useless functions in pac.go
Oct 18, 2014
dbc8e38
readme
Oct 18, 2014
2ddeb36
readme
Oct 18, 2014
8ab772f
update scripts & finish build.sh
Oct 18, 2014
ab60c50
finish install.sh
Oct 18, 2014
1f6eb66
linux & os x release
Oct 18, 2014
3eb6faf
rename win builds
Oct 18, 2014
9e4fb0c
readme
Oct 19, 2014
259aa25
update build script
Oct 19, 2014
4e339fa
readme
Oct 19, 2014
3d20415
remove .jp domains in direct list
Oct 19, 2014
8d5adf2
validate direct sites
Oct 21, 2014
ea4fe97
Update install.sh
j67678 Oct 22, 2014
4bd7be3
remove detectSSL
Feb 24, 2015
a3717d2
correctly close client conn
Feb 25, 2015
22e82c2
version 1.1
Feb 25, 2015
1380a01
remove config entry for detectSSL
Feb 25, 2015
319e6e8
new taskbar wrapper
Mar 11, 2015
94c926e
add locks to directlist
Apr 30, 2015
c46ad58
1.2
Apr 30, 2015
38018d7
check private ip for unknown host
Apr 30, 2015
23e540c
recover from panic when judging ip
May 3, 2015
1e11b11
if trying to get http://0.0.0.0/
May 3, 2015
689402e
update error message
May 3, 2015
8b4ca6e
print lookup host ip error
May 5, 2015
d8a4984
Fix #292: return direct for *.local host in PAC.
cyfdecyf Apr 12, 2015
cdec2e6
fix typo
May 9, 2015
4d9d320
changelog
May 13, 2015
193a758
Fix #302: use crc32 to hash hostname
cyfdecyf May 11, 2015
7e4ca1e
Use Go 1.4.2 on travis.
cyfdecyf May 12, 2015
7166541
Add new encryption in sample rc.
cyfdecyf May 12, 2015
d2bd315
changelog
May 13, 2015
6bd0508
specify at least one parent proxy
Jul 15, 2015
1c16a88
load domain list using proxy
Jul 15, 2015
5628685
1.3
Jul 15, 2015
6a0c490
Update README.md
Jul 15, 2015
f331344
add support for change stat file position in config
fzerorubigd May 31, 2015
8714e57
Implement #328, allow specifying stat/blocked etc. in config file.
cyfdecyf Jun 2, 2015
68d3af9
Setup all logger before calling initLog().
cyfdecyf Jun 2, 2015
50278fd
Remove unused function copyNWithBuf.
cyfdecyf Jun 2, 2015
346a9d0
Find default rc file in parseCmdLineConifg.
cyfdecyf Jun 2, 2015
aec1185
Fix typo.
cyfdecyf Jun 3, 2015
237b8a9
fixes & CHANGELOG
Jul 15, 2015
cb857b5
add google hk and jp in proxy domain list
Jul 15, 2015
1dd106c
Update README.md
Jul 15, 2015
54b6717
update direct & proxy list
Jul 16, 2015
6e1f031
Update README.md
Jul 16, 2015
f0d75d8
clean .cn sites
Jul 16, 2015
79ca937
Update README.md
Jul 16, 2015
2cbabe3
Update README.md
Jul 16, 2015
3746459
Update net.ohrz.meow.plist
Jul 17, 2015
254a6ee
README: compile using Go 1.5
Aug 20, 2015
312dbba
remove tunnel allowed port function
Aug 23, 2015
b9aaa3b
use go 1.5 for travis
Aug 23, 2015
4667452
1.3.1
Aug 23, 2015
05695c1
Update README.md
Aug 23, 2015
f9a69f1
Update README.md
Aug 23, 2015
6a210fa
Update README.md
Aug 23, 2015
a5b49b6
no meowproxy.me
Oct 9, 2015
e54ef5d
1.3.2
Oct 9, 2015
97d2492
download link
Oct 11, 2015
117604e
Update install.sh
j67678 Nov 4, 2015
295bf47
add reject list
wjchen Oct 27, 2015
af19d0d
add more sites
j67678 Nov 20, 2015
62a1417
remove estimateTimeout
j67678 Nov 20, 2015
56af310
add local https proxy support
j67678 Nov 20, 2015
7eed10b
add support for remote https proxy
j67678 Nov 20, 2015
20d7bf9
fix reject when no parent server
j67678 Nov 20, 2015
5ceb7d8
fix pac
j67678 Nov 20, 2015
b732527
refact code and fix tests
j67678 Nov 20, 2015
5825bea
Performance improvement for cn ip search.
j67678 Nov 20, 2015
60a7087
use 1.5.1 for travis ci
j67678 Nov 20, 2015
91b7a96
fix listen meow
j67678 Nov 20, 2015
4124893
exit on error for build.sh
Nov 22, 2015
06d8f69
1.3.3
Nov 22, 2015
85fdd72
add reject file
Nov 22, 2015
dcd23b5
update docs
Nov 22, 2015
1eed558
update README
Nov 22, 2015
019e689
Update README.md
iyee Nov 22, 2015
4ec1f48
Merge pull request #28 from iyee/patch-1
j67678 Nov 23, 2015
535a8a8
Add Linux style service script :/etc/init.d/meow
soimy Nov 23, 2015
4edca0e
Merge pull request #30 from soimy/master
j67678 Nov 30, 2015
e49ac32
Update meow
j67678 Nov 30, 2015
b307652
fix isErrConnReset & isErrTooManyOpenFd
j67678 Dec 3, 2015
7a469f3
fix client connection manage bug (again) (shame)
j67678 Dec 3, 2015
e879993
1.3.4
Dec 3, 2015
5a08dd3
fix variable scope
Dec 3, 2015
c1aaaf3
Update README.md
j67678 Dec 3, 2015
3aa2d8a
Update README.md
j67678 Dec 3, 2015
a1ac489
Update README.md
j67678 Dec 3, 2015
05ddd24
Update README.md
j67678 Feb 18, 2016
55e0875
1.3.5
j67678 Jun 13, 2016
a4e59ee
update script
j67678 Jun 13, 2016
7ede13c
add script
j67678 Jun 13, 2016
dc168cb
update README
j67678 Jun 13, 2016
3d41875
modify config.go
messyidea Jul 21, 2016
6da3449
Merge pull request #64 from messyidea/master
j67678 Jul 22, 2016
e6c2c6c
add git user info
j67678 Jul 22, 2016
f03c2c7
syscall.WSAECONNRESET
j67678 Aug 25, 2016
f11de91
update travis ci
j67678 Aug 25, 2016
222a462
fix
j67678 Aug 25, 2016
a585ba7
go version
j67678 Aug 25, 2016
a480417
upate chinaip; chinaip gen script
j67678 Sep 29, 2016
c14122b
1.5
j67678 Sep 29, 2016
b8d58c0
add CHANGLOG.md
j67678 Sep 29, 2016
a1c1c20
fix build script
j67678 Sep 29, 2016
7c24109
Update rc-full
j67678 Nov 15, 2016
8a4b489
Update rc
j67678 Nov 15, 2016
5141ad3
Update rc
j67678 Nov 15, 2016
23c6afc
Update direct
j67678 Feb 25, 2017
aebeb9b
Update README.md
j67678 Feb 28, 2017
00310d1
Update README.md
j67678 Feb 28, 2017
5d5e363
Update README.md
j67678 Feb 28, 2017
0d70a72
Update README.md
j67678 Mar 17, 2017
cc6df42
Update README.md
j67678 Mar 18, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Update README.md
j67678 committed Oct 5, 2014
commit 87baf3ffbdf6a9435b6c746b9921a986a27ece18
138 changes: 2 additions & 136 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,137 +1,3 @@
# COW (Climb Over the Wall) proxy
# MEOW proxy

COW 是一个简化穿墙的 HTTP 代理服务器。它能自动检测被墙网站,仅对这些网站使用二级代理。

[English README](README-en.md).

当前版本:0.9.3 [CHANGELOG](CHANGELOG)
[![Build Status](https://travis-ci.org/cyfdecyf/cow.png?branch=master)](https://travis-ci.org/cyfdecyf/cow)

**欢迎在 develop branch 进行开发并发送 pull request :)**

## 功能

COW 的设计目标是自动化,理想情况下用户无需关心哪些网站无法访问,可直连网站也不会因为使用二级代理而降低访问速度。

- 作为 HTTP 代理,可提供给移动设备使用;若部署在国内服务器上,可作为 APN 代理
- 支持 HTTP, SOCKS5, [shadowsocks](https://github.com/clowwindy/shadowsocks/wiki/Shadowsocks-%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E) 和 cow 自身作为二级代理
- 可使用多个二级代理,支持简单的负载均衡
- 自动检测网站是否被墙,仅对被墙网站使用二级代理
- 自动生成包含直连网站的 PAC,访问这些网站时可绕过 COW
- 内置[常见可直连网站](site_direct.go),如国内社交、视频、银行、电商等网站(可手工添加)

# 快速开始

安装:

- **OS X, Linux (x86, ARM):** 执行以下命令(也可用于更新)

curl -L git.io/cow | bash

- 环境变量 `COW_INSTALLDIR` 可以指定安装的路径,若该环境变量不是目录则询问用户
- **Windows:** [点此下载](http://dl.chenyufei.info/cow/)
- 熟悉 Go 的用户可用 `go get github.com/cyfdecyf/cow` 从源码安装

编辑 `~/.cow/rc` (Linux) 或 `rc.txt` (Windows),简单的配置例子如下:

#开头的行是注释,会被忽略
# 本地 HTTP 代理地址
# 配置 HTTP 和 HTTPS 代理时请填入该地址
# 或者在自动代理配置中填入 http://127.0.0.1:7777/pac
listen = http://127.0.0.1:7777

# SOCKS5 二级代理
proxy = socks5://127.0.0.1:1080
# HTTP 二级代理
proxy = http://127.0.0.1:8080
proxy = http://user:[email protected]:8080
# shadowsocks 二级代理
proxy = ss://aes-128-cfb:[email protected]:8388
# cow 二级代理
proxy = cow://aes-128-cfb:[email protected]:8388

使用 cow 协议的二级代理需要在国外服务器上安装 COW,并使用如下配置:

listen = cow://aes-128-cfb:[email protected]:8388

完成配置后启动 COW 并配置好代理即可使用。

# 详细使用说明

配置文件在 Unix 系统上为 `~/.cow/rc`,Windows 上为 COW 所在目录的 `rc.txt` 文件。 **[样例配置](doc/sample-config/rc) 包含了所有选项以及详细的说明**,建议下载然后修改。

启动 COW:

- Unix 系统在命令行上执行 `cow &` (若 COW 不在 `PATH` 所在目录,请执行 `./cow &`)
- [Linux 启动脚本](doc/init.d/cow),如何使用请参考注释(Debian 测试通过,其他 Linux 发行版应该也可使用)
- Windows
- 双击 `cow-taskbar.exe`,隐藏到托盘执行
- 双击 `cow-hide.exe`,隐藏为后台程序执行
- 以上两者都会启动 `cow.exe`

PAC url 为 `http://<listen address>/pac`,也可将浏览器的 HTTP/HTTPS 代理设置为 `listen address` 使所有网站都通过 COW 访问。

**使用 PAC 可获得更好的性能,但若 PAC 中某网站从直连变成被封,浏览器会依然尝试直连。遇到这种情况可以暂时不使用 PAC 而总是走 HTTP 代理,让 COW 学习到新的被封网站。**

命令行选项可以覆盖部分配置文件中的选项、打开 debug/request/reply 日志,执行 `cow -h` 来获取更多信息。

## 手动指定被墙和直连网站

**一般情况下无需手工指定被墙和直连网站,该功能只是是为了处理特殊情况和性能优化。**

`~/.cow/blocked` 和 `~/.cow/direct` 可指定被墙和直连网站(`direct` 中的 host 会添加到 PAC):

- 每行一个域名或者主机名(COW 会先检查主机名是否在列表中,再检查域名)
- 二级域名如 `google.com` 相当于 `*.google.com`
- `com.hk`, `edu.cn` 等二级域名下的三级域名,作为二级域名处理。如 `google.com.hk` 相当于 `*.google.com.hk`
- 其他三级及以上域名/主机名做精确匹配,例如 `plus.google.com`

# 技术细节

## 访问网站记录

COW 在 `~/.cow/stat` json 文件中记录经常访问网站被墙和直连访问的次数。

- **对未知网站,先尝试直接连接,失败后使用二级代理重试请求,2 分钟后再尝试直接**
- 内置[常见被墙网站](site_blocked.go),减少检测被墙所需时间(可手工添加)
- 直连访问成功一定次数后相应的 host 会添加到 PAC
- host 被墙一定次数后会直接用二级代理访问
- 为避免误判,会以一定概率再次尝试直连访问
- host 若一段时间没有访问会自动被删除(避免 `stat` 文件无限增长)
- 内置网站列表和用户指定的网站不会出现在统计文件中

## COW 如何检测被墙网站

COW 将以下错误认为是墙在作怪:

- 服务器连接被重置 (connection reset)
- 创建连接超时
- 服务器读操作超时

无论是普通的 HTTP GET 等请求还是 CONNECT 请求,失败后 COW 都会自动重试请求。(如果已经有内容发送回 client 则不会重试而是直接断开连接。)

用连接被重置来判断被墙通常来说比较可靠,超时则不可靠。COW 每隔半分钟会尝试估算合适的超时间隔,避免在网络连接差的情况下把直连网站由于超时也当成被墙。
COW 默认配置下检测到被墙后,过两分钟再次尝试直连也是为了避免误判。

如果超时自动重试给你造成了问题,请参考[样例配置](doc/sample-config/rc)高级选项中的 `readTimeout`, `dialTimeout` 选项。

## 限制

- 不提供 cache
- 不支持 HTTP pipeline(Chrome, Firefox 默认都没开启 pipeline,支持这个功能容易增加问题而好处并不明显)

# 致谢

贡献代码:

- @tevino: http parent proxy basic authentication
- @xupefei: 提供 cow-hide.exe 以在 windows 上在后台执行 cow.exe
- @sunteya: 改进启动和安装脚本
- @fzerorubigd: identify blocked site by HTTP error code

Bug reporter:

- GitHub users: glacjay, trawor, Blaskyy, lucifer9, zellux, xream, hieixu, fantasticfears, perrywky, JayXon, graminc, WingGao, polong, dallascao, luosheng
- Twitter users: 特别感谢 @shao222 多次帮助测试新版并报告了不少 bug, @xixitalk

@glacjay 对 0.3 版本的 COW 提出了让它更加自动化的建议,使我重新考虑 COW 的设计目标并且改进成 0.5 版本之后的工作方式。
MEOW is a fork of [COW](https://github.com/cyfdecyf/cow).