Skip to content

Commit 345a054

Browse files
committed
Export tlscommon.TLSCurveType
1 parent b7f794b commit 345a054

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

transport/tlscommon/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ type Config struct {
3232
CipherSuites []CipherSuite `config:"cipher_suites" yaml:"cipher_suites,omitempty"`
3333
CAs []string `config:"certificate_authorities" yaml:"certificate_authorities,omitempty"`
3434
Certificate CertificateConfig `config:",inline" yaml:",inline"`
35-
CurveTypes []tlsCurveType `config:"curve_types" yaml:"curve_types,omitempty"`
35+
CurveTypes []TLSCurveType `config:"curve_types" yaml:"curve_types,omitempty"`
3636
Renegotiation TLSRenegotiationSupport `config:"renegotiation" yaml:"renegotiation"`
3737
CASha256 []string `config:"ca_sha256" yaml:"ca_sha256,omitempty"`
3838
CATrustedFingerprint string `config:"ca_trusted_fingerprint" yaml:"ca_trusted_fingerprint,omitempty"`

transport/tlscommon/server_config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ type ServerConfig struct {
3434
CipherSuites []CipherSuite `config:"cipher_suites" yaml:"cipher_suites,omitempty"`
3535
CAs []string `config:"certificate_authorities" yaml:"certificate_authorities,omitempty"`
3636
Certificate CertificateConfig `config:",inline" yaml:",inline"`
37-
CurveTypes []tlsCurveType `config:"curve_types" yaml:"curve_types,omitempty"`
37+
CurveTypes []TLSCurveType `config:"curve_types" yaml:"curve_types,omitempty"`
3838
ClientAuth *TLSClientAuth `config:"client_authentication" yaml:"client_authentication,omitempty"` //`none`, `optional` or `required`
3939
CASha256 []string `config:"ca_sha256" yaml:"ca_sha256,omitempty"`
4040
}

transport/tlscommon/types.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,12 @@ func init() {
9696
}
9797
}
9898

99-
var supportedCurveTypes = make(map[tlsCurveType]string, len(tlsCurveTypes))
100-
var tlsCurveTypes = map[string]tlsCurveType{
101-
"P-256": tlsCurveType(tls.CurveP256),
102-
"P-384": tlsCurveType(tls.CurveP384),
103-
"P-521": tlsCurveType(tls.CurveP521),
104-
"X25519": tlsCurveType(tls.X25519),
99+
var supportedCurveTypes = make(map[TLSCurveType]string, len(tlsCurveTypes))
100+
var tlsCurveTypes = map[string]TLSCurveType{
101+
"P-256": TLSCurveType(tls.CurveP256),
102+
"P-384": TLSCurveType(tls.CurveP384),
103+
"P-521": TLSCurveType(tls.CurveP521),
104+
"X25519": TLSCurveType(tls.X25519),
105105
}
106106

107107
var tlsRenegotiationSupportTypes = map[string]TLSRenegotiationSupport{
@@ -272,9 +272,9 @@ func (cs CipherSuite) String() string {
272272
return unknownType
273273
}
274274

275-
type tlsCurveType tls.CurveID
275+
type TLSCurveType tls.CurveID
276276

277-
func (ct *tlsCurveType) Unpack(i interface{}) error {
277+
func (ct *TLSCurveType) Unpack(i interface{}) error {
278278
switch o := i.(type) {
279279
case string:
280280
t, found := tlsCurveTypes[o]
@@ -284,16 +284,16 @@ func (ct *tlsCurveType) Unpack(i interface{}) error {
284284

285285
*ct = t
286286
case int64:
287-
*ct = tlsCurveType(o)
287+
*ct = TLSCurveType(o)
288288
case uint64:
289-
*ct = tlsCurveType(o)
289+
*ct = TLSCurveType(o)
290290
default:
291291
return fmt.Errorf("tls curve type is an unsupported input type: %T", o)
292292
}
293293
return nil
294294
}
295295

296-
func (ct *tlsCurveType) Validate() error {
296+
func (ct *TLSCurveType) Validate() error {
297297
if _, ok := supportedCurveTypes[*ct]; !ok {
298298
return fmt.Errorf("unsupported curve type: %s", tls.CurveID(*ct).String())
299299
}

transport/tlscommon/types_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ func Test_tlsCurveType_Unpack(t *testing.T) {
462462
name string
463463
hasErr bool
464464
in interface{}
465-
exp tlsCurveType
465+
exp TLSCurveType
466466
}{{
467467
name: "unknown string",
468468
hasErr: true,
@@ -471,25 +471,25 @@ func Test_tlsCurveType_Unpack(t *testing.T) {
471471
name: "string",
472472
hasErr: false,
473473
in: "P-256",
474-
exp: tlsCurveType(tls.CurveP256),
474+
exp: TLSCurveType(tls.CurveP256),
475475
}, {
476476
name: "int64",
477477
hasErr: false,
478478
in: int64(23),
479-
exp: tlsCurveType(tls.CurveP256),
479+
exp: TLSCurveType(tls.CurveP256),
480480
}, {
481481
name: "uint64",
482482
hasErr: false,
483483
in: uint64(23),
484-
exp: tlsCurveType(tls.CurveP256),
484+
exp: TLSCurveType(tls.CurveP256),
485485
}, {
486486
name: "unknown type",
487487
hasErr: true,
488488
in: uint8(1),
489489
}}
490490
for _, tc := range tests {
491491
t.Run(tc.name, func(t *testing.T) {
492-
v := new(tlsCurveType)
492+
v := new(TLSCurveType)
493493
err := v.Unpack(tc.in)
494494
if tc.hasErr {
495495
assert.Error(t, err)

0 commit comments

Comments
 (0)