Skip to content

Commit 0434bcb

Browse files
committed
handle socks port properly on linux and mac
1 parent c96ccde commit 0434bcb

3 files changed

Lines changed: 23 additions & 7 deletions

File tree

scripts/proxy_set_linux_sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,21 @@ set_gnome_proxy() {
2424
local MODE=$1
2525
local PROXY_IP=$2
2626
local PROXY_PORT=$3
27-
local IGNORE_HOSTS=$4
27+
local SOCKS_PORT=$4
28+
local IGNORE_HOSTS=$5
2829

2930
# Set the proxy mode
3031
gsettings set org.gnome.system.proxy mode "$MODE"
3132

3233
if [ "$MODE" == "manual" ]; then
3334
# List of protocols
34-
local PROTOCOLS=("http" "https" "ftp" "socks")
35+
local PROTOCOLS=("http" "https" "ftp")
3536

3637
# Loop through protocols to set the proxy
3738
for PROTOCOL in "${PROTOCOLS[@]}"; do
3839
gsettings set org.gnome.system.proxy.$PROTOCOL host "$PROXY_IP"
3940
gsettings set org.gnome.system.proxy.$PROTOCOL port "$PROXY_PORT"
41+
gsettings set org.gnome.system.proxy.socks port "$SOCKS_PORT"
4042
done
4143

4244
# Set ignored hosts
@@ -56,7 +58,8 @@ set_kde_proxy() {
5658
local MODE=$1
5759
local PROXY_IP=$2
5860
local PROXY_PORT=$3
59-
local IGNORE_HOSTS=$4
61+
local SOCKS_PORT=$4
62+
local IGNORE_HOSTS=$5
6063

6164
# Determine the correct kwriteconfig command based on KDE_SESSION_VERSION
6265
if [ "$KDE_SESSION_VERSION" == "6" ]; then
@@ -72,7 +75,7 @@ set_kde_proxy() {
7275
$KWRITECONFIG --file kioslaverc --group "Proxy Settings" --key httpProxy "http://$PROXY_IP:$PROXY_PORT"
7376
$KWRITECONFIG --file kioslaverc --group "Proxy Settings" --key httpsProxy "http://$PROXY_IP:$PROXY_PORT"
7477
$KWRITECONFIG --file kioslaverc --group "Proxy Settings" --key ftpProxy "http://$PROXY_IP:$PROXY_PORT"
75-
$KWRITECONFIG --file kioslaverc --group "Proxy Settings" --key socksProxy "http://$PROXY_IP:$PROXY_PORT"
78+
$KWRITECONFIG --file kioslaverc --group "Proxy Settings" --key socksProxy "http://$PROXY_IP:$SOCKS_PORT"
7679

7780
# Set ignored hosts
7881
$KWRITECONFIG --file kioslaverc --group "Proxy Settings" --key NoProxyFor "$IGNORE_HOSTS"

scripts/proxy_set_osx_sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
set_proxy() {
55
PROXY_IP=$1
66
PROXY_PORT=$2
7+
SOCKS_PORT=$3
78

89
shift 2
910
BYPASS_DOMAINS=("$@")
@@ -25,7 +26,7 @@ set_proxy() {
2526
networksetup -setsecurewebproxy "$SERVICE" "$PROXY_IP" "$PROXY_PORT"
2627

2728
# Set SOCKS proxy
28-
networksetup -setsocksfirewallproxy "$SERVICE" "$PROXY_IP" "$PROXY_PORT"
29+
networksetup -setsocksfirewallproxy "$SERVICE" "$PROXY_IP" "$SOCKS_PORT"
2930

3031
# Set bypass domains
3132
networksetup -setproxybypassdomains "$SERVICE" "${BYPASS_DOMAINS[@]}"

src/system_proxy.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,15 @@ pub fn enable_system_proxy(cfg: &Config) -> Result<(), Error> {
3030

3131
#[cfg(target_os = "macos")]
3232
{
33+
let socks = cfg.socks5_port.unwrap_or(cfg.listen_port);
3334
run_script(
3435
MACOS_SCRIPT,
35-
&["set", &cfg.listen_host, &cfg.listen_port.to_string()],
36+
&[
37+
"set",
38+
&cfg.listen_host,
39+
&cfg.listen_port.to_string(),
40+
&socks.to_string(),
41+
],
3642
)
3743
.map_err(|e| {
3844
Error::new(
@@ -44,9 +50,15 @@ pub fn enable_system_proxy(cfg: &Config) -> Result<(), Error> {
4450

4551
#[cfg(all(unix, not(target_os = "macos")))]
4652
{
53+
let socks = cfg.socks5_port.unwrap_or(cfg.listen_port);
4754
run_script(
4855
LINUX_SCRIPT,
49-
&["manual", &cfg.listen_host, &cfg.lister_port.to_string()],
56+
&[
57+
"manual",
58+
&cfg.listen_host,
59+
&cfg.listen_port.to_string(),
60+
&socks.to_string(),
61+
],
5062
)
5163
.map_err(|e| {
5264
Error::new(

0 commit comments

Comments
 (0)