Skip to content

Commit

Permalink
Merge branch 'master' of github.com:geph-official/geph5
Browse files Browse the repository at this point in the history
  • Loading branch information
nullchinchilla committed Jun 26, 2024
2 parents b75c943 + 54675d6 commit 96fbbc1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
6 changes: 2 additions & 4 deletions binaries/geph5-client-gui/src/pac/macos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ pub fn set_http_proxy(proxy: SocketAddr) -> anyhow::Result<()> {
let shell_src = include_str!("macos_set_proxy.sh");
std::env::set_var("proxy_server", proxy.ip().to_string());
std::env::set_var("port", proxy.port().to_string());
let output = runas::Command::new("bash")
.gui(true)
let output = std::process::Command::new("bash")
.arg("-c")
.arg(shell_src)
.status()?;
Expand All @@ -17,8 +16,7 @@ pub fn set_http_proxy(proxy: SocketAddr) -> anyhow::Result<()> {

pub fn unset_http_proxy() -> anyhow::Result<()> {
let shell_src = include_str!("macos_unset_proxy.sh");
let output = runas::Command::new("bash")
.gui(true)
let output = std::process::Command::new("bash")
.arg("-c")
.arg(shell_src)
.status()?;
Expand Down
15 changes: 10 additions & 5 deletions binaries/geph5-client-gui/src/pac/macos_set_proxy.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
#!/bin/bash

# AppleScript to request administrator privileges and run the script
osascript -e 'do shell script "
# Get the list of network services
network_services=$(networksetup -listallnetworkservices | tail -n +2)
# Loop through each line using read
while IFS= read -r service; do
# Set HTTP and HTTPS proxies
networksetup -setwebproxy "$service" "$proxy_server" $port
networksetup -setwebproxystate "$service" on
networksetup -setsecurewebproxy "$service" "$proxy_server" $port
networksetup -setsecurewebproxystate "$service" on
done <<< "$network_services"
networksetup -setwebproxy \"$service\" \"$proxy_server\" $port
networksetup -setwebproxystate \"$service\" on
networksetup -setsecurewebproxy \"$service\" \"$proxy_server\" $port
networksetup -setsecurewebproxystate \"$service\" on
done <<< \"$network_services\"
" with administrator privileges'

# Note: You need to define the variables $proxy_server and $port before running the script
9 changes: 6 additions & 3 deletions binaries/geph5-client-gui/src/pac/macos_unset_proxy.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#!/bin/bash

# AppleScript to request administrator privileges and run the script
osascript -e 'do shell script "
# Get the list of network services
network_services=$(networksetup -listallnetworkservices | tail -n +2)
# Loop through each line using read
while IFS= read -r service; do
# Disable HTTP and HTTPS proxies
networksetup -setwebproxystate "$service" off
networksetup -setsecurewebproxystate "$service" off
done <<< "$network_services"
networksetup -setwebproxystate \"$service\" off
networksetup -setsecurewebproxystate \"$service\" off
done <<< \"$network_services\"
" with administrator privileges'

0 comments on commit 96fbbc1

Please sign in to comment.