Skip to content

Commit

Permalink
v1.2.8 Refine the Warp routing for chatGPT.
Browse files Browse the repository at this point in the history
  • Loading branch information
fscarmen committed Dec 13, 2024
1 parent 7620079 commit fd7ede0
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 21 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
* * *
## 1.更新信息

2024.12.10 v1.2.7 Thank you to the veteran player Fan Glider Fangliding for the technical guidance on Warp's routing! 感谢资深玩家 风扇滑翔翼 Fangliding 关于 Warp 的分流的技术指导

2024.12.10 v1.2.6 Compatible with Sing-box 1.11.0-beta.8+. Thanks to the PR from brother Maxrxf. I've already given up myself; 适配 Sing-box 1.11.0-beta.8+,感谢 Maxrxf 兄弟的 PR,我自己已经投降的了

2024.10.28 v1.2.6 1. Fixed the bug that clash subscription failed when [-n] re-fetches the subscription; 2. vmess + ws encryption changed from none to auto; 3. Replaced a CDN; 1. 修复 [-n] 重新获取订阅时,clash 订阅失效的bug; 2. vmess + ws 加密方式从none改为auto; 3. 更换了一个 CDN
Expand Down
29 changes: 22 additions & 7 deletions docker_init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ install() {
# 下载 sing-box
echo "正在下载 sing-box ..."
local ONLINE=$(check_latest_sing-box)
local ONLINE=${ONLINE:-'1.11.0-beta.8'}
local ONLINE=${ONLINE:-'1.11.0-beta.9'}
wget https://github.com/SagerNet/sing-box/releases/download/v$ONLINE/sing-box-$ONLINE-linux-$SING_BOX_ARCH.tar.gz -O- | tar xz -C ${WORK_DIR} sing-box-$ONLINE-linux-$SING_BOX_ARCH/sing-box && mv ${WORK_DIR}/sing-box-$ONLINE-linux-$SING_BOX_ARCH/sing-box ${WORK_DIR}/sing-box && rm -rf ${WORK_DIR}/sing-box-$ONLINE-linux-$SING_BOX_ARCH

# 下载 jq
Expand Down Expand Up @@ -69,7 +69,7 @@ install() {

# 检测是否解锁 chatGPT
local SUPPORT_COUNTRY='AD AE AF AG AL AM AO AR AT AU AZ BA BB BD BE BF BG BH BI BJ BN BO BR BS BT BW BZ CA CD CF CG CH CI CL CM CO CR CV CY CZ DE DJ DK DM DO DZ EC EE EG ER ES ET FI FJ FM FR GA GB GD GE GH GM GN GQ GR GT GW GY HN HR HT HU ID IE IL IN IQ IS IT JM JO JP KE KG KH KI KM KN KR KW KZ LA LB LC LI LK LR LS LT LU LV LY MA MC MD ME MG MH MK ML MM MN MR MT MU MV MW MX MY MZ NA NE NG NI NL NO NP NR NZ OM PA PE PG PH PK PL PS PT PW PY QA RO RS RW SA SB SC SD SE SG SI SK SL SM SN SO SR SS ST SV SZ TD TG TH TJ TL TM TN TO TR TT TV TW TZ UA UG US UY UZ VA VC VN VU WS YE ZA ZM ZW'
[[ "${SUPPORT_COUNTRY}" =~ $(wget -qO- --tries=3 --timeout=2 https://chat.openai.com/cdn-cgi/trace | awk -F '=' '/loc/{print $2}') ]] && { CHAT_GPT_OUT_V4=direct && CHAT_GPT_OUT_V6=direct; } || { CHAT_GPT_OUT_V4=warp-IPv4-out && CHAT_GPT_OUT_V6=warp-IPv6-out ; }
[[ "${SUPPORT_COUNTRY}" =~ $(wget -qO- --tries=3 --timeout=2 https://chat.openai.com/cdn-cgi/trace | awk -F '=' '/loc/{print $2}') ]] && CHATGPT_OUT=direct || CHATGPT_OUT=warp-ep

# 生成 log 配置
cat > ${WORK_DIR}/conf/00_log.json << EOF
Expand Down Expand Up @@ -103,7 +103,7 @@ EOF
"endpoints":[
{
"type":"wireguard",
"tag":"wireguard-ep",
"tag":"warp-ep",
"mtu":1280,
"address":[
"172.16.0.2/32",
Expand Down Expand Up @@ -148,12 +148,27 @@ EOF
"action": "sniff"
},
{
"domain":"api.openai.com",
"outbound":"${CHAT_GPT_OUT_V4}"
"action": "resolve",
"domain":[
"api.openai.com"
],
"strategy": "prefer_ipv4"
},
{
"action": "resolve",
"rule_set":[
"geosite-openai"
],
"strategy": "prefer_ipv6"
},
{
"rule_set":"geosite-openai",
"outbound":"${CHAT_GPT_OUT_V6}"
"domain":[
"api.openai.com"
],
"rule_set":[
"geosite-openai"
],
"outbound":"${CHATGPT_OUT}"
}
]
}
Expand Down
42 changes: 28 additions & 14 deletions sing-box.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

# 当前脚本版本号
VERSION='v1.2.7 (2024.12.10)'
VERSION='v1.2.8 (2024.12.13)'

# 各变量默认值
GH_PROXY='https://ghproxy.lvedong.eu.org/'
Expand All @@ -27,8 +27,8 @@ mkdir -p $TEMP_DIR

E[0]="Language:\n 1. English (default) \n 2. 简体中文"
C[0]="${E[0]}"
E[1]="Compatible with Sing-box 1.11.0-beta.8+. Thanks to the PR from brother Maxrxf. I've already given up myself. Due to significant differences in the configuration files, it is not possible to upgrade from the old version. You can only reinstall the script."
C[1]="适配 Sing-box 1.11.0-beta.8+,感谢 Maxrxf 兄弟的 PR,我自己已经投降的了。由于配置文件有很大差异,不能从旧版本升级,只能重装脚本"
E[1]="Thank you to the veteran player Fan Glider Fangliding for the technical guidance on Warp's routing!"
C[1]="感谢资深玩家 风扇滑翔翼 Fangliding 关于 Warp 的分流的技术指导"
E[2]="Downloading Sing-box. Please wait a seconds ..."
C[2]="下载 Sing-box 中,请稍等 ..."
E[3]="Input errors up to 5 times.The script is aborted."
Expand Down Expand Up @@ -519,7 +519,7 @@ check_install() {
{
local VERSION_LATEST=$(wget --no-check-certificate --tries=2 --timeout=3 -qO- ${GH_PROXY}https://api.github.com/repos/SagerNet/sing-box/releases | awk -F '["v-]' '/tag_name/{print $5}' | sort -Vr | sed -n '1p')
local ONLINE=$(wget --no-check-certificate --tries=2 --timeout=3 -qO- ${GH_PROXY}https://api.github.com/repos/SagerNet/sing-box/releases | awk -F '["v]' -v var="tag_name.*$VERSION_LATEST" '$0 ~ var {print $5; exit}')
ONLINE=${ONLINE:-'1.11.0-beta.8'}
ONLINE=${ONLINE:-'1.11.0-beta.9'}
wget --no-check-certificate --continue ${GH_PROXY}https://github.com/SagerNet/sing-box/releases/download/v$ONLINE/sing-box-$ONLINE-linux-$SING_BOX_ARCH.tar.gz -qO- | tar xz -C $TEMP_DIR sing-box-$ONLINE-linux-$SING_BOX_ARCH/sing-box >/dev/null 2>&1
[ -s $TEMP_DIR/sing-box-$ONLINE-linux-$SING_BOX_ARCH/sing-box ] && mv $TEMP_DIR/sing-box-$ONLINE-linux-$SING_BOX_ARCH/sing-box $TEMP_DIR
wget --no-check-certificate --continue -qO $TEMP_DIR/jq ${GH_PROXY}https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux-$JQ_ARCH >/dev/null 2>&1 && chmod +x $TEMP_DIR/jq >/dev/null 2>&1
Expand Down Expand Up @@ -800,8 +800,8 @@ sing-box_variables() {
fi

# 检测是否解锁 chatGPT
CHAT_GPT_OUT=wireguard-ep;
[ "$(check_chatgpt ${DOMAIN_STRATEG: -1})" = 'unlock' ] && CHAT_GPT_OUT=direct
CHATGPT_OUT=warp-ep;
[ "$(check_chatgpt ${DOMAIN_STRATEG: -1})" = 'unlock' ] && CHATGPT_OUT=direct

# 选择安装的协议,由于选项 a 为全部协议,所以选项数不是从 a 开始,而是从 b 开始,处理输入:把大写全部变为小写,把不符合的选项去掉,把重复的选项合并
MAX_CHOOSE_PROTOCOLS=$(asc $[CONSECUTIVE_PORTS+96+1])
Expand Down Expand Up @@ -1174,13 +1174,12 @@ EOF
"endpoints":[
{
"type":"wireguard",
"tag":"wireguard-ep",
"tag":"warp-ep",
"mtu":1280,
"address":[
"172.16.0.2/32",
"2606:4700:110:8a36:df92:102a:9602:fa18/128"
],
"domain_strategy":"${DOMAIN_STRATEG}",
"private_key":"YFYOAdbw1bKTHlNNi+aEjBM3BO7unuFC5rOkMRAz9XY=",
"peers": [
{
Expand Down Expand Up @@ -1220,12 +1219,27 @@ EOF
"action": "sniff"
},
{
"domain":"api.openai.com",
"outbound":"${CHAT_GPT_OUT}"
"action": "resolve",
"domain":[
"api.openai.com"
],
"strategy": "prefer_ipv4"
},
{
"action": "resolve",
"rule_set":[
"geosite-openai"
],
"strategy": "prefer_ipv6"
},
{
"rule_set":"geosite-openai",
"outbound":"${CHAT_GPT_OUT}"
"domain":[
"api.openai.com"
],
"rule_set":[
"geosite-openai"
],
"outbound":"${CHATGPT_OUT}"
}
]
}
Expand Down Expand Up @@ -2848,7 +2862,7 @@ uninstall() {
version() {
local VERSION_LATEST=$(wget --no-check-certificate -qO- ${GH_PROXY}https://api.github.com/repos/SagerNet/sing-box/releases | awk -F '["v-]' '/tag_name/{print $5}' | sort -Vr | sed -n '1p')
local ONLINE=$(wget --no-check-certificate -qO- ${GH_PROXY}https://api.github.com/repos/SagerNet/sing-box/releases | awk -F '["v]' -v var="tag_name.*$VERSION_LATEST" '$0 ~ var {print $5; exit}')
local ONLINE='1.11.0-beta.8'
local ONLINE='1.11.0-beta.9'
local LOCAL=$(${WORK_DIR}/sing-box version | awk '/version/{print $NF}')
info "\n $(text 40) "
[[ -n "$ONLINE" && "$ONLINE" != "$LOCAL" ]] && reading "\n $(text 9) " UPDATE || info " $(text 41) "
Expand Down Expand Up @@ -3108,4 +3122,4 @@ if [ "$NONINTERACTIVE_INSTALL" = 'noninteractive_install' ]; then
else
menu_setting
menu
fi
fi

0 comments on commit fd7ede0

Please sign in to comment.