File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88 "strings"
99 "time"
1010
11- "github.com/cavaliercoder /grab"
11+ "github.com/cavaliergopher /grab/v3 "
1212)
1313
1414// GetCIDRFromIPRange converts IP range to CIDR
@@ -77,27 +77,30 @@ func GetIpsFromIPRange(ipRange string) ([]string, error) {
7777
7878// DownloadFile downloads a file and display status
7979func DownloadFile (filename string , url string ) error {
80- req , err := grab .NewRequest (url )
80+ client := grab .NewClient ()
81+ req , err := grab .NewRequest (filename , url )
8182 if err != nil {
8283 return err
8384 }
84- req .Filename = filename
8585
86- respch := grab .DefaultClient .DoAsync (req )
87- resp := <- respch
88-
89- ticker := time .NewTicker (200 * time .Millisecond )
90- for range ticker .C {
91- if resp .IsComplete () {
92- if resp .Error != nil {
93- return resp .Error
94- }
95- break
86+ resp := client .Do (req )
87+ t := time .NewTicker (200 * time .Millisecond )
88+ defer t .Stop ()
89+
90+ Loop:
91+ for {
92+ select {
93+ case <- t .C :
94+ fmt .Print ("." )
95+ case <- resp .Done :
96+ break Loop
9697 }
97- fmt .Print ("." )
9898 }
9999
100- ticker .Stop ()
100+ if err := resp .Err (); err != nil {
101+ return err
102+ }
103+
101104 return nil
102105}
103106
Original file line number Diff line number Diff line change @@ -6,9 +6,8 @@ require (
66 github.com/0xrawsec/golang-evtx v1.2.9
77 github.com/PuerkitoBio/goquery v1.8.0
88 github.com/akyoto/color v1.8.12
9- github.com/cavaliercoder /grab v1 .0.0
9+ github.com/cavaliergopher /grab/v3 v3 .0.1
1010 github.com/cevaris/ordered_map v0.0.0-20190319150403-3adeae072e73
11- github.com/djherbis/times v1.5.0 // indirect
1211 github.com/go-ole/go-ole v1.2.6
1312 github.com/hako/durafmt v0.0.0-20210608085754-5c1018a4e16b
1413 github.com/josephspurrier/goversioninfo v1.4.0
Original file line number Diff line number Diff line change @@ -17,14 +17,12 @@ github.com/akyoto/tty v0.1.4 h1:TELbnAmrPTIrUJyuBLhrOSCcBnklC2fh0YeCTjksiDE=
1717github.com/akyoto/tty v0.1.4 /go.mod h1:fkWwtA4F5Cq9kiQSlWdkPy5kAyySGYqalWyaRKn3zHo =
1818github.com/andybalholm/cascadia v1.3.1 h1:nhxRkql1kdYCc8Snf7D5/D3spOX+dBgjA6u8x004T2c =
1919github.com/andybalholm/cascadia v1.3.1 /go.mod h1:R4bJ1UQfqADjvDa4P6HZHLh/3OxWWEqc0Sk8XGwHqvA =
20- github.com/cavaliercoder /grab v1 .0.0 h1:H6VQ1NiLO7AvXM6ZyaInnoZrRLeo2FoUTQEcXln4bvQ =
21- github.com/cavaliercoder /grab v1 .0.0 /go.mod h1:tTBkfNqSBfuMmMBFaO2phgyhdYhiZQ/+iXCZDzcDsMI =
20+ github.com/cavaliergopher /grab/v3 v3 .0.1 h1:4z7TkBfmPjmLAAmkkAZNX/6QJ1nNFdv3SdIHXju0Fr4 =
21+ github.com/cavaliergopher /grab/v3 v3 .0.1 /go.mod h1:1U/KNnD+Ft6JJiYoYBAimKH2XrYptb8Kl3DFGmsjpq4 =
2222github.com/cevaris/ordered_map v0.0.0-20190319150403-3adeae072e73 h1:q1g9lSyo/nOIC3W5E3FK3Unrz8b9LdLXCyuC+ZcpPC0 =
2323github.com/cevaris/ordered_map v0.0.0-20190319150403-3adeae072e73 /go.mod h1:507vXsotcZop7NZfBWdhPmVeOse4ko2R7AagJYrpoEg =
2424github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8 =
2525github.com/davecgh/go-spew v1.1.0 /go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38 =
26- github.com/djherbis/times v1.5.0 h1:79myA211VwPhFTqUk8xehWrsEO+zcIZj0zT8mXPVARU =
27- github.com/djherbis/times v1.5.0 /go.mod h1:5q7FDLvbNg1L/KaBmPcWlVR9NmoKo3+ucqUA3ijQhA0 =
2826github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY =
2927github.com/go-ole/go-ole v1.2.6 /go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0 =
3028github.com/golang/snappy v0.0.1 /go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q =
You can’t perform that action at this time.
0 commit comments