Dinnerbone / mcstatus

A Python class for checking the status of an enabled Minecraft server
http://dinnerbone.com/minecraft/tools/status/
1.11k stars 146 forks source link

Ensure the address is valid on server init #190

Closed ItsDrike closed 2 years ago

ItsDrike commented 2 years ago

Closes #189

As shown in the issue, not having any checks for valid values of the server's address can lead to the instance being made without any hint of an error, even though it has unexpected internal values which will be causing issues later. Whenever this happens, since the error will only appear in later usage of this instance, It will not be easy to recognize what's going on. To prevent this, this PR adds a function which simply raises an exception during initialization if the values aren't valid, therefore preventing even the creation of an instance with invalid values.

Note: I've also used regex to ensure that the host address is valid, however I'm not entirely sure if this pattern catches all possible host values correctly, so please make sure to test this before approving the PR.

kevinkjt2000 commented 2 years ago

Thanks again!