From 1ce2608e5627ff1ca1a4fe05269f6a7d40b57058 Mon Sep 17 00:00:00 2001 From: tebuka <171117698+tebuka@users.noreply.github.com> Date: Tue, 11 Jun 2024 18:18:10 -0700 Subject: [PATCH] Move doHandshake to client.go The doHandshake function was split off to separate files to support different implementations for Go < 1.16 and Go >= 1.17. The separate files are not needed now that Go 1.20 is the minimum supported version of Go for the project. --- client.go | 12 ++++++++++++ tls_handshake.go | 21 --------------------- tls_handshake_116.go | 21 --------------------- 3 files changed, 12 insertions(+), 42 deletions(-) delete mode 100644 tls_handshake.go delete mode 100644 tls_handshake_116.go diff --git a/client.go b/client.go index bef9434..73eada1 100644 --- a/client.go +++ b/client.go @@ -409,3 +409,15 @@ func cloneTLSConfig(cfg *tls.Config) *tls.Config { } return cfg.Clone() } + +func doHandshake(ctx context.Context, tlsConn *tls.Conn, cfg *tls.Config) error { + if err := tlsConn.HandshakeContext(ctx); err != nil { + return err + } + if !cfg.InsecureSkipVerify { + if err := tlsConn.VerifyHostname(cfg.ServerName); err != nil { + return err + } + } + return nil +} diff --git a/tls_handshake.go b/tls_handshake.go deleted file mode 100644 index a62b68c..0000000 --- a/tls_handshake.go +++ /dev/null @@ -1,21 +0,0 @@ -//go:build go1.17 -// +build go1.17 - -package websocket - -import ( - "context" - "crypto/tls" -) - -func doHandshake(ctx context.Context, tlsConn *tls.Conn, cfg *tls.Config) error { - if err := tlsConn.HandshakeContext(ctx); err != nil { - return err - } - if !cfg.InsecureSkipVerify { - if err := tlsConn.VerifyHostname(cfg.ServerName); err != nil { - return err - } - } - return nil -} diff --git a/tls_handshake_116.go b/tls_handshake_116.go deleted file mode 100644 index e1b2b44..0000000 --- a/tls_handshake_116.go +++ /dev/null @@ -1,21 +0,0 @@ -//go:build !go1.17 -// +build !go1.17 - -package websocket - -import ( - "context" - "crypto/tls" -) - -func doHandshake(ctx context.Context, tlsConn *tls.Conn, cfg *tls.Config) error { - if err := tlsConn.Handshake(); err != nil { - return err - } - if !cfg.InsecureSkipVerify { - if err := tlsConn.VerifyHostname(cfg.ServerName); err != nil { - return err - } - } - return nil -}