12
12
# See the License for the specific language governing permissions and
13
13
# limitations under the License.
14
14
15
- from re import search , sub , Match
16
- from typing import Optional , Dict
15
+ from re import Match , search , sub
16
+ from typing import Dict , Optional
17
17
18
18
from aws_advanced_python_wrapper .utils .rds_url_type import RdsUrlType
19
19
@@ -59,37 +59,37 @@ class RdsUtils:
59
59
"""
60
60
61
61
AURORA_DNS_PATTERN = r"(?P<instance>.+)\." \
62
- r"(?P<dns>proxy-|cluster-|cluster-ro-|cluster-custom-)?" \
62
+ r"(?P<dns>proxy-|cluster-|cluster-ro-|cluster-custom-|limitless- )?" \
63
63
r"(?P<domain>[a-zA-Z0-9]+\." \
64
- r"(?P<region>[a-zA-Z0-9\-]+)\.rds\.amazonaws\.com)(?!\.cn$ )"
64
+ r"(?P<region>[a-zA-Z0-9\-]+)\.rds\.amazonaws\.com)(?!\.cn)"
65
65
AURORA_INSTANCE_PATTERN = r"(?P<instance>.+)\." \
66
66
r"(?P<domain>[a-zA-Z0-9]+\." \
67
- r"(?P<region>[a-zA-Z0-9\-]+)\.rds\.amazonaws\.com)(?!\.cn$ )"
67
+ r"(?P<region>[a-zA-Z0-9\-]+)\.rds\.amazonaws\.com)(?!\.cn)"
68
68
AURORA_CLUSTER_PATTERN = r"(?P<instance>.+)\." \
69
69
r"(?P<dns>cluster-|cluster-ro-)+" \
70
70
r"(?P<domain>[a-zA-Z0-9]+\." \
71
- r"(?P<region>[a-zA-Z0-9\-]+)\.rds\.amazonaws\.com)(?!\.cn$ )"
71
+ r"(?P<region>[a-zA-Z0-9\-]+)\.rds\.amazonaws\.com)(?!\.cn)"
72
72
AURORA_CUSTOM_CLUSTER_PATTERN = r"(?P<instance>.+)\." \
73
73
r"(?P<dns>cluster-custom-)+" \
74
74
r"(?P<domain>[a-zA-Z0-9]+\." \
75
- r"(?P<region>[a-zA-Z0-9\-]+)\.rds\.amazonaws\.com)(?!\.cn$ )"
75
+ r"(?P<region>[a-zA-Z0-9\-]+)\.rds\.amazonaws\.com)(?!\.cn)"
76
76
AURORA_PROXY_DNS_PATTERN = r"(?P<instance>.+)\." \
77
77
r"(?P<dns>proxy-)+" \
78
78
r"(?P<domain>[a-zA-Z0-9]+\." \
79
- r"(?P<region>[a-zA-Z0-9\\-]+)\.rds\.amazonaws\.com)(?!\.cn$ )"
80
- AURORA_CHINA_DNS_PATTERN = r"(?P<instance>.+)\." \
81
- r"(?P<dns>proxy-|cluster-|cluster-ro-|cluster-custom-)?" \
79
+ r"(?P<region>[a-zA-Z0-9\\-]+)\.rds\.amazonaws\.com)(?!\.cn)"
80
+ AURORA_OLD_CHINA_DNS_PATTERN = r"(?P<instance>.+)\." \
81
+ r"(?P<dns>proxy-|cluster-|cluster-ro-|cluster-custom-|limitless- )?" \
82
82
r"(?P<domain>[a-zA-Z0-9]+\." \
83
83
r"(?P<region>[a-zA-Z0-9\-]+)\.rds\.amazonaws\.com\.cn)"
84
- AURORA_OLD_CHINA_DNS_PATTERN = r"(?P<instance>.+)\." \
85
- r"(?P<dns>proxy-|cluster-|cluster-ro-|cluster-custom-)?" \
84
+ AURORA_CHINA_DNS_PATTERN = r"(?P<instance>.+)\." \
85
+ r"(?P<dns>proxy-|cluster-|cluster-ro-|cluster-custom-|limitless- )?" \
86
86
r"(?P<domain>[a-zA-Z0-9]+\." \
87
87
r"rds\.(?P<region>[a-zA-Z0-9\-]+)\.amazonaws\.com\.cn)"
88
- AURORA_CHINA_CLUSTER_PATTERN = r"(?P<instance>.+)\." \
88
+ AURORA_OLD_CHINA_CLUSTER_PATTERN = r"(?P<instance>.+)\." \
89
89
r"(?P<dns>cluster-|cluster-ro-)+" \
90
90
r"(?P<domain>[a-zA-Z0-9]+\." \
91
91
r"(?P<region>[a-zA-Z0-9\-]+)\.rds\.amazonaws\.com\.cn)"
92
- AURORA_OLD_CHINA_CLUSTER_PATTERN = r"(?P<instance>.+)\." \
92
+ AURORA_CHINA_CLUSTER_PATTERN = r"(?P<instance>.+)\." \
93
93
r"(?P<dns>cluster-|cluster-ro-)+" \
94
94
r"(?P<domain>[a-zA-Z0-9]+\." \
95
95
r"rds\.(?P<region>[a-zA-Z0-9\-]+)\.amazonaws\.com\.cn)"
@@ -105,7 +105,7 @@ class RdsUtils:
105
105
106
106
IP_V4 = r"^(([1-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){1}" \
107
107
r"(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){2}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])"
108
- IP_V6 = r"^[0-9a-fA-F]{1,4}(:[0-9a-fA-F]{1,4}){7}$ "
108
+ IP_V6 = r"^[0-9a-fA-F]{1,4}(:[0-9a-fA-F]{1,4}){7}"
109
109
IP_V6_COMPRESSED = r"^(([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,5})?)::(([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,5})?)"
110
110
111
111
DNS_GROUP = "dns"
@@ -203,7 +203,7 @@ def is_ipv4(self, host: str) -> bool:
203
203
def is_ipv6 (self , host : str ) -> bool :
204
204
if host is None or not host .strip ():
205
205
return False
206
- return search (RdsUtils .IP_V6_COMPRESSED , host ) is not None and search (RdsUtils .IP_V6 , host ) is not None
206
+ return search (RdsUtils .IP_V6_COMPRESSED , host ) is not None or search (RdsUtils .IP_V6 , host ) is not None
207
207
208
208
def is_dns_pattern_valid (self , host : str ) -> bool :
209
209
return "?" in host
@@ -244,6 +244,8 @@ def _find(self, host: str, patterns: list):
244
244
return None
245
245
246
246
def _get_regex_group (self , pattern : Match [str ], group_name : str ):
247
+ if pattern is None :
248
+ return None
247
249
return pattern .group (group_name )
248
250
249
251
def _get_group (self , host : str , group : str ):
0 commit comments