Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

210 Commits

Repository files navigation

banner

GitHub LicensewakatimePyPI - VersionPyPI - Python Version

Uniproxy

Cross-platform python library to set system-wide proxy and proxy bypass domains.

Important

Uniproxy doesn't provide a proxy server. It only sets the system-wide proxy settings.

Features

  • Cross Platform: Uniproxy is cross-platform and can be used on Windows, macOS and Linux.
  • System Wide Proxy: Uniproxy can be used to set system-wide proxy for the host.
  • Bypassing Domains: Uniproxy can be used to set bypass domains which don't go through the system-wide proxy.
  • Environment Variables: Uniproxy can also set environment variables for the proxy.

Installation

$ pip3 install uniproxy

Getting Started

Install the package as mentioned above and import it.

Proxy setup

importuniproxyprox=uniproxy.Uniproxy(ip="127.0.0.1", port=8081) ## Create a uniproxy instanceprox.set_proxy() ## Set system-wide proxy without changing the current proxy enabled state for the OSprox.set_proxy_enabled(True) ## Enable system-wide proxy

This will first edit the OS Settings to set the proxy and then enable the proxy.

importuniproxyprox=uniproxy.Uniproxy(ip="127.0.0.1", port=8081) ## Create a uniproxy instanceprox.join() ## Change

As an alternative, you can also use the above method to set the proxy and enable it directly.

Bypass Domains

importuniproxyprox=uniproxy.Uniproxy(ip="127.0.0.1", port=8081) ## Create a uniproxy instanceprox.set_bypass_domains(["www.google.com", "www.facebook.com"]) ## Set bypass domains

This will set the bypass domains for the proxy. The domains mentioned in the list will not pass through the proxy. Environment variables no_proxy and NO_PROXY will also be set.

Turn off Proxy

importuniproxyprox=uniproxy.Uniproxy(ip="127.0.0.1", port=8081) ## Create a uniproxy instanceprox.set_proxy_enabled(False) ## Disable system-wide proxy

This will disable the system-wide proxy.

Delete Proxy

importuniproxyprox=uniproxy.Uniproxy(ip="127.0.0.1", port=8081) ## Create a uniproxy instanceprox.delete_proxy() ## Delete the proxy settings

This will delete the proxy settings from the system and set them to OS defaults.

Get Proxy Details

importuniproxyprox=uniproxy.Uniproxy(ip="127.0.0.1", port=8081) ## Create a uniproxy instanceprox.join()
print(prox.get_proxy()) ## Get the proxy details

This will output the following (on Linux, KDE)

{
"is_enable": True,
"http": {"ip_address": "127.0.0.1", "port": "8081"},
"https": {"ip_address": "127.0.0.1", "port": "8081"},
"ftp": {"ip_address": "127.0.0.1", "port": "8081"},
}

Get Bypass Domains

importuniproxyprox=uniproxy.Uniproxy(ip="127.0.0.1", port=8081) ## Create a uniproxy instanceprox.set_bypass_domains(["www.google.com", "www.facebook.com"]) ## Set bypass domainsprint(prox.get_bypass_domains()) ## Get bypass domains

This will output the following

['www.google.com', 'www.facebook.com']

MacOS Specific Functionality

Get default network service

importuniproxyprox=uniproxy.Uniproxy(ip="127.0.0.1", port=8081) ## Create a uniproxy instanceprint(prox.proxy.get_default_network_service()) ## Get the default network service

This will output the following (depends on the system and current network configuration):

Wi-Fi

Default network service is determined by parsing the output of route -n get default command. If it fails for some reason the default network service is found out by parsing the output of networksetup -listallnetworkservices command and returning the first network service which is not disabled.

Known Issues

  • Uniproxy only works on SystemD based Linux systems.
  • Uniproxy only supports KDE and GNOME desktop environments on Linux.

Credits

About

Cross-platform python library to set system-wide proxy and proxy bypass domains.

Topics

Resources

Stars

5 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages