#stun #nat

bin+lib nat-detect

a simple nat detect implementation for rust

1 unstable release

0.1.7 Feb 19, 2022
0.1.6 Feb 19, 2022

#30 in #stun

Download history 24/week @ 2024-07-22 100/week @ 2024-07-29 24/week @ 2024-08-05 19/week @ 2024-08-12 69/week @ 2024-08-19 46/week @ 2024-08-26 29/week @ 2024-09-02 36/week @ 2024-09-09 16/week @ 2024-09-16 64/week @ 2024-09-23 33/week @ 2024-09-30 32/week @ 2024-10-07 18/week @ 2024-10-14 38/week @ 2024-10-21 49/week @ 2024-10-28 29/week @ 2024-11-04

138 downloads per month

MIT license

26KB
290 lines

nat-detect

a simple nat detect implementation for rust

                                    +--------+
                                    |  Test  |
                                    |   I    |
                                    +--------+
                                         |
                                         |
                                         V
                                        /\              /\
                                     N /  \ Y          /  \ Y             +--------+
                      UDP     <-------/Resp\--------->/ IP \------------->|  Test  |
                      Blocked         \ ?  /          \Same/              |   II   |
                                       \  /            \? /               +--------+
                                        \/              \/                    |
                                                         | N                  |
                                                         |                    V
                                                         V                    /\
                                                     +--------+  Sym.      N /  \
                                                     |  Test  |  UDP    <---/Resp\
                                                     |   II   |  Firewall   \ ?  /
                                                     +--------+              \  /
                                                         |                    \/
                                                         V                     |Y
                              /\                         /\                    |
               Symmetric  N  /  \       +--------+   N  /  \                   V
                  NAT  <--- / IP \<-----|  Test  |<--- /Resp\               Open
                            \Same/      |   I    |     \ ?  /               Internet
                             \? /       +--------+      \  /
                              \/                         \/
                              |                           |Y
                              |                           |
                              |                           V
                              |                           Full
                              |                           Cone
                              V              /\
                          +--------+        /  \ Y
                          |  Test  |------>/Resp\---->Restricted
                          |   III  |       \ ?  /
                          +--------+        \  /
                                             \/
                                              |N
                                              |       Port
                                              +------>Restricted

Install

cargo install nat-detect

Usage

# use default stun server list
# may be, these default servers will not good work in your net!
nat-detect

# use stun server 193.43.148.37:3478 
nat-detect -s 193.43.148.37:3478

default stun server list use always-online-stun

Dependencies

~6–12MB
~141K SLoC