#!/bin/bash
cur=$(pwd)

docker pull registry.cn-beijing.aliyuncs.com/co1lin/network:latest
# need /etc/v2ray/config.json
# create ./proxy/config.json first
docker run -d -p 9000:1087 --name network --restart=always -v $cur/proxyconf:/etc/v2ray registry.cn-beijing.aliyuncs.com/co1lin/network:latest

echo 'PROXY_ADDR=http://localhost:9000
export HTTP_PROXY=$PROXY_ADDR \
    http_proxy=$PROXY_ADDR \
    HTTPS_PROXY=$PROXY_ADDR \
    https_proxy=$PROXY_ADDR \
    ALL_PROXY=$PROXY_ADDR \
    all_proxy=$PROXY_ADDR \
    no_proxy=
echo "Proxy set to $PROXY_ADDR"
' > proxy

echo '
export HTTP_PROXY='' \
    http_proxy='' \
    HTTPS_PROXY='' \
    https_proxy='' \
    ALL_PROXY='' \
    all_proxy='' \
    no_proxy=
echo "Proxy cleared"
' > unproxy
