Skip to content

Commit

Permalink
fix #224 #237 #239
Browse files Browse the repository at this point in the history
  • Loading branch information
zfl9 committed Jun 6, 2023
1 parent e861f95 commit 844b25c
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
3 changes: 3 additions & 0 deletions gfwlist.ext
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@
# Telegram IPv6
~2001:67c:4e8::/48
~2001:0b28:f23d::/48

# Google Play 问题
@googleapis.cn
56 changes: 56 additions & 0 deletions ss-tproxy
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,17 @@ is_proxy_other() {
is_false "$selfonly"
}

is_drop_quic() {
case "$ipts_drop_quic" in
tcponly)
! is_enabled_udp;;
always)
true;;
*)
false;;
esac
}

is_enabled_ipv4() {
is_true "$ipv4"
}
Expand Down Expand Up @@ -499,6 +510,7 @@ start_chinadns() {

if is_gfwlist_mode; then
sstp_pid_chinadns=$(
trap "" CHLD # 避免bash变为僵尸进程
chinadns-ng \
$args \
-g gfwlist.txt,<(list_ext_domain gfwlist.ext) \
Expand All @@ -509,6 +521,7 @@ start_chinadns() {
)
else # chnroute
sstp_pid_chinadns=$(
trap "" CHLD # 避免bash变为僵尸进程
chinadns-ng \
$args \
-g gfwlist.txt,<(list_ext_domain gfwlist.ext) \
Expand Down Expand Up @@ -801,6 +814,45 @@ create_sstp_rule() {
fi
}

# mangle表 OUTPUT/PREROUTING -p udp --dport 443
drop_quic() {
$1 -t mangle -N SSTP_QUIC

if is_global_mode; then
$1 -t mangle -A SSTP_QUIC \
-m set ! --match-set $white_setname dst \
-j DROP
elif is_gfwlist_mode; then
$1 -t mangle -A SSTP_QUIC \
-m set --match-set $black_setname dst \
-j DROP
elif is_chnroute_mode; then
# 放行白名单ip (若该ip同时也位于黑名单,则不放行)
$1 -t $table -A SSTP_QUIC \
-m set --match-set $white_setname dst \
-m set ! --match-set $black_setname dst \
-j RETURN
$1 -t $table -A SSTP_QUIC \
-j DROP
fi

$1 -t mangle -A SSTP_OUTPUT \
-p udp \
-m udp --dport 443 \
-m conntrack --ctdir ORIGINAL \
-m addrtype ! --dst-type LOCAL \
-m owner ! --gid-owner $proxy_procgroup \
-j SSTP_QUIC

is_proxy_other &&
$1 -t mangle -A SSTP_PREROUTING \
-p udp \
-m udp --dport 443 \
-m conntrack --ctdir ORIGINAL \
-m addrtype ! --dst-type LOCAL \
-j SSTP_QUIC
}

# mangle表 OUTPUT/PREROUTING
do_proxy_tproxy() {
local tcp=$(is_tcp_tproxy && echo 1 || echo 0)
Expand Down Expand Up @@ -964,6 +1016,10 @@ _start_iptables() {
local loopback_addr loopback_addrx white_setname black_setname
init_iptables_param $1

if is_drop_quic; then
drop_quic $1
fi

if is_tcp_tproxy; then
start_iptables_tproxy $1
else
Expand Down
1 change: 1 addition & 0 deletions ss-tproxy.conf
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ ipts_set_snat6='false' # 设置 ipv6 MASQUERADE(SNAT) 规则,self
ipts_reddns_onstop='223.5.5.5#53' # stop后重定向内网主机发来的dns至指定dns,selfonly=false 时有效,详见 README
ipts_reddns6_onstop='240C::6666#53' # stop后重定向内网主机发来的dns至指定dns,selfonly=false 时有效,详见 README
ipts_proxy_dst_port='' # 要代理哪些端口,留空表示全部,多个逗号隔开,冒号表示范围(含边界),详见 README
ipts_drop_quic='tcponly' # 丢弃发往"黑名单"的QUIC: 留空:不丢弃 | tcponly:tcponly时丢弃 | always:总是丢弃

## opts
opts_ss_netstat='auto' # auto/ss/netstat,用哪个端口检测工具: auto(自动选择,优先考虑ss) | ss | netstat
Expand Down

0 comments on commit 844b25c

Please sign in to comment.