From 5cedea4836ff61d07587946e8ba11aa4b2cfd636 Mon Sep 17 00:00:00 2001 From: blank X Date: Sun, 29 Aug 2021 06:43:12 +0700 Subject: [PATCH] Add 60s timeout --- main.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 00777fe..e360f40 100644 --- a/main.go +++ b/main.go @@ -18,6 +18,7 @@ import ( "git.sr.ht/~adnano/go-gemini/tofu" ) +const TIMEOUT_NS time.Duration = time.Duration(60_000_000_000) var ( hosts tofu.KnownHosts hostsfile *tofu.HostWriter @@ -149,7 +150,8 @@ func main() { client := gemini.Client{ TrustCertificate: trustCertificate, } - ctx := context.Background() + ctx, cancel := context.WithTimeout(context.Background(), TIMEOUT_NS) + defer cancel() resp, req, err := do(client, ctx, req, nil) if err != nil { log.Fatal(err)