U
    d                     @   s  d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	Z	d dl
Z
d dlmZmZ d dlmZ d dlmZ g Ze	jZdddZdd ZG d	d
 d
eZG dd deZG dd deZedefi Zdd Zdd Zdd Zdd Zdd Z dd Z!dd Z"dd Z#dd  Z$d!d" Z%d#d$ Z&d%d& Z'd'd( Z(d)d* Z)d+d, Z*d-d. Z+d/d0 Z,d1d2 Z-G d3d4 d4eZ.G d5d6 d6eZ/G d7d8 d8eZ0G d9d: d:eZ1G d;d< d<eZ2G d=d> d>eZ3G d?d@ d@eZ4G dAdB dBeZ5G dCdD dDeZ6G dEdF dFeZ7G dGdH dHeZ8G dIdJ dJeZ9G dKdL dLeZ:G dMdN dNeZ;G dOdP dPeZ<G dQdR dReZ=G dSdT dTeZ>G dUdV dVeZ?G dWdX dXeZ@G dYdZ dZeZAG d[d\ d\eZBG d]d^ d^eZCG d_d` d`eZDG dadb dbeZEG dcdd ddeZFG dedf dfeZGG dgdh dheZHG didj djeZIG dkdl dleZJG dmdn dneZKG dodp dpeZLG dqdr dreZMG dsdt dteZNG dudv dveZOG dwdx dxeZPG dydz dzeZQG d{d| d|eZRG d}d~ d~eZSG dd deZTG dd deZUG dd deZVG dd deZWG dd deZXG dd deZYG dd deZZG dd deZ[G dd deZ\G dd deZ]G dd deZ^G dd deZ_G dd deZ`G dd deZaG dd deZbG dd deZcG dd deZdG dd deZeG dd deZfG dd deZgG dd deZhG dd deZiG dd deZjG dd deZkG dd deZlG dd deZmG dd deZnG dd deZoG dd deZpG dd deZqG dd deZrG dd deZsG dd deZtG dd deZuG ddĄ deZvG ddƄ deZwG ddȄ deZxG ddʄ deZyG dd̄ deZzG dd΄ deZ{G ddЄ deZ|G dd҄ deZ}G ddԄ deZ~G ddք deZG dd؄ deZG ddڄ deZG dd܄ deZdS )    N)__version__util)ConfigError)reloader_enginesc                 C   s:   i }| p
d} t D ]$}| }|j| kr&q| ||j< q|S )N )KNOWN_SETTINGSnamecopy)ignoresettingssZsettingr   r   3/tmp/pip-unpacked-wheel-1tw_qy24/gunicorn/config.pymake_settings   s    
r   c                 C   s(   t d|t jr|ddd}t|dS )Nz0(\d)0Z0o   r   )rematch
IGNORECASEreplaceint)_xr   r   r   auto_int'   s    r   c                       s   e Zd Zd*ddZdd Zdd Z fdd	Zd
d Zdd Zdd Z	e
dd Ze
dd Ze
dd Ze
dd Ze
dd Ze
dd Ze
dd Ze
dd Ze
d d! Ze
d"d# Ze
d$d% Ze
d&d' Ze
d(d) Z  ZS )+ConfigNc                 C   s6   t  | _|| _|p"tjtjd | _tj	
 | _d S )Nr   )r   r   usageospathbasenamesysargvprogenvironr	   env_orig)selfr   r    r   r   r   __init__0   s    zConfig.__init__c                 C   sh   g }t dd | jD }t| jD ]:}| j| j}t|rFd|j}|dj|||d q"d|S )Nc                 s   s   | ]}t |V  qd S N)len).0kr   r   r   	<genexpr>8   s     z!Config.__str__.<locals>.<genexpr>z<{}()>z{k:{kmax}} = {v})r(   vkmax
)	maxr   sortedvaluecallableformat__qualname__appendjoin)r#   linesr+   r(   r*   r   r   r   __str__6   s    zConfig.__str__c                 C   s$   || j krtd| | j |  S Nz No configuration setting for: %s)r   AttributeErrorget)r#   r   r   r   r   __getattr__@   s    
zConfig.__getattr__c                    s,   |dkr|| j krtdt || d S )Nr   zInvalid access!)r   r8   super__setattr__r#   r   r/   	__class__r   r   r<   E   s    zConfig.__setattr__c                 C   s*   || j krtd| | j | | d S r7   )r   r8   setr=   r   r   r   r@   J   s    
z
Config.setc                 C   s   d| j krt| j d S g S )NZGUNICORN_CMD_ARGS)r"   shlexsplitr#   r   r   r   get_cmd_args_from_envO   s    
zConfig.get_cmd_args_from_envc                 C   s|   | j | jd}tjf |}|jdddtjdt d dd |jd	d
tjd t| j| jj	d}|D ]}| j| 
| qb|S )N)r   r    z-vz	--versionversionz%(prog)s (version z)
z&show program's version number and exit)actiondefaultrE   helpargs*)nargsrH   )key)r   r    argparseArgumentParseradd_argumentSUPPRESSr   r.   r   __getitem__
add_option)r#   kwargsparserkeysr(   r   r   r   rT   T   s     
zConfig.parserc                 C   s6   | j d  }|dp|dk}|r2| jdkr2dS |S )Nworker_class
SyncWorkersyncr   Zgthread)r   r9   endswiththreads)r#   uriis_syncr   r   r   worker_class_strf   s
    zConfig.worker_class_strc                 C   sR   | j d  }|dp|dk}|r2| jdkr2d}t|}t|drN|  |S )NrV   rW   rX   r   z%gunicorn.workers.gthread.ThreadWorkersetup)r   r9   rY   rZ   r   
load_classhasattrr^   )r#   r[   r\   rV   r   r   r   rV   p   s    

zConfig.worker_classc                 C   s   | j d  }dd |D S )Nbindc                 S   s   g | ]}t t |qS r   )r   Zparse_addressbytes_to_str)r'   ra   r   r   r   
<listcomp>   s     z"Config.address.<locals>.<listcomp>r   r9   )r#   r   r   r   r   address~   s    zConfig.addressc                 C   s   | j d  S )Nuserrd   rC   r   r   r   uid   s    z
Config.uidc                 C   s   | j d  S )Ngrouprd   rC   r   r   r   gid   s    z
Config.gidc                 C   s,   | j d  }|d k	r|S | j d  S d S )N	proc_namedefault_proc_namerd   )r#   Zpnr   r   r   rj      s    zConfig.proc_namec                 C   sj   | j d  }|dkrtj}|tjkrDd| j krD| j d jd k	rDd}tj|ddd}t|drf|  |S )	Nlogger_classsimplestatsd_hostz!gunicorn.instrument.statsd.Statsdgunicorn.glogging.Loggerzgunicorn.loggers)rG   sectioninstall)	r   r9   LoggerClassrG   r/   r   r_   r`   rq   )r#   r[   rl   r   r   r   rl      s    

zConfig.logger_classc                 C   s   | j p
| jS r%   )certfilekeyfilerC   r   r   r   is_ssl   s    zConfig.is_sslc                 C   s2   i }| j  D ]\}}|jdkr| ||< q|S )NSSL)r   itemsrp   r9   )r#   optsr   r/   r   r   r   ssl_options   s
    
