Skip to content

Instantly share code, notes, and snippets.

@iegik
Last active October 28, 2023 16:18
Show Gist options
  • Save iegik/d8882c0e664eb60681e3f73f29a3d641 to your computer and use it in GitHub Desktop.
Save iegik/d8882c0e664eb60681e3f73f29a3d641 to your computer and use it in GitHub Desktop.
- Toggle proxy switch on/off on Gnome

Logging proxy

brew install mitmproxy
mitmdump -p 9000 -P https://my.server.net -w traffic.log
#!/bin/bash
#p="org.gnome.system.proxy mode";g=gsettings;n="'none'";if [ `$g get $p` == $n ];then $g set $p manual;else $g set $p $n;fi;echo `$g get $p`
p="org.gnome.system.proxy mode";
g=gsettings;
n="'none'";
if [ `$g get $p` == $n ];then
echo "There is no proxy set";
export {{http,https,ftp}_proxy,{HTTP,HTTPS,FTP}_PROXY}=http://`gsettings get org.gnome.system.proxy.http host | sed 's/\x27//g'`:`gsettings get org.gnome.system.proxy.http port`
export {no_proxy,NO_PROXY}=`gsettings get org.gnome.system.proxy ignore-hosts | sed -s 's/[\x27\x5b ]//g;s/]//'`;
export NO_PROXY_LIST=`echo $no_proxy | sed -s 's/,/;/g'`;
# NPM
npm config set proxy true
# APT
sudo mv ~/.apt.conf /etc/apt/apt.conf
$g set $p manual;
else
echo "There is proxy set";
unset {{http,https,ftp}_proxy,{HTTP,HTTPS,FTP}_PROXY};
unset {no_proxy,NO_PROXY};
unset NO_PROXY_LIST;
# NPM
npm config set proxy false
npm cache clean
# APT
sudo mv /etc/apt/apt.conf ~/.apt.conf
$g set $p $n;
fi;
echo `$g get $p`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment