From fdcc41829ad110bad377b72f6aef096402ae12c2 Mon Sep 17 00:00:00 2001 From: Niko Storni Date: Wed, 1 Jul 2020 00:14:51 +0200 Subject: [PATCH] handshake changes --- internal/metrics/metrics.go | 2 +- peer/http3/client.go | 1 + peer/http3/server.go | 4 +++- peer/http3/store.go | 1 + 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/metrics/metrics.go b/internal/metrics/metrics.go index 94bac40..aa89dbb 100644 --- a/internal/metrics/metrics.go +++ b/internal/metrics/metrics.go @@ -53,7 +53,7 @@ func (s *Server) Start() { } func (s *Server) Shutdown() { - s.srv.Shutdown(context.Background()) + _ = s.srv.Shutdown(context.Background()) s.stop.StopAndWait() } diff --git a/peer/http3/client.go b/peer/http3/client.go index ca3d556..aba77c3 100644 --- a/peer/http3/client.go +++ b/peer/http3/client.go @@ -26,6 +26,7 @@ type Client struct { // Close closes the connection with the client. func (c *Client) Close() error { + c.conn.CloseIdleConnections() return c.roundTripper.Close() } diff --git a/peer/http3/server.go b/peer/http3/server.go index c04026e..3cc0155 100644 --- a/peer/http3/server.go +++ b/peer/http3/server.go @@ -9,6 +9,7 @@ import ( "encoding/pem" "math/big" "net/http" + "time" "github.com/lbryio/reflector.go/internal/metrics" "github.com/lbryio/reflector.go/store" @@ -61,13 +62,14 @@ type availabilityResponse struct { // Start starts the server listener to handle connections. func (s *Server) Start(address string) error { log.Println("HTTP3 peer listening on " + address) - quicConf := &quic.Config{} + quicConf := &quic.Config{HandshakeTimeout: 3 * time.Second} r := mux.NewRouter() r.HandleFunc("/get/{hash}", func(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) requestedBlob := vars["hash"] blob, err := s.store.Get(requestedBlob) if err != nil { + log.Errorln(errors.FullTrace(err)) http.Error(w, err.Error(), http.StatusBadRequest) return } diff --git a/peer/http3/store.go b/peer/http3/store.go index 7d5e433..cb68bb2 100644 --- a/peer/http3/store.go +++ b/peer/http3/store.go @@ -31,6 +31,7 @@ func NewStore(opts StoreOpts) *Store { func (p *Store) getClient() (*Client, error) { var qconf quic.Config + qconf.HandshakeTimeout = 3 * time.Second pool, err := x509.SystemCertPool() if err != nil { return nil, err