handshake changes

This commit is contained in:
Niko Storni 2020-07-01 00:14:51 +02:00
parent 09c7718f30
commit fdcc41829a
4 changed files with 6 additions and 2 deletions

View file

@ -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()
}

View file

@ -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()
}

View file

@ -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
}

View file

@ -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