Skip to content

Commit c767cd4

Browse files
committed
Fix SRV hostname validation fails
1 parent fafa00e commit c767cd4

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

pymongo/asynchronous/srv_resolver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ async def _get_srv_response_and_hosts(
137137

138138
# Validate hosts
139139
for node in nodes:
140-
if self.__fqdn == node[0].lower():
140+
if self.__fqdn == node[0].lower() and len(node[0].split(".")) < 3:
141141
raise ConfigurationError(
142142
"Invalid SRV host: return address is identical to SRV hostname"
143143
)

pymongo/synchronous/srv_resolver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def _get_srv_response_and_hosts(
137137

138138
# Validate hosts
139139
for node in nodes:
140-
if self.__fqdn == node[0].lower():
140+
if self.__fqdn == node[0].lower() and len(node[0].split(".")) < 3:
141141
raise ConfigurationError(
142142
"Invalid SRV host: return address is identical to SRV hostname"
143143
)

0 commit comments

Comments
 (0)