Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Does RakNet have any validation to a new client? #114

Open
YurovRuslan opened this issue Jun 27, 2017 · 3 comments
Open

Does RakNet have any validation to a new client? #114

YurovRuslan opened this issue Jun 27, 2017 · 3 comments

Comments

@YurovRuslan
Copy link

YurovRuslan commented Jun 27, 2017

I wonder if RakNet-server has any validation when a new client wants to connect with it. Maybe some random number which client should pass back or smth else?
I'm not found it when searching via code and this situation was surprising for me.

@BigJoe01
Copy link

BigJoe01 commented Jun 27, 2017

Hi,
Raknet version validation working, check raknet version number.
Has password authentication.
In loop check "MessageIdentifiers.h" ID_NEW_INCOMING_CONNECTION packet, after receive send back client validation message, and drop player from server.

@YurovRuslan
Copy link
Author

YurovRuslan commented Jun 28, 2017

Morning!
What file is this loop in? RakPeer.cpp, yes?

@BigJoe01
Copy link

Like this, come from chat example

for (p=server->Receive(); p; server->DeallocatePacket(p), p=server->Receive())
{
// We got a packet, get the identifier with our handy function
packetIdentifier = GetPacketIdentifier(p);

		// Check if this is a network message packet
		switch (packetIdentifier)
		{
		case ID_DISCONNECTION_NOTIFICATION:
			// Connection lost normally
			printf("ID_DISCONNECTION_NOTIFICATION from %s\n", p->systemAddress.ToString(true));;
			break;


		case ID_NEW_INCOMING_CONNECTION:
			// Somebody connected.  We have their IP now
			printf("ID_NEW_INCOMING_CONNECTION from %s with GUID %s\n", p->systemAddress.ToString(true), p->guid.ToString());
			clientID=p->systemAddress; // Record the player ID of the client

			printf("Remote internal IDs:\n");
			for (int index=0; index < MAXIMUM_NUMBER_OF_INTERNAL_IDS; index++)
			{
				RakNet::SystemAddress internalId = server->GetInternalID(p->systemAddress, index);
				if (internalId!=RakNet::UNASSIGNED_SYSTEM_ADDRESS)
				{
					printf("%i. %s\n", index+1, internalId.ToString(true));
				}
			}

			break;

		case ID_INCOMPATIBLE_PROTOCOL_VERSION:
			printf("ID_INCOMPATIBLE_PROTOCOL_VERSION\n");
			break;

		case ID_CONNECTED_PING:
		case ID_UNCONNECTED_PING:
			printf("Ping from %s\n", p->systemAddress.ToString(true));
			break;

		case ID_CONNECTION_LOST:
			// Couldn't deliver a reliable packet - i.e. the other system was abnormally
			// terminated
			printf("ID_CONNECTION_LOST from %s\n", p->systemAddress.ToString(true));;
			break;

		default:
			// The server knows the static data of all clients, so we can prefix the message
			// With the name data
			printf("%s\n", p->data);

			// Relay the message.  We prefix the name for other clients.  This demonstrates
			// That messages can be changed on the server before being broadcast
			// Sending is the same as before
			sprintf(message, "%s", p->data);
			server->Send(message, (const int) strlen(message)+1, HIGH_PRIORITY, RELIABLE_ORDERED, 0, p->systemAddress, true);

			break;
		}

	}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants