Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mellon85/external-ip
External IP crate
https://github.com/mellon85/external-ip
dns http igd ip rust
Last synced: 3 months ago
JSON representation
External IP crate
- Host: GitHub
- URL: https://github.com/mellon85/external-ip
- Owner: mellon85
- License: mit
- Created: 2019-12-29T08:51:20.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-09-19T20:25:32.000Z (4 months ago)
- Last Synced: 2024-11-09T00:30:06.576Z (3 months ago)
- Topics: dns, http, igd, ip, rust
- Language: Rust
- Size: 93.8 KB
- Stars: 6
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# external-ip
[![Build Status](https://travis-ci.com/mellon85/external-ip.svg?branch=master)](https://travis-ci.com/mellon85/external-ip)
Finds the current external IP address contacting http and dns external
services.If at least one of the sources replies the reply with the highest occurrences
will be reported as the IP address.Three functions provides sets of known working sources.
* `get_http_sources`
Returns all known http sources
* `get_dns_sources`
Returns all known dns sources
* `get_sources`
Returns all sources combinedAdditionally a single igd source can be instantiated if the feature is enabled
(`discover_igd`), to retrieve the IP from an home router.
If the feature is enabled `get_sources` will return it as a source too.# Runtime
It requires to run with Tokio runtime due to the dependency on hyper if you use the HTTP resolver.
The DNS resolver can work with other executors at the moment. (tested with futures)# Extend
It's possible to extend how the sources dynamically via the API as long as the
Source interface is implemented and it's passed as a boxed trait object.# Example
For ease of use a single async function is enough to obtain the IP trying with
all the default sources enabled```rust
let result = external_ip::get_ipv4();
let value : Option = block_on(result);```
```rust
let result = external_ip::get_ipv6();
let value : Option = block_on(result);```
# Policies
The library supports 3 consensus policies. The default policy is Random
- All
Query all sources in parallel and return the most common response
- First
Query the sources one by one and return the first success
- Random
Query the sources one by one in random order and return the first success# Families
It's possible to select a specific address family to resolve to and all resolver will try to resolve to that or fail.
- All
- IPv4
- IPv6# Changelog
## v1
- Initial release
## v2
- Based on trust dns instead of c-ares. Now requires less external dependencies (only ssl at the moment)
## v3
- The default policy is now random
## v4
- Consensus is now not consumed when used
## v5
- Added ip family selection option
- Support http sources with IPv6
- Updated http and dns sources