DnsPresetsModal.tsx 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. import { useTranslation } from 'react-i18next';
  2. import { Alert, Button, Modal, Space, Tag } from 'antd';
  3. import './DnsPresetsModal.css';
  4. interface DnsPresetsModalProps {
  5. open: boolean;
  6. onClose: () => void;
  7. onInstall: (servers: string[]) => void;
  8. }
  9. export const PRESETS: { name: string; tags: string[]; data: string[] }[] = [
  10. {
  11. name: 'Google DNS',
  12. tags: ['UDP'],
  13. data: ['8.8.8.8', '8.8.4.4', '2001:4860:4860::8888', '2001:4860:4860::8844'],
  14. },
  15. {
  16. name: 'Cloudflare DNS',
  17. tags: ['UDP'],
  18. data: ['1.1.1.1', '1.0.0.1', '2606:4700:4700::1111', '2606:4700:4700::1001'],
  19. },
  20. {
  21. name: 'AdGuard DNS',
  22. tags: ['UDP'],
  23. data: ['94.140.14.14', '94.140.15.15', '2a10:50c0::ad1:ff', '2a10:50c0::ad2:ff'],
  24. },
  25. {
  26. name: 'AdGuard Family DNS',
  27. tags: ['UDP', 'Family'],
  28. data: ['94.140.14.15', '94.140.15.16', '2a10:50c0::bad1:ff', '2a10:50c0::bad2:ff'],
  29. },
  30. {
  31. name: 'Cloudflare Family DNS',
  32. tags: ['UDP', 'Family'],
  33. data: ['1.1.1.3', '1.0.0.3', '2606:4700:4700::1113', '2606:4700:4700::1003'],
  34. },
  35. {
  36. name: 'Cloudflare DoH',
  37. tags: ['DoH'],
  38. data: ['https://cloudflare-dns.com/dns-query'],
  39. },
  40. {
  41. name: 'Google DoH',
  42. tags: ['DoH'],
  43. data: ['https://dns.google/dns-query'],
  44. },
  45. {
  46. name: 'Quad9 Secure DoH',
  47. tags: ['DoH', 'Malware'],
  48. data: ['https://dns.quad9.net/dns-query'],
  49. },
  50. {
  51. name: 'AdGuard DoH + DoQ',
  52. tags: ['DoH', 'DoQ', 'Ads'],
  53. data: ['https://dns.adguard-dns.com/dns-query', 'quic+local://dns.adguard-dns.com'],
  54. },
  55. {
  56. name: 'Control D Ads DoH + DoQ',
  57. tags: ['DoH', 'DoQ', 'Ads'],
  58. data: ['https://freedns.controld.com/p2', 'quic+local://p2.freedns.controld.com'],
  59. },
  60. {
  61. name: 'Control D Family DoH + DoQ',
  62. tags: ['DoH', 'DoQ', 'Family'],
  63. data: ['https://freedns.controld.com/p4', 'quic+local://p4.freedns.controld.com'],
  64. },
  65. ];
  66. function tagLabel(tag: string, t: (key: string) => string): string {
  67. if (tag === 'Family') return t('pages.xray.dns.dnsPresetFamily');
  68. return tag;
  69. }
  70. export default function DnsPresetsModal({ open, onClose, onInstall }: DnsPresetsModalProps) {
  71. const { t } = useTranslation();
  72. return (
  73. <Modal
  74. open={open}
  75. title={t('pages.xray.dns.dnsPresetTitle')}
  76. footer={null}
  77. mask={{ closable: false }}
  78. onCancel={onClose}
  79. >
  80. <Alert
  81. type="warning"
  82. showIcon
  83. className="preset-warning"
  84. message={t('pages.xray.dns.dnsLeakWarning')}
  85. />
  86. <div className="preset-list">
  87. {PRESETS.map((preset) => (
  88. <div key={preset.name} className="preset-row">
  89. <Space size="small" align="center">
  90. {preset.tags.map((tag) => (
  91. <Tag key={tag} color={tag === 'Family' ? 'purple' : tag === 'UDP' ? 'orange' : 'green'}>
  92. {tagLabel(tag, t)}
  93. </Tag>
  94. ))}
  95. <span className="preset-name">{preset.name}</span>
  96. </Space>
  97. <Button type="primary" size="small" onClick={() => onInstall([...preset.data])}>
  98. {t('install')}
  99. </Button>
  100. </div>
  101. ))}
  102. </div>
  103. </Modal>
  104. );
  105. }