# Generated by the protocol buffer compiler.  DO NOT EDIT!
# sources: common/net/address.proto, common/net/destination.proto, common/net/network.proto, common/net/port.proto
# plugin: python-betterproto2
# This file has been @generated

__all__ = (
    "Network",
    "Endpoint",
    "IpOrDomain",
    "NetworkList",
    "PortList",
    "PortRange",
)

from dataclasses import dataclass

import betterproto2

from ....message_pool import default_message_pool

betterproto2.check_compiler_version("0.5.1")


class Network(betterproto2.Enum):
    Unknown = 0

    TCP = 2

    UDP = 3

    UNIX = 4


@dataclass(eq=False, repr=False)
class Endpoint(betterproto2.Message):
    """
    Endpoint of a network connection.
    """

    network: "Network" = betterproto2.field(
        1, betterproto2.TYPE_ENUM, default_factory=lambda: Network(0)
    )

    address: "IpOrDomain | None" = betterproto2.field(
        2, betterproto2.TYPE_MESSAGE, optional=True
    )

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


default_message_pool.register_message("xray.common.net", "Endpoint", Endpoint)


@dataclass(eq=False, repr=False)
class IpOrDomain(betterproto2.Message):
    """
    Address of a network host. It may be either an IP address or a domain
    address.

    Oneofs:
        - address:
    """

    ip: "bytes | None" = betterproto2.field(
        1, betterproto2.TYPE_BYTES, optional=True, group="address"
    )
    """
    IP address. Must by either 4 or 16 bytes.
    """

    domain: "str | None" = betterproto2.field(
        2, betterproto2.TYPE_STRING, optional=True, group="address"
    )
    """
    Domain address.
    """


default_message_pool.register_message("xray.common.net", "IPOrDomain", IpOrDomain)


@dataclass(eq=False, repr=False)
class NetworkList(betterproto2.Message):
    """
    NetworkList is a list of Networks.
    """

    network: "list[Network]" = betterproto2.field(
        1, betterproto2.TYPE_ENUM, repeated=True
    )


default_message_pool.register_message("xray.common.net", "NetworkList", NetworkList)


@dataclass(eq=False, repr=False)
class PortList(betterproto2.Message):
    """
    PortList is a list of ports.
    """

    range: "list[PortRange]" = betterproto2.field(
        1, betterproto2.TYPE_MESSAGE, repeated=True
    )


default_message_pool.register_message("xray.common.net", "PortList", PortList)


@dataclass(eq=False, repr=False)
class PortRange(betterproto2.Message):
    """
    PortRange represents a range of ports.
    """

    from_: "int" = betterproto2.field(1, betterproto2.TYPE_UINT32)
    """
    The port that this range starts from.
    """

    to: "int" = betterproto2.field(2, betterproto2.TYPE_UINT32)
    """
    The port that this range ends with (inclusive).
    """


default_message_pool.register_message("xray.common.net", "PortRange", PortRange)
