Skip to content

Commit

Permalink
mege watch.service to xray.tproxy
Browse files Browse the repository at this point in the history
  • Loading branch information
CerteKim committed Oct 7, 2021
1 parent e80300b commit 2860000
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 71 deletions.
2 changes: 1 addition & 1 deletion xray/etc/confs/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"tag": "direct",
"protocol": "freedom",
"settings": {
"domainStrategy": "UseIPv4"
"domainStrategy": "UseIP"
}
},
{
Expand Down
1 change: 1 addition & 0 deletions xray/etc/confs/dns.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
{
"address": "https+local://223.5.5.5/dns-query",
"domains": [
"geosite:cn",
"geosite:geolocation-cn"
]
},
Expand Down
69 changes: 0 additions & 69 deletions xray/scripts/watch.service

This file was deleted.

2 changes: 1 addition & 1 deletion xray/scripts/watch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# check online ip
# ip route get 1.2.3.4 | awk '{print $9}'

lastIP6="2001:da8::666"
lastIP6="::114:514:1919:810"

bypass() {
if [ "$isChanged" = true ]; then
Expand Down
54 changes: 54 additions & 0 deletions xray/scripts/xray.tproxy
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,58 @@ intranet6=(::/128 ::1/128 ::ffff:0:0/96 100::/64 64:ff9b::/96 2001::/32 2001:10:
# 2900-2999 5000-5999 OEM; 10000+ APP; 99000-99999 ISOLATE; 100000 USER; 50000-59999 SHARED_GID
AIDs=(1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 2001 2002 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 9997 9998 9999)



# watch
data_path="/data/adb/xray"
bin_name="watch.sh"
bin_path="${data_path}/scripts/${bin_name}"
run_path="${data_path}/run"
pid_file="${run_path}/${bin_name}.pid"
error_log="${run_path}/watch.error.log"

probe_alive() {
[ -f ${pid_file} ] && cmd_file="/proc/`cat ${pid_file}`/cmdline" || return 1
[ -f ${cmd_file} ] && grep -q ${bin_path} ${cmd_file} && return 0 || return 1
}

display_pid() {
if probe_alive ; then
echo "[Info]: ${bin_name} service is running. ( PID: `cat ${pid_file}` )"
return 0
else
echo "[Info]: ${bin_name} service is stopped."
return 1
fi
}

start_service() {
if probe_alive ; then
echo "[Info]: ${bin_name} service is running. ( PID: `cat ${pid_file}` )"
else
echo "[Info]: Starting ${bin_name} service."
nohup ${bin_path} &>${error_log} &
echo -n $! > ${pid_file}
if probe_alive ; then
echo "[Warning]: ${bin_name} service is running ( PID: `cat ${pid_file}` )"
else
echo "[Error]: Start ${bin_name} service Failed."
rm -f ${pid_file}
fi
fi
}

stop_service() {
if display_pid ; then
echo "[Info]: Stopping ${bin_name} service."
kill `cat ${pid_file}`
sleep 1
display_pid
fi
rm -f ${pid_file}
}


add_route() {
ip rule add fwmark ${mark_id} table ${table_id}
[ $proxy2_enable -eq 1 ] && ip rule add fwmark ${mark2_id} table ${table_id}
Expand Down Expand Up @@ -261,6 +313,7 @@ disable_proxy() {
if [ -f /data/adb/xray/ipv6 ] ; then
echo "disable ipv6 proxy"
iptables="ip6tables -w 100"
stop_service
clean_mangle_iptables 2> /dev/null
fi
}
Expand All @@ -280,6 +333,7 @@ enable_proxy() {
echo "enable ipv6 proxy"
iptables="ip6tables -w 100"
create_mangle_iptables
start_service
else
disable_ipv6
fi
Expand Down

0 comments on commit 2860000

Please sign in to comment.