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:
parent
95b439fbd5
commit
2a7bc0e55c
6 changed files with 225 additions and 18 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue