syntax = "proto3";

package xray.app.dns;

import "xcapi/xray/common/net/destination.proto";
import "xcapi/xray/app/router/config.proto";

message NameServer {
  xray.common.net.Endpoint address = 1;
  bytes client_ip = 5;
  bool skipFallback = 6;

  message PriorityDomain {
    DomainMatchingType type = 1;
    string domain = 2;
  }

  message OriginalRule {
    string rule = 1;
    uint32 size = 2;
  }

  repeated PriorityDomain prioritized_domain = 2;
  repeated xray.app.router.GeoIP geoip = 3;
  repeated OriginalRule original_rules = 4;
  QueryStrategy query_strategy = 7;
}

enum DomainMatchingType {
  Full = 0;
  Subdomain = 1;
  Keyword = 2;
  Regex = 3;
}

enum QueryStrategy {
  USE_IP = 0;
  USE_IP4 = 1;
  USE_IP6 = 2;
}

message Config {
  // NameServer list used by this DNS client.
  // A special value 'localhost' as a domain address can be set to use DNS on local system.
  repeated NameServer name_server = 5;

  // Client IP for EDNS client subnet. Must be 4 bytes (IPv4) or 16 bytes
  // (IPv6).
  bytes client_ip = 3;

  message HostMapping {
    DomainMatchingType type = 1;
    string domain = 2;

    repeated bytes ip = 3;

    // ProxiedDomain indicates the mapped domain has the same IP address on this
    // domain. Xray will use this domain for IP queries.
    string proxied_domain = 4;
  }

  repeated HostMapping static_hosts = 4;

  // Tag is the inbound tag of DNS client.
  string tag = 6;

  reserved 7;

  // DisableCache disables DNS cache
  bool disableCache = 8;

  QueryStrategy query_strategy = 9;

  bool disableFallback = 10;
  bool disableFallbackIfMatch = 11;
}
