Whitelist plugin

Started by NicusorN5, Sep 24, 2021, 10:59 PM

Previous topic - Next topic

NicusorN5

Hello everyone!

I created a whitelist plugin that will allow only some specified IPs and players into your server.

Purpose


I wrote this plugin just to relax from other demanding projects like my own game engine and game projects. This took me few days to create because of stupid mistakes I made (reading the files, but not copying the data into the containers, as one example).

Now you might say, "passwording servers is enough" -> yes might be. But what if your friend that's scripting his server has a password made of a LaTeX equation? like this one :
Quote\int e^{x^2} dx = \sum_{n=0}^{\infty}\frac{x^{2n+1}}{n!(2n+1)} + C

or that his password is an entire quote taken from an dubious barely known book? And he can't find the password in his 12k lines of code script that was made from forum snippets? (No one would do that ever (I mean the password thing))

Or maybe you're too lazy to use a single function call in your scripts (i.e SetPassword(string) )

Now again, you might say "I can make this in squirrel too" -> Well this one automatically gets the local IP lol (useless feature probably). Can you do that in Squirrel?

An other reason is that whitelisting is fairly common in multiplayer games like Minecraft, etc.

If you're not convinced f*ck you (/s). (slash s = sarcasm)  (I'm having fun writing this) (Can't wait for the mods to remove the hidden texts)

Well, if you're convinced, here's what you need : this plugin.

Usage


Installation:

Copy the plugin binary compatible with your server into <server root>\plugins\ .
You may need to install the latest MSVC redistributables. Link : https://support.microsoft.com/en-us/topic/the-latest-supported-visual-c-downloads-2647da03-1eea-4433-9aff-95f26a218cc0

First use:

Upon running the server for the first time, the plugin will automatically create 2 files called : allowed_ips.txt and allowed_nicks.txt .

The file allowed_ips is filled with all the local IPs (192.168.1.6 as a example)+ localhost IP (127.0.0.1) and allowed_nicks is filled with 2 example nicknames.

Modifying the whitelist:

Modifying the whitelist requires opening and editing the two created files ( allowed_ips.txt and allowed_nicks.txt ) with your editor of choice(ex. MS Notepad, Notepad++, VS Code, et cetera).

For performance reasons, unlike INIParser, this plugin will keep the whitelists in it's memory instead of continuously reading the files. Therefore modifying the whitelist would require restarting the server after the files are saved!



Future development


If needed Linux support might be taken in consideration. But until then (because probably no one would want this plugin)... That's like the single version that is ever released of this plugin.

Links


Links are here:

Github (source code): https://github.com/NicusorN5/VCMPWhitelistPlugin
Github releases : https://github.com/NicusorN5/VCMPWhitelistPlugin/releases/


habi

#1
Nice attempt. with char* and non null terminated strings.
But why do you #include "whitelist.h" in main.h and #include "main.h" in whitelist.h. i feel like laughing.

Include every .h file inside main.h and at last including main.h in every .cpp.

Xmair

Quote from: habi on Feb 26, 2022, 10:56 AMInclude every .h file inside main.h and at last including main.h in every .cpp.
.. what

Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD

habi

See  i have main.cpp, game.cpp, functions.cpp and events.cpp and i have main.h, game.h, functions.h and events.h
game.h contains header of functions and classes in game.cpp
functions.h contain that of functions.cpp
And so on.
So in main.h i will
#ifndef MAIN_H
#def MAIN_H
#include "game.h"
#include "function.h"
#include "events.h"
//other stuff
#endif
In main.cpp
#include "main.h"In game.cpp,
#include "main.h"In functions.cpp and events.cpp also,
#include "main.h"Problem solved!..

NicusorN5

I honestly don't remember, This compiles though.

What not null terminated C-strings are you talking about though?

habi

uint8_t CheckPlayer(char* name, size_t name_s, const char* password, const char* ip)
{
//Make a copy of the name, since the size_t parameter tells me this is not a null-terminated string
char* namebuff = new char[name_s + 1];

NicusorN5

Ah yes, I wasn't sure if the player name is null terminated or not (when getting it from the VCMP api call).

Also, who says that strings that aren't null terminated are bad? Windows's system (NtCreateFile for example uses UNICODE_STRING that is a struct that contains a char pointer and a size)

.

#7
Quote from: Xmair on Feb 26, 2022, 11:17 AM
Quote from: habi on Feb 26, 2022, 10:56 AMInclude every .h file inside main.h and at last including main.h in every .cpp.
.. what

He means there's a cyclical header dependency. Header A includes header B and header B includes header A.

Quote from: Athanatos on Mar 01, 2022, 06:21 AMI honestly don't remember, This compiles though.

What not null terminated C-strings are you talking about though?

You're probably using MSVC to compile. Well, MSVC compiles everything. Even broken or non-standard code. That's why I don't use it much. The moment you try to migrate to other compilers or platforms you'll see what "compiles everything" does to code.
.

NicusorN5

Quote from: . on Mar 02, 2022, 07:35 PMYou're probably using MSVC to compile. Well, MSVC compiles everything. Even broken or non-standard code.
Ight you caught me