fix building previous commit with go1.23

This commit is contained in:
Mechiel Lukkien 2025-05-15 14:25:18 +02:00
parent 4a14abc254
commit 76e58f4a63
3 changed files with 31 additions and 9 deletions

14
curves.go Normal file
View File

@ -0,0 +1,14 @@
//go:build !go1.24
package main
import (
"crypto/tls"
)
var curvesList = []tls.CurveID{
tls.CurveP256,
tls.CurveP384,
tls.CurveP521,
tls.X25519,
}

15
curves_go124.go Normal file
View File

@ -0,0 +1,15 @@
//go:build go1.24
package main
import (
"crypto/tls"
)
var curvesList = []tls.CurveID{
tls.CurveP256,
tls.CurveP384,
tls.CurveP521,
tls.X25519,
tls.X25519MLKEM768,
}

11
main.go
View File

@ -1921,13 +1921,6 @@ func cmdSMTPDial(c *cmd) {
} }
} }
curvesList := []tls.CurveID{
tls.CurveP256,
tls.CurveP384,
tls.CurveP521,
tls.X25519,
tls.X25519MLKEM768,
}
curves := map[string]tls.CurveID{} curves := map[string]tls.CurveID{}
for _, a := range curvesList { for _, a := range curvesList {
curves[strings.ToLower(a.String())] = a curves[strings.ToLower(a.String())] = a
@ -2017,7 +2010,7 @@ exchanged during connection set up.
tlsConfig.RootCAs = pool tlsConfig.RootCAs = pool
} }
if tlsCiphersuites != "" { if tlsCiphersuites != "" {
for s := range strings.SplitSeq(tlsCiphersuites, ",") { for _, s := range strings.Split(tlsCiphersuites, ",") {
s = strings.TrimSpace(s) s = strings.TrimSpace(s)
c, ok := ciphersuites[s] c, ok := ciphersuites[s]
if !ok { if !ok {
@ -2030,7 +2023,7 @@ exchanged during connection set up.
} }
} }
if tlsCurves != "" { if tlsCurves != "" {
for s := range strings.SplitSeq(tlsCurves, ",") { for _, s := range strings.Split(tlsCurves, ",") {
s = strings.TrimSpace(s) s = strings.TrimSpace(s)
if c, ok := curves[s]; !ok { if c, ok := curves[s]; !ok {
log.Fatalf("unknown ecc key exchange algorithm %q", s) log.Fatalf("unknown ecc key exchange algorithm %q", s)