JackJohnsn Posted January 31, 2021 Share Posted January 31, 2021 (edited) I have multiple dedicated servers, and I want to restrict each of them to a region based on geolocation. I see that dedicated servers sometimes print a message like CLOSE_CONNECTION_WITH_REASON, followed by a reason. At this point the client's ID and IP is received by the server. I was wondering if I can hook into this step and manually reject connections from a range of IPs. Any help is appreciated. Edited January 31, 2021 by JackJohnsn Link to comment https://forums.kleientertainment.com/forums/topic/126601-how-can-i-reject-a-clients-authentication-on-a-dedicated-server/ Share on other sites More sharing options...
penguin0616 Posted January 31, 2021 Share Posted January 31, 2021 I believe there's a way to do this, albeit a way that clients are capable of circumventing thanks to how I'm thinking of it. Is there a particular reason you're trying to do this, or a situation you're trying to encounter/avoid? 1 Link to comment https://forums.kleientertainment.com/forums/topic/126601-how-can-i-reject-a-clients-authentication-on-a-dedicated-server/#findComment-1423758 Share on other sites More sharing options...
JackJohnsn Posted February 1, 2021 Author Share Posted February 1, 2021 4 hours ago, penguin0616 said: Is there a particular reason you're trying to do this, or a situation you're trying to encounter/avoid? Just trying to lock each server to its specified region. Specifically on SEA. Could you please provide some info about your method? Link to comment https://forums.kleientertainment.com/forums/topic/126601-how-can-i-reject-a-clients-authentication-on-a-dedicated-server/#findComment-1423804 Share on other sites More sharing options...
penguin0616 Posted February 1, 2021 Share Posted February 1, 2021 (edited) You can use TheNet:GetCountryCode() as a method of determining a client's country. It isn't perfect but I believe it is your best bet. A server mod with all_clients_require_mod could perform the check provided it is running on a client, and if not correct, disconnect the user. Only issue is you'd have to come up with a table of all the country codes, and I don't know how they choose them. Edited February 1, 2021 by penguin0616 1 Link to comment https://forums.kleientertainment.com/forums/topic/126601-how-can-i-reject-a-clients-authentication-on-a-dedicated-server/#findComment-1423806 Share on other sites More sharing options...
JackJohnsn Posted February 2, 2021 Author Share Posted February 2, 2021 On 2/1/2021 at 8:21 AM, penguin0616 said: You can use TheNet:GetCountryCode() as a method of determining a client's country Thanks, but I'm mostly interested in how and when to execute the code. Such as when you use AddClassPostConstruct() to modify a class's constructor. So basically where should I attach my custom function to? Link to comment https://forums.kleientertainment.com/forums/topic/126601-how-can-i-reject-a-clients-authentication-on-a-dedicated-server/#findComment-1424338 Share on other sites More sharing options...
penguin0616 Posted February 2, 2021 Share Posted February 2, 2021 (edited) Quote So basically where should I attach my custom function to? You can attach it pretty much anywhere you want, you just have to do *something* when the mod gets loaded on the client. Quote but I'm mostly interested in how and when to execute the code The only how/when condition that's worth worrying about is making sure your mod instance is running on a client, which you can verify with a standard mastersim check. Doing the check on a server could end up leading to a crash, which is probably not desired. Spoiler If you don't have any preference or have no clue on where you want to put your function, you can use an AddSimPostInit. Though that will mean the client is in the server longer before you get to do a check. Edited February 2, 2021 by penguin0616 1 Link to comment https://forums.kleientertainment.com/forums/topic/126601-how-can-i-reject-a-clients-authentication-on-a-dedicated-server/#findComment-1424361 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now