networksetup

Crates.ionetworksetup
lib.rsnetworksetup
version0.1.1
sourcesrc
created_at2020-10-29 08:56:39.018277
updated_at2020-10-29 08:59:22.138892
descriptionChange macos system network settings
homepagehttps://github.com/wyhaya/networksetup
repositoryhttps://github.com/wyhaya/networksetup.git
max_upload_size
id306566
size9,959
(wyhaya)

documentation

README

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"]);
}
Commit count: 0

cargo fmt