mirror of
https://github.com/projectdiscovery/httpx.git
synced 2024-09-11 17:46:08 +03:00
Merge pull request #75 from jimen0/simplifications-patch
all: simplify logic statements and remove unneeded conversions
This commit is contained in:
commit
4c5b8e6ffe
2
common/cache/dialer.go
vendored
2
common/cache/dialer.go
vendored
@ -39,7 +39,7 @@ func NewDialer(options Options) (DialerFunc, error) {
|
||||
finalIps = append(finalIps, ip)
|
||||
}
|
||||
}
|
||||
if err != nil || len(finalIps) <= 0 {
|
||||
if err != nil || len(finalIps) == 0 {
|
||||
return nil, &NoAddressFoundError{}
|
||||
} // Dial to the IPs finally.
|
||||
for _, ip := range ips {
|
||||
|
@ -26,7 +26,7 @@ func (c *CustomPorts) Set(value string) error {
|
||||
// splits on comma
|
||||
potentialPorts := strings.Split(value, ",")
|
||||
|
||||
// check if port is a single integer value or needs to be expanded futher
|
||||
// check if port is a single integer value or needs to be expanded further
|
||||
for _, potentialPort := range potentialPorts {
|
||||
potentialRange := strings.Split(strings.TrimSpace(potentialPort), "-")
|
||||
// it's a single port?
|
||||
|
@ -14,10 +14,7 @@ func FileExists(filename string) bool {
|
||||
// FolderExists checks if a folder exists
|
||||
func FolderExists(folderpath string) bool {
|
||||
_, err := os.Stat(folderpath)
|
||||
if os.IsNotExist(err) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
return !os.IsNotExist(err)
|
||||
}
|
||||
|
||||
// HasStdin determines if the user has piped input
|
||||
|
@ -117,7 +117,7 @@ func (h *HTTPX) Do(req *retryablehttp.Request) (*Response, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp.Raw = string(rawresp)
|
||||
resp.Raw = rawresp
|
||||
|
||||
var respbody []byte
|
||||
// websockets don't have a readable body
|
||||
|
@ -5,11 +5,7 @@ import "net"
|
||||
// IsCidr determines if the given ip is a cidr range
|
||||
func IsCidr(ip string) bool {
|
||||
_, _, err := net.ParseCIDR(ip)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
return err == nil
|
||||
}
|
||||
|
||||
// IsIP determines if the given string is a valid ip
|
||||
|
Loading…
Reference in New Issue
Block a user