mirror of
https://github.com/aykhans/dodo.git
synced 2025-04-21 11:16:47 +00:00
Compare commits
4 Commits
4686e26ede
...
04e5b5f3eb
Author | SHA1 | Date | |
---|---|---|---|
04e5b5f3eb | |||
2bebf09adb | |||
ebacebff16 | |||
575ca2913a |
@ -12,7 +12,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
VERSION string = "0.5.2"
|
VERSION string = "0.5.3"
|
||||||
DefaultUserAgent string = "Dodo/" + VERSION
|
DefaultUserAgent string = "Dodo/" + VERSION
|
||||||
ProxyCheckURL string = "https://www.google.com"
|
ProxyCheckURL string = "https://www.google.com"
|
||||||
DefaultMethod string = "GET"
|
DefaultMethod string = "GET"
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package requests
|
package requests
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -10,9 +9,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Response struct {
|
type Response struct {
|
||||||
StatusCode int
|
Response string
|
||||||
Error error
|
Time time.Duration
|
||||||
Time time.Duration
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Responses []*Response
|
type Responses []*Response
|
||||||
@ -45,17 +43,10 @@ func (respones Responses) Print() {
|
|||||||
}
|
}
|
||||||
total.Sum += response.Time
|
total.Sum += response.Time
|
||||||
|
|
||||||
if response.Error != nil {
|
mergedResponses[response.Response] = append(
|
||||||
mergedResponses[response.Error.Error()] = append(
|
mergedResponses[response.Response],
|
||||||
mergedResponses[response.Error.Error()],
|
response.Time,
|
||||||
response.Time,
|
)
|
||||||
)
|
|
||||||
} else {
|
|
||||||
mergedResponses[fmt.Sprintf("%d", response.StatusCode)] = append(
|
|
||||||
mergedResponses[fmt.Sprintf("%d", response.StatusCode)],
|
|
||||||
response.Time,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
allDurations = append(allDurations, response.Time)
|
allDurations = append(allDurations, response.Time)
|
||||||
}
|
}
|
||||||
allDurations.Sort()
|
allDurations.Sort()
|
||||||
|
@ -2,6 +2,7 @@ package requests
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -142,18 +143,16 @@ func sendRequest(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
*responseData = append(*responseData, &Response{
|
*responseData = append(*responseData, &Response{
|
||||||
StatusCode: 0,
|
Response: err.Error(),
|
||||||
Error: err,
|
Time: completedTime,
|
||||||
Time: completedTime,
|
|
||||||
})
|
})
|
||||||
increase <- 1
|
increase <- 1
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
*responseData = append(*responseData, &Response{
|
*responseData = append(*responseData, &Response{
|
||||||
StatusCode: response.StatusCode(),
|
Response: strconv.Itoa(response.StatusCode()),
|
||||||
Error: nil,
|
Time: completedTime,
|
||||||
Time: completedTime,
|
|
||||||
})
|
})
|
||||||
increase <- 1
|
increase <- 1
|
||||||
}()
|
}()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user