Skip to content

Commit

Permalink
add advanced config
Browse files Browse the repository at this point in the history
  • Loading branch information
Asutorufa committed Jan 28, 2025
1 parent bedefce commit df1ec15
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 20 deletions.
26 changes: 25 additions & 1 deletion app/docs/config/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Loading, { Error } from '../common/loading';
import { FetchProtobuf, useProtoSWR } from '../common/proto';
import { SettingCheck, SettingTypeSelect } from "../common/switch";
import { GlobalToastContext } from '../common/toast';
import { setting as Setting, system_proxySchema } from '../pbes/config/config_pb';
import { advanced_configSchema, setting as Setting, system_proxySchema } from '../pbes/config/config_pb';
import { config_service } from '../pbes/config/grpc/config_pb';
import { log_level, log_levelSchema } from '../pbes/config/log/log_pb';
import { Remind, SettingInputText } from './components';
Expand Down Expand Up @@ -112,6 +112,30 @@ function ConfigComponent() {
onChange={(e) => setSetting({ ...setting, logcat: { ...setting.logcat, level: e } }, false)}
/>

<hr />

<Card.Title className='mb-2'>Advanced</Card.Title>

<Form.Label>UDP Buffer Size ({setting.advancedConfig ? setting.advancedConfig.udpBufferSize : 2048} Bytes)</Form.Label>
<Form.Range value={setting.advancedConfig ? setting.advancedConfig.udpBufferSize : 2048} min={2048} max={65535}
onChange={(v) => {
setSetting(prev => {
const tmp = { ...prev }
if (!tmp.advancedConfig) tmp.advancedConfig = create(advanced_configSchema, { udpBufferSize: v.target.valueAsNumber, relayBufferSize: 4096 })
else tmp.advancedConfig = { ...tmp.advancedConfig, udpBufferSize: v.target.valueAsNumber }
return tmp
}, false)
}
} />

<Form.Label>Relay Buffer Size ({setting.advancedConfig ? setting.advancedConfig.relayBufferSize : 4096} Bytes)</Form.Label>
<Form.Range value={setting.advancedConfig ? setting.advancedConfig.relayBufferSize : 4096} min={2048} max={65535}
onChange={(v) => setSetting(prev => {
const tmp = { ...prev }
if (!tmp.advancedConfig) tmp.advancedConfig = create(advanced_configSchema, { relayBufferSize: v.target.valueAsNumber, udpBufferSize: 2048 })
else tmp.advancedConfig = { ...tmp.advancedConfig, relayBufferSize: v.target.valueAsNumber }
return tmp
}, false)} />
</fieldset>

</Card.Body>
Expand Down
37 changes: 32 additions & 5 deletions app/docs/pbes/config/config_pb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import type { Message } from "@bufbuild/protobuf";
* Describes the file config/config.proto.
*/
export const file_config_config: GenFile = /*@__PURE__*/
fileDesc("ChNjb25maWcvY29uZmlnLnByb3RvEg55dWhhaWluLmNvbmZpZyLgAwoHc2V0dGluZxIMCgRpcHY2GAcgASgIEkYKHmlwdjZfbG9jYWxfYWRkcl9wcmVmZXJfdW5pY2FzdBgKIAEoCFIeaXB2Nl9sb2NhbF9hZGRyX3ByZWZlcl91bmljYXN0EiQKDW5ldF9pbnRlcmZhY2UYBiABKAlSDW5ldF9pbnRlcmZhY2USQAoMc3lzdGVtX3Byb3h5GAEgASgLMhwueXVoYWlpbi5jb25maWcuc3lzdGVtX3Byb3h5UgxzeXN0ZW1fcHJveHkSJgoGYnlwYXNzGAIgASgLMhYueXVoYWlpbi5ieXBhc3MuY29uZmlnEiQKA2RucxgEIAEoCzIXLnl1aGFpaW4uZG5zLmRuc19jb25maWcSMAoGc2VydmVyGAUgASgLMiAueXVoYWlpbi5saXN0ZW5lci5pbmJvdW5kX2NvbmZpZxIjCgZsb2djYXQYCCABKAsyEy55dWhhaWluLmxvZy5sb2djYXQSRgoOY29uZmlnX3ZlcnNpb24YCSABKAsyHi55dWhhaWluLmNvbmZpZy5jb25maWdfdmVyc2lvblIOY29uZmlnX3ZlcnNpb24SKgoIcGxhdGZvcm0YCyABKAsyGC55dWhhaWluLmNvbmZpZy5wbGF0Zm9ybSIsCgxzeXN0ZW1fcHJveHkSDAoEaHR0cBgCIAEoCBIOCgZzb2NrczUYAyABKAgitAEKBGluZm8SDwoHdmVyc2lvbhgBIAEoCRIOCgZjb21taXQYAiABKAkSHgoKYnVpbGRfdGltZRgDIAEoCVIKYnVpbGRfdGltZRIeCgpnb192ZXJzaW9uGAQgASgJUgpnb192ZXJzaW9uEgwKBGFyY2gYBSABKAkSEAoIcGxhdGZvcm0YBiABKAkSCgoCb3MYByABKAkSEAoIY29tcGlsZXIYCCABKAkSDQoFYnVpbGQYCSADKAkiIQoOY29uZmlnX3ZlcnNpb24SDwoHdmVyc2lvbhgBIAEoBCIsCghwbGF0Zm9ybRIgCgthbmRyb2lkX2FwcBgBIAEoCFILYW5kcm9pZF9hcHBCOFouZ2l0aHViLmNvbS9Bc3V0b3J1ZmEveXVoYWlpbi9wa2cvcHJvdG9zL2NvbmZpZ5IDBdI+AhADYghlZGl0aW9uc3DoBw", [file_config_log_log, file_config_bypass_bypass, file_config_dns_dns, file_config_listener_listener, file_google_protobuf_go_features]);
fileDesc("ChNjb25maWcvY29uZmlnLnByb3RvEg55dWhhaWluLmNvbmZpZyKrBAoHc2V0dGluZxIMCgRpcHY2GAcgASgIEkYKHmlwdjZfbG9jYWxfYWRkcl9wcmVmZXJfdW5pY2FzdBgKIAEoCFIeaXB2Nl9sb2NhbF9hZGRyX3ByZWZlcl91bmljYXN0EiQKDW5ldF9pbnRlcmZhY2UYBiABKAlSDW5ldF9pbnRlcmZhY2USQAoMc3lzdGVtX3Byb3h5GAEgASgLMhwueXVoYWlpbi5jb25maWcuc3lzdGVtX3Byb3h5UgxzeXN0ZW1fcHJveHkSJgoGYnlwYXNzGAIgASgLMhYueXVoYWlpbi5ieXBhc3MuY29uZmlnEiQKA2RucxgEIAEoCzIXLnl1aGFpaW4uZG5zLmRuc19jb25maWcSMAoGc2VydmVyGAUgASgLMiAueXVoYWlpbi5saXN0ZW5lci5pbmJvdW5kX2NvbmZpZxIjCgZsb2djYXQYCCABKAsyEy55dWhhaWluLmxvZy5sb2djYXQSRgoOY29uZmlnX3ZlcnNpb24YCSABKAsyHi55dWhhaWluLmNvbmZpZy5jb25maWdfdmVyc2lvblIOY29uZmlnX3ZlcnNpb24SKgoIcGxhdGZvcm0YCyABKAsyGC55dWhhaWluLmNvbmZpZy5wbGF0Zm9ybRJJCg9hZHZhbmNlZF9jb25maWcYDCABKAsyHy55dWhhaWluLmNvbmZpZy5hZHZhbmNlZF9jb25maWdSD2FkdmFuY2VkX2NvbmZpZyJpCg9hZHZhbmNlZF9jb25maWcSKAoPdWRwX2J1ZmZlcl9zaXplGAEgASgFUg91ZHBfYnVmZmVyX3NpemUSLAoRcmVsYXlfYnVmZmVyX3NpemUYAiABKAVSEXJlbGF5X2J1ZmZlcl9zaXplIiwKDHN5c3RlbV9wcm94eRIMCgRodHRwGAIgASgIEg4KBnNvY2tzNRgDIAEoCCK0AQoEaW5mbxIPCgd2ZXJzaW9uGAEgASgJEg4KBmNvbW1pdBgCIAEoCRIeCgpidWlsZF90aW1lGAMgASgJUgpidWlsZF90aW1lEh4KCmdvX3ZlcnNpb24YBCABKAlSCmdvX3ZlcnNpb24SDAoEYXJjaBgFIAEoCRIQCghwbGF0Zm9ybRgGIAEoCRIKCgJvcxgHIAEoCRIQCghjb21waWxlchgIIAEoCRINCgVidWlsZBgJIAMoCSIhCg5jb25maWdfdmVyc2lvbhIPCgd2ZXJzaW9uGAEgASgEIiwKCHBsYXRmb3JtEiAKC2FuZHJvaWRfYXBwGAEgASgIUgthbmRyb2lkX2FwcEI4Wi5naXRodWIuY29tL0FzdXRvcnVmYS95dWhhaWluL3BrZy9wcm90b3MvY29uZmlnkgMF0j4CEANiCGVkaXRpb25zcOgH", [file_config_log_log, file_config_bypass_bypass, file_config_dns_dns, file_config_listener_listener, file_google_protobuf_go_features]);

/**
* @generated from message yuhaiin.config.setting
Expand Down Expand Up @@ -76,6 +76,11 @@ export type setting = Message<"yuhaiin.config.setting"> & {
* @generated from field: yuhaiin.config.platform platform = 11;
*/
platform?: platform;

/**
* @generated from field: yuhaiin.config.advanced_config advanced_config = 12 [json_name = "advanced_config"];
*/
advancedConfig?: advanced_config;
};

