From 0e8bdf7fe5bfbf70e2b85e930b84f66c579328a8 Mon Sep 17 00:00:00 2001 From: Swann Date: Thu, 2 Jul 2020 10:12:08 +0200 Subject: [PATCH] feat: IPC port is now verified on update. feat: A wrong ip is filled with the default one 127.0.0.1 --- multi_user/preferences.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/multi_user/preferences.py b/multi_user/preferences.py index f7f0003..e915180 100644 --- a/multi_user/preferences.py +++ b/multi_user/preferences.py @@ -53,6 +53,15 @@ def update_ip(self, context): self['ip'] = ip.group() else: logging.error("Wrong IP format") + self['ip'] = "127.0.0.1" + +def update_port(self, context): + max_port = self.port + 3 + + if self.ipc_port < max_port and \ + self['ipc_port'] >= self.port: + logging.error("IPC Port in conflic with the port, assigning a random value") + self['ipc_port'] = random.randrange(self.port+4, 10000) class ReplicatedDatablock(bpy.types.PropertyGroup): type_name: bpy.props.StringProperty() @@ -101,7 +110,8 @@ class SessionPrefs(bpy.types.AddonPreferences): ipc_port: bpy.props.IntProperty( name="ipc_port", description='internal ttl port(only usefull for multiple local instances)', - default=5561 + default=5561, + update=update_port ) init_method: bpy.props.EnumProperty( name='init_method',