Skip to content

Commit

Permalink
update ssrp
Browse files Browse the repository at this point in the history
  • Loading branch information
fightroad committed Sep 17, 2024
1 parent 5409cb5 commit 61f027b
Show file tree
Hide file tree
Showing 9 changed files with 307 additions and 304 deletions.
27 changes: 16 additions & 11 deletions trunk/user/chnroute/scripts/update_chnroute.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,29 @@

set -e -o pipefail

[ "$1" != "force" ] && [ "$(nvram get ss_update_chnroute)" != "1" ] && exit 0
NAME=chnroute
CHNROUTE_URL="$(nvram get ss_chnroute_url)"

logger -st "chnroute" "Starting update..."
log() {
logger -t "$NAME" "$@"
echo "$(date "+%Y-%m-%d %H:%M:%S") $@" >> "/tmp/ssrplus.log"
}

[ "$1" != "force" ] && [ "$(nvram get ss_update_chnroute)" != "1" ] && exit 0

log "CHNRoute 开始更新..."
[ ! -d /etc/storage/chinadns/ ] && mkdir /etc/storage/chinadns/
rm -f /tmp/chinadns_chnroute.txt

if [ -z "$CHNROUTE_URL" ]; then
curl -k -s --connect-timeout 20 --retry 3 http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest | \
awk -F\| '/CN\|ipv4/ { printf("%s/%d\n", $4, 32-log($5)/log(2)) }' > /tmp/chinadns_chnroute.txt
curl -s -o /tmp/chinadns_chnroute.txt --connect-timeout 10 --retry 3 "$CHNROUTE_URL"
else
curl -k -s --connect-timeout 20 --retry 3 -o /tmp/chinadns_chnroute.txt "$CHNROUTE_URL"
curl -s --connect-timeout 10 --retry 3 http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest | \
awk -F\| '/CN\|ipv4/ { printf("%s/%d\n", $4, 32-log($5)/log(2)) }' > /tmp/chinadns_chnroute.txt
fi

[ ! -d /etc/storage/chinadns/ ] && mkdir /etc/storage/chinadns/
mv -f /tmp/chinadns_chnroute.txt /etc/storage/chinadns/chnroute.txt

mtd_storage.sh save >/dev/null 2>&1

[ -f /usr/bin/shadowsocks.sh ] && [ "$(nvram get ss_enable)" = "1" ] && [ "$(nvram get ss_run_mode)" = "router" ] && /usr/bin/shadowsocks.sh restart >/dev/null 2>&1

logger -st "chnroute" "Update done"
log "CHNRoute 更新完成!"
echo 3 > /proc/sys/vm/drop_caches
[ -f /usr/bin/shadowsocks.sh ] && [ "$(nvram get ss_enable)" = "1" ] && [ "$(nvram get ss_run_mode)" = "router" ] && /usr/bin/shadowsocks.sh restart >/dev/null 2>&1
15 changes: 5 additions & 10 deletions trunk/user/httpd/variables.c
Original file line number Diff line number Diff line change
Expand Up @@ -1025,12 +1025,6 @@
#if defined(APP_SHADOWSOCKS)
struct variable variables_ShadowsocksConf[] = {
{"ss_enable","",NULL, EVM_RESTART_SHADOWSOCKS},
{"trojan_local_enable","",NULL, EVM_RESTART_SHADOWSOCKS},
{"trojan_local","",NULL, EVM_RESTART_SHADOWSOCKS},
{"trojan_link","",NULL, EVM_RESTART_SHADOWSOCKS},
{"v2_local_enable","",NULL, EVM_RESTART_SHADOWSOCKS},
{"v2_local","",NULL, EVM_RESTART_SHADOWSOCKS},
{"v2_link","",NULL, EVM_RESTART_SHADOWSOCKS},
{"global_server","",NULL, EVM_RESTART_SHADOWSOCKS},
{"backup_server","",NULL, EVM_RESTART_SHADOWSOCKS},
{"udp_relay_server","",NULL, EVM_RESTART_SHADOWSOCKS},
Expand Down Expand Up @@ -1093,12 +1087,13 @@
{"socks5_aenable","",NULL, EVM_RESTART_SHADOWSOCKS},
{"socks5_s_username","",NULL, EVM_RESTART_SHADOWSOCKS},
{"socks5_s_password","",NULL, EVM_RESTART_SHADOWSOCKS},
{"ss_turn","",NULL, EVM_RESTART_SHADOWSOCKS},
{"lan_con","",NULL, EVM_RESTART_SHADOWSOCKS},
{"ss_chnroute_url","",NULL, FALSE},
{"ss_watchcat", "",NULL, FALSE},
{"ss_turn_s","",NULL, EVM_RESTART_SHADOWSOCKS},
{"ss_turn_ss","",NULL, EVM_RESTART_SHADOWSOCKS},
{"ss_gfwlist_url","",NULL, FALSE},
{"ss_cgroups", "",NULL, EVM_RESTART_SHADOWSOCKS},
{"ss_cgoups_cpu_s", "",NULL, EVM_RESTART_SHADOWSOCKS},
{"ss_cgoups_mem_s", "",NULL, EVM_RESTART_SHADOWSOCKS},
{"ss_watchcat", "",NULL, FALSE},
{"ss_keyword","",NULL, FALSE},
{"ss_update_chnroute","",NULL, EVM_RESTART_SHADOWSOCKS},
{"ss_update_gfwlist","",NULL, EVM_RESTART_SHADOWSOCKS},
Expand Down
Loading

0 comments on commit 61f027b

Please sign in to comment.