From cbd5b7890a2769cfb5299292a2491b2857ec45b2 Mon Sep 17 00:00:00 2001 From: "@jhidalgo_umu" Date: Sun, 20 Apr 2025 18:56:24 +0200 Subject: [PATCH 1/2] sofia_hash not a method; new UI field --- DeviceManager.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/DeviceManager.py b/DeviceManager.py index c42318f..a5ff004 100755 --- a/DeviceManager.py +++ b/DeviceManager.py @@ -172,7 +172,7 @@ def local_ip(): ) -def sofia_hash(self, password): +def sofia_hash(password): md5 = hashlib.md5(bytes(password, "utf-8")).digest() chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" return "".join([chars[sum(x) % 62] for x in zip(md5[::2], md5[1::2])]) @@ -203,7 +203,6 @@ def GetAllAddr(): if "inet " in x and "127.0." not in x ] - def SearchXM(devices): server = socket(AF_INET, SOCK_DGRAM) server.bind(("", 34569)) @@ -438,6 +437,7 @@ def SearchBeward(devices): def ConfigXM(data): config = {} + #TODO: may be just copy whwole devices[data[1]] to config? for k in [u"HostName",u"HttpPort",u"MAC",u"MaxBps",u"MonMode",u"SSLPort",u"TCPMaxConn",u"TCPPort",u"TransferPlan",u"UDPPort","UseHSDownLoad"]: if k in devices[data[1]]: @@ -447,8 +447,9 @@ def ConfigXM(data): config[u"GateWay"] = SetIP(data[4]) config[u"HostIP"] = SetIP(data[2]) config[u"Submask"] = SetIP(data[3]) - config[u"Username"] = "admin" + config[u"Username"] = data[6] #"admin" config[u"Password"] = sofia_hash(data[5]) + devices[data[1]][u"GateWay"] = config[u"GateWay"] devices[data[1]][u"HostIP"] = config[u"HostIP"] devices[data[1]][u"Submask"] = config[u"Submask"] @@ -934,12 +935,16 @@ class GUITk: self.l5.grid(row=6, column=0, pady=3, padx=5, sticky=W + N) self.tcp = Entry(self.fr_config, width=5, font="6") self.tcp.grid(row=6, column=1, pady=3, padx=5, sticky=W + N) - self.l6 = Label(self.fr_config, text=_("Password")) + self.l6 = Label(self.fr_config, text=_("Username")) self.l6.grid(row=7, column=0, pady=3, padx=5, sticky=W + N) + self.username = Entry(self.fr_config, width=15, font="6") + self.username.grid(row=7, column=1, pady=3, padx=5, sticky=W + N) + self.l6 = Label(self.fr_config, text=_("Password")) + self.l6.grid(row=8, column=0, pady=3, padx=5, sticky=W + N) self.passw = Entry(self.fr_config, width=15, font="6") - self.passw.grid(row=7, column=1, pady=3, padx=5, sticky=W + N) + self.passw.grid(row=8, column=1, pady=3, padx=5, sticky=W + N) self.aply = Button(self.fr_config, text=_("Apply"), command=self.setconfig) - self.aply.grid(row=8, column=1, pady=3, padx=5, sticky="ew") + self.aply.grid(row=9, column=1, pady=3, padx=5, sticky="ew") self.l7 = Label(self.fr_tools, text=_("Vendor")) self.l7.grid(row=0, column=0, pady=3, padx=5, sticky="wns") @@ -1020,6 +1025,8 @@ class GUITk: self.http.insert(END, devices[dev]["HttpPort"]) self.tcp.delete(0, END) self.tcp.insert(END, devices[dev]["TCPPort"]) + self.username.delete(0, END) + self.username.insert(END, "admin") def setconfig(self): dev = self.table.item(self.table.selection()[0], option="values")[0] @@ -1034,6 +1041,7 @@ class GUITk: self.mask.get(), self.gate.get(), self.passw.get(), + self.username.get(), ] ) if result["Ret"] == 100: From 854d41f39d9d3b767da2bc08e168b388c08051a8 Mon Sep 17 00:00:00 2001 From: Dmitry Ilyin <6576495+widgetii@users.noreply.github.com> Date: Mon, 4 May 2026 09:46:54 +0300 Subject: [PATCH 2/2] DeviceManager: clean up Username field PR - Restore the blank line between GetAllAddr and SearchXM, drop the stray blank lines added in ConfigXM and the trailing whitespace on the new Password label grid call. - Rename the duplicated self.l6 used for the Username label to self.l8 so the Password label's self.l6 is no longer shadowed. - Prefill the Username entry from devices[dev] when the discovered value is available, falling back to "admin" only when missing. - Drop the inline #"admin" comment. Co-Authored-By: Claude Opus 4.7 (1M context) --- DeviceManager.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/DeviceManager.py b/DeviceManager.py index a5ff004..4811213 100755 --- a/DeviceManager.py +++ b/DeviceManager.py @@ -203,6 +203,7 @@ def GetAllAddr(): if "inet " in x and "127.0." not in x ] + def SearchXM(devices): server = socket(AF_INET, SOCK_DGRAM) server.bind(("", 34569)) @@ -437,7 +438,6 @@ def SearchBeward(devices): def ConfigXM(data): config = {} - #TODO: may be just copy whwole devices[data[1]] to config? for k in [u"HostName",u"HttpPort",u"MAC",u"MaxBps",u"MonMode",u"SSLPort",u"TCPMaxConn",u"TCPPort",u"TransferPlan",u"UDPPort","UseHSDownLoad"]: if k in devices[data[1]]: @@ -447,9 +447,8 @@ def ConfigXM(data): config[u"GateWay"] = SetIP(data[4]) config[u"HostIP"] = SetIP(data[2]) config[u"Submask"] = SetIP(data[3]) - config[u"Username"] = data[6] #"admin" + config[u"Username"] = data[6] config[u"Password"] = sofia_hash(data[5]) - devices[data[1]][u"GateWay"] = config[u"GateWay"] devices[data[1]][u"HostIP"] = config[u"HostIP"] devices[data[1]][u"Submask"] = config[u"Submask"] @@ -935,12 +934,12 @@ class GUITk: self.l5.grid(row=6, column=0, pady=3, padx=5, sticky=W + N) self.tcp = Entry(self.fr_config, width=5, font="6") self.tcp.grid(row=6, column=1, pady=3, padx=5, sticky=W + N) - self.l6 = Label(self.fr_config, text=_("Username")) - self.l6.grid(row=7, column=0, pady=3, padx=5, sticky=W + N) + self.l8 = Label(self.fr_config, text=_("Username")) + self.l8.grid(row=7, column=0, pady=3, padx=5, sticky=W + N) self.username = Entry(self.fr_config, width=15, font="6") self.username.grid(row=7, column=1, pady=3, padx=5, sticky=W + N) self.l6 = Label(self.fr_config, text=_("Password")) - self.l6.grid(row=8, column=0, pady=3, padx=5, sticky=W + N) + self.l6.grid(row=8, column=0, pady=3, padx=5, sticky=W + N) self.passw = Entry(self.fr_config, width=15, font="6") self.passw.grid(row=8, column=1, pady=3, padx=5, sticky=W + N) self.aply = Button(self.fr_config, text=_("Apply"), command=self.setconfig) @@ -1026,7 +1025,7 @@ class GUITk: self.tcp.delete(0, END) self.tcp.insert(END, devices[dev]["TCPPort"]) self.username.delete(0, END) - self.username.insert(END, "admin") + self.username.insert(END, devices[dev].get("Username", "admin")) def setconfig(self): dev = self.table.item(self.table.selection()[0], option="values")[0]