#networking #system #macos #http-proxy

yanked networksetup

Change macos system network settings

0.1.1 Oct 29, 2020
0.1.0 Oct 29, 2020

#62 in #http-proxy


Used in lopxy

MIT license

9KB
179 lines

networksetup Crates.io

A rust library for setting up macOS networks by calling networksetup command

API Docs

Usage

Add this in your Cargo.toml:

[dependencies]
networksetup = "*"

Example

use networksetup::{auto_proxy, dns_server, web_proxy, Address, Config, Network};

fn main() {
    // Set PAC Automatic Proxy
    auto_proxy(
        Network::WiFi,
        Config::Value("https://example.com/proxy.pac"),
    );

    // Set HTTP Proxy
    let addr = Address::new("0.0.0.0", "80");
    web_proxy(Network::WiFi, Config::Value(&addr));

    // Set Socks Proxy
    let addr = Address::new("127.0.0.1", "1080");
    web_proxy(Network::Ethernet, Config::Value(&addr));
    // Close
    web_proxy(Network::Ethernet, Config::Off);

    // Set DNS Server
    dns_server(Network::WiFi, &vec!["1.1.1.1", "8.8.8.8"]);
}

No runtime deps