MCPcopy Create free account
hub / github.com/ProspectOne/perfops-cli / isValidTarget

Function isValidTarget

perfops/run.go:410–427  ·  view source on GitHub ↗

isValidTarget checks if a string is a valid target, i.e., a public domain name or an IP address.

(s string)

Source from the content-addressed store, hash-verified

408// isValidTarget checks if a string is a valid target, i.e., a public
409// domain name or an IP address.
410func isValidTarget(s string) bool {
411 if s == "" {
412 return false
413 }
414 if ip := net.ParseIP(s); ip != nil {
415 return true
416 }
417 // Assume domain name and require at least one level above TLD
418 i := strings.LastIndex(s, ".")
419 if i == -1 || len(s)-1 == i {
420 return false
421 }
422 // TLD may not start with a number
423 if c := s[i+1]; c >= '0' && c <= '9' {
424 return false
425 }
426 return true
427}
428
429// isValidLimit retruns a value indicating whether the limit is valid,
430// e.g., for requests without an API key the limit is capped at 20.

Callers 5

DNSPerfMethod · 0.85
DNSResolveMethod · 0.85
CurlMethod · 0.85
doPostRunRequestMethod · 0.85
TestIsValidTargetFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestIsValidTargetFunction · 0.68