mirror of
https://gitea.intern.drachenfels.de/ruben/goget.git
synced 2026-02-08 12:48:01 +00:00
Add --no-proxy flag to disable http proxy.
This commit is contained in:
8
goget.go
8
goget.go
@ -23,6 +23,7 @@ type client struct {
|
||||
ReadTimeout time.Duration
|
||||
Retries int
|
||||
RetryWait time.Duration
|
||||
NoProxy bool
|
||||
}
|
||||
|
||||
func main() {
|
||||
@ -38,6 +39,7 @@ func main() {
|
||||
flag.DurationVar(&c.ReadTimeout, "read-timeout", 10*time.Second, "TCP connections that that are longer idle will be aborted")
|
||||
flag.BoolVar(&c.Insecure, "insecure", false, "Disable TLS certificate verification.")
|
||||
flag.BoolVar(&showVersion, "version", false, "Show version and exit.")
|
||||
flag.BoolVar(&c.NoProxy, "no-proxy", false, "Ignore *_proxy environment variables.")
|
||||
|
||||
flag.StringVar(&filename, "filename", "", "Filename / path where to write downloaded file to. Defaults to filename of the URL.")
|
||||
flag.Parse()
|
||||
@ -95,6 +97,12 @@ func (c *client) DownloadFile(filename string, url string) (err error) {
|
||||
},
|
||||
}
|
||||
|
||||
if c.NoProxy {
|
||||
tr.Proxy = nil
|
||||
} else {
|
||||
tr.Proxy = http.ProxyFromEnvironment
|
||||
}
|
||||
|
||||
client := &http.Client{Transport: tr}
|
||||
|
||||
// Get the data
|
||||
|
||||
Reference in New Issue
Block a user