OpenTTD Source 20241224-master-gf74b0cf984
network_stun.h
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
7
10#ifndef NETWORK_STUN_H
11#define NETWORK_STUN_H
12
13#include "core/tcp_stun.h"
14
17private:
18 std::string token;
19 uint8_t family = AF_UNSPEC;
20 bool sent_result = false;
21
22public:
23 std::shared_ptr<TCPConnecter> connecter{};
25
26 NetworkRecvStatus CloseConnection(bool error = true) override;
28 void SendReceive();
29
30 void Connect(const std::string &token, uint8_t family);
31
32 static std::unique_ptr<ClientNetworkStunSocketHandler> Stun(const std::string &token, uint8_t family);
33};
34
35#endif /* NETWORK_STUN_H */
Class for handling the client side of the STUN connection.
void Connect(const std::string &token, uint8_t family)
Connect to the STUN server over either IPv4 or IPv6.
std::string token
Token of this STUN handler.
void SendReceive()
Check whether we received/can send some data from/to the STUN server and when that's the case handle ...
uint8_t family
Family of this STUN handler.
static std::unique_ptr< ClientNetworkStunSocketHandler > Stun(const std::string &token, uint8_t family)
Send a STUN packet to the STUN server.
std::shared_ptr< TCPConnecter > connecter
Connecter instance.
NetworkAddress local_addr
Local addresses of the socket.
NetworkRecvStatus CloseConnection(bool error=true) override
This will put this socket handler in a close state.
bool sent_result
Did we sent the result of the STUN connection?
Wrapper for (un)resolved network addresses; there's no reason to transform a numeric IP to a string a...
Definition address.h:28
Base socket handler for all STUN TCP sockets.
Definition tcp_stun.h:26
NetworkRecvStatus
Status of a network client; reasons why a client has quit.
Definition core.h:23
Basic functions to receive and send TCP packets to/from the STUN server.