Advanced Ip filtering (#4424)

* Added IP Bans configuration

* Fixing warnings

* Added ban enabled option and unit tests

* Fixed py34 tox

* http: requested changes fix

* Requested changes fix
This commit is contained in:
Vlad Korniev 2016-11-24 21:52:10 -08:00 committed by Paulus Schoutsen
parent 95b439fbd5
commit 2a7bc0e55c
6 changed files with 225 additions and 18 deletions

View file

@ -1,6 +1,6 @@
"""Helpers for config validation using voluptuous."""
from collections import OrderedDict
from datetime import timedelta
from datetime import timedelta, datetime as datetime_sys
import os
import re
from urllib.parse import urlparse
@ -297,6 +297,22 @@ def time(value):
return time_val
def datetime(value):
"""Validate datetime."""
if isinstance(value, datetime_sys):
return value
try:
date_val = dt_util.parse_datetime(value)
except TypeError:
date_val = None
if date_val is None:
raise vol.Invalid('Invalid datetime specified: {}'.format(value))
return date_val
def time_zone(value):
"""Validate timezone."""
if dt_util.get_time_zone(value) is not None: