group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
GlobalDirectoryServer Class Reference

#include <GlobalDirectoryServer.hpp>

Collaboration diagram for GlobalDirectoryServer:
[legend]

Classes

struct  ServerRecord
struct  ClientEndpoint

Public Member Functions

bool init (const char *bindHost, Uint16 tcpPort, Uint16 udpPort)
 Start the UDP-only directory/relay service.
void run ()
void stop ()

Private Member Functions

void pollUdp ()
void pruneExpired ()
void handleDirectoryControl (const net::UdpReceivedMessage &msg)
void handleRegistration (const net::UdpReceivedMessage &msg, net::discovery::DirectoryMessage kind, const std::uint8_t *data, std::size_t len)
void handleListRequest (const net::UdpReceivedMessage &msg)
void handlePunchRequest (const net::UdpReceivedMessage &msg, const std::uint8_t *data, std::size_t len)
void handleRelayPayload (const net::UdpReceivedMessage &msg)
void sendDirectory (const net::UdpEndpointAddr &dest, const std::vector< std::uint8_t > &payload)
void sendRelay (const net::UdpEndpointAddr &dest, const std::uint8_t *payload, std::size_t len)
net::RelayToken makeRelayToken (std::uint32_t serverId, std::uint32_t clientNonce, Uint64 nowMs) const
bool validateRelayToken (const net::RelayToken &token, std::uint32_t serverId, std::uint32_t clientNonce, Uint64 nowMs) const

Private Attributes

net::UdpEndpoint udpEndpoint_
std::vector< std::uint8_t > relaySecret_
std::unordered_map< std::uint32_t, ServerRecordservers_
std::unordered_map< std::uint64_t, ClientEndpointclientsByRelaySession_
std::uint32_t nextServerId_ = 1
std::atomic< bool > shouldStop_ {false}

Member Function Documentation

◆ handleDirectoryControl()

void GlobalDirectoryServer::handleDirectoryControl ( const net::UdpReceivedMessage & msg)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handleListRequest()

void GlobalDirectoryServer::handleListRequest ( const net::UdpReceivedMessage & msg)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handlePunchRequest()

void GlobalDirectoryServer::handlePunchRequest ( const net::UdpReceivedMessage & msg,
const std::uint8_t * data,
std::size_t len )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handleRegistration()

void GlobalDirectoryServer::handleRegistration ( const net::UdpReceivedMessage & msg,
net::discovery::DirectoryMessage kind,
const std::uint8_t * data,
std::size_t len )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handleRelayPayload()

void GlobalDirectoryServer::handleRelayPayload ( const net::UdpReceivedMessage & msg)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ init()

bool GlobalDirectoryServer::init ( const char * bindHost,
Uint16 tcpPort,
Uint16 udpPort )

Start the UDP-only directory/relay service.

Parameters
bindHostOptional bind host. nullptr means all interfaces.
tcpPortIgnored legacy argument, kept so old launch scripts that pass "tcp udp" still work during cutover.
udpPortPublic UDP directory/relay port.
Here is the caller graph for this function:

◆ makeRelayToken()

net::RelayToken GlobalDirectoryServer::makeRelayToken ( std::uint32_t serverId,
std::uint32_t clientNonce,
Uint64 nowMs ) const
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pollUdp()

void GlobalDirectoryServer::pollUdp ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pruneExpired()

void GlobalDirectoryServer::pruneExpired ( )
private
Here is the caller graph for this function:

◆ run()

void GlobalDirectoryServer::run ( )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendDirectory()

void GlobalDirectoryServer::sendDirectory ( const net::UdpEndpointAddr & dest,
const std::vector< std::uint8_t > & payload )
private
Here is the caller graph for this function:

◆ sendRelay()

void GlobalDirectoryServer::sendRelay ( const net::UdpEndpointAddr & dest,
const std::uint8_t * payload,
std::size_t len )
private
Here is the caller graph for this function:

◆ stop()

void GlobalDirectoryServer::stop ( )
Here is the caller graph for this function:

◆ validateRelayToken()

bool GlobalDirectoryServer::validateRelayToken ( const net::RelayToken & token,
std::uint32_t serverId,
std::uint32_t clientNonce,
Uint64 nowMs ) const
private
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ clientsByRelaySession_

std::unordered_map<std::uint64_t, ClientEndpoint> GlobalDirectoryServer::clientsByRelaySession_
private

◆ nextServerId_

std::uint32_t GlobalDirectoryServer::nextServerId_ = 1
private

◆ relaySecret_

std::vector<std::uint8_t> GlobalDirectoryServer::relaySecret_
private

◆ servers_

std::unordered_map<std::uint32_t, ServerRecord> GlobalDirectoryServer::servers_
private

◆ shouldStop_

std::atomic<bool> GlobalDirectoryServer::shouldStop_ {false}
private

◆ udpEndpoint_

net::UdpEndpoint GlobalDirectoryServer::udpEndpoint_
private

The documentation for this class was generated from the following files: