HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/engines/__pycache__/webhook.cpython-310.pyc
o

�N�g�@s2dZddlZddlZddlZddlZddd�ZdS)z
Send events from webhook api
�N�c	s�t�d�dkrtjj�ttd�j�nd��fdd��G�fdd�dtjjj	j
�}tjjj	�d	|fg�}d}t||g�rA||d
�}tjjj
jdd�}|��tjjjj||d
�}|j||d�|��dS)a
    Api to listen for webhooks to send to the reactor.

    Implement the webhook behavior in an engine.
    :py:class:`rest_cherrypy Webhook docs <salt.netapi.rest_cherrypy.app.Webhook>`

    Unlike the rest_cherrypy Webhook, this is only an unauthenticated webhook
    endpoint.  If an authenticated webhook endpoint is needed, use the salt-api
    webhook which runs on the master and authenticates through eauth.

    .. note: This is really meant to be used on the minion, because salt-api
             needs to be run on the master for use with eauth.

    .. warning:: Unauthenticated endpoint

        This engine sends webhook calls to the event stream.  If the engine is
        running on a minion with `file_client: local` the event is sent to the
        minion event stream.  Otherwise it is sent to the master event stream.

    Example Config

    .. code-block:: yaml

        engines:
          - webhook: {}

    .. code-block:: yaml

        engines:
          - webhook:
              port: 8000
              address: 10.128.1.145
              ssl_crt: /etc/pki/tls/certs/localhost.crt
              ssl_key: /etc/pki/tls/certs/localhost.key

    .. note: For making an unsigned key, use the following command
             `salt-call --local tls.create_self_signed_cert`
    Z__roleZmasterZsock_dirNcs$�r	�||�dStd||�dS)z'
        How to fire the event
        z
event.sendN)Z__salt__)�tag�msg)�fire_master��H/opt/saltstack/salt/lib/python3.10/site-packages/salt/engines/webhook.py�fire9szstart.<locals>.firecseZdZ�fdd�ZdS)zstart.<locals>.WebHookcs>|jj}|jj}t|t�r|nt|�|d�}�d||�dS)N)�headers�bodyzsalt/engines/hook/)�requestr
r	�
isinstance�dict)�selfrr
r	�payload�rrr�postEs�zstart.<locals>.WebHook.postN)�__name__�
__module__�__qualname__rrrrr�WebHookBsrz/(.*))�certfile�keyfileF)�make_current)�ssl_options)�address)Z__opts__�get�salt�utils�eventZget_master_eventZ
fire_event�extZtornadoZwebZRequestHandlerZApplication�allZioloopZIOLooprZ
httpserverZ
HTTPServer�listen�start)	r�portZssl_crtZssl_keyrZapplicationrZio_loopZhttp_serverr)rrrr"s,'��	
�

�r")NrNN)�__doc__Zsalt.ext.tornado.httpserverrZsalt.ext.tornado.ioloopZsalt.ext.tornado.webZsalt.utils.eventr"rrrr�<module>s