C3-Client: some fixes
This commit is contained in:
parent
ded4b69aa3
commit
6d696d72c9
|
@ -462,6 +462,8 @@ def collectRelays(args, nonFatal = False):
|
||||||
|
|
||||||
gateway = getRequest(f'/api/gateway/{_gateway["agentId"]}')
|
gateway = getRequest(f'/api/gateway/{_gateway["agentId"]}')
|
||||||
|
|
||||||
|
if 'relays' not in gateway.keys() or len(gateway['relays']) == 0: continue
|
||||||
|
|
||||||
for relay in gateway['relays']:
|
for relay in gateway['relays']:
|
||||||
if len(relay_id) > 0:
|
if len(relay_id) > 0:
|
||||||
if relay["agentId"].lower() != relay_id.lower() and relay["name"].lower() != relay_id.lower():
|
if relay["agentId"].lower() != relay_id.lower() and relay["name"].lower() != relay_id.lower():
|
||||||
|
@ -511,14 +513,17 @@ def getCommandIdMapping(gateway, command):
|
||||||
return capability['commandIds'][command.lower()]
|
return capability['commandIds'][command.lower()]
|
||||||
|
|
||||||
def onPing(args):
|
def onPing(args):
|
||||||
if args.keep_pinging > 0:
|
try:
|
||||||
while True:
|
if args.keep_pinging > 0:
|
||||||
print(f'[.] Sending a ping every {args.keep_pinging} seconds.')
|
while True:
|
||||||
|
print(f'[.] Sending a ping every {args.keep_pinging} seconds.')
|
||||||
|
_onPing(args)
|
||||||
|
time.sleep(args.keep_pinging)
|
||||||
|
else:
|
||||||
|
print('[.] Pinging only once...')
|
||||||
_onPing(args)
|
_onPing(args)
|
||||||
time.sleep(args.keep_pinging)
|
except KeyboardInterrupt as e:
|
||||||
else:
|
print('[.] User stopped Pinging process.')
|
||||||
print('[.] Pinging only once...')
|
|
||||||
_onPing(args)
|
|
||||||
|
|
||||||
def _onPing(args):
|
def _onPing(args):
|
||||||
relays = collectRelays(args)
|
relays = collectRelays(args)
|
||||||
|
@ -871,11 +876,10 @@ def collectChannels(args, channelName):
|
||||||
if name.lower() != channelName.lower():
|
if name.lower() != channelName.lower():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
Logger.dbg(f'Adding channel {c["iid"]} in Relay {relay["name"]}.')
|
Logger.dbg(f'Adding channel {channel["iid"]} in Gateway {gateway["name"]}.')
|
||||||
channels.append({
|
channels.append({
|
||||||
'url' : f'/api/gateway/{gateway["agentId"]}/relay/{relay["agentId"]}/channel/{channel["iid"]}/command',
|
'url' : f'/api/gateway/{gateway["agentId"]}/channel/{channel["iid"]}/command',
|
||||||
'gateway' : gateway,
|
'gateway' : gateway,
|
||||||
'relay' : relay,
|
|
||||||
'channelId' : channel['iid'],
|
'channelId' : channel['iid'],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue