]> Sergey Matveev's repositories - tofuproxy.git/blobdiff - tls/dial.go
Unify copyright comment format
[tofuproxy.git] / tls / dial.go
index fe9ea75e10887ec601d61952f5b3dcb1bff289bf..aead1c8e70eee70c0467ccae91e487cbe052b7fc 100644 (file)
@@ -1,20 +1,18 @@
-/*
-tofuproxy -- flexible HTTP/HTTPS proxy, TLS terminator, X.509 TOFU
-             manager, WARC/geminispace browser
-Copyright (C) 2021 Sergey Matveev <stargrave@stargrave.org>
-
-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 <http://www.gnu.org/licenses/>.
-*/
+// tofuproxy -- flexible HTTP/HTTPS proxy, TLS terminator, X.509 TOFU
+//              manager, WARC/geminispace browser
+// Copyright (C) 2021-2024 Sergey Matveev <stargrave@stargrave.org>
+//
+// 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 <http://www.gnu.org/licenses/>.
 
 package tofuproxy
 
@@ -24,7 +22,6 @@ import (
        "crypto/x509"
        "fmt"
        "net"
-       "strings"
 
        "go.cypherpunks.ru/ucspi"
        "go.stargrave.org/tofuproxy/fifos"
@@ -33,7 +30,8 @@ import (
 var sessionCache = tls.NewLRUClientSessionCache(1024)
 
 func DialTLS(ctx context.Context, network, addr string) (net.Conn, error) {
-       host := strings.Split(addr, ":")[0]
+       host, _, _ := SplitHostPort(addr)
+       host = toLowerCaseASCII(host)
        ccg := ClientCertificateGetter{host: host}
        cfg := tls.Config{
                VerifyPeerCertificate: func(