mtproto.tsx 3.9 KB

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