Revision 2632795d lib/utils.py
b/lib/utils.py | ||
---|---|---|
1352 | 1352 |
return IsValidIP4(ip) or IsValidIP6(ip) |
1353 | 1353 |
|
1354 | 1354 |
|
1355 |
def GetAddressFamily(ip): |
|
1356 |
"""Get the address family of the given address. |
|
1357 |
|
|
1358 |
@type ip: str |
|
1359 |
@param ip: ip address whose family will be returned |
|
1360 |
@rtype: int |
|
1361 |
@return: socket.AF_INET or socket.AF_INET6 |
|
1362 |
@raise errors.GenericError: for invalid addresses |
|
1363 |
|
|
1364 |
""" |
|
1365 |
if IsValidIP6(ip): |
|
1366 |
return socket.AF_INET6 |
|
1367 |
elif IsValidIP4(ip): |
|
1368 |
return socket.AF_INET |
|
1369 |
else: |
|
1370 |
raise errors.GenericError("Address %s not valid" % ip) |
|
1371 |
|
|
1372 |
|
|
1355 | 1373 |
def IsValidShellParam(word): |
1356 | 1374 |
"""Verifies is the given word is safe from the shell's p.o.v. |
1357 | 1375 |
|
Also available in: Unified diff