From 21ac58f5dabc78a8c7bb56249f5fa0151202e3d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Benencia?= Date: Fri, 3 Aug 2012 13:36:15 -0300 Subject: Added functions is_ip() and is_domain() --- core.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/core.py b/core.py index 430bdf2..44e3f90 100644 --- a/core.py +++ b/core.py @@ -1,9 +1,11 @@ import socketserver import ipaddr +import re class Daemon(): def __init__(self, data): - self.data = data + self.data = data + self.domain_regexp = re.compile("(?!-)[A-Z\d-]{1,63}(? 255: + return False + + if hostname[-1:] == ".": + hostname = hostname[:-1] # strip exactly one dot from the right, if present + + return all(self.domain_regexp.match(x) for x in hostname.split(".")) # TODO def get_help(self): -- cgit v1.2.3