X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=tls.go;h=28f54fb6737d8fee566dcffdbfe53298a7d3933b;hb=refs%2Fheads%2Fmaster;hp=b2ad433d6ddc0bb3d16c2c0b391b4ae0fadfa8cb;hpb=e05f6f8830b01d52cc21cd5f97cef6616a5334b9;p=godlighty.git diff --git a/tls.go b/tls.go index b2ad433..7ccc8f7 100644 --- a/tls.go +++ b/tls.go @@ -1,19 +1,17 @@ -/* -godlighty -- highly-customizable HTTP, HTTP/2, HTTPS server -Copyright (C) 2021-2023 Sergey Matveev - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, version 3 of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ +// godlighty -- highly-customizable HTTP, HTTP/2, HTTPS server +// Copyright (C) 2021-2025 Sergey Matveev +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 3 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . package godlighty @@ -25,6 +23,7 @@ import ( "fmt" "log" "os" + "slices" ) var ( @@ -41,24 +40,14 @@ var ( ) func CHIHasTLS13(chi *tls.ClientHelloInfo) bool { - for _, v := range chi.SupportedVersions { - if v == tls.VersionTLS13 { - return true - } - } - return false + return slices.Contains(chi.SupportedVersions, tls.VersionTLS13) } func CHIHasEdDSA(chi *tls.ClientHelloInfo) bool { if !CHIHasTLS13(chi) { return false } - for _, ss := range chi.SignatureSchemes { - if ss == tls.Ed25519 { - return true - } - } - return false + return slices.Contains(chi.SignatureSchemes, tls.Ed25519) } func GetCertificate(chi *tls.ClientHelloInfo) (*tls.Certificate, error) { @@ -72,7 +61,7 @@ func GetCertificate(chi *tls.ClientHelloInfo) (*tls.Certificate, error) { cert = HostToEdDSACertificate[chi.ServerName] } else { if CHIHasEdDSA(chi) { - if cert := HostToEdDSACertificate[chi.ServerName]; cert != nil { + if cert = HostToEdDSACertificate[chi.ServerName]; cert != nil { return cert, nil } }