Git Product home page Git Product logo

proxy-config's Introduction

proxy-config

Appveyor Build status Travis Build Status Crates.io Documentation

A Rust library to get proxy configuration from the OS.

Usage

extern crate proxy_config;

if let Ok(proxy) = proxy_config::get_proxy_for_url(&url) {
    // use proxy to connect...
}

License

This project is provided under the terms of the Apache License 2.0 or the MIT License, at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

proxy-config's People

Contributors

mattico avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

proxy-config's Issues

proxy_autoconfig_type bit check error

In function proxy_autoconfig_type() the logic of check bits is wrong causing detecting of proxy type to fail.

Was:

if (bytes[8] & (1 << 2)) == bytes[8]

Should be:

if (bytes[8] & (1 << 2)) == (1 << 2)

Same for the line where the 3rd bit is checked:

} else if (bytes[8] & (1 << 3)) == bytes[8] {

to

} else if (bytes[8] & (1 << 3)) == (1 << 3)

Improve env var module

Some ideas looking at https://github.com/inejge/env_proxy:

  • Improve tests
    • Synchronize env var access
    • Clear env vars between tests
    • More tests
  • Add support for NO_PROXY=*
  • Support space-separated domains
  • Add support for ALL_PROXY
  • Fall back to HTTP_PROXY, then ALL_PROXY, if value not found in <scheme>_PROXY

Websocket URL scheme error

Hi I discovered something with library it doesn't support websocket protocol as valid scheme even I've filled all protocols and selected "Use same proxy server for all protocols" option in windows proxy settings menu. Url library parses the following wss address correctly but proxy_config library throws error for the Url

Reproduce code is like following

extern crate proxy_config;
extern crate url;


use url::Url;
use proxy_config::ProxyConfigError;


fn main() {
//    app::bootstrap::startup();
    let resolved_url = Url::parse(&"wss://echo.websocket.org").unwrap();
    println!("{}", resolved_url);
    match proxy_config::get_proxy_for_url(Url::parse(&"wss://echo.websocket.org").unwrap()) {
        Ok(proxy) => {
            println!("{}", proxy);
        }
        Err(ProxyConfigError::NoProxyNeededError) => {
            println!("No proxy needed for described URL");
        }

        Err(e) => {
            println!("Error getting proxy for  described URL {}", e);
        }
    }
}

Output:

wss://echo.websocket.org/
Error getting proxy for described URL no proxy found for scheme: 'wss'

Documentation

Things that need improving:

  • Expand readme with installation instructions, examples.
  • Add examples of using this library with other libraries
    • Reqwest
    • Hyper
  • Expand API docs

Figure out proxy configuration precedence

Most systems will have at least two ways of getting proxy info: Environment Variables and something else. We need to decide on a ranking for these methods. Probably also want to provide a mechanism for ignoring input from one source or another. A decent solution would just have each mechanism as a separate cargo feature. A user that wants to disable env config can just disable that feature. I don't think there's a need to do this at runtime.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.