24 |
24 |
25 |
25 |
26 def isValidIPv4Address(address): |
26 def isValidIPv4Address(address): |
27 """ |
27 """ |
28 Public function to check, if the given address is a valid IPv4 address. |
28 Public function to check, if the given address is a valid IPv4 address. |
29 |
29 |
30 @param address IPv4 address string |
30 @param address IPv4 address string |
31 @type str |
31 @type str |
32 @return flag indicating validity |
32 @return flag indicating validity |
33 @rtype bool |
33 @rtype bool |
34 """ |
34 """ |
35 h = QHostAddress(address) |
35 h = QHostAddress(address) |
36 return ( |
36 return ( |
37 not h.isNull() and |
37 not h.isNull() |
38 h.protocol() == QAbstractSocket.NetworkLayerProtocol.IPv4Protocol |
38 and h.protocol() == QAbstractSocket.NetworkLayerProtocol.IPv4Protocol |
39 ) |
39 ) |
40 |
40 |
41 |
41 |
42 def isValidIPv6Address(address): |
42 def isValidIPv6Address(address): |
43 """ |
43 """ |
44 Public function to check, if the given address is a valid IPv6 address. |
44 Public function to check, if the given address is a valid IPv6 address. |
45 |
45 |
46 @param address IPv6 address string |
46 @param address IPv6 address string |
47 @type str |
47 @type str |
48 @return flag indicating validity |
48 @return flag indicating validity |
49 @rtype bool |
49 @rtype bool |
50 """ |
50 """ |
51 h = QHostAddress(address) |
51 h = QHostAddress(address) |
52 return ( |
52 return ( |
53 not h.isNull() and |
53 not h.isNull() |
54 h.protocol() == QAbstractSocket.NetworkLayerProtocol.IPv6Protocol |
54 and h.protocol() == QAbstractSocket.NetworkLayerProtocol.IPv6Protocol |
55 ) |
55 ) |