Skip to main content

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

Project description

banner

GitHub License wakatime PyPI - Version PyPI - 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

import uniproxy

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

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

import uniproxy

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

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

Bypass Domains

import uniproxy

prox = uniproxy.Uniproxy(ip="127.0.0.1", port=8081)  ## Create a uniproxy instance
prox.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

import uniproxy

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

This will disable the system-wide proxy.

Delete Proxy

import uniproxy

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

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

Get Proxy Details

import uniproxy

prox = uniproxy.Uniproxy(ip="127.0.0.1", port=8081)  ## Create a uniproxy instance
prox.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

import uniproxy

prox = uniproxy.Uniproxy(ip="127.0.0.1", port=8081)  ## Create a uniproxy instance
prox.set_bypass_domains(["www.google.com", "www.facebook.com"])  ## Set bypass domains
print(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

import uniproxy

prox = uniproxy.Uniproxy(ip="127.0.0.1", port=8081)  ## Create a uniproxy instance
print(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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

uniproxy-1.1.1.tar.gz (19.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

uniproxy-1.1.1-py3-none-any.whl (20.9 kB view details)

Uploaded Python 3

File details

Details for the file uniproxy-1.1.1.tar.gz.

File metadata

  • Download URL: uniproxy-1.1.1.tar.gz
  • Upload date:
  • Size: 19.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.13.3 Linux/6.14.10-arch1-1

File hashes

Hashes for uniproxy-1.1.1.tar.gz
Algorithm Hash digest
SHA256 9248ceb2005b717a230b388651699f3764dd393d10738d1983323e4936742135
MD5 b5b851a69383bc703d4f0508ceb33c22
BLAKE2b-256 ab3563b705502469442e5b9007925e6b94d9f866ef1dc5d1082c2871bbbae2ea

See more details on using hashes here.

File details

Details for the file uniproxy-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: uniproxy-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 20.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.13.3 Linux/6.14.10-arch1-1

File hashes

Hashes for uniproxy-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 17f43a2494ecb8d795a6e88849768ea04345d4bcb0076692e623a20371e8e74b
MD5 25c4e7cddd299fb5497a81b4410dc29a
BLAKE2b-256 e9a5ba8a24936dad30f2c29ec87303910528867e55e4859d46b664921d90c684

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page