diff --git a/README.md b/README.md index 0fa915c7..f543d39f 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ brew install ipinfo-cli OR to install the latest `amd64` version without automatic updates: ```bash -curl -Ls https://github.com/ipinfo/cli/releases/download/ipinfo-2.8.0/macos.sh | sh +curl -Ls https://github.com/ipinfo/cli/releases/download/ipinfo-2.8.1/macos.sh | sh ``` ### Ubuntu PPA @@ -43,14 +43,14 @@ sudo apt install ipinfo for automatic updates. ```bash -curl -Ls https://github.com/ipinfo/cli/releases/download/ipinfo-2.8.0/deb.sh | sh +curl -Ls https://github.com/ipinfo/cli/releases/download/ipinfo-2.8.1/deb.sh | sh ``` OR ```bash -curl -LO https://github.com/ipinfo/cli/releases/download/ipinfo-2.8.0/ipinfo_2.8.0.deb -sudo dpkg -i ipinfo_2.8.0.deb +curl -LO https://github.com/ipinfo/cli/releases/download/ipinfo-2.8.1/ipinfo_2.8.1.deb +sudo dpkg -i ipinfo_2.8.1.deb ``` ### FreeBSD @@ -71,13 +71,13 @@ makepkg -si *Note*: run powershell as administrator before executing this command. ```bash -iwr -useb https://github.com/ipinfo/cli/releases/download/ipinfo-2.8.0/windows.ps1 | iex +iwr -useb https://github.com/ipinfo/cli/releases/download/ipinfo-2.8.1/windows.ps1 | iex ``` ### Docker ```bash -docker run ipinfo/ipinfo:2.8.0 +docker run ipinfo/ipinfo:2.8.1 ``` ### Using `go install` @@ -128,12 +128,12 @@ After choosing a platform `PLAT` from above, run: ```bash # for Windows, use ".zip" instead of ".tar.gz" -curl -LO https://github.com/ipinfo/cli/releases/download/ipinfo-2.8.0/ipinfo_2.8.0_${PLAT}.tar.gz +curl -LO https://github.com/ipinfo/cli/releases/download/ipinfo-2.8.1/ipinfo_2.8.1_${PLAT}.tar.gz # OR -wget https://github.com/ipinfo/cli/releases/download/ipinfo-2.8.0/ipinfo_2.8.0_${PLAT}.tar.gz +wget https://github.com/ipinfo/cli/releases/download/ipinfo-2.8.1/ipinfo_2.8.1_${PLAT}.tar.gz -tar -xvf ipinfo_2.8.0_${PLAT}.tar.gz -mv ipinfo_2.8.0_${PLAT} /usr/local/bin/ipinfo +tar -xvf ipinfo_2.8.1_${PLAT}.tar.gz +mv ipinfo_2.8.1_${PLAT} /usr/local/bin/ipinfo ``` ### Using `git` diff --git a/debian/changelog b/debian/changelog index b1cdd1b2..3a51a993 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,5 @@ -ipinfo (2.8.0) focal; urgency=medium +ipinfo (2.8.1) focal; urgency=medium - * 2.8.0 release. + * 2.8.1 release. -- umar Mon, 22 Nov 2021 12:32:18 +0500 diff --git a/debian/files b/debian/files index 4adb8a9c..de5b8aa1 100644 --- a/debian/files +++ b/debian/files @@ -1 +1 @@ -ipinfo_2.8.0_source.buildinfo utils optional +ipinfo_2.8.1_source.buildinfo utils optional diff --git a/go.mod b/go.mod index ebb4904f..61626ec9 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/fatih/color v1.10.0 github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-multierror v1.1.1 - github.com/ipinfo/go/v2 v2.6.0 + github.com/ipinfo/go/v2 v2.7.0 github.com/jszwec/csvutil v1.4.0 github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 github.com/posener/script v1.1.5 diff --git a/go.sum b/go.sum index 260ac3ed..41048dd4 100644 --- a/go.sum +++ b/go.sum @@ -9,8 +9,8 @@ github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brv github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= -github.com/ipinfo/go/v2 v2.6.0 h1:OXyubfiXI4CnXTvyUfFKYG8NoLb3cMXaM+d8mNd3sIc= -github.com/ipinfo/go/v2 v2.6.0/go.mod h1:2MrJVdUamrTc5VdC7yrbKGbsOOxMtdUpnpBJmtZgA8o= +github.com/ipinfo/go/v2 v2.7.0 h1:+1l8e4zjKOCgiZ6RNsOLbdlXJkCA+Qgc4i6W7g/S9Wg= +github.com/ipinfo/go/v2 v2.7.0/go.mod h1:tRDkYfM20b1XzNqorn1Q1O6Xtg7uzw3Wn3I2R0SyJh4= github.com/jszwec/csvutil v1.4.0 h1:ro7gZN8PRsyNUEX8qE/eYPE5/kffEXMs+4eRcOd1oUk= github.com/jszwec/csvutil v1.4.0/go.mod h1:Rpu7Uu9giO9subDyMCIQfHVDuLrcaC36UA4YcJjGBkg= github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8= @@ -21,6 +21,7 @@ github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaR github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 h1:Qj1ukM4GlMWXNdMBuXcXfz/Kw9s1qm0CLY32QxuSImI= github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ= +github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -28,14 +29,15 @@ github.com/posener/script v1.1.5 h1:su+9YHNlevT+Hlq2Xul5skh5kYDIBE+x4xu+5mLDT9o= github.com/posener/script v1.1.5/go.mod h1:Rg3ijooqulo05aGLyGsHoLmIOUzHUVK19WVgrYBPU/E= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU= go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4= -golang.org/x/sync v0.0.0-20201207232520-09787c993a3a h1:DcqTD9SDLc+1P/r1EmRBwnVsrOwW+kk2vWf9n+1sGhs= -golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220513210516-0976fa681c29 h1:w8s32wxx3sY+OjLlv9qltkLU5yvJzxjjgiHWLjdIcw4= +golang.org/x/sync v0.0.0-20220513210516-0976fa681c29/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200923182605-d9f96fdee20d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -46,6 +48,7 @@ golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf h1:MZ2shdL+ZM/XzY3ZGOnh4Nlp golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= diff --git a/ipinfo/cmd_bulk.go b/ipinfo/cmd_bulk.go index 7777e5c8..00c1df65 100644 --- a/ipinfo/cmd_bulk.go +++ b/ipinfo/cmd_bulk.go @@ -125,6 +125,7 @@ func cmdBulk() (err error) { data, err := ii.GetIPInfoBatch(ips, ipinfo.BatchReqOpts{ TimeoutPerBatch: 60 * 30, // 30min + ConcurrentBatchRequestsLimit: 20, }) if err != nil { return err diff --git a/ipinfo/cmd_default.go b/ipinfo/cmd_default.go index d5e5184e..ee6297f4 100644 --- a/ipinfo/cmd_default.go +++ b/ipinfo/cmd_default.go @@ -129,6 +129,7 @@ func cmdDefault() (err error) { data, err := ii.GetIPInfoBatch(ips, ipinfo.BatchReqOpts{ TimeoutPerBatch: 60 * 30, // 30min + ConcurrentBatchRequestsLimit: 20, }) if err != nil { return err diff --git a/ipinfo/deb.sh b/ipinfo/deb.sh index 1a19f936..727f9087 100755 --- a/ipinfo/deb.sh +++ b/ipinfo/deb.sh @@ -1,6 +1,6 @@ #!/bin/sh -VSN=2.8.0 +VSN=2.8.1 curl -LO https://github.com/ipinfo/cli/releases/download/ipinfo-${VSN}/ipinfo_${VSN}.deb sudo dpkg -i ipinfo_${VSN}.deb diff --git a/ipinfo/dist/DEBIAN/control b/ipinfo/dist/DEBIAN/control index 2a43d2c7..b291c721 100644 --- a/ipinfo/dist/DEBIAN/control +++ b/ipinfo/dist/DEBIAN/control @@ -1,6 +1,6 @@ Source: ipinfo Section: utils -Version: 2.8.0 +Version: 2.8.1 Priority: optional Maintainer: IPinfo Vcs-Git: https://github.com/ipinfo/cli diff --git a/ipinfo/macos.sh b/ipinfo/macos.sh index 542b4b84..5972126f 100755 --- a/ipinfo/macos.sh +++ b/ipinfo/macos.sh @@ -1,6 +1,6 @@ #!/bin/sh -VSN=2.8.0 +VSN=2.8.1 PLAT=darwin_amd64 curl -LO https://github.com/ipinfo/cli/releases/download/ipinfo-${VSN}/ipinfo_${VSN}_${PLAT}.tar.gz diff --git a/ipinfo/main.go b/ipinfo/main.go index affc0f69..5ed57cf4 100644 --- a/ipinfo/main.go +++ b/ipinfo/main.go @@ -11,7 +11,7 @@ import ( ) var progBase = filepath.Base(os.Args[0]) -var version = "2.8.0" +var version = "2.8.1" // global flags. var fHelp bool diff --git a/ipinfo/windows.ps1 b/ipinfo/windows.ps1 index f5f67402..9b986bfe 100644 --- a/ipinfo/windows.ps1 +++ b/ipinfo/windows.ps1 @@ -1,4 +1,4 @@ -$VSN = "2.8.0" +$VSN = "2.8.1" # build the filename for the Zip archive and exe file $FileName = "ipinfo_$($VSN)_windows_amd64" diff --git a/vendor/github.com/ipinfo/go/v2/ipinfo/batch.go b/vendor/github.com/ipinfo/go/v2/ipinfo/batch.go index febfe02a..691a28c6 100644 --- a/vendor/github.com/ipinfo/go/v2/ipinfo/batch.go +++ b/vendor/github.com/ipinfo/go/v2/ipinfo/batch.go @@ -13,8 +13,9 @@ import ( ) const ( - batchMaxSize = 1000 - batchReqTimeoutDefault = 5 + batchMaxSize = 1000 + batchReqTimeoutDefault = 5 + batchDefaultConcurrentRequestsLimit = 8 ) // Internal batch type used by common batch functionality to temporarily store @@ -63,6 +64,12 @@ type BatchReqOpts struct { // 0 means no total timeout; `TimeoutPerBatch` will still apply. TimeoutTotal uint64 + // ConcurrentBatchRequestsLimit is the maximum number of concurrent batch + // requests that will be mid-flight for inputs that exceed the batch limit. + // + // 0 means to use a default of 8; any negative number implies unlimited concurrency. + ConcurrentBatchRequestsLimit int + // Filter, if turned on, will filter out a URL whose value was deemed empty // on the server. Filter bool @@ -85,6 +92,7 @@ func (c *Client) GetBatch( ) (Batch, error) { var batchSize int var timeoutPerBatch int64 + var maxConcurrentBatchRequests int var totalTimeoutCtx context.Context var totalTimeoutCancel context.CancelFunc var lookupUrls []string @@ -118,6 +126,13 @@ func (c *Client) GetBatch( batchSize = int(opts.BatchSize) } + // use correct concurrent requests limit; either default or user-provided. + if opts.ConcurrentBatchRequestsLimit == 0 { + maxConcurrentBatchRequests = batchDefaultConcurrentRequestsLimit + } else { + maxConcurrentBatchRequests = opts.ConcurrentBatchRequestsLimit + } + // use correct timeout per batch; either default or user-provided. if opts.TimeoutPerBatch == 0 { timeoutPerBatch = batchReqTimeoutDefault @@ -137,6 +152,7 @@ func (c *Client) GetBatch( } errg, ctx := errgroup.WithContext(totalTimeoutCtx) + errg.SetLimit(maxConcurrentBatchRequests) for i := 0; i < len(lookupUrls); i += batchSize { end := i + batchSize if end > len(lookupUrls) { diff --git a/vendor/github.com/ipinfo/go/v2/ipinfo/client.go b/vendor/github.com/ipinfo/go/v2/ipinfo/client.go index 07d89543..d96ee4fb 100644 --- a/vendor/github.com/ipinfo/go/v2/ipinfo/client.go +++ b/vendor/github.com/ipinfo/go/v2/ipinfo/client.go @@ -13,7 +13,7 @@ import ( const ( defaultBaseURL = "https://ipinfo.io/" - defaultUserAgent = "IPinfoClient/Go/2.6.0" + defaultUserAgent = "IPinfoClient/Go/2.7.0" ) // A Client is the main handler to communicate with the IPinfo API. diff --git a/vendor/golang.org/x/sync/errgroup/errgroup.go b/vendor/golang.org/x/sync/errgroup/errgroup.go index 9857fe53..1eab2fdf 100644 --- a/vendor/golang.org/x/sync/errgroup/errgroup.go +++ b/vendor/golang.org/x/sync/errgroup/errgroup.go @@ -8,9 +8,12 @@ package errgroup import ( "context" + "fmt" "sync" ) +type token struct{} + // A Group is a collection of goroutines working on subtasks that are part of // the same overall task. // @@ -20,10 +23,19 @@ type Group struct { wg sync.WaitGroup + sem chan token + errOnce sync.Once err error } +func (g *Group) done() { + if g.sem != nil { + <-g.sem + } + g.wg.Done() +} + // WithContext returns a new Group and an associated Context derived from ctx. // // The derived Context is canceled the first time a function passed to Go @@ -45,14 +57,48 @@ func (g *Group) Wait() error { } // Go calls the given function in a new goroutine. +// It blocks until the new goroutine can be added without the number of +// active goroutines in the group exceeding the configured limit. // // The first call to return a non-nil error cancels the group; its error will be // returned by Wait. func (g *Group) Go(f func() error) { + if g.sem != nil { + g.sem <- token{} + } + g.wg.Add(1) + go func() { + defer g.done() + + if err := f(); err != nil { + g.errOnce.Do(func() { + g.err = err + if g.cancel != nil { + g.cancel() + } + }) + } + }() +} + +// TryGo calls the given function in a new goroutine only if the number of +// active goroutines in the group is currently below the configured limit. +// +// The return value reports whether the goroutine was started. +func (g *Group) TryGo(f func() error) bool { + if g.sem != nil { + select { + case g.sem <- token{}: + // Note: this allows barging iff channels in general allow barging. + default: + return false + } + } + g.wg.Add(1) go func() { - defer g.wg.Done() + defer g.done() if err := f(); err != nil { g.errOnce.Do(func() { @@ -63,4 +109,23 @@ func (g *Group) Go(f func() error) { }) } }() + return true +} + +// SetLimit limits the number of active goroutines in this group to at most n. +// A negative value indicates no limit. +// +// Any subsequent call to the Go method will block until it can add an active +// goroutine without exceeding the configured limit. +// +// The limit must not be modified while any goroutines in the group are active. +func (g *Group) SetLimit(n int) { + if n < 0 { + g.sem = nil + return + } + if len(g.sem) != 0 { + panic(fmt.Errorf("errgroup: modify limit while %v goroutines in the group are still active", len(g.sem))) + } + g.sem = make(chan token, n) } diff --git a/vendor/modules.txt b/vendor/modules.txt index aac6554d..49d1f65f 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -10,7 +10,7 @@ github.com/hashicorp/errwrap # github.com/hashicorp/go-multierror v1.1.1 ## explicit github.com/hashicorp/go-multierror -# github.com/ipinfo/go/v2 v2.6.0 +# github.com/ipinfo/go/v2 v2.7.0 ## explicit github.com/ipinfo/go/v2/ipinfo github.com/ipinfo/go/v2/ipinfo/cache @@ -40,7 +40,7 @@ github.com/stretchr/testify/assert # go.etcd.io/bbolt v1.3.6 ## explicit go.etcd.io/bbolt -# golang.org/x/sync v0.0.0-20201207232520-09787c993a3a +# golang.org/x/sync v0.0.0-20220513210516-0976fa681c29 golang.org/x/sync/errgroup # golang.org/x/sys v0.0.0-20211004093028-2c5d950f24ef ## explicit