Crate stun_client
source ·Expand description
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"),
}
});
Modules
- This module is for NAT Behavior Discovery based on RFC5780. To use this module, the STUN server side must support the OTHER-ADDRESS and CHANGE-REQUEST attributes.
Structs
- STUN client. The transport protocol is UDP only and only supports simple STUN Binding requests.
- Struct representing STUN header
- Struct representing STUN message
- STUN client options.
Enums
- Enum representing STUN attribute
- Enum representing STUN class
- An enum that defines the type of STUN error code.
- Enum representing STUN method
- Defines the error used by the stun_client library.
Constants
- CHANGE-REQUEST attribute
- ERROR-CODE attribute
- MAPPED-ADDRESS attribute
- OTHER-ADDRESS attribute
- RESPONSE-ORIGIN attribute
- SOFTWARE attribute
- XOR-MAPPED-ADDRESS attribute
- The “change IP” flag for the CHANGE-REQUEST attribute.
- The “change port” flag for the CHANGE-REQUEST attribute.
- A constant that represents a class error response
- A constant that represents a class indication
- A constant that represents a class request
- A constant that represents a class success response
- STUN header size
- Magic cookie
- Binding method