zConfig.ssl_optionsc              	   C   sp   | j d  }i }|s|S |D ]L}t|}z|dd\}}W n  tk
r`   td| Y nX |||< q|S )Nraw_env=r   environment setting %r invalid)r   r9   r   rb   rB   
ValueErrorRuntimeError)r#   rz   enver   r(   r*   r   r   r   r      s    

z
Config.envc                 C   s:   | j d  d k	rdS dtjkr6tjd  }|dkS dS )NsendfileFZSENDFILE)y1yestrueT)r   r9   r   r!   lower)r#   r   r   r   r   r      s    
zConfig.sendfilec                 C   s   | j d  S )N
reuse_portrd   rC   r   r   r   r      s    zConfig.reuse_portc              	   C   s   | j d  }|d krd S i }|D ]f}t|}ztd|d\}}W n  tk
rf   td| Y nX |dd}|dd}|||< q"|S )Nraw_paste_global_confz(?<!\\)=r   r|   z\=r{   )	r   r9   r   rb   r   rB   r}   r~   r   )r#   Zraw_global_confZglobal_confr   r   r(   r*   r   r   r   paste_global_conf   s    

zConfig.paste_global_conf)NN)__name__
__module__r2   r$   r6   r:   r<   r@   rD   rT   propertyr]   rV   re   rg   ri   rj   rl   ru   ry   r   r   r   r   __classcell__r   r   r>   r   r   .   sB   


	











r   c                       s$   e Zd Z fddZdd Z  ZS )SettingMetac                    sr   t  j}dd |D }|s(|| |||S tt|d< t|d |d< || |||}||dd t| |S )Nc                 S   s   g | ]}t |tr|qS r   )
isinstancer   )r'   br   r   r   rc      s     
 z'SettingMeta.__new__.<locals>.<listcomp>order	validatordesc )r;   __new__r&   r   staticmethodfmt_descr9   r3   )clsr   basesattrsZ	super_newparents	new_classr>   r   r   r      s    
zSettingMeta.__new__c                 C   s2   t | }t| d| t| d| d  d S )Nr   shortr   )textwrapdedentstripsetattr
splitlines)r   r   r   r   r   r      s    zSettingMeta.fmt_desc)r   r   r2   r   r   r   r   r   r>   r   r      s   r   c                   @   s|   e Zd ZdZdZdZdZdZdZdZ	dZ
dZdZdZdZdZdd Zdd Zdd Zdd	 Zd
d Zdd ZeZdd ZdS )SettingNc                 C   s   | j d k	r| | j  d S r%   )rG   r@   rC   r   r   r   r$     s    
zSetting.__init__c                 C   s   | j s
d S t| j }d| j| jf }|dd}| j| jp<d| jpDtd |d}| j	d k	rb| j	|d< |d dkrx|
d | jd k	r| j|d	< | jd k	r| j|d
< |j|| d S )Nz%s [%s]%z%%store)destrF   typerG   rH   metavarrF   r   rK   const)clitupler   rG   r   r   rF   r   strmetapoprK   r   rO   )r#   rT   rI   Zhelp_txtrS   r   r   r   rR     s(    







zSetting.add_optionc                 C   s
   t  | S r%   )r	   rC   r   r   r   r	   1  s    zSetting.copyc                 C   s   | j S r%   )r/   rC   r   r   r   r9   4  s    zSetting.getc                 C   s(   t | jstd| j | || _d S )NzInvalid validator: %s)r0   r   	TypeErrorr   r/   )r#   valr   r   r   r@   7  s    
zSetting.setc                 C   s   | j |j ko| j|jk S r%   )rp   r   )r#   otherr   r   r   __lt__<  s    
zSetting.__lt__c                 C   s   d| j j| j jt| | jf S )Nz"<%s.%s object at %x with value %r>)r?   r   r   idr/   rC   r   r   r   __repr__A  s    zSetting.__repr__)r   r   r2   r   r/   rp   r   r   r   r   rF   rG   r   r   rK   r   r$   rR   r	   r9   r@   r   Z__cmp__r   r   r   r   r   r      s*   r   c                 C   sh   | d krd S t | tr| S t | ts0td|  |   dkrDdS |   dkrXdS td|  d S )NzInvalid type for casting: %sr   TfalseFzInvalid boolean: %s)r   boolr   r   r   r   r}   r   r   r   r   validate_boolM  s    

r   c                 C   s   t | tstd|  | S )NzValue is not a dictionary: %s )r   dictr   r   r   r   r   validate_dict]  s    
r   c                 C   s6   t | tst| d} nt| } | dk r2td|  | S )Nr   zValue must be positive: %s)r   r   r}   r   r   r   r   validate_pos_intc  s    
r   c              	   C   s   i }dd t tD D ]}tt|||dd  < q| |krB||  S zt| }|| kr^|W S W n ttfk
rx   Y nX td| d|f d S )Nc                 S   s   g | ]}| d r|qS )	PROTOCOL_)
startswith)r'   pr   r   r   rc   p  s     
 z(validate_ssl_version.<locals>.<listcomp>	   z*Invalid ssl_version: %s. Valid options: %sz, )dirsslgetattrr   valuesr}   r   r4   )r   Zssl_versionsprotocolZintvalr   r   r   validate_ssl_versionn  s    
r   c                 C   s*   | d krd S t | ts"td|  |  S )NzNot a string: %s)r   r   r   r   r   r   r   r   validate_string  s
    
r   c                 C   s(   | d krd S t j| s$td|  | S )NzFile %s does not exists.)r   r   existsr}   r   r   r   r   validate_file_exists  s
    r   c                 C   s&   | sg S t | tr| g} dd | D S )Nc                 S   s   g | ]}t |qS r   )r   r'   r*   r   r   r   rc     s     z(validate_list_string.<locals>.<listcomp>)r   r   r   r   r   r   validate_list_string  s
    
r   c                 C   s   dd t | D S )Nc                 S   s   g | ]}t |qS r   )r   r   r   r   r   rc     s     z3validate_list_of_existing_files.<locals>.<listcomp>)r   r   r   r   r   validate_list_of_existing_files  s    r   c                 C   s$   t | } | sg S dd | dD S )Nc                 S   s   g | ]}|r|  qS r   )r   r   r   r   r   rc     s      z+validate_string_to_list.<locals>.<listcomp>,)r   rB   r   r   r   r   validate_string_to_list  s    r   c                 C   s0   t | st | r|  } t | r(| S t| S r%   )inspect
isfunctionismethodisclassr   r   r   r   r   validate_class  s
    
r   c                    s    fdd}|S )Nc              
      s   t | trz| dd\}}W n  tk
r>   td|  Y nX zt||gd}t||} W nP tk
r } ztt|W 5 d }~X Y n$ tk
r   td||f Y nX t	| std|   dkr t
| krtd  | S )	N.r   zFValue '%s' is not import string. Format: module[.submodules...].object)fromlistzCan not load '%s' from '%s'zValue is not callable: %szValue must have an arity of: %s)r   r   rsplitr}   r   
__import__r   ImportErrorr8   r0   r   	get_arity)r   mod_nameZobj_namemodr   arityr   r   _validate_callable  s*    
z-validate_callable.<locals>._validate_callabler   )r   r   r   r   r   validate_callable  s    r   c                 C   sb   | d krt  S t| tr| S |  r.t| S zt| jW S  tk
r\   t	d|  Y nX d S )NzNo such user: '%s')
r   geteuidr   r   isdigitpwdgetpwnampw_uidKeyErrorr   r   r   r   r   validate_user  s    
r   c                 C   sb   | d krt  S t| tr| S |  r.t| S zt| jW S  tk
r\   t	d|  Y nX d S )NzNo such group: '%s')
r   getegidr   r   r   grpgetgrnamgr_gidr   r   r   r   r   r   validate_group  s    
r   c                    sV   t d  t }|dkr" S |dkr6 fddS |dkrJ fddS tdd S )	Nr         c                    s    | ||S r%   r   )workerreqr   _rr   r   r   <lambda>      z'validate_post_request.<locals>.<lambda>   c                    s
    | |S r%   r   )r   r   _er   r   r   r   r     r   zValue must have an arity of: 4)r   r   r   r   )r   largsr   r   r   validate_post_request  s    
r   c                 C   sF   t | } tjtjtjt | }tj|sBt	d|  |S )Nzcan't chdir to %r)
r   r   r   abspathnormpathr4   r   getcwdr   r   )r   r   r   r   r   validate_chdir  s
    "r   c                 C   sJ   t | } | d krd S | d}t|dkr>|d t|d fS tdd S )N:r   r   r   z$Value must consist of: hostname:port)r   rB   r&   r   r   )r   elementsr   r   r   validate_hostport  s    
r   c                 C   s   | t krtd|  | S )NzInvalid reload_engine: %r)r   r   r   r   r   r   validate_reload_engine  s    r   c                  C   s.   t jt jt  d} t j| r*| S d S )Nzgunicorn.conf.py)r   r   r4   r   r   r   )Zconfig_pathr   r   r   get_default_config_file  s    r   c                   @   s,   e Zd ZdZdZddgZdZeZdZ	dZ
dS )	
ConfigFileconfigConfig Filez-cz--configZCONFIGz./gunicorn.conf.pya          The Gunicorn config file.

        A string of the form ``PATH``, ``file:PATH``, or ``python:MODULE_NAME``.

        Only has an effect when specified on the command line or as part of an
        application specific configuration.

        By default, a file named ``gunicorn.conf.py`` will be read from the same
        directory where gunicorn is being run.

        .. versionchanged:: 19.4
           Loading the config from a Python module requires the ``python:``
           prefix.
        Nr   r   r2   r   rp   r   r   r   r   rG   r   r   r   r   r   r     s   r   c                   @   s$   e Zd ZdZdZdZeZdZdZ	dS )WSGIAppZwsgi_appr  STRINGNzz        A WSGI application path in pattern ``$(MODULE_NAME):$(VARIABLE_NAME)``.

        .. versionadded:: 20.1.0
        
r   r   r2   r   rp   r   r   r   rG   r   r   r   r   r   r  6  s   r  c                   @   sR   e Zd ZdZdZdZddgZdZeZ	de
jkrDde
jdgZnd	gZd
ZdS )Bindra   r3   Server Socketz-bz--bindZADDRESSZPORTz0.0.0.0:{0}z127.0.0.1:8000an          The socket to bind.

        A string of the form: ``HOST``, ``HOST:PORT``, ``unix:PATH``,
        ``fd://FD``. An IP is a valid ``HOST``.

        .. versionchanged:: 20.0
           Support for ``fd://FD`` got added.

        Multiple addresses can be bound. ex.::

            $ gunicorn -b 127.0.0.1:8000 -b [::1]:8000 test:app

        will bind the `test:app` application on localhost both on ipv6
        and ipv4 interfaces.

        If the ``PORT`` environment variable is defined, the default
        is ``['0.0.0.0:$PORT']``. If it is not defined, the default
        is ``['127.0.0.1:8000']``.
        N)r   r   r2   r   rF   rp   r   r   r   r   r   r!   r1   r9   rG   r   r   r   r   r   r  B  s   
r  c                   @   s.   e Zd ZdZdZdgZdZeZe	Z
dZdZdS )Backlogbacklogr  z	--backlogINTi   a{          The maximum number of pending connections.

        This refers to the number of clients that can be waiting to be served.
        Exceeding this number results in the client getting an error when
        attempting to connect. It should only affect servers under significant
        load.

        Must be a positive integer. Generally set in the 64-2048 range.
        Nr   r   r2   r   rp   r   r   r   r   r   r   rG   r   r   r   r   r   r	  e  s   r	  c                   @   s>   e Zd ZdZdZddgZdZeZe	Z
e	ejddZdZd	S )
WorkersworkersWorker Processesz-wz	--workersr  ZWEB_CONCURRENCYr   a          The number of worker processes for handling requests.

        A positive integer generally in the ``2-4 x $(NUM_CORES)`` range.
        You'll want to vary this a bit to find the best for your particular
        application's work load.

        By default, the value of the ``WEB_CONCURRENCY`` environment variable,
        which is set by some Platform-as-a-Service providers such as Heroku. If
        it is not defined, the default is ``1``.
        N)r   r   r2   r   rp   r   r   r   r   r   r   r   r!   r9   rG   r   r   r   r   r   r  y  s   r  c                   @   s,   e Zd ZdZdZddgZdZeZdZ	dZ
dS )	WorkerClassrV   r  z-kz--worker-classr  rX   a          The type of workers to use.

        The default class (``sync``) should handle most "normal" types of
        workloads. You'll want to read :doc:`design` for information on when
        you might want to choose one of the other worker classes. Required
        libraries may be installed using setuptools' ``extras_require`` feature.

        A string referring to one of the following bundled classes:

        * ``sync``
        * ``eventlet`` - Requires eventlet >= 0.24.1 (or install it via
          ``pip install gunicorn[eventlet]``)
        * ``gevent``   - Requires gevent >= 1.4 (or install it via
          ``pip install gunicorn[gevent]``)
        * ``tornado``  - Requires tornado >= 0.2 (or install it via
          ``pip install gunicorn[tornado]``)
        * ``gthread``  - Python 2 requires the futures package to be installed
          (or install it via ``pip install gunicorn[gthread]``)

        Optionally, you can provide your own worker by giving Gunicorn a
        Python path to a subclass of ``gunicorn.workers.base.Worker``.
        This alternative syntax will load the gevent class:
        ``gunicorn.workers.ggevent.GeventWorker``.
        Nr   r   r2   r   rp   r   r   r   r   rG   r   r   r   r   r   r    s   r  c                   @   s.   e Zd ZdZdZdgZdZeZe	Z
dZdZdS )WorkerThreadsrZ   r  z	--threadsr  r   am          The number of worker threads for handling requests.

        Run each worker with the specified number of threads.

        A positive integer generally in the ``2-4 x $(NUM_CORES)`` range.
        You'll want to vary this a bit to find the best for your particular
        application's work load.

        If it is not defined, the default is ``1``.

        This setting only affects the Gthread worker type.

        .. note::
           If you try to use the ``sync`` worker type and set the ``threads``
           setting to more than 1, the ``gthread`` worker type will be used
           instead.
        Nr  r   r   r   r   r    s   r  c                   @   s.   e Zd ZdZdZdgZdZeZe	Z
dZdZdS )WorkerConnectionsZworker_connectionsr  z--worker-connectionsr  i  z        The maximum number of simultaneous clients.

        This setting only affects the Eventlet and Gevent worker types.
        Nr  r   r   r   r   r    s   r  c                   @   s.   e Zd ZdZdZdgZdZeZe	Z
dZdZdS )MaxRequestsZmax_requestsr  z--max-requestsr  r   a          The maximum number of requests a worker will process before restarting.

        Any value greater than zero will limit the number of requests a worker
        will process before automatically restarting. This is a simple method
        to help limit the damage of memory leaks.

        If this is set to zero (the default) then the automatic worker
        restarts are disabled.
        Nr  r   r   r   r   r    s   r  c                   @   s.   e Zd ZdZdZdgZdZeZe	Z
dZdZdS )MaxRequestsJitterZmax_requests_jitterr  z--max-requests-jitterr  r   aB          The maximum jitter to add to the *max_requests* setting.

        The jitter causes the restart per worker to be randomized by
        ``randint(0, max_requests_jitter)``. This is intended to stagger worker
        restarts to avoid all workers restarting at the same time.

        .. versionadded:: 19.2
        Nr  r   r   r   r   r    s   r  c                   @   s0   e Zd ZdZdZddgZdZeZe	Z
dZdZdS )	Timeouttimeoutr  z-tz	--timeoutr     aH          Workers silent for more than this many seconds are killed and restarted.

        Value is a positive number or 0. Setting it to 0 has the effect of
        infinite timeouts by disabling timeouts for all workers entirely.

        Generally, the default of thirty seconds should suffice. Only set this
        noticeably higher if you're sure of the repercussions for sync workers.
        For the non sync workers it just means that the worker process is still
        communicating and is not tied to the length of time required to handle a
        single request.
        Nr  r   r   r   r   r    s   r  c                   @   s.   e Zd ZdZdZdgZdZeZe	Z
dZdZdS )GracefulTimeoutZgraceful_timeoutr  z--graceful-timeoutr  r  a          Timeout for graceful workers restart.

        After receiving a restart signal, workers have this much time to finish
        serving requests. Workers still alive after the timeout (starting from
        the receipt of the restart signal) are force killed.
        Nr  r   r   r   r   r    s   r  c                   @   s.   e Zd ZdZdZdgZdZeZe	Z
dZdZdS )	Keepalive	keepaliver  z--keep-aliver  r   a          The number of seconds to wait for requests on a Keep-Alive connection.

        Generally set in the 1-5 seconds range for servers with direct connection
        to the client (e.g. when you don't have separate load balancer). When
        Gunicorn is deployed behind a load balancer, it often makes sense to
        set this to a higher value.

        .. note::
           ``sync`` worker does not support persistent connections and will
           ignore this option.
        Nr  r   r   r   r   r  )  s   r  c                   @   s.   e Zd ZdZdZdgZdZeZe	Z
dZdZdS )LimitRequestLineZlimit_request_lineSecurityz--limit-request-liner  i  a          The maximum size of HTTP request line in bytes.

        This parameter is used to limit the allowed size of a client's
        HTTP request-line. Since the request-line consists of the HTTP
        method, URI, and protocol version, this directive places a
        restriction on the length of a request-URI allowed for a request
        on the server. A server needs this value to be large enough to
        hold any of its resource names, including any information that
        might be passed in the query part of a GET request. Value is a number
        from 0 (unlimited) to 8190.

        This parameter can be used to prevent any DDOS attack.
        Nr  r   r   r   r   r  ?  s   r  c                   @   s.   e Zd ZdZdZdgZdZeZe	Z
dZdZdS )LimitRequestFieldsZlimit_request_fieldsr  z--limit-request-fieldsr  d   a?          Limit the number of HTTP headers fields in a request.

        This parameter is used to limit the number of headers in a request to
        prevent DDOS attack. Used with the *limit_request_field_size* it allows
        more safety. By default this value is 100 and can't be larger than
        32768.
        Nr  r   r   r   r   r  W  s   r  c                   @   s.   e Zd ZdZdZdgZdZeZe	Z
dZdZdS )LimitRequestFieldSizeZlimit_request_field_sizer  z--limit-request-field_sizer  i  a6          Limit the allowed size of an HTTP request header field.

        Value is a positive number or 0. Setting it to 0 will allow unlimited
        header field sizes.

        .. warning::
           Setting this parameter to a very high or unlimited value can open
           up for DDOS attacks.
        Nr  r   r   r   r   r   i  s   r   c                   @   s*   e Zd ZdZdZdgZeZdZdZ	dZ
dS )Reloadreload	Debuggingz--reload
store_trueFa          Restart workers when code changes.

        This setting is intended for development. It will cause workers to be
        restarted whenever application code changes.

        The reloader is incompatible with application preloading. When using a
        paste configuration be sure that the server block does not import any
        application code or the reload will not work as designed.

        The default behavior is to attempt inotify with a fallback to file
        system polling. Generally, inotify should be preferred if available
        because it consumes less system resources.

        .. note::
           In order to use the inotify reloader, you must have the ``inotify``
           package installed.
        Nr   r   r2   r   rp   r   r   r   rF   rG   r   r   r   r   r   r!  }  s   r!  c                   @   s*   e Zd ZdZdZdgZdZeZdZ	dZ
dS )ReloadEngineZreload_enginer#  z--reload-enginer  autoz        The implementation that should be used to power :ref:`reload`.

        Valid engines are:

        * ``'auto'``
        * ``'poll'``
        * ``'inotify'`` (requires inotify)

        .. versionadded:: 19.7
        N)r   r   r2   r   rp   r   r   r   r   rG   r   r   r   r   r   r&    s   r&  c                   @   s.   e Zd ZdZdZdZdgZdZeZ	g Z
dZdS )ReloadExtraFilesZreload_extra_filesr3   r#  z--reload-extra-fileZFILESz        Extends :ref:`reload` option to also watch and reload on additional files
        (e.g., templates, configurations, specifications, etc.).

        .. versionadded:: 19.8
        N)r   r   r2   r   rF   rp   r   r   r   r   rG   r   r   r   r   r   r(    s   r(  c                   @   s*   e Zd ZdZdZdgZeZdZdZ	dZ
dS )SpewZspewr#  z--spewr$  Fz|        Install a trace function that spews every line executed by the server.

        This is the nuclear option.
        Nr%  r   r   r   r   r)    s   r)  c                   @   s*   e Zd ZdZdZdgZeZdZdZ	dZ
dS )ConfigCheckZcheck_configr#  z--check-configr$  Fz        Check the configuration and exit. The exit status is 0 if the
        configuration is correct, and 1 if the configuration is incorrect.
        Nr%  r   r   r   r   r*    s   r*  c                   @   s*   e Zd ZdZdZdgZeZdZdZ	dZ
dS )PrintConfigZprint_configr#  z--print-configr$  Fza        Print the configuration settings as fully resolved. Implies :ref:`check-config`.
        Nr%  r   r   r   r   r+    s   r+  c                   @   s*   e Zd ZdZdZdgZeZdZdZ	dZ
dS )
PreloadAppZpreload_appServer Mechanicsz	--preloadr$  FaY          Load application code before the worker processes are forked.

        By preloading an application you can save some RAM resources as well as
        speed up server boot times. Although, if you defer application loading
        to each worker process, you can reload your application code easily by
        restarting workers.
        Nr%  r   r   r   r   r,    s   r,  c                   @   s*   e Zd ZdZdZdgZeZdZdZ	dZ
dS )Sendfiler   r-  z--no-sendfilestore_constFa          Disables the use of ``sendfile()``.

        If not set, the value of the ``SENDFILE`` environment variable is used
        to enable or disable its usage.

        .. versionadded:: 19.2
        .. versionchanged:: 19.4
           Swapped ``--sendfile`` with ``--no-sendfile`` to actually allow
           disabling.
        .. versionchanged:: 19.6
           added support for the ``SENDFILE`` environment variable
        N)r   r   r2   r   rp   r   r   r   rF   r   r   r   r   r   r   r.    s   r.  c                   @   s*   e Zd ZdZdZdgZeZdZdZ	dZ
dS )	ReusePortr   r-  z--reuse-portr$  Fzg        Set the ``SO_REUSEPORT`` flag on the listening socket.

        .. versionadded:: 19.8
        Nr%  r   r   r   r   r0    s   r0  c                   @   s*   e Zd ZdZdZdgZeZe	 Z
dZdS )Chdirchdirr-  z--chdirzM        Change directory to specified directory before loading apps.
        N)r   r   r2   r   rp   r   r   r   r   r   rG   r   r   r   r   r   r1    s   r1  c                   @   s,   e Zd ZdZdZddgZeZdZdZ	dZ
dS )	Daemondaemonr-  z-Dz--daemonr$  Fz        Daemonize the Gunicorn process.

        Detaches the server from the controlling terminal and enters the
        background.
        Nr%  r   r   r   r   r3  &  s   r3  c                   @   s0   e Zd ZdZdZdZddgZdZeZ	g Z
dZdS )	Envrz   r3   r-  z-ez--envENVa|          Set environment variables in the execution environment.

        Should be a list of strings in the ``key=value`` format.

        For example on the command line:

        .. code-block:: console

            $ gunicorn -b 127.0.0.1:8000 --env FOO=1 test:app

        Or in the configuration file:

        .. code-block:: python

            raw_env = ["FOO=1"]
        Nr   r   r2   r   rF   rp   r   r   r   r   rG   r   r   r   r   r   r5  5  s   r5  c                   @   s,   e Zd ZdZdZddgZdZeZdZ	dZ
dS )PidfileZpidfiler-  z-pz--pidFILENzf        A filename to use for the PID file.

        If not set, no PID file will be written.
        r  r   r   r   r   r8  Q  s   r8  c                   @   s*   e Zd ZdZdZdgZdZeZdZ	dZ
dS )WorkerTmpDirZworker_tmp_dirr-  z--worker-tmp-dirDIRNa          A directory to use for the worker heartbeat temporary file.

        If not set, the default temporary directory will be used.

        .. note::
           The current heartbeat system involves calling ``os.fchmod`` on
           temporary file handlers and may block a worker for arbitrary time
           if the directory is on a disk-backed filesystem.

           See :ref:`blocking-os-fchmod` for more detailed information
           and a solution for avoiding this problem.
        r  r   r   r   r   r:  _  s   r:  c                   @   s0   e Zd ZdZdZddgZdZeZe	
 ZdZdS )Userrf   r-  z-uz--userUSERz        Switch worker processes to run as this user.

        A valid user id (as an integer) or the name of a user that can be
        retrieved with a call to ``pwd.getpwnam(value)`` or ``None`` to not
        change the worker process user.
        N)r   r   r2   r   rp   r   r   r   r   r   r   rG   r   r   r   r   r   r<  u  s   r<  c                   @   s0   e Zd ZdZdZddgZdZeZe	
 ZdZdS )Grouprh   r-  z-gz--groupZGROUPz        Switch worker process to run as this group.

        A valid group id (as an integer) or the name of a user that can be
        retrieved with a call to ``pwd.getgrnam(value)`` or ``None`` to not
        change the worker processes group.
        N)r   r   r2   r   rp   r   r   r   r   r   r   rG   r   r   r   r   r   r>    s   r>  c                   @   s0   e Zd ZdZdZddgZdZeZe	Z
dZdZdS )	Umaskumaskr-  z-mz--umaskr  r   a          A bit mask for the file mode on files written by Gunicorn.

        Note that this affects unix socket permissions.

        A valid value for the ``os.umask(mode)`` call or a string compatible
        with ``int(value, 0)`` (``0`` means Python guesses the base, so values
        like ``0``, ``0xFF``, ``0022`` are valid for decimal, hex, and octal
        representations)
        N)r   r   r2   r   rp   r   r   r   r   r   r   rG   r   r   r   r   r   r?    s   r?  c                   @   s*   e Zd ZdZdZdgZeZdZdZ	dZ
dS )
Initgroups
initgroupsr-  z--initgroupsr$  Fz        If true, set the worker process's group access list with all of the
        groups of which the specified username is a member, plus the specified
        group id.

        .. versionadded:: 19.7
        Nr%  r   r   r   r   rA    s   rA  c                   @   s$   e Zd ZdZdZdZeZdZdZ	dS )TmpUploadDirZtmp_upload_dirr-  r;  Na6          Directory to store temporary request data as they are read.

        This may disappear in the near future.

        This path should be writable by the process permissions set for Gunicorn
        workers. If not specified, Gunicorn will choose a system generated
        temporary directory.
        r  r   r   r   r   rC    s   rC  c                   @   s(   e Zd ZdZdZeZddddZdZdS )	SecureSchemeHeaderZsecure_scheme_headersr-  r   httpson)zX-FORWARDED-PROTOCOLzX-FORWARDED-PROTOzX-FORWARDED-SSLa{  
        A dictionary containing headers and values that the front-end proxy
        uses to indicate HTTPS requests. If the source IP is permitted by
        ``forwarded-allow-ips`` (below), *and* at least one request header matches
        a key-value pair listed in this dictionary, then Gunicorn will set
        ``wsgi.url_scheme`` to ``https``, so your application can tell that the
        request is secure.

        If the other headers listed in this dictionary are not present in the request, they will be ignored,
        but if the other headers are present and do not match the provided values, then
        the request will fail to parse. See the note below for more detailed examples of this behaviour.

        The dictionary should map upper-case header names to exact string
        values. The value comparisons are case-sensitive, unlike the header
        names, so make sure they're exactly what your front-end proxy sends
        when handling HTTPS requests.

        It is important that your front-end proxy configuration ensures that
        the headers defined here can not be passed directly from the client.
        N	r   r   r2   r   rp   r   r   rG   r   r   r   r   r   rD    s   rD  c                   @   s4   e Zd ZdZdZdgZdZeZe	j
ddZdZdS )	ForwardedAllowIPSZforwarded_allow_ipsr-  z--forwarded-allow-ipsr  ZFORWARDED_ALLOW_IPS	127.0.0.1a
          Front-end's IPs from which allowed to handle set secure headers.
        (comma separate).

        Set to ``*`` to disable checking of Front-end IPs (useful for setups
        where you don't know in advance the IP address of Front-end, but
        you still trust the environment).

        By default, the value of the ``FORWARDED_ALLOW_IPS`` environment
        variable. If it is not defined, the default is ``"127.0.0.1"``.
        
        .. note::
        
            The interplay between the request headers, the value of ``forwarded_allow_ips``, and the value of
            ``secure_scheme_headers`` is complex. Various scenarios are documented below to further elaborate. In each case, we 
            have a request from the remote address 134.213.44.18, and the default value of ``secure_scheme_headers``:
            
            .. code::
            
                secure_scheme_headers = {
                    'X-FORWARDED-PROTOCOL': 'ssl',
                    'X-FORWARDED-PROTO': 'https',
                    'X-FORWARDED-SSL': 'on'
                }
            
        
            .. list-table:: 
                :header-rows: 1
                :align: center
                :widths: auto
                
                * - ``forwarded-allow-ips``
                  - Secure Request Headers
                  - Result
                  - Explanation
                * - .. code:: 
                    
                        ["127.0.0.1"]
                  - .. code::
                  
                        X-Forwarded-Proto: https
                  - .. code:: 
                    
                        wsgi.url_scheme = "http"
                  - IP address was not allowed
                * - .. code:: 
                    
                        "*"
                  - <none>
                  - .. code:: 
                    
                        wsgi.url_scheme = "http"
                  - IP address allowed, but no secure headers provided
                * - .. code:: 
                    
                        "*"
                  - .. code::
                  
                        X-Forwarded-Proto: https
                  - .. code:: 
                    
                        wsgi.url_scheme = "https"
                  - IP address allowed, one request header matched
                * - .. code:: 
                    
                        ["134.213.44.18"]
                  - .. code::
                  
                        X-Forwarded-Ssl: on
                        X-Forwarded-Proto: http
                  - ``InvalidSchemeHeaders()`` raised
                  - IP address allowed, but the two secure headers disagreed on if HTTPS was used
                

        N)r   r   r2   r   rp   r   r   r   r   r   r!   r9   rG   r   r   r   r   r   rH    s   rH  c                   @   s*   e Zd ZdZdZdgZdZeZdZ	dZ
dS )	AccessLogZ	accesslogLoggingz--access-logfiler9  NzW        The Access log file to write to.

        ``'-'`` means log to stdout.
        r  r   r   r   r   rJ  ?  s   rJ  c                   @   s*   e Zd ZdZdZdgZeZdZdZ	dZ
dS )DisableRedirectAccessToSyslogZ!disable_redirect_access_to_syslogrK  z#--disable-redirect-access-to-syslogr$  FzL    Disable redirect access logs to syslog.

    .. versionadded:: 19.8
    Nr%  r   r   r   r   rL  M  s   rL  c                   @   s*   e Zd ZdZdZdgZdZeZdZ	dZ
dS )AccessLogFormatZaccess_log_formatrK  z--access-logformatr  z;%(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"a          The access log format.

        ===========  ===========
        Identifier   Description
        ===========  ===========
        h            remote address
        l            ``'-'``
        u            user name
        t            date of the request
        r            status line (e.g. ``GET / HTTP/1.1``)
        m            request method
        U            URL path without query string
        q            query string
        H            protocol
        s            status
        B            response length
        b            response length or ``'-'`` (CLF format)
        f            referer
        a            user agent
        T            request time in seconds
        M            request time in milliseconds
        D            request time in microseconds
        L            request time in decimal seconds
        p            process ID
        {header}i    request header
        {header}o    response header
        {variable}e  environment variable
        ===========  ===========

        Use lowercase for header and environment variable names, and put
        ``{...}x`` names inside ``%(...)s``. For example::

            %({x-forwarded-for}i)s
        Nr  r   r   r   r   rM  [  s   rM  c                   @   s,   e Zd ZdZdZddgZdZeZdZ	dZ
dS )	ErrorLogZerrorlogrK  z--error-logfilez
--log-filer9  -z        The Error log file to write to.

        Using ``'-'`` for FILE makes gunicorn log to stderr.

        .. versionchanged:: 19.2
           Log to stderr by default.

        Nr  r   r   r   r   rN    s   rN  c                   @   s*   e Zd ZdZdZdgZdZeZdZ	dZ
dS )LoglevelZloglevelrK  z--log-levelZLEVELinfoz        The granularity of Error log outputs.

        Valid level names are:

        * ``'debug'``
        * ``'info'``
        * ``'warning'``
        * ``'error'``
        * ``'critical'``
        Nr  r   r   r   r   rP    s   rP  c                   @   s*   e Zd ZdZdZdgZeZdZdZ	dZ
dS )CaptureOutputcapture_outputrK  z--capture-outputr$  Fzm        Redirect stdout/stderr to specified file in :ref:`errorlog`.

        .. versionadded:: 19.6
        Nr%  r   r   r   r   rR    s   rR  c                   @   s*   e Zd ZdZdZdgZdZeZdZ	dZ
dS )rr   rl   rK  z--logger-classr  ro   aa          The logger you want to use to log events in Gunicorn.

        The default class (``gunicorn.glogging.Logger``) handles most
        normal usages in logging. It provides error and access logging.

        You can provide your own logger by giving Gunicorn a Python path to a
        class that quacks like ``gunicorn.glogging.Logger``.
        Nr  r   r   r   r   rr     s   rr   c                   @   s*   e Zd ZdZdZdgZdZeZdZ	dZ
dS )	LogConfigZ	logconfigrK  z--log-configr9  Nzz    The log config file to use.
    Gunicorn uses the standard Python logging module's Configuration
    file format.
    r  r   r   r   r   rT    s   rT  c                   @   s    e Zd ZdZdZeZi ZdZdS )LogConfigDictZlogconfig_dictrK  aj      The log config dictionary to use, using the standard Python
    logging module's dictionary configuration format. This option
    takes precedence over the :ref:`logconfig` option, which uses the
    older file configuration format.

    Format: https://docs.python.org/3/library/logging.config.html#logging.config.dictConfig

    .. versionadded:: 19.8
    NrG  r   r   r   r   rU    s
   rU  c                   @   sT   e Zd ZdZdZdgZdZeZe	dkr,dZ
n e	dkr:dZ
ne	d	krHd
Z
ndZ
dZdS )SyslogToZsyslog_addrrK  z--log-syslog-toZSYSLOG_ADDRdarwinzunix:///var/run/syslog)ZfreebsdZ	dragonflyzunix:///var/run/logZopenbsdzunix:///dev/logzudp://localhost:514aY      Address to send syslog messages.

    Address is a string of the form:

    * ``unix://PATH#TYPE`` : for unix domain socket. ``TYPE`` can be ``stream``
      for the stream driver or ``dgram`` for the dgram driver.
      ``stream`` is the default.
    * ``udp://HOST:PORT`` : for UDP sockets
    * ``tcp://HOST:PORT`` : for TCP sockets

    N)r   r   r2   r   rp   r   r   r   r   PLATFORMrG   r   r   r   r   r   rV    s   rV  c                   @   s*   e Zd ZdZdZdgZeZdZdZ	dZ
dS )SyslogsyslogrK  z--log-syslogr$  Fz    Send *Gunicorn* logs to syslog.

    .. versionchanged:: 19.8
       You can now disable sending access logs by using the
       :ref:`disable-redirect-access-to-syslog` setting.
    Nr%  r   r   r   r   rY  
  s   rY  c                   @   s*   e Zd ZdZdZdgZdZeZdZ	dZ
dS )SyslogPrefixZsyslog_prefixrK  z--log-syslog-prefixZSYSLOG_PREFIXNz    Makes Gunicorn use the parameter as program-name in the syslog entries.

    All entries will be prefixed by ``gunicorn.<prefix>``. By default the
    program name is the name of the process.
    r  r   r   r   r   r[    s   r[  c                   @   s*   e Zd ZdZdZdgZdZeZdZ	dZ
dS )SyslogFacilityZsyslog_facilityrK  z--log-syslog-facilityZSYSLOG_FACILITYrf   z    Syslog facility name
    Nr  r   r   r   r   r\  )  s   r\  c                   @   s,   e Zd ZdZdZddgZeZdZdZ	dZ
dS )	EnableStdioInheritanceZenable_stdio_inheritancerK  z-Rz--enable-stdio-inheritanceFr$  z    Enable stdio inheritance.

    Enable inheritance for stdio file descriptors in daemon mode.

    Note: To disable the Python stdout buffering, you can to set the user
    environment variable ``PYTHONUNBUFFERED`` .
    Nr   r   r2   r   rp   r   r   r   rG   rF   r   r   r   r   r   r]  5  s   r]  c                   @   s*   e Zd ZdZdZdgZdZdZeZ	dZ
dS )
StatsdHostrn   rK  z--statsd-hostZSTATSD_ADDRNzR    ``host:port`` of the statsd server to log to.

    .. versionadded:: 19.1
    )r   r   r2   r   rp   r   r   rG   r   r   r   r   r   r   r   r_  G  s   r_  c                   @   s*   e Zd ZdZdZdgZdZdZeZ	dZ
dS )DogstatsdTagsZdogstatsd_tagsrK  z--dogstatsd-tagsZDOGSTATSD_TAGSr   z}    A comma-delimited list of datadog statsd (dogstatsd) tags to append to
    statsd metrics.

    .. versionadded:: 20
    Nr   r   r2   r   rp   r   r   rG   r   r   r   r   r   r   r   r`  U  s   r`  c                   @   s*   e Zd ZdZdZdgZdZdZeZ	dZ
dS )StatsdPrefixZstatsd_prefixrK  z--statsd-prefixZSTATSD_PREFIXr   z    Prefix to use when emitting statsd metrics (a trailing ``.`` is added,
    if not provided).

    .. versionadded:: 19.2
    Nra  r   r   r   r   rb  c  s   rb  c                   @   s,   e Zd ZdZdZddgZdZeZdZ	dZ
dS )Procnamerj   Process Namingz-nz--namer  Na          A base to use with setproctitle for process naming.

        This affects things like ``ps`` and ``top``. If you're going to be
        running more than one instance of Gunicorn you'll probably want to set a
        name to tell them apart. This requires that you install the setproctitle
        module.

        If not set, the *default_proc_name* setting will be used.
        r  r   r   r   r   rc  r  s   rc  c                   @   s    e Zd ZdZdZeZdZdZdS )DefaultProcNamerk   rd  gunicornzP        Internal setting that is adjusted for each type of application.
        N)	r   r   r2   r   rp   r   r   rG   r   r   r   r   r   re    s
   re  c                   @   s*   e Zd ZdZdZdgZdZeZdZ	dZ
dS )
PythonPath
pythonpathr-  z--pythonpathr  Nz        A comma-separated list of directories to add to the Python path.

        e.g.
        ``'/home/djangoprojects/myproject,/home/python/mylibrary'``.
        r  r   r   r   r   rg    s   rg  c                   @   s,   e Zd ZdZdZddgZdZeZdZ	dZ
dS )PasteZpaster-  z--pastez--pasterr  Na[          Load a PasteDeploy config file. The argument may contain a ``#``
        symbol followed by the name of an app section from the config file,
        e.g. ``production.ini#admin``.

        At this time, using alternate server blocks is not supported. Use the
        command line arguments to control server configuration instead.
        r  r   r   r   r   ri    s   ri  c                   @   s4   e Zd ZdZdZedZeZdd Z	e
e	ZdZdS )
OnStartingon_startingServer Hooksr   c                 C   s   d S r%   r   serverr   r   r   rk    s    zOnStarting.on_startingz        Called just before the master process is initialized.

        The callable needs to accept a single instance variable for the Arbiter.
        N)r   r   r2   r   rp   r   r   r0   r   rk  r   rG   r   r   r   r   r   rj    s   rj  c                   @   s4   e Zd ZdZdZedZeZdd Z	e
e	ZdZdS )OnReload	on_reloadrl  r   c                 C   s   d S r%   r   rm  r   r   r   rp    s    zOnReload.on_reloadz        Called to recycle workers during a reload via SIGHUP.

        The callable needs to accept a single instance variable for the Arbiter.
        N)r   r   r2   r   rp   r   r   r0   r   rp  r   rG   r   r   r   r   r   ro    s   ro  c                   @   s4   e Zd ZdZdZedZeZdd Z	e
e	ZdZdS )	WhenReady
when_readyrl  r   c                 C   s   d S r%   r   rm  r   r   r   rr    s    zWhenReady.when_readyz        Called just after the server is started.

        The callable needs to accept a single instance variable for the Arbiter.
        N)r   r   r2   r   rp   r   r   r0   r   rr  r   rG   r   r   r   r   r   rq    s   rq  c                   @   s4   e Zd ZdZdZedZeZdd Z	e
e	ZdZdS )Preforkpre_forkrl  r   c                 C   s   d S r%   r   rn  r   r   r   r   rt    s    zPrefork.pre_forkz        Called just before a worker is forked.

        The callable needs to accept two instance variables for the Arbiter and
        new Worker.
        N)r   r   r2   r   rp   r   r   r0   r   rt  r   rG   r   r   r   r   r   rs    s   rs  c                   @   s4   e Zd ZdZdZedZeZdd Z	e
e	ZdZdS )Postfork	post_forkrl  r   c                 C   s   d S r%   r   ru  r   r   r   rw    s    zPostfork.post_forkz        Called just after a worker has been forked.

        The callable needs to accept two instance variables for the Arbiter and
        new Worker.
        N)r   r   r2   r   rp   r   r   r0   r   rw  r   rG   r   r   r   r   r   rv    s   rv  c                   @   s4   e Zd ZdZdZedZeZdd Z	e
e	ZdZdS )PostWorkerInitpost_worker_initrl  r   c                 C   s   d S r%   r   r   r   r   r   ry    s    zPostWorkerInit.post_worker_initz        Called just after a worker has initialized the application.

        The callable needs to accept one instance variable for the initialized
        Worker.
        N)r   r   r2   r   rp   r   r   r0   r   ry  r   rG   r   r   r   r   r   rx    s   rx  c                   @   s4   e Zd ZdZdZedZeZdd Z	e
e	ZdZdS )	WorkerInt
worker_intrl  r   c                 C   s   d S r%   r   rz  r   r   r   r|    s    zWorkerInt.worker_intz        Called just after a worker exited on SIGINT or SIGQUIT.

        The callable needs to accept one instance variable for the initialized
        Worker.
        N)r   r   r2   r   rp   r   r   r0   r   r|  r   rG   r   r   r   r   r   r{    s   r{  c                   @   s4   e Zd ZdZdZedZeZdd Z	e
e	ZdZdS )WorkerAbortworker_abortrl  r   c                 C   s   d S r%   r   rz  r   r   r   r~  +  s    zWorkerAbort.worker_abortz        Called when a worker received the SIGABRT signal.

        This call generally happens on timeout.

        The callable needs to accept one instance variable for the initialized
        Worker.
        N)r   r   r2   r   rp   r   r   r0   r   r~  r   rG   r   r   r   r   r   r}  %  s   r}  c                   @   s4   e Zd ZdZdZedZeZdd Z	e
e	ZdZdS )PreExecpre_execrl  r   c                 C   s   d S r%   r   rm  r   r   r   r  ?  s    zPreExec.pre_execz        Called just before a new master process is forked.

        The callable needs to accept a single instance variable for the Arbiter.
        N)r   r   r2   r   rp   r   r   r0   r   r  r   rG   r   r   r   r   r   r  9  s   r  c                   @   s4   e Zd ZdZdZedZeZdd Z	e
e	ZdZdS )
PreRequestpre_requestrl  r   c                 C   s   | j d|j|jf  d S )Nz%s %s)logdebugmethodr   )r   r   r   r   r   r  O  s    zPreRequest.pre_requestz        Called just before a worker processes the request.

        The callable needs to accept two instance variables for the Worker and
        the Request.
        N)r   r   r2   r   rp   r   r   r0   r   r  r   rG   r   r   r   r   r   r  I  s   r  c                   @   s0   e Zd ZdZdZeZeZdd Z	e
e	ZdZdS )PostRequestpost_requestrl  c                 C   s   d S r%   r   )r   r   r!   respr   r   r   r  `  s    zPostRequest.post_requestz        Called after a worker processes the request.

        The callable needs to accept two instance variables for the Worker and
        the Request.
        N)r   r   r2   r   rp   r   r   r0   r   r  r   rG   r   r   r   r   r   r  Z  s   r  c                   @   s4   e Zd ZdZdZedZeZdd Z	e
