diff --git a/ios/imagemounter/imagedownloader.go b/ios/imagemounter/imagedownloader.go index d3dc522c..1c56c733 100644 --- a/ios/imagemounter/imagedownloader.go +++ b/ios/imagemounter/imagedownloader.go @@ -9,6 +9,7 @@ import ( "path/filepath" "runtime" "strings" + "time" "github.com/Masterminds/semver" "github.com/danielpaulus/go-ios/ios" @@ -247,8 +248,12 @@ func validateBaseDirAndLookForImage(baseDir string, imageToFind string) (string, // write as it downloads and not load the whole file into memory. // PS: Taken from golangcode.com func downloadFile(filepath string, url string) error { + c := &http.Client{ + Timeout: 2 * time.Minute, + Transport: http.DefaultTransport, + } // Get the data - resp, err := http.Get(url) + resp, err := c.Get(url) if err != nil { return err } diff --git a/ios/imagemounter/tss.go b/ios/imagemounter/tss.go index 5258ccfb..6e987919 100644 --- a/ios/imagemounter/tss.go +++ b/ios/imagemounter/tss.go @@ -20,7 +20,8 @@ type tssClient struct { func newTssClient() tssClient { c := &http.Client{ - Timeout: 1 * time.Minute, + Timeout: 1 * time.Minute, + Transport: http.DefaultTransport, } return tssClient{ diff --git a/ios/mobileactivation/albert.go b/ios/mobileactivation/albert.go index 6eff689e..c7838247 100644 --- a/ios/mobileactivation/albert.go +++ b/ios/mobileactivation/albert.go @@ -15,7 +15,8 @@ const ( ) var netClient = &http.Client{ - Timeout: time.Second * 5, + Timeout: time.Second * 5, + Transport: http.DefaultTransport, } func sendHandshakeRequest(body io.Reader) (http.Header, io.ReadCloser, error) { diff --git a/main.go b/main.go index 4d2fe381..494116f6 100644 --- a/main.go +++ b/main.go @@ -7,6 +7,8 @@ import ( "encoding/json" "fmt" "io" + "net/http" + "net/url" "os" "os/signal" "path" @@ -145,6 +147,8 @@ Options: > connect a device and open Xcode --rsd-port= Port of remote service discovery on the device through the tunnel > This parameter is similar to '--address' and can be obtained by the same log filter + --proxyurl= Set this if you want go-ios to use a http proxy for outgoing requests, like for downloading images or contacting Apple during device activation. + > A simple format like: "http://PROXY_LOGIN:PROXY_PASS@proxyIp:proxyPort" works. Otherwise use the HTTP_PROXY system env var. The commands work as following: The default output of all commands is JSON. Should you prefer human readable outout, specify the --nojson option with your command. @@ -291,6 +295,15 @@ The commands work as following: printVersion() return } + proxyUrl, _ := arguments.String("--proxyurl") + if proxyUrl == "" { + proxyUrl = os.Getenv("HTTP_PROXY") + } + if proxyUrl != "" { + parsedUrl, err := url.Parse(proxyUrl) + exitIfError("failed parsing proxy url", err) + http.DefaultTransport = &http.Transport{Proxy: http.ProxyURL(parsedUrl)} + } b, _ := arguments.Bool("listen") if b { @@ -1115,6 +1128,7 @@ func imageCommand1(device ios.DeviceEntry, arguments docopt.Opts) bool { if err != nil { log.WithFields(log.Fields{"basedir": basedir, "udid": device.Properties.SerialNumber, "err": err}). Error("failed downloading image") + return false } log.WithFields(log.Fields{"basedir": basedir, "udid": device.Properties.SerialNumber}).Info("success downloaded image")