Skip to content

Commit

Permalink
fixes to ssh listenaddress handling
Browse files Browse the repository at this point in the history
  • Loading branch information
kiekerjan committed Jul 21, 2024
1 parent ff993f6 commit 2f18624
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
8 changes: 5 additions & 3 deletions management/status_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,14 @@ def check_ssh_running_extended(def_port, name):

# Check each address, and work with the first one found
for la in listenaddresses:
ipaddr, port = parse_listenaddress(la)

ipaddr, port, t = parse_listenaddress(la)
if not ipaddr:
continue

if not port:
if port:
port = int(port)
else:
port = def_port

if try_connect(ipaddr, port):
Expand Down
9 changes: 7 additions & 2 deletions management/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,13 @@ def parse_listenaddress(la_str):

if rightpos >= 0:
ip = la_str[leftpos:rightpos]
if len(la_str) > rightpos + 1:
port = la_str[rightpos + 1:]
if iptype == 4:
rightpos += 1
else:
rightpos += 2

if len(la_str) > rightpos:
port = la_str[rightpos:]

return ip, port, iptype

Expand Down

0 comments on commit 2f18624

Please sign in to comment.