summaryrefslogtreecommitdiff
path: root/proxy.sh
blob: 2469fc035ac3e42ed913106751ee71595c9e3cf0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env dash
# update sub and change proxy
# author: touka@nopwd.lol

# ============================
# FIRST READ THE SCRIPT!!
echo "FIRST READ THE SCRIPT!!"
exit
# ============================

set -e

# -- change it to your needs --
V2RAY_CONFIG=$HOME/.config/v2ray
V2RAY_SUB="https://your-v2ray-sub-link"
OFFSET=3 # line number of first vless link in the decoded links.
# -----------------------------

if [ "$#" -eq 0 ]; then
printf "Usage:
  $0 [OPTION?]
Options:
  n           Update subscription
  c [number]  Change link(to number default first)
"
exit
fi

cd $V2RAY_CONFIG

case "$1" in
	n)
		curl -s -L -o proxies-encode.txt $V2RAY_SUB
		base64 -d proxies-encode.txt > proxies.txt
		echo "$0: updated subscription"
		;;
	c)
		linkn=0
		if [ ! -z $2 ]; then
			linkn=$2
		fi
		awk 'NR==$linkn+$OFFSET' proxies.txt > proxy$linkn.txt
		echo "$0: selected proxy $linkn"
		vless2json.sh proxy$linkn.txt > config.json
		echo "$0: created config.json"
		;;
	*)
		echo "$0: wrong option"
		;;
esac