-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Started whitelist code (WIP) #8
base: master
Are you sure you want to change the base?
Conversation
@danielga couple things I'm unsure about are my LUA->ThrowError usage and the whitelist read location. I'll be testing it out later. |
I think my ThrowError usage looks better now. |
I'll change the whitelist structure to a map of sets instead of vector of pairs. |
It's working. Started a game and it allowed the valid whitelisted address and blocked another valid non-whitelisted address. Switched the port in the whitelist and reloaded the map and the whitelist updated to the new port. Last thing to figure out is where to read the whitelist file from and then to update documentation. |
Anywhere in the base game folder, common/GarrysMod is accessible to lua so maybe AppData? Not sure. Right now it's reading from steamapps/common, idk if that's ideal or not. |
I'd prefer lua to not be able to read the whitelist. |
Also forgot to mention I haven't tested it on Linux since I don't have a linux installation. |
Isn't the executable directory enough to prevent Lua from reading the file? I don't remember any search path that has it. Also, can you give me examples of how the regex helps parsing the file (whitelist examples)? |
The full list is here https://wiki.garrysmod.com/page/File_Search_Paths . "EXECUTABLE_PATH" lets you get there. Here's a sample whitelist
|
Could probably change it to domain:port to be more conventional |
I've tried reading/opening a file with the |
Noticed |
Doesn't look like LUA->ThrowError is working. Any idea what's wrong? |
Ok I just realized my pcall(require is the reason it didn't error. I'll forward the error to ErrorNoHalt and test it tonight. |
I'm also going to add the * wildcard so you can do |
Looks like it's working. |
@Python1320 any comments/suggestions? |
Seems to crash on linux atm. Crashes whenever the module is loaded. |
Is there a specific way you have to build it? He just used premake5 gmake, then make -f gmcl_socket.core.make |
Sounds like a bug in the code. |
It works fine in windows though. |
Maybe garrysmod_common has some issue with Linux? @DaDamRival did you try with a valid whitelist with a valid entry? Would be good to try that and make sure its not the Lua->ThrowError that's crashing it. |
Different compilers have different behavior in undefined behavior situations. You could try executing the code on a Linux VM with a simple executable. |
I think he only tried loading it without the whitelist to see if it would error as expected but it crashed, but hopefully he'll reply with some more information here soon. |
Seems like that was indeed the issue. Works fine when the whitelist exists. |
@DaDamRival could you try replacing them with this? case PARSE_CANT_READ:
LUA->PushString("Failed to read whitelist file!");
LUA->Error();
break;
case PARSE_NO_ENTRIES:
LUA->PushString("Didn't find any valid entries in whitelist file!");
LUA->Error();
break; |
That doesn't work either unfortunately. Willox says ThrowError works fine for him in Linux, so perhaps its something wrong with garrysmod_common |
Besides a few issues with undefined symbols (I might need to add the whole-archive flag to the lua_shared project on garrysmod_common), the module loaded perfectly fine with a valid whitelist and threw an error properly with an invalid whitelist. |
Ok, let me know if anything needs to change. I'll have this version deployed on starfall meanwhile. |
Feel free to push modifications or reject if you have a different plan. I'm mostly just experimenting.
Closes: #7