TimothyYe / godns

A dynamic DNS client tool that supports AliDNS, Cloudflare, Google Domains, DNSPod, HE.net & DuckDNS & DreamHost, etc, written in Go.
https://timothyye.github.io/godns/
Apache License 2.0
1.52k stars 224 forks source link

No timeout when getting ip with http client #211

Closed Fallen-Breath closed 1 year ago

Fallen-Breath commented 1 year ago

Describe the bug

The following code that creates a http client for quering ip does not specify the timeout for the client

https://github.com/TimothyYe/godns/blob/c5c5a274dc1f6feb3f076f538eb22efd63743a4d/internal/utils/ip.go#L99-L100

As a result, if the http request made by this client is somehow blocked (e.g. request during an ip change), godns will just stuck there, which is bad

Suggestions

Specify a timeout, like what the GetHTTPClient function in internal/utils/http.go does

https://github.com/TimothyYe/godns/blob/c5c5a274dc1f6feb3f076f538eb22efd63743a4d/internal/utils/http.go#L17-L20

or just reuse the GetHTTPClient function to create the http client, so it can use the proxy from the config file as well (edit: the proxy cannot be used, that's a silly idea)

Fallen-Breath commented 1 year ago

Example log:

image

TimothyYe commented 1 year ago

Thanks for pointing our this hidden issue, it has been fixed in the latest release.