Add support for PROXY and PORT envs
This commit is contained in:
@@ -47,9 +47,9 @@ func MainApp(configPath string) {
|
|||||||
|
|
||||||
apiClient := http.NewHTTPClient(
|
apiClient := http.NewHTTPClient(
|
||||||
config.GetToken(),
|
config.GetToken(),
|
||||||
config.GetRetriesUntilFailed()*10, // default retries = 2, so this is 20
|
config.GetRetriesUntilFailed()*2, // default retries = 2, so this is 4
|
||||||
config.GetApiTimeoutSecs(), // default api timeout = 60
|
config.GetApiTimeoutSecs(), // default api timeout = 60
|
||||||
false, // ipv6 support is not needed for api client
|
false, // ipv6 support is not needed for api client
|
||||||
config,
|
config,
|
||||||
log.Named("api_client"),
|
log.Named("api_client"),
|
||||||
)
|
)
|
||||||
@@ -64,10 +64,10 @@ func MainApp(configPath string) {
|
|||||||
)
|
)
|
||||||
|
|
||||||
downloadClient := http.NewHTTPClient(
|
downloadClient := http.NewHTTPClient(
|
||||||
"",
|
"", // no token required for download client
|
||||||
config.GetRetriesUntilFailed(),
|
config.GetRetriesUntilFailed(), //
|
||||||
config.GetDownloadTimeoutSecs(),
|
config.GetDownloadTimeoutSecs(), //
|
||||||
true,
|
true, // download client supports ipv6
|
||||||
config,
|
config,
|
||||||
log.Named("download_client"),
|
log.Named("download_client"),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
|
import "os"
|
||||||
|
|
||||||
type ConfigInterface interface {
|
type ConfigInterface interface {
|
||||||
GetConfig() ZurgConfig
|
GetConfig() ZurgConfig
|
||||||
GetVersion() string
|
GetVersion() string
|
||||||
@@ -80,6 +82,9 @@ func (z *ZurgConfig) GetHost() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (z *ZurgConfig) GetPort() string {
|
func (z *ZurgConfig) GetPort() string {
|
||||||
|
if os.Getenv("PORT") != "" {
|
||||||
|
return os.Getenv("PORT")
|
||||||
|
}
|
||||||
if z.Port == "" {
|
if z.Port == "" {
|
||||||
return "9999"
|
return "9999"
|
||||||
}
|
}
|
||||||
@@ -95,6 +100,9 @@ func (z *ZurgConfig) GetPassword() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (z *ZurgConfig) GetProxy() string {
|
func (z *ZurgConfig) GetProxy() string {
|
||||||
|
if os.Getenv("PROXY") != "" {
|
||||||
|
return os.Getenv("PROXY")
|
||||||
|
}
|
||||||
return z.Proxy
|
return z.Proxy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -72,8 +72,9 @@ func NewHTTPClient(
|
|||||||
}
|
}
|
||||||
|
|
||||||
var dialer proxy.Dialer = &net.Dialer{
|
var dialer proxy.Dialer = &net.Dialer{
|
||||||
Timeout: time.Duration(timeoutSecs) * time.Second, // timeout to establish connection
|
Timeout: time.Duration(timeoutSecs) * time.Second, // timeout for dns resolution, tcp handshake
|
||||||
}
|
}
|
||||||
|
|
||||||
if proxyURLString := cfg.GetProxy(); proxyURLString != "" {
|
if proxyURLString := cfg.GetProxy(); proxyURLString != "" {
|
||||||
proxyURL, err := url.Parse(proxyURLString)
|
proxyURL, err := url.Parse(proxyURLString)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user