#include "p2p/stunprober/stun_prober.h"
#include <cstdint>
#include <map>
#include <memory>
#include <set>
#include <string>
#include <utility>
#include "api/array_view.h"
#include "api/packet_socket_factory.h"
#include "api/task_queue/pending_task_safety_flag.h"
#include "api/transport/stun.h"
#include "api/units/time_delta.h"
#include "rtc_base/async_packet_socket.h"
#include "rtc_base/checks.h"
#include "rtc_base/network/received_packet.h"
#include "rtc_base/thread.h"
#include "rtc_base/time_utils.h"
namespace stunprober {
namespace {
SafeTask;
TimeDelta;
const int THREAD_WAKE_UP_INTERVAL_MS = …;
template <typename T>
void IncrementCounterByAddress(std::map<T, int>* counter_per_ip, const T& ip) { … }
}
class StunProber::Requester : public sigslot::has_slots<> { … };
StunProber::Requester::Requester(
StunProber* prober,
rtc::AsyncPacketSocket* socket,
const std::vector<rtc::SocketAddress>& server_ips)
: … { … }
StunProber::Requester::~Requester() { … }
void StunProber::Requester::SendStunRequest() { … }
void StunProber::Requester::Request::ProcessResponse(
rtc::ArrayView<const uint8_t> payload) { … }
void StunProber::Requester::OnStunResponseReceived(
rtc::AsyncPacketSocket* socket,
const rtc::ReceivedPacket& packet) { … }
StunProber::Requester::Request* StunProber::Requester::GetRequestByAddress(
const rtc::IPAddress& ipaddr) { … }
StunProber::Stats::Stats() = default;
StunProber::Stats::~Stats() = default;
StunProber::ObserverAdapter::ObserverAdapter() = default;
StunProber::ObserverAdapter::~ObserverAdapter() = default;
void StunProber::ObserverAdapter::OnPrepared(StunProber* stunprober,
Status status) { … }
void StunProber::ObserverAdapter::OnFinished(StunProber* stunprober,
Status status) { … }
StunProber::StunProber(rtc::PacketSocketFactory* socket_factory,
rtc::Thread* thread,
std::vector<const rtc::Network*> networks)
: … { … }
StunProber::~StunProber() { … }
bool StunProber::Start(const std::vector<rtc::SocketAddress>& servers,
bool shared_socket_mode,
int interval_ms,
int num_request_per_ip,
int timeout_ms,
const AsyncCallback callback) { … }
bool StunProber::Prepare(const std::vector<rtc::SocketAddress>& servers,
bool shared_socket_mode,
int interval_ms,
int num_request_per_ip,
int timeout_ms,
StunProber::Observer* observer) { … }
bool StunProber::Start(StunProber::Observer* observer) { … }
bool StunProber::ResolveServerName(const rtc::SocketAddress& addr) { … }
void StunProber::OnSocketReady(rtc::AsyncPacketSocket* socket,
const rtc::SocketAddress& addr) { … }
void StunProber::OnServerResolved(
const webrtc::AsyncDnsResolverResult& result) { … }
void StunProber::CreateSockets() { … }
StunProber::Requester* StunProber::CreateRequester() { … }
bool StunProber::SendNextRequest() { … }
bool StunProber::should_send_next_request(int64_t now) { … }
int StunProber::get_wake_up_interval_ms() { … }
void StunProber::MaybeScheduleStunRequests() { … }
bool StunProber::GetStats(StunProber::Stats* prob_stats) const { … }
void StunProber::ReportOnPrepared(StunProber::Status status) { … }
void StunProber::ReportOnFinished(StunProber::Status status) { … }
}