gitscope
← marzneshin / Diff · 4d0417b → 4d0417b
Changes 4d0417b..4d0417b
Patch commit
diff --git a/dashboard/src/modules/hosts/dialogs/mutation/profiles/general/schema.ts b/dashboard/src/modules/hosts/dialogs/mutation/profiles/general/schema.ts
index 1a70683..a1ebd51 100644
--- a/dashboard/src/modules/hosts/dialogs/mutation/profiles/general/schema.ts
+++ b/dashboard/src/modules/hosts/dialogs/mutation/profiles/general/schema.ts
@@ -67,7 +67,6 @@ export const GeneralSchema = HostSchema.merge(TlsSchema).extend({
])
.optional()
.default("none"),
- is_disabled: z.boolean(),
});
diff --git a/dashboard/src/modules/hosts/dialogs/mutation/profiles/hysteria2/schema.ts b/dashboard/src/modules/hosts/dialogs/mutation/profiles/hysteria2/schema.ts
index e4982f5..0fe6039 100644
--- a/dashboard/src/modules/hosts/dialogs/mutation/profiles/hysteria2/schema.ts
+++ b/dashboard/src/modules/hosts/dialogs/mutation/profiles/hysteria2/schema.ts
@@ -5,7 +5,6 @@ export const Hysteria2Schema =
HostSchema.merge(
TlsSchema.extend({
path: z.string().nullable().optional(),
- is_disabled: z.boolean(),
}))
;
diff --git a/dashboard/src/modules/hosts/dialogs/mutation/profiles/shadowtls/schema.ts b/dashboard/src/modules/hosts/dialogs/mutation/profiles/shadowtls/schema.ts
index e4ab869..d715b15 100644
--- a/dashboard/src/modules/hosts/dialogs/mutation/profiles/shadowtls/schema.ts
+++ b/dashboard/src/modules/hosts/dialogs/mutation/profiles/shadowtls/schema.ts
@@ -2,10 +2,6 @@ import { z } from "zod";
import { HostSchema, TlsSchema } from "@marzneshin/modules/hosts";
export const ShadowTlsSchema =
- HostSchema.merge(
- TlsSchema.extend({
- is_disabled: z.boolean(),
- }))
- ;
+ HostSchema.merge(TlsSchema);
export type ShadowTlsSchemaType = z.infer<typeof ShadowTlsSchema>;
diff --git a/dashboard/src/modules/hosts/dialogs/mutation/profiles/tuic/default.ts b/dashboard/src/modules/hosts/dialogs/mutation/profiles/tuic/default.ts
index e73bb66..35bb820 100644
--- a/dashboard/src/modules/hosts/dialogs/mutation/profiles/tuic/default.ts
+++ b/dashboard/src/modules/hosts/dialogs/mutation/profiles/tuic/default.ts
@@ -8,4 +8,5 @@ export const tuicProfileDefaultValue: TuicSchemaType = {
remark: '',
alpn: '',
allowinsecure: false,
+ is_disabled: false,
};
diff --git a/dashboard/src/modules/hosts/dialogs/mutation/profiles/wireguard/schema.ts b/dashboard/src/modules/hosts/dialogs/mutation/profiles/wireguard/schema.ts
index 2504f83..cc4bf0e 100644
--- a/dashboard/src/modules/hosts/dialogs/mutation/profiles/wireguard/schema.ts
+++ b/dashboard/src/modules/hosts/dialogs/mutation/profiles/wireguard/schema.ts
@@ -1,9 +1,8 @@
import { z } from "zod";
import { HostSchema } from "@marzneshin/modules/hosts";
-export const WireguardSchema = HostSchema.extend({
+export const WireguardSchema = HostSchema.merge(z.object({
path: z.string().nullable().optional(),
- is_disabled: z.boolean(),
allowed_ips: z.string().nullable().optional(),
mtu: z.coerce
.number()
@@ -14,6 +13,6 @@ export const WireguardSchema = HostSchema.extend({
.string()
.nullable()
.optional(),
-});
+}));
export type WireguardSchemaType = z.infer<typeof WireguardSchema>;
diff --git a/dashboard/src/modules/hosts/domain/host.ts b/dashboard/src/modules/hosts/domain/host.ts
index 14db109..8950367 100644
--- a/dashboard/src/modules/hosts/domain/host.ts
+++ b/dashboard/src/modules/hosts/domain/host.ts
@@ -4,17 +4,23 @@ import { ProtocolType } from "@marzneshin/modules/inbounds";
export const HostSchema = z.object({
remark: z.string().min(1, "Remark is required"),
address: z.string().min(1, "Address is required"),
+ is_disabled: z.boolean().default(false),
weight: z.coerce
.number().int()
.nullable()
.optional(),
- port: z.coerce
- .number()
- .gte(1, "Port must be more than 1")
- .lte(65535, "Port can not be more than 65535")
- .or(z.string())
- .nullable()
- .optional(),
+ port: z
+ .preprocess(
+ (val) => (val === "" || val === undefined ? null : Number(val)),
+ z.union([
+ z
+ .number()
+ .int()
+ .gte(1, "Port must be more than 1")
+ .lte(65535, "Port cannot be more than 65535"),
+ z.null(),
+ ])
+ ),
});