-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* specify minimum tls version * feat: config supports tls * add httpOpts to function sigs * comment TLSVersion --------- Co-authored-by: Guy Edwards <guyfedwards@gmail.com>
- Loading branch information
1 parent
8455e6d
commit 6263b22
Showing
5 changed files
with
66 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package config | ||
|
||
import ( | ||
"crypto/tls" | ||
"fmt" | ||
) | ||
|
||
// CloudFlare blocks requests unless a minimum TLSVersion is specified. | ||
var tlsVersions map[string]uint16 = map[string]uint16{ | ||
"TLS 1.0": tls.VersionTLS10, | ||
"TLS 1.1": tls.VersionTLS11, | ||
"TLS 1.2": tls.VersionTLS12, | ||
"TLS 1.3": tls.VersionTLS13, | ||
} | ||
|
||
type HTTPOptions struct { | ||
//MinTLSVersion must be set to one of the strings returned by | ||
//tls.VersionName. "TLS 1.2" by default. | ||
MinTLSVersion string `yaml:"mintls,omitempty"` | ||
} | ||
|
||
// TLSVersion maps one of a few supported TLS version strings to the corresponding | ||
// standard TLS library constant so that an HTTP client can be configured. | ||
func TLSVersion(configStr string) (uint16, error) { | ||
if version, ok := tlsVersions[configStr]; ok { | ||
return version, nil | ||
} | ||
return 0, fmt.Errorf("unsupported tls version: %s", configStr) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters