shadowtunnel v1.2 釋出,新增 DNS 代理和負載均衡高可用
shadowtunnel v1.2釋出啦!shadowtunnel 是一款可以在你本地機器和遠端服務之間建立安全的加密隧道,保護你的 tcp 流量,能高效壓縮傳輸,流量無特徵。
local machine <----> shadowtunnel <---> service on remote.
另外可靠訊息,shadowtunnel的openwrt版本luci-app-shadowtunnel.ipx即將問世,支援一鍵透明代理,讓所有連結到你的路由裝置自動走shadowtunnel隧道,歡迎關注shadowtunnel,獲取最新動態.
更新內容:
-
新增了-daemon引數,後臺執行功能.
-
新增了-forever引數,永久執行功能,異常退出會自己重啟.
-
新增了-log引數,設定日誌輸出到檔案.
-
新增了-profiling引數,除錯分析功能,用於遇到效能問題的時候可以獲取除錯資訊用於解決問題.
-
新增了-nolog引數,禁用日誌輸出功能,可以節省CPU.
-
新增了DNS代理功能,提供安全的DNS解析,詳細資訊參考手冊DNS部分.
-
新增了負載均衡高可用功能,詳細情況檢視命令幫助-lb開頭引數.
使用
Usage of ./shadowtunnel: -Eoutbound connection is encrypted -Uoutbound connection is udp -ccompress traffic -cache string dns query cache file path (default "cache.dat") -daemon daemon mode -debug show debug info -dns string local dns server listen on address -dns-proxy is dns endpoint or not -dns-server string remote dns server to resolve domain (default "8.8.8.8:53") -einbound connection is encrypted -f weight forward address,such as : 127.0.0.1:8080 or with @weight: 127.0.0.1:8080@1 -forever forever mode -l string local listen address, such as : 0.0.0.0:33000 (default ":50000") -lb-activeafter int host going actived after this success count (default 1) -lb-hashtarget hash use target address to choose parent for LB, only worked for LB's hash method and using `-redir` (default true) -lb-inactiveafter int host going inactived after this fail count (default 2) -lb-method string load balance method when use multiple parent,can be <roundrobin|leastconn|leasttime|hash|weight> (default "leasttime") -lb-onlyha high availability mode use only high availability mode to choose parent for LB -lb-retrytime int sleep time milliseconds after checking (default 2000) -lb-timeout int tcp milliseconds timeout of connecting to parent (default 3000) -log string logging output to file -m string method of encrypt/decrypt, these below are supported : aes-128-cfb,aes-192-cfb,des-cfb,cast5-cfb,rc4-md5,chacha20,aes-256-cfb, aes-128-ctr,aes-192-ctr,aes-256-ctr,bf-cfb,rc4-md5-6,chacha20-ietf (default "aes-192-cfb") -nolog turn off logging -p string password of encrypt/decrypt (default "shadowtunnel") -profiling profiling mode, in this mode, you should stopping process by : Ctrl+C or 'kill -s SIGHUP $PID_OF_shadowtunnel' -redir read target from socket's redirect opts of iptables -t int connection timeout seconds (default 3) -ttl int cache seconds of dns query , if zero , default ttl used. (default 300) -uinbound connection is udp -vshow version
示例
1.http 代理
假設有一個 vps,它的 IP 是 2.2.2.2
首先在 2.2.2.2 啟動一個 http 代理 然後下載 http 代理程式,使用 root 許可權在 vps 上執行下面的命令:
wgetofollow,noindex" target="_blank">https://github.com/snail007/goproxy/releases/download/v4.9/proxy-linux-amd64.tar.gz && tar zxfv proxy-linux-amd64.tar.gz && rm proxy-linux-amd64.tar.gz && mv proxy /usr/bin/ && proxy http -p 127.0.0.1:38080 &
2.在 vps 啟動一個隧道
下載 shadowtunnel 程式,使用 root 許可權在 vps 上執行下面的命令:
wgethttps://github.com/snail007/shadowtunnel/releases/download/v1.1/shadowtunnel-linux-amd64.tar.gz && tar zxfv shadowtunnel-linux-amd64.tar.gz && rm shadowtunnel-linux-amd64.tar.gz && mv shadowtunnel /usr/bin/
在 vps 上監聽 :50000 並轉發到 127.0.0.1:38080 :
shadowtunnel -e -f 127.0.0.1:38080 -l :50000
3.在本地機器上啟動一個隧道
在本地機器上監聽 :50000 並轉發到 2.2.2.2:50000 :
shadowtunnel -E -f 2.2.2.2:50000 -l :50000
4.在 chrome 中設定 http 代理配置
設定本地 chrome 的http代理配置如下:
ip: 127.0.0.1 port: 50000
5.完成
TCP over UDP
1.http 代理
假設有一個 vps,它的 IP 是 2.2.2.2
首先在 2.2.2.2 啟動一個 http 代理 然後下載 http 代理程式,使用 root 許可權在 vps 上執行下面的命令:
wget https://github.com/snail007/goproxy/releases/download/v4.9/proxy-linux-amd64.tar.gz && tar zxfv proxy-linux-amd64.tar.gz && rm proxy-linux-amd64.tar.gz && mv proxy /usr/bin/ && proxy http -p 127.0.0.1:38080 &
2.在 vps 啟動一個隧道
下載 shadowtunnel 程式,使用 root 許可權在 vps 上執行下面的命令:
wget https://github.com/snail007/shadowtunnel/releases/download/v1.1/shadowtunnel-linux-amd64.tar.gz && tar zxfv shadowtunnel-linux-amd64.tar.gz && rm shadowtunnel-linux-amd64.tar.gz && mv shadowtunnel /usr/bin/
在 vps 上監聽UDP :50000 並轉發到TCP 127.0.0.1:38080 :
shadowtunnel -u -e -f 127.0.0.1:38080 -l :50000 -p your-password
3.在本地機器上啟動一個隧道
在本地機器上監聽TCP :50000 並轉發到UDP 2.2.2.2:50000 :
shadowtunnel -U -E -f 2.2.2.2:50000 -l :50000 -p your-password
4.在 chrome 中設定 http 代理配置
設定本地 chrome 的http代理配置如下:
ip: 127.0.0.1 port: 50000
5.完成
Deamon & Forever & Log
-daemon:
使用引數-daemon可以讓shadowtunnel脫離當前命令列,後臺執行.
-forever:
使用引數-forever可以讓shadowtunnel以建立並監控子程序的方式執行,
如果發生異常退出,會重啟子程序,保證服務永遠線上.
-log
使用引數-log可以設定日誌輸出到檔案,而不是在命令列輸出.
-nolog
使用引數-nolog可以從徹底關閉日誌輸出,節省CPU佔用.
一般是-daemon -forever -log /tmp/st.log 三個引數聯合使用,這樣出問題時,也可以通過看日誌發現問題原因.
例項:
shadowtunnel -u -e -f 127.0.0.1:38080 -l :50000 -p your-password -daemon -forever -log /tmp/st.log
DNS服務
shadowtunnel可以在提供本地DNS查詢服務,同時具有快取功能,可以提高解析速度.
在本地啟動埠轉發的同時啟動一個DNS服務,需要有上級配合.
-dns 引數可以設定本地DNS服務監聽的IP和埠,比如:0.0.0.0:5353
-dns-server 引數可以設定最終用來解析域名的DNS伺服器,要求是伺服器必須支援TCP方式的DNS查詢,預設是:8.8.8.8:53.
本地例項:
shadowtunnel -E -f 2.2.2.2:50000 -l :50000 -p your-password -dns :5353 -dns-server 8.8.8.8:53
上級例項:
如果上級是鏈式,那麼鏈條中需要執行DNS代理的上級需要加上-dns-proxy引數.
shadowtunnel -e -f 127.0.0.1:38080 -l :50000 -p your-password -dns-proxy
DNS快取
-ttl 引數可以設定DNS查詢結果快取時間,單位秒,如果是0,使用查詢結果的ttl.
-cache 引數設定DNS快取檔案位置,防止程式重啟快取消失,降低效能.
負載均衡
支援上級負載均衡,多個上級重複-f引數即可.
shadowtunnel -E -f 2.2.2.2:50000 -f 3.3.3.3:50000 -l :50000
設定重試間隔和超時時間
shadowtunnel -E -f 2.2.2.2:50000 -f 3.3.3.3:50000 -l :50000 -lb-method leastconn -lb-retrytime 300 -lb-timeout 300
設定權重
shadowtunnel -E -f 2.2.2.2:50000@2 -f 3.3.3.3:50000@1 -l :50000 -lb-method weight -lb-retrytime 300 -lb-timeout 300
使用目標地址選擇上級
shadowtunnel -E -f 2.2.2.2:50000@2 -f 3.3.3.3:50000@1 -l :50000 -lb-method hash -lb-hashtarget -lb-retrytime 300 -lb-timeout 300
下載地址: