blob: cc4bb572c2f88060751256129b68c0dfa2537171 (
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
#!/bin/bash
set_proxy() {
case "$XDG_SESSION_DESKTOP" in
"gnome" | "gnome-xorg" | "ubuntu")
gsettings set org.gnome.system.proxy mode "manual"
gsettings set org.gnome.system.proxy.socks host "127.0.0.1"
gsettings set org.gnome.system.proxy.socks port "10808"
gsettings set org.gnome.system.proxy.http host "127.0.0.1"
gsettings set org.gnome.system.proxy.http port "10809"
gsettings set org.gnome.system.proxy.https host "127.0.0.1"
gsettings set org.gnome.system.proxy.https port "10809"
;;
*)
echo "Only support GNOME currently, please set proxy manually."
;;
esac
}
unset_proxy() {
case "$XDG_SESSION_DESKTOP" in
"gnome" | "gnome-xorg" | "ubuntu")
gsettings set org.gnome.system.proxy mode "none"
;;
*)
echo "Only support GNOME currently, please unset proxy manually."
;;
esac
}
cd "$(dirname "$0")"
V2RAY_HOME=${V2RAY_HOME:-$(pwd)}
V2RAY_CONFIG_DIR=${V2RAY_CONFIG_DIR:-$(pwd)}
V2RAY="$V2RAY_HOME/v2ray"
V2RAY_SUB="$V2RAY_CONFIG_DIR/subscription"
[[ -f "$V2RAY" ]] \
|| { echo "V2ray not found, try to download it..."; "$V2RAY_HOME/upgrade.sh" || exit 1; }
if [[ "$#" -ne 0 && -f "$1" ]]
then
set_proxy \
&& "$V2RAY" -config "$1"
else
if [[ "$#" -eq 0 ]]
then
[[ -f "$V2RAY_SUB" ]] || "$V2RAY_HOME/update.sh" || exit 1
"$V2RAY_HOME/vmess2json/vmess2json.py" \
< "$V2RAY_SUB" \
--inbounds "http:10809,socks:10808" \
--output "$V2RAY_CONFIG_DIR/config.json" \
&& set_proxy \
&& "$V2RAY" -config "$V2RAY_CONFIG_DIR/config.json"
else
echo "$1 does not exist." >&2
exit 1
fi
fi
unset_proxy && printf "\nV2ray stopped.\n"
|