mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
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:
committed by
Paulus Schoutsen
parent
95b439fbd5
commit
2a7bc0e55c
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user