o ;s*b @sxdZdZdZddlmZzddlmZWney#ddlmZYnwddl m Z m Z dd l m Z Gd d d eZd S) z!Cyril Jaquier, Yaroslav Halchenkoz:Copyright (c) 2004 Cyril Jaquier, 2013- Yaroslav HalchenkoGPL)Lock)Mapping)DuplicateJailExceptionUnknownJailException)Jailc@sJeZdZdZddZdddZddZd d Zd d Zd dZ ddZ dS)JailsaBHandles the jails. This class handles the jails. Creation, deletion or access to a jail must be done through this class. This class is thread-safe which is not the case of the jail itself, including filter and actions. This class is based on Mapping type, and the `add` method must be used to add additional jails. cCst|_t|_dSN)r _Jails__lockdict_jailsselfr7/usr/lib/python3/dist-packages/fail2ban/server/jails.py__init__,s zJails.__init__NcCsf|j&||jvrtrt|nt||||j|<WddSWddS1s,wYdS)aUAdds a jail. Adds a new jail if not already present which should use the given backend. Parameters ---------- name : str The name of the jail. backend : str The backend to use. db : Fail2BanDb Fail2Ban's persistent database instance. Raises ------ DuplicateJailException If jail name is already present. N)r r noduplicatesrr )rnamebackenddbrrradd0s "z Jails.addcCs ||jvSr )rrrrrrexistsKs z Jails.existscCsHzz|j|j|WW|jStyt|w|jwr )r acquirerreleaseKeyErrorrrrrr __getitem__Ns     zJails.__getitem__cCsLzz |j|j|=Wn tyt|wW|jdS|jwr )r rrrrrrrrr __delitem__Ws   zJails.__delitem__cC.z|jt|jW|jS|jwr )r rlenrrrrrr__len__`  z Jails.__len__cCr r )r riterrrrrrr__iter__gr#zJails.__iter__r ) __name__ __module__ __qualname____doc__rrrrrr"r%rrrrr "s   r N) __author__ __copyright__ __license__ threadingrcollections.abcr ImportError collections exceptionsrrjailr r rrrrs