e	ZdZdS )	ChildExit
child_exitrl  r   c                 C   s   d S r%   r   ru  r   r   r   r  q  s    zChildExit.child_exitz        Called just after a worker has been exited, in the master process.

        The callable needs to accept two instance variables for the Arbiter and
        the just-exited Worker.

        .. versionadded:: 19.7
        N)r   r   r2   r   rp   r   r   r0   r   r  r   rG   r   r   r   r   r   r  k  s   r  c                   @   s4   e Zd ZdZdZedZeZdd Z	e
e	ZdZdS )
WorkerExitworker_exitrl  r   c                 C   s   d S r%   r   ru  r   r   r   r    s    zWorkerExit.worker_exitz        Called just after a worker has been exited, in the worker process.

        The callable needs to accept two instance variables for the Arbiter and
        the just-exited Worker.
        N)r   r   r2   r   rp   r   r   r0   r   r  r   rG   r   r   r   r   r   r  ~  s   r  c                   @   s4   e Zd ZdZdZedZeZdd Z	e
e	ZdZdS )NumWorkersChangednworkers_changedrl  r   c                 C   s   d S r%   r   )rn  	new_value	old_valuer   r   r   r    s    z"NumWorkersChanged.nworkers_changeda7          Called just after *num_workers* has been changed.

        The callable needs to accept an instance variable of the Arbiter and
        two integers of number of workers after and before change.

        If the number of workers is set for the first time, *old_value* would
        be ``None``.
        N)r   r   r2   r   rp   r   r   r0   r   r  r   rG   r   r   r   r   r   r    s   r  c                   @   s0   e Zd ZdZdZedZdd ZeeZ	dZ
