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(
133
133
) -> tuple [resolver .Answer , list [tuple [str , Any ]]]:
134
134
results = await self ._resolve_uri (encapsulate_errors )
135
135
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
+
136
141
# Construct address tuples
137
142
nodes = [
138
143
(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(
133
133
) -> tuple [resolver .Answer , list [tuple [str , Any ]]]:
134
134
results = self ._resolve_uri (encapsulate_errors )
135
135
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
+
136
141
# Construct address tuples
137
142
nodes = [
138
143
(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):
588
588
},
589
589
{
590
590
"query" : "_mongodb._tcp.mongo.local" ,
591
- "mock_target" : "mongo.local" ,
591
+ "mock_target" : "foo. mongo.local" ,
592
592
"expected_error" : "Invalid SRV host" ,
593
593
},
594
594
]
You can’t perform that action at this time.
0 commit comments