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

__all__ = (
    "DomainMatchingType",
    "QueryStrategy",
    "Config",
    "ConfigHostMapping",
    "NameServer",
    "NameServerOriginalRule",
    "NameServerPriorityDomain",
)

from dataclasses import dataclass

import betterproto2

from ....message_pool import default_message_pool

betterproto2.check_compiler_version("0.5.1")


class DomainMatchingType(betterproto2.Enum):
    Full = 0

    Subdomain = 1

    Keyword = 2

    Regex = 3


class QueryStrategy(betterproto2.Enum):
    USE_IP = 0

    USE_IP4 = 1

    USE_IP6 = 2


@dataclass(eq=False, repr=False)
class Config(betterproto2.Message):
    name_server: "list[NameServer]" = betterproto2.field(
        5, betterproto2.TYPE_MESSAGE, repeated=True
    )
    """
    NameServer list used by this DNS client.
    A special value 'localhost' as a domain address can be set to use DNS on local system.
    """

    client_ip: "bytes" = betterproto2.field(3, betterproto2.TYPE_BYTES)
    """
    Client IP for EDNS client subnet. Must be 4 bytes (IPv4) or 16 bytes
    (IPv6).
    """

    static_hosts: "list[ConfigHostMapping]" = betterproto2.field(
        4, betterproto2.TYPE_MESSAGE, repeated=True
    )

    tag: "str" = betterproto2.field(6, betterproto2.TYPE_STRING)
    """
    Tag is the inbound tag of DNS client.
    """

    disable_cache: "bool" = betterproto2.field(8, betterproto2.TYPE_BOOL)
    """
    DisableCache disables DNS cache
    """

    query_strategy: "QueryStrategy" = betterproto2.field(
        9, betterproto2.TYPE_ENUM, default_factory=lambda: QueryStrategy(0)
    )

    disable_fallback: "bool" = betterproto2.field(10, betterproto2.TYPE_BOOL)

    disable_fallback_if_match: "bool" = betterproto2.field(11, betterproto2.TYPE_BOOL)


default_message_pool.register_message("xray.app.dns", "Config", Config)


@dataclass(eq=False, repr=False)
class ConfigHostMapping(betterproto2.Message):
    type: "DomainMatchingType" = betterproto2.field(
        1, betterproto2.TYPE_ENUM, default_factory=lambda: DomainMatchingType(0)
    )

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

    ip: "list[bytes]" = betterproto2.field(3, betterproto2.TYPE_BYTES, repeated=True)

    proxied_domain: "str" = betterproto2.field(4, betterproto2.TYPE_STRING)
    """
    ProxiedDomain indicates the mapped domain has the same IP address on this
    domain. Xray will use this domain for IP queries.
    """


default_message_pool.register_message(
    "xray.app.dns", "Config.HostMapping", ConfigHostMapping
)


@dataclass(eq=False, repr=False)
class NameServer(betterproto2.Message):
    address: "__common__net__.Endpoint | None" = betterproto2.field(
        1, betterproto2.TYPE_MESSAGE, optional=True
    )

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

    skip_fallback: "bool" = betterproto2.field(6, betterproto2.TYPE_BOOL)

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

    geoip: "list[_router__.GeoIp]" = betterproto2.field(
        3, betterproto2.TYPE_MESSAGE, repeated=True
    )

    original_rules: "list[NameServerOriginalRule]" = betterproto2.field(
        4, betterproto2.TYPE_MESSAGE, repeated=True
    )

    query_strategy: "QueryStrategy" = betterproto2.field(
        7, betterproto2.TYPE_ENUM, default_factory=lambda: QueryStrategy(0)
    )

    allow_unexpected_i_ps: "bool" = betterproto2.field(8, betterproto2.TYPE_BOOL)

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

    timeout_ms: "int" = betterproto2.field(10, betterproto2.TYPE_UINT64)


default_message_pool.register_message("xray.app.dns", "NameServer", NameServer)


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

    size: "int" = betterproto2.field(2, betterproto2.TYPE_UINT32)


default_message_pool.register_message(
    "xray.app.dns", "NameServer.OriginalRule", NameServerOriginalRule
)


@dataclass(eq=False, repr=False)
class NameServerPriorityDomain(betterproto2.Message):
    type: "DomainMatchingType" = betterproto2.field(
        1, betterproto2.TYPE_ENUM, default_factory=lambda: DomainMatchingType(0)
    )

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


default_message_pool.register_message(
    "xray.app.dns", "NameServer.PriorityDomain", NameServerPriorityDomain
)


from ...common import net as __common__net__
from .. import router as _router__