dS )OnExiton_exitrl  r   c                 C   s   d S r%   r   rm  r   r   r   r    s    zOnExit.on_exitz        Called just before exiting Gunicorn.

        The callable needs to accept a single instance variable for the Arbiter.
        N)r   r   r2   r   rp   r   r   r  r   rG   r   r   r   r   r   r    s   r  c                   @   s*   e Zd ZdZdZdgZeZdZdZ	dZ
dS )ProxyProtocolZproxy_protocolr-  z--proxy-protocolFr$  a           Enable detect PROXY protocol (PROXY mode).

        Allow using HTTP and Proxy together. It may be useful for work with
        stunnel as HTTPS frontend and Gunicorn as HTTP server.

        PROXY protocol: http://haproxy.1wt.eu/download/1.5/doc/proxy-protocol.txt

        Example for stunnel config::

            [https]
            protocol = proxy
            accept  = 443
            connect = 80
            cert = /etc/ssl/certs/stunnel.pem
            key = /etc/ssl/certs/stunnel.key
        Nr^  r   r   r   r   r    s   r  c                   @   s&   e Zd ZdZdZdgZeZdZdZ	dS )ProxyAllowFromZproxy_allow_ipsr-  z--proxy-allow-fromrI  a          Front-end's IPs from which allowed accept proxy requests (comma separate).

        Set to ``*`` to disable checking of Front-end IPs (useful for setups
        where you don't know in advance the IP address of Front-end, but
        you still trust the environment)
        N)
