Blog Archives

Mar 03

ProxyChain

这几个工具都支持带用户名密码认证的上级代理,代理可以是 socks4/5,http-connect 等,glider 和 gost 还额外支持 ss,ssr 作为上级代理,但是对用户名密码或者附加参数中带‘@’号处理有些问题。

还需要注意,代理链中的第二级代理(最后一级?),‘必须’要具有外网 IP ,不然很容易失败。(这也是为什么要求支持用户名密码认证)

范例:
本地代理监听 0.0.0.0:7777 端口,上级两个代理级联(代理链),第一代理为: 192.168.2.20:7575 ,第二代理为:1.1.1.1:10086 (用户名 user , 密码 passwd)

gost:(https://github.com/ginuerzh/gost)

gost -L=:7777 -F=socks5://192.168.2.20:7575 -F=socks5://user:passwd@1.1.1.1:10086 -D

glider: (https://github.com/nadoo/glider)

glider -listen 0.0.0.0:7777 -forward socks5://192.168.2.20:7575,socks5://user:passwd@1.1.1.1:10086 -verbose

proxychains+microsocks (https://github.com/rofl0r/proxychains-ng, https://github.com/rofl0r/microsocks)

proxychains 配置文件:
strict_chain
proxy_dns
remote_dns_subnet 224
tcp_read_time_out 15000
tcp_connect_time_out 8000
[ProxyList]
socks5 192.168.2.20 7575
socks5 1.1.1.1 10086 user passwd

命令行:
proxychains4 microsocks -p 7777

访问流程:
客户端请求-->SOCKS5:7777-->SOCKS5:192.168.2.20:7575-->SOCKS5:1.1.1.1:10086-->远程服务

gost 启动很慢,内存占用极高,glider 比较均衡,这两个都是 golang 编写的;proxychains+microsocks 是 C 写的,占用最小,适合配置不高的设备,但是需要自己编译,配置稍显麻烦。


May 04

CoreDNS 1.5 彻底废除了 Proxy 插件,用 Forward 插件替代,但想不到怎么写才能实现分流,它不允许一个服务器块中用两次 forward。

只好重新把 Proxy 插件编译进去,添加原 coredns/proxy 插件,编译会出错:

proxy.go:107:22: state.ErrorMessage undefined (type request.Request has no field or method ErrorMessage)

暴力修改过的版本,可以编译通过并且可用:https://github.com/rampageX/proxy

编译方法:

按照官方的方法,git clone 下来后,修改 plugin.cfg ,添加一句:

proxy:github.com/rampageX/proxy

然后 make 即可。

root@phicomm-n1:/devel/src/coredns# ./coredns -plugins
Server types:
dns

Caddyfile loaders:
flag
default

Other plugins:
dns.alternate
dns.any
dns.auto
dns.autopath
dns.bind
dns.cache
dns.cancel
dns.chaos
dns.debug
dns.dnssec
dns.dnstap
dns.erratic
dns.errors
dns.etcd
dns.federation
dns.file
dns.forward
dns.grpc
dns.health
dns.hosts
dns.k8s_external
dns.kubernetes
dns.loadbalance
dns.log
dns.loop
dns.metadata
dns.nsid
dns.pprof
dns.prometheus
dns.proxy
dns.ready
dns.reload
dns.rewrite
dns.root
dns.route53
dns.secondary
dns.template
dns.tls
dns.trace
dns.whoami
on

:mrgreen: :mrgreen: :mrgreen:


Mar 28

Specify a web root for the WebUi

redir /syncthing /syncthing/ 302
proxy /syncthing http://syncthing:8384/ {
transparent
without /syncthing
}

:mrgreen: :mrgreen: :mrgreen:


Dec 03

项目地址:
https://github.com/aarond10/https_dns_proxy

特色功能:
自从 Google 发布 DNS-Over-HTTPS 服务以来,其实有很多基于此服务写的程序,但是目前看起来这个项目实现的比较好:
C++ 实现,执行文件很小 (30kiB,静态编译的版本约为 900k),比大多数用 Go 写的小得多
基于 Curl HTTP/2 API , 解析延迟极小
单线程无阻塞式查询,适用于嵌入式系统如路由器等
最好作为 DNSMASQ 这样带缓存的 DNS 服务器上游.
由于 Google 这个服务支持 EDNS SUBNET 的查询,所以理论上通过这个服务器查询的结果不会有 CDN 的问题,当然实际还需时间来证明。

Usage: https_dns_proxy [-a ] [-p ]
[-e ] [-d] [-u ] [-g ] [-b ]
[-l ]
-a listen_addr 监听地址. (127.0.0.1)
-p listen_port 监听端口. (5053)
-e subnet_addr edns-client-subnet edns 子网 “203.31.0.0/16”. 建议通过路由器外网地址来计算()
-d 后台运行.
-u user 用户名. (nobody)
-g group 用户组. (nobody)
-b dns_servers 用来解析 dns.google.com 的域名服务器. (8.8.8.8,8.8.4.4)
-t proxy_server 代理服务器,例如: socks5://127.0.0.1:1080,http://127.0.0.1:8080 (注意上面 dns.google.com 的解析不通过此代理!)
-l logfile 日志文件. (-)
-v 开启调试信息. (INFO)

上面的 subnet_addr 可以通过一些命令行获取,例如:

$(nvram get wan_ipaddr | cut -d "." -f 1-2).0.0/16

如果是内网,则应该用:

curl -sS ifconfig.co | cut -d "." -f 1-2
或者
wget http://ipecho.net/plain -O - -q | cut -d "." -f 1-2

这个在 Tomatoware 上静态编译稍微有点麻烦:

1. 首先要编译 curl (及其库)支持 http2,这样用到 nghttp2:

git clone https://github.com/tatsuhiro-t/nghttp2.git
cd nghttp2
autoreconf -i
automake
autoconf
./configure --prefix=/mmc
make
make install

2. 编译 curl :

#!/bin/sh

[ ! -e ./curl.pem ] && wget -qO curl.pem https://curl.haxx.se/ca/cacert.pem

[ -n "$1" ] && ssVersion=$1 || ssVersion="git"

mkdir -p done/${ssVersion}/OpenSSL-opt

echo "Compiling OpenSSL Version..."
make clean
[ ! -e  /opt/sbin/curl.pem ] && cp ./curl.pem /opt/sbin/
./configure --prefix=/mmc --with-ca-bundle=/opt/sbin/curl.pem --with-nghttp2 
--disable-ldap
make -j2 LDFLAGS="-all-static -s" LIBS="-ldl"
[ $? -eq 0 ] || { echo "Compiling OpenSSL failed."; exit 1; }
make install
mv -f src/curl done/${ssVersion}/OpenSSL-opt/

echo -e "Compile Result:n"

file done/${ssVersion}/OpenSSL-opt/curl

echo ""

done/${ssVersion}/OpenSSL-opt/curl -V

3. 静态编译 https_dns_proxy,修改过的 CMakeList.txt:

project(HttpsDnsProxy)
cmake_minimum_required(VERSION 2.8)

#set(CMAKE_BUILD_TYPE "Debug")
set(CMAKE_BUILD_TYPE "Release")

# set(CMAKE_C_FLAGS "-Wall --pedantic -Wno-strict-aliasing")

set(NXJSON_DIR lib/nxjson/)
set(NXJSON_SRC ${NXJSON_DIR}/nxjson.c)

find_path(LIBCARES_INCLUDE_DIR ares.h)
find_path(LIBCURL_INCLUDE_DIR curl/curl.h)
find_path(LIBEV_INCLUDE_DIR ev.h)
include_directories(
${LIBCARES_INCLUDE_DIR} ${LIBCURL_INCLUDE_DIR}
${LIBEV_INCLUDE_DIR} ${NXJSON_DIR} src)

# The main binary
set(TARGET_NAME "https_dns_proxy")
aux_source_directory(src SRC_LIST)
set(SRC_LIST ${SRC_LIST} ${NXJSON_SRC})
add_executable(${TARGET_NAME} ${SRC_LIST})
#set(LIBS ${LIBS} cares curl ev resolv ssl crypto dl z m)
set(LIBS ${LIBS} cares curl ev resolv ssh2 ssl psl crypto dl z m nghttp2)
target_link_libraries(${TARGET_NAME} ${LIBS})

# Link to static libraries if needed
IF(STATIC_LIB)
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s -static")
ENDIF(STATIC_LIB)

install(CODE "MESSAGE(\"Please install manually for now.\")")

然后:

mkdir b
cd b
cmake -DSTATIC_LIB=ON ..
make

file ./https_dns_proxy
./https_dns_proxy: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, stripped


Jun 28

GAppProxy

Internet | 7 评论 » | Trackback | FavLinks | 5,883 次阅读

请先留意这里
GAppProxy设计的初衷是为教育网用户提供一个免费的国际代理,请各位朋友不要宣传其他用途,我想各位和我一样都不愿意看到Google App Engine这个平台被封禁. 如果您觉得GAppProxy还不错,请尽可能的自己做fetch服务. 谢谢支持!

什么是GAppProxy?
一个开源的HTTP Proxy软件. 使用Python编写,运行于Google App Engine上.

GAppProxy的优势:
是一个完整的Proxy解决方案: 与常见的HTTP Proxy不同,GAppProxy运行在Google App Engine上,不需要专门的服务器,这是最大优势. 个人的Proxy: 自己管理,自己使用,当然,也可共享:) 依托于Google App Engine: Google的网络比较可靠.

GAppProxy的劣势:
仅支持标准80端口的HTTP协议,443端口的HTTPS协议正在实现中,其他端口均不支持. 需要安装客户端. GAppProxy的设想用户:
教育网用户(不能直接访问国外网络者). 其他需代理的用户.

GAppProxy目前的状态:
HTTP Proxy功能已经可用,当然也需要进一步测试. HTTPS Proxy功能正在实现中. 管理/认证等功能尚无. 希望有对此软件感兴趣者加入,贡献力量.

项目网站,http://gappproxy.googlecode.com

GAppProxy将要做的:
完善Proxy的细节功能,提高用户体验. 用wx做一个客户端的图形界面,取代目前的命令行窗口运行模式,方便windows用户使用. 写一份详细的使用手册.

如何安装使用:

普通Windows用户:
下载proxy.zip,解压,双击运行dist目录下的proxy.exe. 配置浏览器,设置HTTP代理为127.0.0.1:8000. 注意: 该版本目前尚不支持HTTPS.

有Python 2.5以上版本解释器的Windows/Linux用户:
下载proxy.py,双击运行,默认监听地址为127.0.0.1:8000 配置浏览器,设置HTTP代理为127.0.0.1:8000.

拥有Google App帐号并且希望自己搭Proxy服务的用户:
从项目svn处下载fetch.py,修改app.yaml,然后将其上传到自己的Google App目录下. 修改proxy.py,使其指向自己的Google App站点. 其他与前两种用户相同.

其他
每个客户端(proxy.py/proxy.exe)我都会在Windows+IE/Firefox和Linux+Firefox下测试正常后再提交. GAppProxy使用Google Code提供的svn管理代码,这个很有用,而且基本的用法也很容易掌握,建议还不了解的用户试试.

Tor 快得多哦。

2008 年 8 月 18 日更新:

主页更新了 r19 的 Windows 版本,支持本地代理,支持多 Fetch 做负载均衡,通过 Proxy.conf 文件设置多个 Fetch Server 。

但是这个版本的 install.bat 有点问题,安装后服务不能正常启动,表现为 srvany.exe 不能 加载 proxy.exe。查了一下应该是 proxy.exe 找不到 proxy.conf 的原因,在 install.bat 中加了一句为服务添加工作目录就可以了。

@echo reg add HKLM\SYSTEM\CurrentControlSet\Services\GAppProxy\Parameters /v AppDirectory /d %cd% >> Register_As_Server.bat


[2/4]  < 1 2 3 4 >