Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/goenning/proxyvars
https://github.com/goenning/proxyvars
Last synced: 13 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/goenning/proxyvars
- Owner: goenning
- License: mit
- Created: 2023-04-21T08:54:40.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-03T13:12:38.000Z (8 months ago)
- Last Synced: 2024-11-27T20:13:34.114Z (about 1 month ago)
- Language: Rust
- Size: 23.4 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## proxyvars
proxyvars is a parser for the `HTTP_PROXY`, `HTTPS_PROXY` and `NO_PROXY` environment variables, with `NO_PROXY` matcher based on [Go's implementation](https://github.com/golang/net/blob/master/http/httpproxy/proxy.go).
This crate can:
- Read `HTTPS_PROXY` and `HTTP_PROXY` and its lowercase variants
- Read, parse and evaluate the `NO_PROXY` environment variables against a given URL
- Supports CIDR
- Supports IPv4/IPv6 address and optinal ports
- Supports Hostnames and optinal ports
- Supports Wildcard### Usage
```rust
if let Some(no_proxy) = proxyvars::no_proxy() {
// This environment has NO_PROXY defined
if no_proxy.matches("https://company.com") {
// We should not use a proxy for this URL
} else {
// We should use a proxy for this URL, which are available at:
let https_proxy = proxyvars::https_proxy();
let http_proxy = proxyvars::http_proxy();
}
}
```### Notes
1. The implementation of the `NO_PROXY` matcher is heavily inspired by Go's implementation located at [http/httpproxy/proxy.go](https://github.com/golang/net/blob/master/http/httpproxy/proxy.go).
2. It's outside the scope of this crate to actually perform the proxying.