r   r   r2   r   rp   r   r   r   rG   r   r   r   r   r   r    s   r  c                   @   s*   e Zd ZdZdZdgZdZeZdZ	dZ
dS )KeyFilert   rv   z	--keyfiler9  Nz    SSL key file
    r  r   r   r   r   r    s   r  c                   @   s*   e Zd ZdZdZdgZdZeZdZ	dZ
dS )CertFilers   rv   z
--certfiler9  Nz    SSL certificate file
    r  r   r   r   r   r    s   r  c                   @   sD   e Zd ZdZdZdgZeZee	dr,e	j
Zne	jZdZe	jZdZdS )
SSLVersionssl_versionrv   z--ssl-versionPROTOCOL_TLSz    SSL version to use (see stdlib ssl module's)

    .. versionchanged:: 20.0.1
       The default value has been changed from ``ssl.PROTOCOL_SSLv23`` to
       ``ssl.PROTOCOL_TLS`` when Python >= 3.6 .

    a      SSL version to use.

    ============= ============
    --ssl-version Description
    ============= ============
    SSLv3         SSLv3 is not-secure and is strongly discouraged.
    SSLv23        Alias for TLS. Deprecated in Python 3.6, use TLS.
    TLS           Negotiate highest possible version between client/server.
                  Can yield SSL. (Python 3.6+)
    TLSv1         TLS 1.0
    TLSv1_1       TLS 1.1 (Python 3.4+)
    TLSv1_2       TLS 1.2 (Python 3.4+)
    TLS_SERVER    Auto-negotiate the highest protocol version like TLS,
                  but only support server-side SSLSocket connections.
                  (Python 3.6+)
    ============= ============

    .. versionchanged:: 19.7
       The default value has been changed from ``ssl.PROTOCOL_TLSv1`` to
       ``ssl.PROTOCOL_SSLv23``.
    .. versionchanged:: 20.0
       This setting now accepts string names based on ``ssl.PROTOCOL_``
       constants.
    N)r   r   r2   r   rp   r   r   r   r`   r   r  rG   PROTOCOL_SSLv23r   r   r   r   r   r    s   
r  c                   @   s(   e Zd ZdZdZdgZeZej	Z
dZdS )CertReqs	cert_reqsrv   z--cert-reqszI    Whether client certificate is required (see stdlib ssl module's)
    N)r   r   r2   r   rp   r   r   r   r   	CERT_NONErG   r   r   r   r   r   r  #  s   r  c                   @   s*   e Zd ZdZdZdgZdZeZdZ	dZ
dS )CACertsca_certsrv   z
--ca-certsr9  Nz    CA certificates file
    r  r   r   r   r   r  .  s   r  c                   @   s*   e Zd ZdZdZdgZdZdZeZ	dZ
dS )SuppressRaggedEOFssuppress_ragged_eofsrv   z--suppress-ragged-eofsr$  Tz7    Suppress ragged EOFs (see stdlib ssl module's)
    N)r   r   r2   r   rp   r   rF   rG   r   r   r   r   r   r   r   r  :  s   r  c                   @   s*   e Zd ZdZdZdgZeZdZdZ	dZ
dS )DoHandshakeOnConnectdo_handshake_on_connectrv   z--do-handshake-on-connectr$  FzU    Whether to perform SSL handshake on socket connect (see stdlib ssl module's)
    Nr%  r   r   r   r   r  F  s   r  c                   @   s&   e Zd ZdZdZdgZeZdZdZ	dS )Ciphersciphersrv   z	--ciphersNa      SSL Cipher suite to use, in the format of an OpenSSL cipher list.

    By default we use the default cipher list from Python's ``ssl`` module,
    which contains ciphers considered strong at the time of each Python
    release.

    As a recommended alternative, the Open Web App Security Project (OWASP)
    offers `a vetted set of strong cipher strings rated A+ to C-
    <https://www.owasp.org/index.php/TLS_Cipher_String_Cheat_Sheet>`_.
    OWASP provides details on user-agent compatibility at each security level.

    See the `OpenSSL Cipher List Format Documentation
    <https://www.openssl.org/docs/manmaster/man1/ciphers.html#CIPHER-LIST-FORMAT>`_
    for details on the format of an OpenSSL cipher list.
    )
