Crates.io | uip |
lib.rs | uip |
version | 0.1.6 |
source | src |
created_at | 2023-04-10 18:23:58.59536 |
updated_at | 2023-04-13 13:59:42.468751 |
description | A tool to quickly determine the public IP address of a machine behind NAT with the help of STUN servers. |
homepage | |
repository | https://github.com/dndx/uip |
max_upload_size | |
id | 835344 |
size | 52,046 |
A tool to quickly determine the public IP address of a machine behind NAT with the help of STUN servers.
This tool is as simple as it sounds, when executed, it outputs the current machine's
public IP address by sending a binding request to the STUN server and displaying the
XOR-MAPPED-ADDRESS
or MAPPED-ADDRESS
attribute returned by the STUN server.
Either download pre-built binaries from the release page, or use cargo install uip
to install it.
$ uip -h
A tool to quickly determine the public IP address of a machine behind
NAT with the help of STUN servers.
Usage: uip [OPTIONS] [HOST:PORT]
Arguments:
[HOST:PORT] STUN server host and port. If PORT is omitted, it defaults to 3478 [default: stun.cloudflare.com]
Options:
-4, --ipv4-only Do not use IPv6 addresses when connecting to STUN server
-h, --help Print help
-V, --version Print version
$ uip stun.cloudflare.com
203.0.113.1
$ uip stun.l.google.com:19302
203.0.113.1
This program use return code 0
to indicate success and a valid IP has been returned.
All other return code indicates error.
The program timeouts after 5
seconds in case a response can not be received.
To debug, run it with RUST_LOG=debug uip
.
stun.cloudflare.com
stun.l.google.com
stun1.l.google.com
stun2.l.google.com
stun3.l.google.com
stun4.l.google.com
stun.syncthing.net
stun.xten.com
stun.qq.com
stun.miwifi.com
stun.chat.bilibili.com
public-stun-list.txt (Unverified)
This script was modified from the stun_client.rs
example of the WebRTC.rs project by Rain Liu yliu@webrtc.rs.
uip
added better error handling, more friendly command line interface and fallback to MAPPED-ADDRESS
attribute
in case XOR-MAPPED-ADDRESS
can not be found since some servers that I tested does not return XOR-MAPPED-ADDRESS
.
Copyright 2023 Datong Sun (dndx@idndx.com)
Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option. Files in the project may not be copied, modified, or distributed except according to those terms.