目的是为了处理所有走代理的请求
1
AoEiuV020CN 2022-08-08 10:31:19 +08:00
不一定有效,毕竟 linux 情况比 windows 复杂,
以下代码 export 变量针对的是命令行,dconf 针对的是类 gnome 桌面里的“系统代理”, proxy() { echo setup system proxy... export http_proxy_host='proxyhost' export socks_proxy_host=$http_proxy_host export http_proxy_port='1082' export socks_proxy_port='1081' export ALL_PROXY="socks5://$socks_proxy_host:$socks_proxy_port/" # ftp 代理会导致 wget 无法下载 ftp 文件, unset FTP_PROXY export HTTPS_PROXY="http://$http_proxy_host:$http_proxy_port/" export HTTP_PROXY="http://$http_proxy_host:$http_proxy_port/" # 写死 127.0.0.1 因为 flutter 的 websocket 需要, export NO_PROXY="localhost,127.0.0.1,127.0.0.0/8,::1" export all_proxy=$ALL_PROXY unset ftp_proxy export http_proxy=$HTTP_PROXY export https_proxy=$HTTPS_PROXY export no_proxy=$NO_PROXY which dconf &>/dev/null && ( dconf write /system/proxy/http/host "'$http_proxy_host'" dconf write /system/proxy/http/port "$http_proxy_port" dconf write /system/proxy/https/host "'$http_proxy_host'" dconf write /system/proxy/https/port "$http_proxy_port" dconf reset /system/proxy/ftp/host dconf reset /system/proxy/ftp/port dconf write /system/proxy/socks/host "'$socks_proxy_host'" dconf write /system/proxy/socks/port "$socks_proxy_port" dconf write /system/proxy/ignore-hosts "['localhost', '127.0.0.1', '127.0.0.0/8', '::1']" dconf write /system/proxy/mode "'manual'" ) || true } noproxy() { unset ALL_PROXY unset FTP_PROXY unset HTTPS_PROXY unset HTTP_PROXY unset NO_PROXY unset all_proxy unset ftp_proxy unset http_proxy unset https_proxy unset no_proxy which dconf &>/dev/null && ( dconf write /system/proxy/mode "'none'" ) || true } |
2
AoEiuV020CN 2022-08-08 10:35:32 +08:00
等等,你一会儿 shell 一会儿 windows 的,到底是什么环境,
我这里还有个 cmd 设置 windows 系统代理的代码, 用到第三方工具 sysproxy.exe ,否则无法立即生效, set sysproxy=%pwd%../sysproxy/sysproxy.exe echo 设置 ie 代理, %sysproxy% global 127.0.0.1:1081 "<local>" echo 关闭 ie 代理, %sysproxy% set 1 - - - |
3
MEIerer OP @AoEiuV020CN 我是想通过用 shell 命令来控制 window 系统代理,网上找了一些法子都没效果
|
4
MEIerer OP 通过 IE 吗,我回去试试
|