r   r   r2   r   rp   r   r   r   rG   r   r   r   r   r   r  R  s   r  c                   @   s.   e Zd ZdZdZdZdgZdZeZ	g Z
dZdS )PasteGlobalConfr   r3   r-  z--paste-globalZCONFa`          Set a PasteDeploy global config variable in ``key=value`` form.

        The option can be specified multiple times.

        The variables are passed to the the PasteDeploy entrypoint. Example::

            $ gunicorn -b 127.0.0.1:8000 --paste development.ini --paste-global FOO=1 --paste-global BAR=2

        .. versionadded:: 19.7
        Nr7  r   r   r   r   r  j  s   r  c                   @   s*   e Zd ZdZdZdgZeZdZdZ	dZ
dS )StripHeaderSpacesZstrip_header_spacesr-  z--strip-header-spacesr$  Fa;          Strip spaces present between the header name and the the ``:``.

        This is known to induce vulnerabilities and is not compliant with the HTTP/1.1 standard.
        See https://portswigger.net/research/http-desync-attacks-request-smuggling-reborn.

        Use with care and only if necessary.
        Nr%  r   r   r   r   r    s   r  )N)rM   r	   r   r   r   r   r   rA   r   r   r   rf  r   r   Zgunicorn.errorsr   Zgunicorn.reloaderr   r   platformrX  r   r   objectr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r	  r  r  r  r  r  r  r  r  r  r  r  r   r!  r&  r(  r)  r*  r+  r,  r.  r0  r1  r3  r5  r8  r:  r<  r>  r?  rA  rC  rD  rH  rJ  rL  rM  rN  rP  rR  rr   rT  rU  rV  rY  r[  r\  r]  r_  r`  rb  rc  re  rg  ri  rj  ro  rq  rs  rv  rx  r{  r}  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r   r   r   <module>   s   
 >J	#" T,
/