Skip to content

Commit

Permalink
requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
aditi-khare-mongoDB committed Sep 3, 2024
1 parent da90490 commit ff800b4
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 34 deletions.
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"cSpell.words": [
"domainname"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ ______________________________________________________________________

Presently, seeding a driver with an initial list of ReplicaSet or MongoS addresses is somewhat cumbersome, requiring a
comma-delimited list of host names to attempt connections to. A standardized answer to this problem exists in the form
of SRV records, which allow administrators to configure a single domain to return a list of host names. Supporting this
feature would assist our users by decreasing maintenance load, primarily by removing the need to maintain seed lists at
an application level.
of SRV records, which allow administrators to configure a single hostname to return a list of host names. Supporting
this feature would assist our users by decreasing maintenance load, primarily by removing the need to maintain seed
lists at an application level.

This specification builds on the [Connection String](../connection-string/connection-string-spec.md) specification. It
adds a new protocol scheme and modifies how the
Expand All @@ -37,6 +37,30 @@ mongodb+srv://{subdomain}.{domainname}/{options}
`{options}` refers to the optional elements from the [Connection String](../connection-string/connection-string-spec.md)
specification following the `Host Information`. This includes the `Auth database` and `Connection Options`.

For the purposes of this document, `{hostname}` will be divided using the following terminology. If an SRV `{hostname}`
has:

1. Three or more `.` separated parts, then the left-most part is the `{subdomain}` and the remaining portion is the
`{domainname}`.

- Examples:
- `{hostname}` = `cluster_1.tests.mongodb.co.uk`

- `{subdomain}` = `cluster_1`
- `{domainname}` = `tests.mongodb.co.uk`

- `{hostname}` = `hosts_34.example.com`

- `{subdomain}` = `hosts_34`
- `{domainname}` = `example.com`

2. One or two `.` separated part(s), then the `{hostname}` is equivalent to the `{domainname}`, and there is no
subdomain.

- Examples:
- `{hostname}` = `{domainname}` = `localhost`
- `{hostname}` = `{domainname}` = `mongodb.local`

### MongoClient Configuration

#### srvMaxHosts
Expand Down Expand Up @@ -87,24 +111,6 @@ If `mongodb+srv` is used, a driver MUST implicitly also enable TLS. Clients can
either the Connection String, or options passed in as parameters in code to the MongoClient constructor (or equivalent
API for each driver), but not through a TXT record (discussed in a later section).

#### Terminology

For the purposes of this document, `{hostname}` will be divided using the following terminology.

If an SRV `{hostname}` has:

- 3 or more `.` separated parts:
- the left-most part is the `{subdomain}`
- the remaining portion is the `{domain}`
- examples:
- `{cluster_1.tests.mongodb.co.uk}`
- `{hosts_34.example.com}`
- have 1 or 2 `.` separated part(s):
- the `{hostname}` is equivalent to the `{domain}`
- examples:
- `{localhost}`
- `{mongodb.local}`

#### Querying DNS

In this preprocessing step, the driver will query the DNS server for SRV records on the hostname, prefixed with the SRV
Expand All @@ -122,9 +128,10 @@ A driver MUST verify that the host names returned through SRV records end with t
Drivers MUST raise an error and MUST NOT initiate a connection to any returned host name which does not share the same
`{domainname}`.

In the case that the SRV record has less than three `.` separated parts, the returned address MUST NOT be identical to
the original `{hostname}`. The next major version should the host names returned through all SRVs require to end with
the entire `{hostname}`.
In the case that the SRV record has less than three `.` separated parts, the returned address MUST must end with the
SRV's entire `{hostname}` and MUST NOT be identical to the original `{hostname}`. The next major version MUST no longer
allow an SRV record, with any number of parts, to return address that doesn't end with the SRVs' entire `{hostname}`.
Drivers MUST document this in a prior minor release.

The driver MUST NOT attempt to connect to any hosts until the DNS query has returned its results.

Expand Down
24 changes: 14 additions & 10 deletions source/initial-dns-seedlist-discovery/tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,32 @@ Seedlist Discovery spec.

### Prose Tests

1. When given the following valid SRVs, parse the connection string without throwing a parse related error.
For the following prose tests, it is assumed drivers are be able to stub DNS results to easily test invalid DNS
resolution results.

a. Only one domain level (ex: `mongodb+srv://localhost`).
1. When given the following valid SRVs, the pre-DNS SRV validation step not cause any errors.

b. Only two domain levels (ex: `mongodb+srv://mongo.local`).
a. Only one domain level: `mongodb+srv://localhost`.

b. Only two domain levels: `mongodb+srv://mongo.local`.

<br />

2. When given an SRV that does NOT end with the original SRV's `{domainname}`, throw a runtime error.
2. For the following steps, run each of these cases: SRVs with one, two, and three `.` separated parts.

For example, the SRV `mongodb+srv://blogs.mongodb.com` resolving to `blogs.evil.com` should prompt an error.
When given an SRV that does NOT end with the original SRV's domain name, throw a runtime error.

Run this test for the following test cases: SRVs with one, two, and three `.` separated parts.
For example, the SRV `mongodb+srv://blogs.mongodb.com` resolving to `blogs.evil.com` should prompt an error, since
the returned address does not end with `mongodb.com`.

<br />

3. When given an SRV with less than three `.` separated parts that returns identical address to the original
`{hostname}`, throw a runtime error.
3. For the following steps, run each of these cases: SRVs with one, and two `.` separated parts.

For example, the SRV `mongodb+srv://mongo.local` resolving to `mongo.local` should prompt an error.
When given an SRV that returns identical address to the original hostname, throw a runtime error.

Run this test for both cases: one and two `.` separated parts.
For example, the SRV `mongodb+srv://mongo.local` resolving to `mongo.local` should prompt an error since it is
identical to the original hostname.

## Test Setup

Expand Down

0 comments on commit ff800b4

Please sign in to comment.