403Webshell
Server IP : 15.235.198.142  /  Your IP : 216.73.216.12
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux ballsack 6.8.0-45-generic #45-Ubuntu SMP PREEMPT_DYNAMIC Fri Aug 30 12:02:04 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 8.3.6
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/twisted/protocols/haproxy/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/twisted/protocols/haproxy/_parser.py
# -*- test-case-name: twisted.protocols.haproxy.test.test_parser -*-
# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.

"""
Parser for 'haproxy:' string endpoint.
"""
from typing import Mapping, Tuple

from zope.interface import implementer

from twisted.internet import interfaces
from twisted.internet.endpoints import (
    IStreamServerEndpointStringParser,
    _WrapperServerEndpoint,
    quoteStringArgument,
    serverFromString,
)
from twisted.plugin import IPlugin
from . import proxyEndpoint


def unparseEndpoint(args: Tuple[object, ...], kwargs: Mapping[str, object]) -> str:
    """
    Un-parse the already-parsed args and kwargs back into endpoint syntax.

    @param args: C{:}-separated arguments

    @param kwargs: C{:} and then C{=}-separated keyword arguments

    @return: a string equivalent to the original format which this was parsed
        as.
    """

    description = ":".join(
        [quoteStringArgument(str(arg)) for arg in args]
        + sorted(
            "{}={}".format(
                quoteStringArgument(str(key)), quoteStringArgument(str(value))
            )
            for key, value in kwargs.items()
        )
    )
    return description


@implementer(IPlugin, IStreamServerEndpointStringParser)
class HAProxyServerParser:
    """
    Stream server endpoint string parser for the HAProxyServerEndpoint type.

    @ivar prefix: See L{IStreamServerEndpointStringParser.prefix}.
    """

    prefix = "haproxy"

    def parseStreamServer(
        self, reactor: interfaces.IReactorCore, *args: object, **kwargs: object
    ) -> _WrapperServerEndpoint:
        """
        Parse a stream server endpoint from a reactor and string-only arguments
        and keyword arguments.

        @param reactor: The reactor.

        @param args: The parsed string arguments.

        @param kwargs: The parsed keyword arguments.

        @return: a stream server endpoint
        @rtype: L{IStreamServerEndpoint}
        """
        subdescription = unparseEndpoint(args, kwargs)
        wrappedEndpoint = serverFromString(reactor, subdescription)
        return proxyEndpoint(wrappedEndpoint)

Youez - 2016 - github.com/yon3zu
LinuXploit