fix: support socks proxy addr

This commit is contained in:
libm committed 2025-02-15 23:18:47 +08:00
1 parent eb740c661e
commit 5477b7380e
2 files changed
+29 -8

No files matched your search

+26 -7
View File
@@ -4,27 +4,46 @@
function clashon() {
sudo systemctl start clash && _okcat '已开启代理环境' ||
_failcat '启动失败: 执行 "systemctl status clash" 查看日志' || return 1
_get_port
local proxy_addr=http://127.0.0.1:${PROXY_PORT}
export http_proxy=$proxy_addr
export https_proxy=$proxy_addr
export HTTP_PROXY=$proxy_addr
export HTTPS_PROXY=$proxy_addr
local http_proxy_addr=http://127.0.0.1:${HTTP_PROXY_PORT}
local socks_proxy_addr=socks5://127.0.0.1:${SOCKS_PROXY_PORT}
local no_proxy_addr="localhost,127.0.0.1,::1"
export http_proxy=$http_proxy_addr
export https_proxy=$http_proxy
export HTTP_PROXY=$http_proxy
export HTTPS_PROXY=$http_proxy
export all_proxy=$socks_proxy_addr
export ALL_PROXY=$all_proxy
export no_proxy=$no_proxy_addr
export NO_PROXY=$no_proxy
}
function clashoff() {
sudo systemctl stop clash && _okcat '已关闭代理环境' ||
_failcat '关闭失败: 执行 "systemctl status clash" 查看日志' || return 1
unset http_proxy
unset https_proxy
unset HTTP_PROXY
unset HTTPS_PROXY
unset all_proxy
unset ALL_PROXY
unset no_proxy
unset NO_PROXY
}
clashrestart() {
{ clashoff && clashon; } >&/dev/null
}
clashstatus() {
sudo systemctl status clash
}
function clashui() {
# 防止tun模式强制走代理
clashoff >&/dev/null
@@ -32,8 +51,8 @@ function clashui() {
# ifconfig.me
# cip.cc
_get_port
local public_ip=$(curl -s --noproxy "*" ifconfig.me)
local public_address="http://${public_ip}:${UI_PORT}/ui"
local public_ip=$(curl -s --noproxy "*" --connect-timeout 2 ifconfig.me)
local public_address="http://${public_ip:-公网IP}:${UI_PORT}/ui"
# 内网ip
# ip route get 1.1.1.1 | grep -oP 'src \K\S+'
local local_ip=$(hostname -I | awk '{print $1}')
+3 -1
View File
@@ -70,10 +70,12 @@ function _get_os() {
function _get_port() {
local port=$(sudo $BIN_YQ '.port // ""' $CLASH_CONFIG_RUNTIME)
local socks_port=$(sudo $BIN_YQ '.socks-port // ""' $CLASH_CONFIG_RUNTIME)
local mixed_port=$(sudo $BIN_YQ '.mixed-port // ""' $CLASH_CONFIG_RUNTIME)
local external_port=$(sudo $BIN_YQ '.external-controller // ""' $CLASH_CONFIG_RUNTIME | cut -d':' -f2)
PROXY_PORT="${mixed_port:-${port:-7890}}"
HTTP_PROXY_PORT="${mixed_port:-${port:-7890}}"
SOCKS_PROXY_PORT="${mixed_port:-${socks_port:-7891}}"
UI_PORT=${external_port:-9090}
}