a =*f @sLdZdZdZddlmZddlmZddlmZee Z Gdd d eZ d S) z Cyril Jaquierz Copyright (c) 2004 Cyril JaquierZGPL) ConfigReader) JailReader) getLoggerc@s>eZdZdddZeddZddZdd d Zdd d ZdS) JailsReaderFcKs$tj|fi|t|_||_dS)z Parameters ---------- force_enable : bool, optional Passed to JailReader to force enable the jails. It is for internal use N)r__init__list_JailsReader__jails_JailsReader__force_enable)self force_enablekwargsr?/usr/lib/python3.9/site-packages/fail2ban/client/jailsreader.pyr%szJailsReader.__init__cCs|jS)N)r r rrrjails1szJailsReader.jailscCst|_t|dS)Njail)rr rreadrrrrr5szJailsReader.readNTc Csg}t|d||_|dur&|}n|g}d}|D]x}|dkrBq4t||j|j|jd}|}|r|r|dO}|j |q4t d||rdnd |j ||d O}q4|r|d@p|d @ S) zDReads configuration for jail(s) and adds enabled jails to __jails Z DefinitionNZINCLUDES)r share_configZ use_configrzErrors in jail %r.%sz Skipping...r) r getOptionsZ_JailsReader__optssectionsrr rZ_cfgZ isEnabledr appendlogSyserror) r sectionZ ignoreWrongZoptsrZ parse_statusZsecrretrrrr9s*   zJailsReader.getOptionscCsRt}|jD]}||j|dq |jD]"}|jds*|d|gq*|S)zConvert read before __opts and jails to the commands stream Parameters ---------- allow_missing : bool Either to allow log files to be missing entirely. Primarily is used for testing )allow_no_filesz config-errorstart)rr extendconvertoptionsgetrgetName)r rstreamrrrrr![s    zJailsReader.convert)F)NT)F) __name__ __module__ __qualname__rpropertyrrrr!rrrrr#s    "rN) __author__Z __copyright__Z __license__Z configreaderrZ jailreaderrZhelpersrr&rrrrrrs