File tree Expand file tree Collapse file tree 3 files changed +11
-1
lines changed Expand file tree Collapse file tree 3 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -133,6 +133,11 @@ async def _get_srv_response_and_hosts(
133133 ) -> tuple [resolver .Answer , list [tuple [str , Any ]]]:
134134 results = await self ._resolve_uri (encapsulate_errors )
135135
136+ if self .__fqdn == results [0 ].target .to_text ():
137+ raise ConfigurationError (
138+ "Invalid SRV host: return address is identical to SRV hostname"
139+ )
140+
136141 # Construct address tuples
137142 nodes = [
138143 (maybe_decode (res .target .to_text (omit_final_dot = True )), res .port ) # type: ignore[attr-defined]
Original file line number Diff line number Diff line change @@ -133,6 +133,11 @@ def _get_srv_response_and_hosts(
133133 ) -> tuple [resolver .Answer , list [tuple [str , Any ]]]:
134134 results = self ._resolve_uri (encapsulate_errors )
135135
136+ if self .__fqdn == results [0 ].target .to_text ():
137+ raise ConfigurationError (
138+ "Invalid SRV host: return address is identical to SRV hostname"
139+ )
140+
136141 # Construct address tuples
137142 nodes = [
138143 (maybe_decode (res .target .to_text (omit_final_dot = True )), res .port ) # type: ignore[attr-defined]
Original file line number Diff line number Diff line change @@ -588,7 +588,7 @@ def test_error_when_return_address_does_not_end_with_srv_domain(self):
588588 },
589589 {
590590 "query" : "_mongodb._tcp.mongo.local" ,
591- "mock_target" : "mongo.local" ,
591+ "mock_target" : "foo. mongo.local" ,
592592 "expected_error" : "Invalid SRV host" ,
593593 },
594594 ]
You can’t perform that action at this time.
0 commit comments