fix(all): increase global http client timeout to 35s and precise lower timeouts where needed

- Fix DNS blocklists slow downloads, fix #3102
- Leave 35s timeout for updaters
- Set timeouts to 1s for local calls
- Set timeouts to 5s for LAN VPN calls and small external calls
- Set timeouts to 10s external VPN API calls
This commit is contained in:
Quentin McGaw
2026-02-20 16:40:51 +00:00
parent c5eacac644
commit d586793169
10 changed files with 76 additions and 1 deletions
@@ -9,6 +9,7 @@ import (
"net/http"
"regexp"
"strconv"
"time"
"github.com/qdm12/gluetun/internal/provider/common"
"github.com/qdm12/gluetun/internal/provider/utils"
@@ -23,6 +24,12 @@ var ErrPortForwardedNotFound = errors.New("port forwarded not found")
func (p *Provider) PortForward(ctx context.Context, objects utils.PortForwardObjects) (
ports []uint16, err error,
) {
// Define a timeout since the default client has a large timeout and we don't
// want to wait too long.
const timeout = 10 * time.Second
ctx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()
url := "https://connect.pvdatanet.com/v3/Api/port?ip[]=" + objects.InternalIP.String()
request, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
if err != nil {