File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change 3
3
PORT_SPEC = re .compile (
4
4
"^" # Match full string
5
5
"(" # External part
6
- r"((?P<host>[a-fA-F\d.:]+):)?" # Address
6
+ r"(\[? (?P<host>[a-fA-F\d.:]+)\]? :)?" # Address
7
7
r"(?P<ext>[\d]*)(-(?P<ext_end>[\d]+))?:" # External range
8
8
")?"
9
9
r"(?P<int>[\d]+)(-(?P<int_end>[\d]+))?" # Internal range
Original file line number Diff line number Diff line change @@ -541,6 +541,12 @@ def test_split_port_with_ipv6_address(self):
541
541
assert internal_port == ["2000" ]
542
542
assert external_port == [("2001:abcd:ef00::2" , "1000" )]
543
543
544
+ def test_split_port_with_ipv6_square_brackets_address (self ):
545
+ internal_port , external_port = split_port (
546
+ "[2001:abcd:ef00::2]:1000:2000" )
547
+ assert internal_port == ["2000" ]
548
+ assert external_port == [("2001:abcd:ef00::2" , "1000" )]
549
+
544
550
def test_split_port_invalid (self ):
545
551
with pytest .raises (ValueError ):
546
552
split_port ("0.0.0.0:1000:2000:tcp" )
You can’t perform that action at this time.
0 commit comments