fail2ban.client.configreader module¶
- class fail2ban.client.configreader.ConfigReader(use_config=None, share_config=None, **kwargs)¶
Bases:
object
Generic config reader class.
A caching adapter which automatically reuses already shared configuration.
- Attributes:
- share_config
Methods
options
(section[, withDefault])Return a list of option names for the given section name.
read
(name[, once])Overloads a default (not shared) read of config reader.
get
getBaseDir
getOptions
has_option
has_section
merge_defaults
merge_section
sections
setBaseDir
- get(sec, opt, raw=False, vars={})¶
- getBaseDir()¶
- getOptions(section, *args, **kwargs)¶
- has_option(sec, opt, withDefault=True)¶
- has_section(sec)¶
- merge_defaults(d)¶
- merge_section(section, *args, **kwargs)¶
- options(section, withDefault=False)¶
Return a list of option names for the given section name.
Parameter withDefault controls the include of names from section [DEFAULT]
- read(name, once=True)¶
Overloads a default (not shared) read of config reader.
To prevent multiple reads of config files with it includes, reads into the config reader, if it was not yet cached/shared by ‘name’.
- sections()¶
- setBaseDir(basedir)¶
Bases:
SafeConfigParserWithIncludes
Unshared config reader (previously ConfigReader).
Do not use this class (internal not shared/cached representation). Use ConfigReader instead.
- Attributes:
- converters
- share_config
Methods
add_section
(section)Create a new section in the configuration.
clear
()get
(section, option, *[, raw, vars, fallback])Get an option value for a given section.
get_ex
(section, option[, raw, vars])Get an option value for a given section.
getint
(section, option, *[, raw, vars, fallback])has_option
(section, option)Check for the existence of a given option in a given section.
has_section
(section)Indicate whether the named section is present in the configuration.
items
([section, raw, vars])Return a list of (name, value) tuples for each option in a section.
keys
()options
(section[, withDefault])Return a list of option names for the given section name.
pop
(k[,d])If key is not found, d is returned if given, otherwise KeyError is raised.
popitem
()Remove a section from the parser and return it as a (section_name, section_proxy) tuple.
read
(filename)Read and parse a filename or an iterable of filenames.
read_dict
(dictionary[, source])Read configuration from a dictionary.
read_file
(f[, source])Like read() but the argument must be a file-like object.
read_string
(string[, source])Read configuration from a given string.
remove_option
(section, option)Remove an option.
remove_section
(section)Remove a file section.
sections
()Return a list of section names, excluding [DEFAULT]
set
(section, option[, value])Set an option.
setdefault
(k[,d])update
([E, ]**F)If E present and has a .keys() method, does: for k in E.keys(): D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v
values
()write
(fp[, space_around_delimiters])Write an .ini-format representation of the configuration state.
defaults
getBaseDir
getOptions
get_defaults
get_sections
getboolean
getfloat
merge_section
optionxform
setBaseDir
Read and parse a filename or an iterable of filenames.
Files that cannot be opened are silently ignored; this is designed so that you can specify an iterable of potential configuration file locations (e.g. current directory, user’s home directory, systemwide directory), and all existing configuration files in the iterable will be read. A single filename may also be given.
Return list of successfully read files.
- class fail2ban.client.configreader.DefinitionInitConfigReader(file_, jailName, initOpts, **kwargs)¶
Bases:
ConfigReader
Config reader for files with options grouped in [Definition] and [Init] sections.
Is a base class for readers of filters and actions, where definitions in jails might provide custom values for options defined in [Init] section.
- Attributes:
- share_config
Methods
convertOptions
(opts, configOpts)Convert interpolated combined options to expected type.
getCombOption
(optname)Get combined definition option (as string) using pre-set and init options as preselection (values with higher precedence as specified in section).
options
(section[, withDefault])Return a list of option names for the given section name.
read
()Overloads a default (not shared) read of config reader.
convert
get
getBaseDir
getCombined
getFile
getJailName
getOptions
has_option
has_section
merge_defaults
merge_section
sections
setBaseDir
setFile
setJailName
- convert()¶
- convertOptions(opts, configOpts)¶
Convert interpolated combined options to expected type.
- getCombOption(optname)¶
Get combined definition option (as string) using pre-set and init options as preselection (values with higher precedence as specified in section).
Can be used only after calling of getOptions.
- getCombined(ignore=())¶
- getFile()¶
- getJailName()¶
- getOptions(pOpts, all=False)¶
- read()¶
Overloads a default (not shared) read of config reader.
To prevent multiple reads of config files with it includes, reads into the config reader, if it was not yet cached/shared by ‘name’.
- readexplicit()¶
- setFile(fileName)¶
- setJailName(jailName)¶