o _ @sLdZdZdZddlmZddlmZddlmZee Z Gdd d eZ d S) z Cyril Jaquierz Copyright (c) 2004 Cyril JaquierGPL) 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/dist-packages/fail2ban/client/jailsreader.pyr%s zJailsReader.__init__cCs|jS)N)r r rrrjails1szJailsReader.jailscCst|_t|dS)Njail)r r rreadrrrrr5s zJailsReader.readNTc Csg}t|d||_|dur|}n|g}d}|D]<}|dkr!qt||j|j|jd}|}|rA|r@|dO}|j |qt d||rIdnd |j ||d O}q|r]|d@pa|d @ S) zDReads configuration for jail(s) and adds enabled jails to __jails DefinitionNINCLUDES)r share_config use_configrzErrors in jail %r.%sz Skipping...r) r getOptions_JailsReader__optssectionsrr r_cfg isEnabledr appendlogSyserror) r section ignoreWrongoptsr parse_statussecrretrrrr9s,    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)r r extendconvertoptionsgetr getName)r r)streamrrrrr,[s   zJailsReader.convert)F)NT) __name__ __module__ __qualname__rpropertyrrrr,rrrrr#s   "rN) __author__ __copyright__ __license__ configreaderr jailreaderrhelpersrr1r!rrrrrs