local ip checking helper

This commit is contained in:
Ruud
2013-09-02 15:27:18 +02:00
parent 2715dbaaa5
commit 3e28cd5c95
+5
View File
@@ -106,6 +106,11 @@ def md5(text):
def sha1(text):
return hashlib.sha1(text).hexdigest()
def isLocalIP(ip):
ip = ip.lstrip('htps:/')
regex = '/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1)$/'
return re.search(regex, ip) is not None or 'localhost' in ip or ip[:4] == '127.'
def getExt(filename):
return os.path.splitext(filename)[1][1:]