Closed Fallen-Breath closed 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
GetHTTPClient
internal/utils/http.go
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)
Example log:
Thanks for pointing our this hidden issue, it has been fixed in the latest release.
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 ininternal/utils/http.go
doeshttps://github.com/TimothyYe/godns/blob/c5c5a274dc1f6feb3f076f538eb22efd63743a4d/internal/utils/http.go#L17-L20
or just reuse the(edit: the proxy cannot be used, that's a silly idea)GetHTTPClient
function to create the http client, so it can use the proxy from the config file as well