[hostlist] Add port value validation

When in console, and adding a new host with an invalid port number, the
console starts printing many exceptions regarding the value.
Therefor, we will make sure that the port value is between 0 and 65535.
This commit is contained in:
DjLegolas 2022-08-01 20:02:18 +03:00 committed by Calum Lind
parent 7af584d649
commit 38feea0fa4
No known key found for this signature in database
GPG Key ID: 90597A687B836BA3
1 changed files with 2 additions and 0 deletions

View File

@ -50,6 +50,8 @@ def validate_host_info(hostname, port):
if not isinstance(port, int): if not isinstance(port, int):
raise ValueError('Invalid port. Must be an integer') raise ValueError('Invalid port. Must be an integer')
if not 0 <= port <= 65535:
raise ValueError('Invalid port. Must be between 0-65535')
def migrate_hostlist(old_filename, new_filename): def migrate_hostlist(old_filename, new_filename):