From 80bdbb642dbf2ed38634f3c2e6f8022d514e8f1b Mon Sep 17 00:00:00 2001 From: sloum Date: Mon, 29 Jun 2020 21:45:24 -0700 Subject: [PATCH] Adds timeout to tls for gemini and increases gopher timeout --- gemini/gemini.go | 4 +++- gopher/gopher.go | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/gemini/gemini.go b/gemini/gemini.go index 44c8545..ae5af8e 100644 --- a/gemini/gemini.go +++ b/gemini/gemini.go @@ -6,6 +6,7 @@ import ( "crypto/tls" "fmt" "io/ioutil" + "net" "net/url" "strconv" "strings" @@ -26,6 +27,7 @@ type TofuDigest struct { } var BlockBehavior = "block" +var TlsTimeout = time.Duration(15) * time.Second //------------------------------------------------\\ // + + + R E C E I V E R S + + + \\ @@ -189,7 +191,7 @@ func Retrieve(host, port, resource string, td *TofuDigest) (string, error) { return &td.ClientCert, nil } - conn, err := tls.Dial("tcp", addr, conf) + conn, err := tls.DialWithDialer(&net.Dialer{Timeout: TlsTimeout}, "tcp", addr, conf) if err != nil { return "", fmt.Errorf("TLS Dial Error: %s", err.Error()) } diff --git a/gopher/gopher.go b/gopher/gopher.go index 20e76e9..68721d3 100644 --- a/gopher/gopher.go +++ b/gopher/gopher.go @@ -49,7 +49,7 @@ var types = map[string]string{ // be better. func Retrieve(host, port, resource string) ([]byte, error) { nullRes := make([]byte, 0) - timeOut := time.Duration(5) * time.Second + timeOut := time.Duration(15) * time.Second if host == "" || port == "" { return nullRes, errors.New("Incomplete request url")