#stun #p2p #nat #udp

stun-client

This is a simple async_std based asynchronous STUN client library

4 releases

0.1.4 Jul 17, 2023
0.1.2 May 28, 2021
0.1.1 May 10, 2021
0.1.0 May 3, 2021

#1382 in Asynchronous

MIT license

37KB
748 lines

test

stun-client

This is a simple async_std based asynchronous STUN client library. At the moment only some features of RFC8489 are implemented and only simple binding requests are possible.

It also supports the OTHER-ADDRESS and CHANGE-REQUEST attributes for RFC5780 -based NAT Behavior Discovery.

Install

Documentation

Examples


lib.rs:

This is a simple async_std based asynchronous STUN client library. At the moment only some features of RFC8489 are implemented and only simple binding requests are possible.

It also supports the OTHER-ADDRESS and CHANGE-REQUEST attributes for RFC5780 -based NAT Behavior Discovery

Example

use async_std::task;
use stun_client::*;

task::block_on(async {
    let mut client = Client::new("0.0.0.0:0", None).await.unwrap();
    let res = client
        .binding_request("stun.l.google.com:19302", None)
        .await
        .unwrap();
    let class = res.get_class();
    match class {
        Class::SuccessResponse => {
            let xor_mapped_addr = Attribute::get_xor_mapped_address(&res);
            println!("XOR-MAPPED-ADDRESS: {}", xor_mapped_addr.unwrap());
        },
        _ => panic!("error"),
    }
});

Dependencies

~9–22MB
~299K SLoC