# Generated by the protocol buffer compiler.  DO NOT EDIT!
# sources: transport/internet/config.proto
# plugin: python-betterproto2
# This file has been @generated

__all__ = (
    "AddressPortStrategy",
    "DomainStrategy",
    "SocketConfigTProxyMode",
    "CustomSockopt",
    "ProxyConfig",
    "SocketConfig",
    "StreamConfig",
    "TransportConfig",
)

from dataclasses import dataclass

import betterproto2

from ....message_pool import default_message_pool

betterproto2.check_compiler_version("0.5.1")


class AddressPortStrategy(betterproto2.Enum):
    None_ = 0

    SrvPortOnly = 1

    SrvAddressOnly = 2

    SrvPortAndAddress = 3

    TxtPortOnly = 4

    TxtAddressOnly = 5

    TxtPortAndAddress = 6


class DomainStrategy(betterproto2.Enum):
    AS_IS = 0

    USE_IP = 1

    USE_IP4 = 2

    USE_IP6 = 3

    USE_IP46 = 4

    USE_IP64 = 5

    FORCE_IP = 6

    FORCE_IP4 = 7

    FORCE_IP6 = 8

    FORCE_IP46 = 9

    FORCE_IP64 = 10


class SocketConfigTProxyMode(betterproto2.Enum):
    Off = 0
    """
    TProxy is off.
    """

    TProxy = 1
    """
    TProxy mode.
    """

    Redirect = 2
    """
    Redirect mode.
    """


@dataclass(eq=False, repr=False)
class CustomSockopt(betterproto2.Message):
    system: "str" = betterproto2.field(1, betterproto2.TYPE_STRING)

    network: "str" = betterproto2.field(2, betterproto2.TYPE_STRING)

    level: "str" = betterproto2.field(3, betterproto2.TYPE_STRING)

    opt: "str" = betterproto2.field(4, betterproto2.TYPE_STRING)

    value: "str" = betterproto2.field(5, betterproto2.TYPE_STRING)

    type: "str" = betterproto2.field(6, betterproto2.TYPE_STRING)


default_message_pool.register_message(
    "xray.transport.internet", "CustomSockopt", CustomSockopt
)


@dataclass(eq=False, repr=False)
class ProxyConfig(betterproto2.Message):
    tag: "str" = betterproto2.field(1, betterproto2.TYPE_STRING)

    transport_layer_proxy: "bool" = betterproto2.field(2, betterproto2.TYPE_BOOL)


default_message_pool.register_message(
    "xray.transport.internet", "ProxyConfig", ProxyConfig
)


@dataclass(eq=False, repr=False)
class SocketConfig(betterproto2.Message):
    """
    SocketConfig is options to be applied on network sockets.
    """

    mark: "int" = betterproto2.field(1, betterproto2.TYPE_INT32)
    """
    Mark of the connection. If non-zero, the value will be set to SO_MARK.
    """

    tfo: "int" = betterproto2.field(2, betterproto2.TYPE_INT32)
    """
    TFO is the state of TFO settings.
    """

    tproxy: "SocketConfigTProxyMode" = betterproto2.field(
        3, betterproto2.TYPE_ENUM, default_factory=lambda: SocketConfigTProxyMode(0)
    )
    """
    TProxy is for enabling TProxy socket option.
    """

    receive_original_dest_address: "bool" = betterproto2.field(
        4, betterproto2.TYPE_BOOL
    )
    """
    ReceiveOriginalDestAddress is for enabling IP_RECVORIGDSTADDR socket
    option. This option is for UDP only.
    """

    bind_address: "bytes" = betterproto2.field(5, betterproto2.TYPE_BYTES)

    bind_port: "int" = betterproto2.field(6, betterproto2.TYPE_UINT32)

    accept_proxy_protocol: "bool" = betterproto2.field(7, betterproto2.TYPE_BOOL)

    domain_strategy: "DomainStrategy" = betterproto2.field(
        8, betterproto2.TYPE_ENUM, default_factory=lambda: DomainStrategy(0)
    )

    dialer_proxy: "str" = betterproto2.field(9, betterproto2.TYPE_STRING)

    tcp_keep_alive_interval: "int" = betterproto2.field(10, betterproto2.TYPE_INT32)

    tcp_keep_alive_idle: "int" = betterproto2.field(11, betterproto2.TYPE_INT32)

    tcp_congestion: "str" = betterproto2.field(12, betterproto2.TYPE_STRING)

    interface: "str" = betterproto2.field(13, betterproto2.TYPE_STRING)

    v6only: "bool" = betterproto2.field(14, betterproto2.TYPE_BOOL)

    tcp_window_clamp: "int" = betterproto2.field(15, betterproto2.TYPE_INT32)

    tcp_user_timeout: "int" = betterproto2.field(16, betterproto2.TYPE_INT32)

    tcp_max_seg: "int" = betterproto2.field(17, betterproto2.TYPE_INT32)

    penetrate: "bool" = betterproto2.field(18, betterproto2.TYPE_BOOL)

    tcp_mptcp: "bool" = betterproto2.field(19, betterproto2.TYPE_BOOL)

    custom_sockopt: "list[CustomSockopt]" = betterproto2.field(
        20, betterproto2.TYPE_MESSAGE, repeated=True
    )

    address_port_strategy: "AddressPortStrategy" = betterproto2.field(
        21, betterproto2.TYPE_ENUM, default_factory=lambda: AddressPortStrategy(0)
    )


default_message_pool.register_message(
    "xray.transport.internet", "SocketConfig", SocketConfig
)


@dataclass(eq=False, repr=False)
class StreamConfig(betterproto2.Message):
    address: "__common__net__.IpOrDomain | None" = betterproto2.field(
        8, betterproto2.TYPE_MESSAGE, optional=True
    )

    port: "int" = betterproto2.field(9, betterproto2.TYPE_UINT32)

    protocol_name: "str" = betterproto2.field(5, betterproto2.TYPE_STRING)
    """
    Effective network.
    """

    transport_settings: "list[TransportConfig]" = betterproto2.field(
        2, betterproto2.TYPE_MESSAGE, repeated=True
    )

    security_type: "str" = betterproto2.field(3, betterproto2.TYPE_STRING)
    """
    Type of security. Must be a message name of the settings proto.
    """

    security_settings: "list[__common__serial__.TypedMessage]" = betterproto2.field(
        4, betterproto2.TYPE_MESSAGE, repeated=True
    )
    """
    Transport security settings. They can be either TLS or REALITY.
    """

    socket_settings: "SocketConfig | None" = betterproto2.field(
        6, betterproto2.TYPE_MESSAGE, optional=True
    )


default_message_pool.register_message(
    "xray.transport.internet", "StreamConfig", StreamConfig
)


@dataclass(eq=False, repr=False)
class TransportConfig(betterproto2.Message):
    protocol_name: "str" = betterproto2.field(3, betterproto2.TYPE_STRING)
    """
    Transport protocol name.
    """

    settings: "__common__serial__.TypedMessage | None" = betterproto2.field(
        2, betterproto2.TYPE_MESSAGE, optional=True
    )
    """
    Specific transport protocol settings.
    """


default_message_pool.register_message(
    "xray.transport.internet", "TransportConfig", TransportConfig
)


from ...common import net as __common__net__
from ...common import serial as __common__serial__
