Don Newton | 379ae25 | 2019-04-01 12:17:06 -0400 | [diff] [blame^] | 1 | // Copyright (C) MongoDB, Inc. 2017-present. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 4 | // not use this file except in compliance with the License. You may obtain |
| 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | |
| 7 | package description |
| 8 | |
| 9 | import ( |
| 10 | "fmt" |
| 11 | ) |
| 12 | |
| 13 | // MaxStalenessSupported returns an error if the given server version |
| 14 | // does not support max staleness. |
| 15 | func MaxStalenessSupported(wireVersion *VersionRange) error { |
| 16 | if wireVersion != nil && wireVersion.Max < 5 { |
| 17 | return fmt.Errorf("max staleness is only supported for servers 3.4 or newer") |
| 18 | } |
| 19 | |
| 20 | return nil |
| 21 | } |
| 22 | |
| 23 | // ScramSHA1Supported returns an error if the given server version |
| 24 | // does not support scram-sha-1. |
| 25 | func ScramSHA1Supported(wireVersion *VersionRange) error { |
| 26 | if wireVersion != nil && wireVersion.Max < 3 { |
| 27 | return fmt.Errorf("SCRAM-SHA-1 is only supported for servers 3.0 or newer") |
| 28 | } |
| 29 | |
| 30 | return nil |
| 31 | } |
| 32 | |
| 33 | // SessionsSupported returns true of the given server version indicates that it supports sessions. |
| 34 | func SessionsSupported(wireVersion *VersionRange) bool { |
| 35 | return wireVersion != nil && wireVersion.Max >= 6 |
| 36 | } |