MCPcopy Index your code
hub / github.com/GoEdgeLab/EdgeNode / IsIPv4

Function IsIPv4

internal/utils/ip.go:36–45  ·  view source on GitHub ↗

IsIPv4 是否为IPv4

(ip string)

Source from the content-addressed store, hash-verified

34
35// IsIPv4 是否为IPv4
36func IsIPv4(ip string) bool {
37 var data = net.ParseIP(ip)
38 if data == nil {
39 return false
40 }
41 if strings.Contains(ip, ":") {
42 return false
43 }
44 return data.To4() != nil
45}
46
47// IsIPv6 是否为IPv6
48func IsIPv6(ip string) bool {

Callers 6

TestIsIPv4Function · 0.92
TestIsIPv6Function · 0.92
updateAllowIPListMethod · 0.92
AddIPElementMethod · 0.92
DeleteIPElementMethod · 0.92
IsIPv6Function · 0.85

Calls 2

ParseIPMethod · 0.80
ContainsMethod · 0.45

Tested by 2

TestIsIPv4Function · 0.74
TestIsIPv6Function · 0.74