Skip to content

Commit

Permalink
🐛 fix(node): Port config
Browse files Browse the repository at this point in the history
  • Loading branch information
web-ppanel committed Dec 18, 2024
1 parent 2926abc commit a20834a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 3 additions & 3 deletions apps/admin/app/dashboard/server/form-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { z } from '@shadcn/ui/lib/zod';
export const protocols = ['shadowsocks', 'vmess', 'vless', 'trojan', 'hysteria2', 'tuic'];

const nullableString = z.string().nullish();
const portSchema = z.number().min(1).max(65535);
const portSchema = z.number().max(65535).nullish();
const securityConfigSchema = z
.object({
sni: nullableString,
Expand All @@ -13,7 +13,7 @@ const securityConfigSchema = z
reality_public_key: nullableString,
reality_short_id: nullableString,
reality_server_addr: nullableString,
reality_server_port: portSchema.nullish(),
reality_server_port: portSchema,
})
.nullish();

Expand Down Expand Up @@ -94,7 +94,7 @@ const baseFormSchema = z.object({
group_id: z.number().nullish(),
enable_relay: z.boolean().nullish().default(false),
relay_host: nullableString,
relay_port: z.number().nullish(),
relay_port: portSchema,
});

export const formSchema = z.intersection(baseFormSchema, protocolConfigSchema);
6 changes: 6 additions & 0 deletions apps/admin/app/dashboard/server/node-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ export default function NodeForm<T extends { [x: string]: any }>({
<EnhancedInput
{...field}
type='number'
min={1}
max={65535}
onValueChange={(value) => {
form.setValue(field.name, value);
}}
Expand Down Expand Up @@ -343,6 +345,8 @@ export default function NodeForm<T extends { [x: string]: any }>({
<EnhancedInput
{...field}
type='number'
min={1}
max={65535}
onValueChange={(value) => {
form.setValue(field.name, value);
}}
Expand Down Expand Up @@ -666,6 +670,8 @@ export default function NodeForm<T extends { [x: string]: any }>({
<EnhancedInput
{...field}
type='number'
min={1}
max={65535}
placeholder={t('form.security_config.serverPortPlaceholder')}
onValueChange={(value) => {
form.setValue(field.name, value);
Expand Down

0 comments on commit a20834a

Please sign in to comment.