perf: 优化提示

This commit is contained in:
ibuler
2023-03-22 14:56:20 +08:00
parent 180ded1773
commit ba076f6612
3 changed files with 14 additions and 5 deletions

View File

@@ -100,9 +100,17 @@ class JMSInventory:
host.update(self.make_proxy_command(gateway))
def asset_to_host(self, asset, account, automation, protocols, platform):
if protocols:
protocol = protocols[0].name
port = protocol[0].port
primary_protocol = [p for p in protocols if p.primary]
if len(primary_protocol) >= 1:
primary = primary_protocol[0]
elif protocols:
primary = protocols[0]
else:
primary = None
if primary:
protocol = primary.name
port = primary.port
else:
protocol = 'null'
port = 0