Strip IPv6 [] correctly even with non-4-character segments (#9249)

* Strip IPv6 [] correctly even with non-4-character segments

For example, the existing code failed to properly strip
`[____:____:____:600:____:a2:____:____]` resulting in the trailing `]`
below.  (four character segments and node id redacted with `_`)

```
FULL_NODE ____:____:____:600:____:a2:____:____]   8444/8444  ________... Nov 12 20:46:47      1.5|18.9
                                                 -SB Height:  1131954    -Hash: 344cbef3...
```

* Simply IPv6 strip

Technically this hazards stripping multiple brackets from either end or a right bracket from the left, etc.  Perhaps this is ok.
This commit is contained in:
Kyle Altendorf 2021-11-19 14:14:57 -05:00 committed by GitHub
parent 4b389c8fc0
commit d45f8db533
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -118,8 +118,7 @@ async def show_async(
host = con["peer_host"]
# Strip IPv6 brackets
if host[0] == "[":
host = host[1:39]
host = host.strip("[]")
# Nodetype length is 9 because INTRODUCER will be deprecated
if NodeType(con["type"]) is NodeType.FULL_NODE:
peak_height = con["peak_height"]