shfmt tunsocks.sh
This commit is contained in:
parent
2b1095760f
commit
ba4bbfa18c
10
tunsocks.sh
10
tunsocks.sh
@ -8,19 +8,18 @@ nsname="$1"
|
||||
device="tun${nsname}"
|
||||
ns="${nsname}ns"
|
||||
|
||||
if [ "$2" = use_env ];then
|
||||
if [ "$2" = use_env ]; then
|
||||
proxy="$SOCKS_PROXY"
|
||||
shift
|
||||
else
|
||||
proxy="socks5:///run/nnss-${nsname}/sock"
|
||||
fi
|
||||
|
||||
setup()
|
||||
{
|
||||
setup() {
|
||||
ip tuntap add mode tun dev "$device"
|
||||
|
||||
/usr/bin/tun2socks -device "$device" -proxy "$proxy" &
|
||||
echo "$!" > "$pidfile"
|
||||
echo "$!" >"$pidfile"
|
||||
sleep 5
|
||||
|
||||
ip netns add "$ns"
|
||||
@ -34,8 +33,7 @@ setup()
|
||||
wait
|
||||
}
|
||||
|
||||
cleanup()
|
||||
{
|
||||
cleanup() {
|
||||
ip tuntap del mode tun dev "$device" || true
|
||||
kill "$(cat "$pidfile")"
|
||||
ip -n "$ns" tuntap del mode tun dev "$device"
|
||||
|
Loading…
x
Reference in New Issue
Block a user