mtproto.tsx 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. import { useTranslation } from 'react-i18next';
  2. import { Input, InputNumber, Select, Switch } from 'antd';
  3. import { useFormContext, useWatch } from 'react-hook-form';
  4. import { FormField } from '@/components/form/rhf';
  5. import { useOutboundTags } from '@/api/queries/useOutboundTags';
  6. export default function MtprotoFields() {
  7. const { t } = useTranslation();
  8. const { control } = useFormContext();
  9. const routeThroughXray = useWatch({ control, name: 'settings.routeThroughXray' }) as
  10. | boolean
  11. | undefined;
  12. const { data: outboundTags } = useOutboundTags({ excludeBlackhole: true });
  13. return (
  14. <>
  15. <FormField
  16. name={['settings', 'fakeTlsDomain']}
  17. label={t('pages.inbounds.form.fakeTlsDomain')}
  18. tooltip={t('pages.inbounds.form.mtprotoFakeTlsDomainHint')}
  19. >
  20. <Input placeholder="www.cloudflare.com" />
  21. </FormField>
  22. <FormField
  23. name={['settings', 'domainFronting', 'ip']}
  24. label={t('pages.inbounds.form.mtgDomainFrontingIp')}
  25. tooltip={t('pages.inbounds.form.mtgDomainFrontingHint')}
  26. >
  27. <Input placeholder="127.0.0.1" />
  28. </FormField>
  29. <FormField
  30. name={['settings', 'domainFronting', 'port']}
  31. label={t('pages.inbounds.form.mtgDomainFrontingPort')}
  32. >
  33. <InputNumber min={0} max={65535} placeholder="443" style={{ width: '100%' }} />
  34. </FormField>
  35. <FormField
  36. name={['settings', 'domainFronting', 'proxyProtocol']}
  37. label={t('pages.inbounds.form.mtgDomainFrontingProxyProtocol')}
  38. valueProp="checked"
  39. >
  40. <Switch />
  41. </FormField>
  42. <FormField
  43. name={['settings', 'proxyProtocolListener']}
  44. label={t('pages.inbounds.form.mtgProxyProtocolListener')}
  45. valueProp="checked"
  46. >
  47. <Switch />
  48. </FormField>
  49. <FormField name={['settings', 'preferIp']} label={t('pages.inbounds.form.mtgPreferIp')}>
  50. <Select
  51. allowClear
  52. placeholder="prefer-ipv6"
  53. options={[
  54. { value: 'prefer-ipv6', label: 'prefer-ipv6' },
  55. { value: 'prefer-ipv4', label: 'prefer-ipv4' },
  56. { value: 'only-ipv6', label: 'only-ipv6' },
  57. { value: 'only-ipv4', label: 'only-ipv4' },
  58. ]}
  59. />
  60. </FormField>
  61. <FormField
  62. name={['settings', 'debug']}
  63. label={t('pages.inbounds.form.mtgDebug')}
  64. valueProp="checked"
  65. >
  66. <Switch />
  67. </FormField>
  68. <FormField
  69. name={['settings', 'throttleMaxConnections']}
  70. label={t('pages.inbounds.form.mtgThrottleMaxConnections')}
  71. tooltip={t('pages.inbounds.form.mtgThrottleMaxConnectionsHint')}
  72. >
  73. <InputNumber min={0} placeholder="0" style={{ width: '100%' }} />
  74. </FormField>
  75. <FormField
  76. name={['settings', 'routeThroughXray']}
  77. label={t('pages.inbounds.form.mtgRouteThroughXray')}
  78. tooltip={t('pages.inbounds.form.mtgRouteThroughXrayHint')}
  79. valueProp="checked"
  80. >
  81. <Switch />
  82. </FormField>
  83. {routeThroughXray && (
  84. <FormField
  85. name={['settings', 'outboundTag']}
  86. label={t('pages.inbounds.form.mtgRouteOutbound')}
  87. tooltip={t('pages.inbounds.form.mtgRouteOutboundHint')}
  88. >
  89. <Select
  90. id="mtprotoOutboundTag"
  91. allowClear
  92. showSearch
  93. placeholder={t('pages.inbounds.form.mtgRouteOutboundPlaceholder')}
  94. options={(outboundTags ?? []).map((tag) => ({ value: tag, label: tag }))}
  95. />
  96. </FormField>
  97. )}
  98. <FormField
  99. name={['settings', 'publicIpv4']}
  100. label={t('pages.inbounds.form.mtgPublicIpv4')}
  101. tooltip={t('pages.inbounds.form.mtgPublicIpHint')}
  102. >
  103. <Input allowClear placeholder="1.2.3.4" />
  104. </FormField>
  105. <FormField
  106. name={['settings', 'publicIpv6']}
  107. label={t('pages.inbounds.form.mtgPublicIpv6')}
  108. tooltip={t('pages.inbounds.form.mtgPublicIpHint')}
  109. >
  110. <Input allowClear placeholder="2001:db8::1" />
  111. </FormField>
  112. </>
  113. );
  114. }