STUN Client for NAT traversal.
More...
#include <stun.h>
STUN Client for NAT traversal.
Example usage:
if (result.success && result.mapped_address) {
std::cout <<
"Public address: " << result.
mapped_address->to_string() << std::endl;
}
STUN Client for NAT traversal.
StunResult binding_request(const std::string &server, uint16_t port=STUN_DEFAULT_PORT, int timeout_ms=0)
Send STUN Binding Request to discover public address.
std::optional< StunMappedAddress > mapped_address
Definition at line 383 of file stun.h.
◆ StunClient() [1/4]
| librats::StunClient::StunClient |
( |
| ) |
|
◆ StunClient() [2/4]
◆ ~StunClient()
| librats::StunClient::~StunClient |
( |
| ) |
|
◆ StunClient() [3/4]
| librats::StunClient::StunClient |
( |
const StunClient & |
| ) |
|
|
delete |
◆ StunClient() [4/4]
◆ binding_request()
Send STUN Binding Request to discover public address.
- Parameters
-
| server | STUN server hostname or IP |
| port | STUN server port (default: 3478) |
| timeout_ms | Total timeout in milliseconds (0 for config default) |
- Returns
- Result containing mapped address or error
◆ binding_request_with_socket()
| StunResult librats::StunClient::binding_request_with_socket |
( |
socket_t |
socket, |
|
|
const std::string & |
server, |
|
|
uint16_t |
port, |
|
|
int |
timeout_ms = 0 |
|
) |
| |
Send STUN Binding Request using existing socket Useful when you need to discover the mapped address for a specific local socket.
- Parameters
-
| socket | UDP socket to use (must be bound) |
| server | STUN server hostname or IP |
| port | STUN server port |
| timeout_ms | Total timeout in milliseconds |
- Returns
- Result containing mapped address or error
◆ config()
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ send_request()
| std::optional< StunMessage > librats::StunClient::send_request |
( |
socket_t |
socket, |
|
|
const StunMessage & |
request, |
|
|
const std::string & |
server, |
|
|
uint16_t |
port, |
|
|
int |
timeout_ms |
|
) |
| |
Send a raw STUN message and wait for response.
- Parameters
-
| socket | UDP socket to use |
| request | STUN message to send |
| server | Destination server |
| port | Destination port |
| timeout_ms | Total timeout |
- Returns
- Response message or empty if timeout/error
◆ set_config()
The documentation for this class was generated from the following file: