a =*f @sxdZdZdZddlmZzddlmZWneyFddlmZYn0ddl 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 HalchenkoZGPL)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_jailsselfr9/usr/lib/python3.9/site-packages/fail2ban/server/jails.py__init__,szJails.__init__NcCsP|j6||jvrt|nt||||j|<Wdn1sB0YdS)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 rr)rnameZbackendZdbrrradd0s  z Jails.addcCs ||jvSr )r rrrrrexistsJsz Jails.existscCs^zLz"|j|j|WW|jSty>t|Yn0W|jn |j0dSr )r acquirer releaseKeyErrorrrrrr __getitem__Ms    zJails.__getitem__cCsRz@z|j|j|=Wnty2t|Yn0W|jn |j0dSr )r rr rrrrrrr __delitem__Vs    zJails.__delitem__cCs2z |jt|jW|jS|j0dSr )r rlenr rrrrr__len___s    z Jails.__len__cCs2z |jt|jW|jS|j0dSr )r riterr rrrrr__iter__fs    zJails.__iter__)N) __name__ __module__ __qualname____doc__rrrrrrrrrrrr "s    r N) __author__Z __copyright__Z __license__ threadingrcollections.abcr ImportError collections exceptionsrrZjailrr rrrrs