mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-04 06:00:15 +00:00
(svn r15961) -Codechange: prepare the 'client' side for receiving 'session keys' from the masterserver so servers can register with multiple IPs as the same server.
This commit is contained in:
parent
ebb1ed6601
commit
0678cb561d
@ -280,6 +280,7 @@ void NetworkUDPSocketHandler::HandleUDPPacket(Packet *p, NetworkAddress *client_
|
||||
UDP_COMMAND(PACKET_UDP_SERVER_UNREGISTER);
|
||||
UDP_COMMAND(PACKET_UDP_CLIENT_GET_NEWGRFS);
|
||||
UDP_COMMAND(PACKET_UDP_SERVER_NEWGRFS);
|
||||
UDP_COMMAND(PACKET_UDP_MASTER_SESSION_KEY);
|
||||
|
||||
default:
|
||||
if (this->HasClientQuit()) {
|
||||
@ -315,5 +316,6 @@ DEFINE_UNAVAILABLE_UDP_RECEIVE_COMMAND(PACKET_UDP_MASTER_RESPONSE_LIST);
|
||||
DEFINE_UNAVAILABLE_UDP_RECEIVE_COMMAND(PACKET_UDP_SERVER_UNREGISTER);
|
||||
DEFINE_UNAVAILABLE_UDP_RECEIVE_COMMAND(PACKET_UDP_CLIENT_GET_NEWGRFS);
|
||||
DEFINE_UNAVAILABLE_UDP_RECEIVE_COMMAND(PACKET_UDP_SERVER_NEWGRFS);
|
||||
DEFINE_UNAVAILABLE_UDP_RECEIVE_COMMAND(PACKET_UDP_MASTER_SESSION_KEY);
|
||||
|
||||
#endif /* ENABLE_NETWORK */
|
||||
|
@ -86,6 +86,7 @@ enum PacketUDPType {
|
||||
PACKET_UDP_SERVER_UNREGISTER, ///< Request to be removed from the server-list
|
||||
PACKET_UDP_CLIENT_GET_NEWGRFS, ///< Requests the name for a list of GRFs (GRF_ID and MD5)
|
||||
PACKET_UDP_SERVER_NEWGRFS, ///< Sends the list of NewGRF's requested.
|
||||
PACKET_UDP_MASTER_SESSION_KEY, ///< Sends a fresh session key to the client
|
||||
PACKET_UDP_END ///< Must ALWAYS be on the end of this list!! (period)
|
||||
};
|
||||
|
||||
@ -110,6 +111,7 @@ protected:
|
||||
DECLARE_UDP_RECEIVE_COMMAND(PACKET_UDP_SERVER_UNREGISTER);
|
||||
DECLARE_UDP_RECEIVE_COMMAND(PACKET_UDP_CLIENT_GET_NEWGRFS);
|
||||
DECLARE_UDP_RECEIVE_COMMAND(PACKET_UDP_SERVER_NEWGRFS);
|
||||
DECLARE_UDP_RECEIVE_COMMAND(PACKET_UDP_MASTER_SESSION_KEY);
|
||||
|
||||
void HandleUDPPacket(Packet *p, NetworkAddress *client_addr);
|
||||
|
||||
|
@ -28,6 +28,9 @@
|
||||
|
||||
ThreadMutex *_network_udp_mutex = ThreadMutex::New();
|
||||
|
||||
/** Session key to register ourselves to the master server */
|
||||
static uint64 _session_key = 0;
|
||||
|
||||
enum {
|
||||
ADVERTISE_NORMAL_INTERVAL = 30000, // interval between advertising in ticks (15 minutes)
|
||||
ADVERTISE_RETRY_INTERVAL = 300, // readvertise when no response after this many ticks (9 seconds)
|
||||
@ -43,6 +46,7 @@ NetworkUDPSocketHandler *_udp_master_socket = NULL; ///< udp master socket
|
||||
class MasterNetworkUDPSocketHandler : public NetworkUDPSocketHandler {
|
||||
protected:
|
||||
DECLARE_UDP_RECEIVE_COMMAND(PACKET_UDP_MASTER_ACK_REGISTER);
|
||||
DECLARE_UDP_RECEIVE_COMMAND(PACKET_UDP_MASTER_SESSION_KEY);
|
||||
public:
|
||||
virtual ~MasterNetworkUDPSocketHandler() {}
|
||||
};
|
||||
@ -56,6 +60,12 @@ DEF_UDP_RECEIVE_COMMAND(Master, PACKET_UDP_MASTER_ACK_REGISTER)
|
||||
if (!_settings_client.network.server_advertise) NetworkUDPRemoveAdvertise();
|
||||
}
|
||||
|
||||
DEF_UDP_RECEIVE_COMMAND(Master, PACKET_UDP_MASTER_SESSION_KEY)
|
||||
{
|
||||
_session_key = p->Recv_uint64();
|
||||
DEBUG(net, 2, "[udp] received new session key from master server");
|
||||
}
|
||||
|
||||
///*** Communication with clients (we are server) ***/
|
||||
|
||||
class ServerNetworkUDPSocketHandler : public NetworkUDPSocketHandler {
|
||||
@ -503,6 +513,7 @@ void NetworkUDPAdvertiseThread(void *pntr)
|
||||
p.Send_string(NETWORK_MASTER_SERVER_WELCOME_MESSAGE);
|
||||
p.Send_uint8 (NETWORK_MASTER_SERVER_VERSION);
|
||||
p.Send_uint16(_settings_client.network.server_port);
|
||||
p.Send_uint64(_session_key);
|
||||
|
||||
_network_udp_mutex->BeginCritical();
|
||||
if (_udp_master_socket != NULL) _udp_master_socket->SendPacket(&p, &out_addr);
|
||||
|
Loading…
Reference in New Issue
Block a user