def configure(self, config: dict, json_key: str='banlist') -> dict:
"""Configure the ban list.
The section of the given key is a dict with two required values:
"file" is the path of the file where the addresses are stored, and
"duration" is the number of seconds an address is rejected.
If the key is missing, the ban list is disabled.
:param config: (dict) Configuration dictionary.
:param json_key: (str) Key of the ban list dict in dict.
:raises: TypeError: the section is not a dict.
:raises: ValueError: a required value is missing or invalid.
:return: (dict) Loaded settings: {"file": str, "duration": int}.
"""
_cfg = config.get(json_key, None)
if _cfg is None:
self.__filename = ''
self.__duration = 0
return {'file': '', 'duration': 0}
if isinstance(_cfg, dict) is False:
raise TypeError(f"JSON key '{json_key}' must be a dict.")
_filename = _cfg.get('file', '')
if type(_filename) is not str or len(_filename) == 0:
raise ValueError(f'{json_key}.file must be a non-empty string.')
_duration = _cfg.get('duration', 0)
if isinstance(_duration, int) is False or _duration <= 0:
raise ValueError(f'{json_key}.duration must be a number of seconds.')
self.__filename = _filename
self.__duration = _duration
return {'file': _filename, 'duration': _duration}