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§
- nat_
behavior_ discovery - 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§
- Client
- STUN client. The transport protocol is UDP only and only supports simple STUN Binding requests.
- Header
- Struct representing STUN header
- Message
- Struct representing STUN message
- Options
- STUN client options.
Enums§
- Attribute
- Enum representing STUN attribute
- Class
- Enum representing STUN class
- Error
Code - An enum that defines the type of STUN error code.
- Method
- Enum representing STUN method
- STUN
Client Error - Defines the error used by the stun_client library.
Constants§
- ATTR_
CHANGE_ REQUEST - CHANGE-REQUEST attribute
- ATTR_
ERROR_ CODE - ERROR-CODE attribute
- ATTR_
MAPPED_ ADDRESS - MAPPED-ADDRESS attribute
- ATTR_
OTHER_ ADDRESS - OTHER-ADDRESS attribute
- ATTR_
RESPONSE_ ORIGIN - RESPONSE-ORIGIN attribute
- ATTR_
SOFTWARE - SOFTWARE attribute
- ATTR_
XOR_ MAPPED_ ADDRESS - XOR-MAPPED-ADDRESS attribute
- CHANGE_
REQUEST_ IP_ FLAG - The “change IP” flag for the CHANGE-REQUEST attribute.
- CHANGE_
REQUEST_ PORT_ FLAG - The “change port” flag for the CHANGE-REQUEST attribute.
- CLASS_
ERROR_ RESPONSE - A constant that represents a class error response
- CLASS_
INDICATION - A constant that represents a class indication
- CLASS_
REQUEST - A constant that represents a class request
- CLASS_
SUCCESS_ RESPONSE - A constant that represents a class success response
- FAMILY_
IPV4 - FAMILY_
IPV6 - HEADER_
BYTE_ SIZE - STUN header size
- MAGIC_
COOKIE - Magic cookie
- METHOD_
BINDING - Binding method