/**
Expand All @@ -85,6 +90,28 @@ export type setting = Message<"yuhaiin.config.setting"> & {
export const settingSchema: GenMessage<setting> = /*@__PURE__*/
messageDesc(file_config_config, 0);

/**
* @generated from message yuhaiin.config.advanced_config
*/
export type advanced_config = Message<"yuhaiin.config.advanced_config"> & {
/**
* @generated from field: int32 udp_buffer_size = 1 [json_name = "udp_buffer_size"];
*/
udpBufferSize: number;

/**
* @generated from field: int32 relay_buffer_size = 2 [json_name = "relay_buffer_size"];
*/
relayBufferSize: number;
};

/**
* Describes the message yuhaiin.config.advanced_config.
* Use `create(advanced_configSchema)` to create a new message.
*/
export const advanced_configSchema: GenMessage<advanced_config> = /*@__PURE__*/
messageDesc(file_config_config, 1);

/**
* @generated from message yuhaiin.config.system_proxy
*/
Expand All @@ -105,7 +132,7 @@ export type system_proxy = Message<"yuhaiin.config.system_proxy"> & {
* Use `create(system_proxySchema)` to create a new message.
*/
export const system_proxySchema: GenMessage<system_proxy> = /*@__PURE__*/
messageDesc(file_config_config, 1);
messageDesc(file_config_config, 2);

/**
* @generated from message yuhaiin.config.info
Expand Down Expand Up @@ -162,7 +189,7 @@ export type info = Message<"yuhaiin.config.info"> & {
* Use `create(infoSchema)` to create a new message.
*/
export const infoSchema: GenMessage<info> = /*@__PURE__*/
messageDesc(file_config_config, 2);
messageDesc(file_config_config, 3);

/**
* @generated from message yuhaiin.config.config_version
Expand All @@ -179,7 +206,7 @@ export type config_version = Message<"yuhaiin.config.config_version"> & {
* Use `create(config_versionSchema)` to create a new message.
*/
export const config_versionSchema: GenMessage<config_version> = /*@__PURE__*/
messageDesc(file_config_config, 3);
messageDesc(file_config_config, 4);

/**
* @generated from message yuhaiin.config.platform
Expand All @@ -196,5 +223,5 @@ export type platform = Message<"yuhaiin.config.platform"> & {
* Use `create(platformSchema)` to create a new message.
*/
export const platformSchema: GenMessage<platform> = /*@__PURE__*/
messageDesc(file_config_config, 4);
messageDesc(file_config_config, 5);

24 changes: 12 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"@bufbuild/buf": "^1.50.0",
"@bufbuild/protobuf": "^2.2.3",
"@bufbuild/protoc-gen-es": "^2.2.3",
"@types/node": "^22.10.10",
"@types/node": "^22.12.0",
"@types/react": "^19.0.8",
"@types/react-dom": "^19.0.3",
"bootstrap": "^v5.3.3",
Expand All @@ -23,7 +23,7 @@
"start": "next start"
},
"devDependencies": {
"eslint": "^9.18.0",
"eslint": "^9.19.0",
"eslint-config-next": "^15.1.6"
}
}

0 comments on commit df1ec15

Please sign in to comment.