mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-11-02 00:34:46 +03:00
d7698ec7aa
* feat(xray): browse geosite/geoip categories from routing rules Routing rules made you type category names from memory: nothing showed which categories a database actually contains, what is inside one, or whether a name resolves at all — a typo only surfaced when Xray refused the config. The panel now reads Xray's .dat databases itself and exposes them over four endpoints: databases in the asset folder, a database's categories, one page of a category's rules, and validation of the tokens already in a rule. The reader walks the protobuf wire format directly rather than decoding into Go structs, because a 10 MB geosite.dat holds well over a million domains and materialising them costs ~284 MB where streaming costs ~19 MB. Only the category index is cached, entry pages are scanned on demand, and scans are serialised, so twenty concurrent requests peak at 87 MB instead of 1 GB. A database's type is decided by its contents, not its file name, since custom .dat files are named freely. In the rule form, the source-IP, IP and domain fields gain a database button opening the browser: search over categories, a preview of what a category holds, and a multi-select that merges into the field. Plain domains, CIDRs and categories the panel does not know are left untouched; categories already present come back ticked, and unticking one removes it from the rule. * fix(xray): read geo databases through os.Root and match codes verbatim CodeQL flagged the database read as a path built from a user-supplied value, and it was right about the shape of it. The file name arrives in a request; resolve() rejects traversal and stats the file through an os.Root, but the read itself went through a joined path with os.ReadFile. That left the symlink defence incomplete: the stat could pass while the read followed a link planted — or swapped in — afterwards. Reads now go through the same root, so a request-supplied name never becomes a path this code resolves on its own, and the size limit is applied to the opened file rather than to a separate stat of it. Lookup no longer trims the category code either. It backs the routing-token validator, and the core matches codes verbatim: "geosite: cn" will not start Xray, so repairing that space here hid exactly the typo the validator exists to report. * fix(xray): address review findings on the geo category browser Asset folder. The browser read config.GetBinFolderPath() unconditionally, but the core honours a preset XRAY_LOCATION_ASSET and only falls back to the bin folder (ensureXrayAssetLocation). On an install pointing at a shared asset directory the panel listed an empty folder and reported perfectly valid geosite:/geoip: tokens as missing — the validator warning about a correct config. The directory is now resolved with the core's precedence. Paging. Serving one page read and rescanned the whole database, so walking category-ads-all re-read it per page. The index now records each category's byte range and a page reads only that record through the os.Root handle, with the current category's records held for the duration of a paging session. Profiling that also showed the real cost was not the read but the slice of payload pointers built per call — a category holds a hundred thousand of them — so records are now walked with a callback instead. Ten pages over category-ads-all: 239 MB allocated, now 4.3 MB. Cached failures. Any error from reading a file was latched under the file's size+mtime, so a transient ENOMEM or EMFILE marked a healthy database as damaged until it changed on disk. Only deterministic failures are cached. Wrong kind. A geoip: token typed into a domain field parsed as a plain domain and was waved through, though the core cannot resolve it as one. It is now reported, with its own reason and wording. Frontend. The category filter fed the query key on every keystroke, so each character triggered a request that re-scanned the database; it is debounced now. GeoTokenInput accepts and forwards a ref, so React Hook Form can focus these three fields on a validation error again. A failed validation shows that it failed instead of rendering the same empty state as "no issues". Also drops an unreachable branch in the token-count guard and corrects the categories endpoint docs, where limit is unbounded by default. --------- Co-authored-by: STRENCH0 <17428017+STRENCH0@users.noreply.github.com>
740 lines
22 KiB
TypeScript
740 lines
22 KiB
TypeScript
// Code generated by tools/openapigen. DO NOT EDIT.
|
|
import { z } from 'zod';
|
|
export const GeoKindSchema = z.string();
|
|
export type GeoKind = z.infer<typeof GeoKindSchema>;
|
|
|
|
export const OnlineAPISupportSchema = z.number().int();
|
|
export type OnlineAPISupport = z.infer<typeof OnlineAPISupportSchema>;
|
|
|
|
export const ProcessStateSchema = z.string();
|
|
export type ProcessState = z.infer<typeof ProcessStateSchema>;
|
|
|
|
export const ProtocolSchema = z.string();
|
|
export type Protocol = z.infer<typeof ProtocolSchema>;
|
|
|
|
export const SubLinkProviderSchema = z.unknown();
|
|
export type SubLinkProvider = z.infer<typeof SubLinkProviderSchema>;
|
|
|
|
export const staticEgressResolverSchema = z.string();
|
|
export type staticEgressResolver = z.infer<typeof staticEgressResolverSchema>;
|
|
|
|
export const trafficLocalApplyActionSchema = z.number().int();
|
|
export type trafficLocalApplyAction = z.infer<typeof trafficLocalApplyActionSchema>;
|
|
|
|
export const transportBitsSchema = z.number().int();
|
|
export type transportBits = z.infer<typeof transportBitsSchema>;
|
|
|
|
export const AllSettingSchema = z.object({
|
|
datepicker: z.string(),
|
|
expireDiff: z.number().int().min(0),
|
|
externalTrafficInformEnable: z.boolean(),
|
|
externalTrafficInformURI: z.string(),
|
|
ldapAutoCreate: z.boolean(),
|
|
ldapAutoDelete: z.boolean(),
|
|
ldapBaseDN: z.string(),
|
|
ldapBindDN: z.string(),
|
|
ldapDefaultExpiryDays: z.number().int().min(0),
|
|
ldapDefaultLimitIP: z.number().int().min(0),
|
|
ldapDefaultTotalGB: z.number().int().min(0),
|
|
ldapEnable: z.boolean(),
|
|
ldapFlagField: z.string(),
|
|
ldapHost: z.string(),
|
|
ldapInboundTags: z.string(),
|
|
ldapInsecureSkipVerify: z.boolean(),
|
|
ldapInvertFlag: z.boolean(),
|
|
ldapPassword: z.string(),
|
|
ldapPort: z.number().int().min(0).max(65535),
|
|
ldapSyncCron: z.string(),
|
|
ldapTruthyValues: z.string(),
|
|
ldapUseTLS: z.boolean(),
|
|
ldapUserAttr: z.string(),
|
|
ldapUserFilter: z.string(),
|
|
ldapVlessField: z.string(),
|
|
outboundDownThreshold: z.number().int().min(1).max(100),
|
|
pageSize: z.number().int().min(0).max(1000),
|
|
panelOutbound: z.string(),
|
|
remarkTemplate: z.string(),
|
|
restartXrayOnClientDisable: z.boolean(),
|
|
sessionMaxAge: z.number().int().min(1).max(525600),
|
|
smtpCpu: z.number().int().min(0).max(100),
|
|
smtpEnable: z.boolean(),
|
|
smtpEnabledEvents: z.string(),
|
|
smtpEncryptionType: z.string(),
|
|
smtpFrom: z.string(),
|
|
smtpFromName: z.string(),
|
|
smtpHost: z.string(),
|
|
smtpMemory: z.number().int().min(0).max(100),
|
|
smtpPassword: z.string(),
|
|
smtpPort: z.number().int().min(1).max(65535),
|
|
smtpTo: z.string(),
|
|
smtpUsername: z.string(),
|
|
subAnnounce: z.string(),
|
|
subCertFile: z.string(),
|
|
subClashAutoDetect: z.boolean(),
|
|
subClashEnable: z.boolean(),
|
|
subClashEnableRouting: z.boolean(),
|
|
subClashPath: z.string(),
|
|
subClashRules: z.string(),
|
|
subClashURI: z.string(),
|
|
subClashUserAgentRegex: z.string(),
|
|
subDomain: z.string(),
|
|
subEnable: z.boolean(),
|
|
subEnableRouting: z.boolean(),
|
|
subEncrypt: z.boolean(),
|
|
subHideSettings: z.boolean(),
|
|
subIncyEnableRouting: z.boolean(),
|
|
subIncyRoutingRules: z.string(),
|
|
subJsonAlwaysArray: z.boolean(),
|
|
subJsonAutoDetect: z.boolean(),
|
|
subJsonEnable: z.boolean(),
|
|
subJsonFinalMask: z.string(),
|
|
subJsonMux: z.string(),
|
|
subJsonPath: z.string(),
|
|
subJsonRules: z.string(),
|
|
subJsonURI: z.string(),
|
|
subJsonUserAgentRegex: z.string(),
|
|
subKeyFile: z.string(),
|
|
subListen: z.string(),
|
|
subPath: z.string(),
|
|
subPort: z.number().int().min(1).max(65535),
|
|
subProfileUrl: z.string(),
|
|
subRoutingRules: z.string(),
|
|
subShowIdentityOnAllLinks: z.boolean(),
|
|
subSupportUrl: z.string(),
|
|
subThemeDir: z.string(),
|
|
subTitle: z.string(),
|
|
subURI: z.string(),
|
|
subUpdates: z.number().int().min(0).max(525600),
|
|
tgBotAPIServer: z.string(),
|
|
tgBotBackup: z.boolean(),
|
|
tgBotChatId: z.string(),
|
|
tgBotEnable: z.boolean(),
|
|
tgBotProxy: z.string(),
|
|
tgBotToken: z.string(),
|
|
tgCpu: z.number().int().min(0).max(100),
|
|
tgEnabledEvents: z.string(),
|
|
tgLang: z.string(),
|
|
tgMemory: z.number().int().min(0).max(100),
|
|
tgRunTime: z.string(),
|
|
timeLocation: z.string(),
|
|
trafficDiff: z.number().int().min(0).max(100),
|
|
trustedProxyCIDRs: z.string(),
|
|
twoFactorEnable: z.boolean(),
|
|
twoFactorToken: z.string(),
|
|
warpUpdateInterval: z.number().int().min(0),
|
|
webBasePath: z.string(),
|
|
webCertFile: z.string(),
|
|
webDomain: z.string(),
|
|
webKeyFile: z.string(),
|
|
webListen: z.string(),
|
|
webPort: z.number().int().min(1).max(65535),
|
|
});
|
|
export type AllSetting = z.infer<typeof AllSettingSchema>;
|
|
|
|
export const AllSettingViewSchema = z.object({
|
|
datepicker: z.string(),
|
|
expireDiff: z.number().int().min(0),
|
|
externalTrafficInformEnable: z.boolean(),
|
|
externalTrafficInformURI: z.string(),
|
|
hasApiToken: z.boolean(),
|
|
hasLdapPassword: z.boolean(),
|
|
hasNordSecret: z.boolean(),
|
|
hasSmtpPassword: z.boolean(),
|
|
hasTgBotToken: z.boolean(),
|
|
hasTwoFactorToken: z.boolean(),
|
|
hasWarpSecret: z.boolean(),
|
|
ldapAutoCreate: z.boolean(),
|
|
ldapAutoDelete: z.boolean(),
|
|
ldapBaseDN: z.string(),
|
|
ldapBindDN: z.string(),
|
|
ldapDefaultExpiryDays: z.number().int().min(0),
|
|
ldapDefaultLimitIP: z.number().int().min(0),
|
|
ldapDefaultTotalGB: z.number().int().min(0),
|
|
ldapEnable: z.boolean(),
|
|
ldapFlagField: z.string(),
|
|
ldapHost: z.string(),
|
|
ldapInboundTags: z.string(),
|
|
ldapInsecureSkipVerify: z.boolean(),
|
|
ldapInvertFlag: z.boolean(),
|
|
ldapPassword: z.string(),
|
|
ldapPort: z.number().int().min(0).max(65535),
|
|
ldapSyncCron: z.string(),
|
|
ldapTruthyValues: z.string(),
|
|
ldapUseTLS: z.boolean(),
|
|
ldapUserAttr: z.string(),
|
|
ldapUserFilter: z.string(),
|
|
ldapVlessField: z.string(),
|
|
outboundDownThreshold: z.number().int().min(1).max(100),
|
|
pageSize: z.number().int().min(0).max(1000),
|
|
panelOutbound: z.string(),
|
|
remarkTemplate: z.string(),
|
|
restartXrayOnClientDisable: z.boolean(),
|
|
sessionMaxAge: z.number().int().min(1).max(525600),
|
|
smtpCpu: z.number().int().min(0).max(100),
|
|
smtpEnable: z.boolean(),
|
|
smtpEnabledEvents: z.string(),
|
|
smtpEncryptionType: z.string(),
|
|
smtpFrom: z.string(),
|
|
smtpFromName: z.string(),
|
|
smtpHost: z.string(),
|
|
smtpMemory: z.number().int().min(0).max(100),
|
|
smtpPassword: z.string(),
|
|
smtpPort: z.number().int().min(1).max(65535),
|
|
smtpTo: z.string(),
|
|
smtpUsername: z.string(),
|
|
subAnnounce: z.string(),
|
|
subCertFile: z.string(),
|
|
subClashAutoDetect: z.boolean(),
|
|
subClashEnable: z.boolean(),
|
|
subClashEnableRouting: z.boolean(),
|
|
subClashPath: z.string(),
|
|
subClashRules: z.string(),
|
|
subClashURI: z.string(),
|
|
subClashUserAgentRegex: z.string(),
|
|
subDomain: z.string(),
|
|
subEnable: z.boolean(),
|
|
subEnableRouting: z.boolean(),
|
|
subEncrypt: z.boolean(),
|
|
subHideSettings: z.boolean(),
|
|
subIncyEnableRouting: z.boolean(),
|
|
subIncyRoutingRules: z.string(),
|
|
subJsonAlwaysArray: z.boolean(),
|
|
subJsonAutoDetect: z.boolean(),
|
|
subJsonEnable: z.boolean(),
|
|
subJsonFinalMask: z.string(),
|
|
subJsonMux: z.string(),
|
|
subJsonPath: z.string(),
|
|
subJsonRules: z.string(),
|
|
subJsonURI: z.string(),
|
|
subJsonUserAgentRegex: z.string(),
|
|
subKeyFile: z.string(),
|
|
subListen: z.string(),
|
|
subPath: z.string(),
|
|
subPort: z.number().int().min(1).max(65535),
|
|
subProfileUrl: z.string(),
|
|
subRoutingRules: z.string(),
|
|
subShowIdentityOnAllLinks: z.boolean(),
|
|
subSupportUrl: z.string(),
|
|
subThemeDir: z.string(),
|
|
subTitle: z.string(),
|
|
subURI: z.string(),
|
|
subUpdates: z.number().int().min(0).max(525600),
|
|
tgBotAPIServer: z.string(),
|
|
tgBotBackup: z.boolean(),
|
|
tgBotChatId: z.string(),
|
|
tgBotEnable: z.boolean(),
|
|
tgBotProxy: z.string(),
|
|
tgBotToken: z.string(),
|
|
tgCpu: z.number().int().min(0).max(100),
|
|
tgEnabledEvents: z.string(),
|
|
tgLang: z.string(),
|
|
tgMemory: z.number().int().min(0).max(100),
|
|
tgRunTime: z.string(),
|
|
timeLocation: z.string(),
|
|
trafficDiff: z.number().int().min(0).max(100),
|
|
trustedProxyCIDRs: z.string(),
|
|
twoFactorEnable: z.boolean(),
|
|
twoFactorToken: z.string(),
|
|
warpUpdateInterval: z.number().int().min(0),
|
|
webBasePath: z.string(),
|
|
webCertFile: z.string(),
|
|
webDomain: z.string(),
|
|
webKeyFile: z.string(),
|
|
webListen: z.string(),
|
|
webPort: z.number().int().min(1).max(65535),
|
|
});
|
|
export type AllSettingView = z.infer<typeof AllSettingViewSchema>;
|
|
|
|
export const ApiTokenSchema = z.object({
|
|
createdAt: z.number().int(),
|
|
enabled: z.boolean(),
|
|
expiresAt: z.number().int(),
|
|
id: z.number().int(),
|
|
name: z.string(),
|
|
scope: z.string(),
|
|
token: z.string(),
|
|
});
|
|
export type ApiToken = z.infer<typeof ApiTokenSchema>;
|
|
|
|
export const ApiTokenViewSchema = z.object({
|
|
createdAt: z.number().int(),
|
|
enabled: z.boolean(),
|
|
expiresAt: z.number().int(),
|
|
id: z.number().int(),
|
|
name: z.string(),
|
|
scope: z.string(),
|
|
token: z.string().optional(),
|
|
});
|
|
export type ApiTokenView = z.infer<typeof ApiTokenViewSchema>;
|
|
|
|
export const ClientSchema = z.object({
|
|
adTag: z.string().optional(),
|
|
allowedIPs: z.array(z.string()).optional(),
|
|
auth: z.string().optional(),
|
|
comment: z.string(),
|
|
created_at: z.number().int().optional(),
|
|
email: z.string(),
|
|
enable: z.boolean(),
|
|
expiryTime: z.number().int(),
|
|
flow: z.string().optional(),
|
|
group: z.string().optional(),
|
|
id: z.string().optional(),
|
|
keepAlive: z.number().int().optional(),
|
|
limitIp: z.number().int(),
|
|
password: z.string().optional(),
|
|
preSharedKey: z.string().optional(),
|
|
privateKey: z.string().optional(),
|
|
publicKey: z.string().optional(),
|
|
reset: z.number().int(),
|
|
reverse: z.lazy(() => ClientReverseSchema).nullable().optional(),
|
|
secret: z.string().optional(),
|
|
security: z.string(),
|
|
subId: z.string(),
|
|
tgId: z.number().int(),
|
|
totalGB: z.number().int(),
|
|
updated_at: z.number().int().optional(),
|
|
});
|
|
export type Client = z.infer<typeof ClientSchema>;
|
|
|
|
export const ClientInboundSchema = z.object({
|
|
clientId: z.number().int(),
|
|
createdAt: z.number().int(),
|
|
flowOverride: z.string(),
|
|
inboundId: z.number().int(),
|
|
});
|
|
export type ClientInbound = z.infer<typeof ClientInboundSchema>;
|
|
|
|
export const ClientRecordSchema = z.object({
|
|
adTag: z.string(),
|
|
allowedIPs: z.string(),
|
|
auth: z.string(),
|
|
comment: z.string(),
|
|
createdAt: z.number().int(),
|
|
email: z.string(),
|
|
enable: z.boolean(),
|
|
expiryTime: z.number().int(),
|
|
flow: z.string(),
|
|
group: z.string(),
|
|
id: z.number().int(),
|
|
keepAlive: z.number().int(),
|
|
limitHwid: z.number().int(),
|
|
limitIp: z.number().int(),
|
|
password: z.string(),
|
|
preSharedKey: z.string(),
|
|
privateKey: z.string(),
|
|
publicKey: z.string(),
|
|
reset: z.number().int(),
|
|
reverse: z.unknown(),
|
|
secret: z.string(),
|
|
security: z.string(),
|
|
subId: z.string(),
|
|
tgId: z.number().int(),
|
|
totalGB: z.number().int(),
|
|
updatedAt: z.number().int(),
|
|
uuid: z.string(),
|
|
});
|
|
export type ClientRecord = z.infer<typeof ClientRecordSchema>;
|
|
|
|
export const ClientReverseSchema = z.object({
|
|
tag: z.string(),
|
|
});
|
|
export type ClientReverse = z.infer<typeof ClientReverseSchema>;
|
|
|
|
export const ClientTrafficSchema = z.object({
|
|
down: z.number().int(),
|
|
email: z.string(),
|
|
enable: z.boolean(),
|
|
expiryTime: z.number().int(),
|
|
id: z.number().int(),
|
|
inboundId: z.number().int(),
|
|
lastOnline: z.number().int(),
|
|
lastSubFetch: z.number().int(),
|
|
reset: z.number().int(),
|
|
subId: z.string(),
|
|
total: z.number().int(),
|
|
up: z.number().int(),
|
|
uuid: z.string(),
|
|
});
|
|
export type ClientTraffic = z.infer<typeof ClientTrafficSchema>;
|
|
|
|
export const FallbackParentInfoSchema = z.object({
|
|
masterId: z.number().int(),
|
|
path: z.string().optional(),
|
|
});
|
|
export type FallbackParentInfo = z.infer<typeof FallbackParentInfoSchema>;
|
|
|
|
export const GeoCategorySchema = z.object({
|
|
attributes: z.array(z.string()),
|
|
code: z.string(),
|
|
entries: z.number().int(),
|
|
});
|
|
export type GeoCategory = z.infer<typeof GeoCategorySchema>;
|
|
|
|
export const GeoCategoryPageSchema = z.object({
|
|
items: z.array(z.lazy(() => GeoCategorySchema)),
|
|
total: z.number().int(),
|
|
});
|
|
export type GeoCategoryPage = z.infer<typeof GeoCategoryPageSchema>;
|
|
|
|
export const GeoEntrySchema = z.object({
|
|
kind: z.string(),
|
|
value: z.string(),
|
|
});
|
|
export type GeoEntry = z.infer<typeof GeoEntrySchema>;
|
|
|
|
export const GeoEntryPageSchema = z.object({
|
|
items: z.array(z.lazy(() => GeoEntrySchema)),
|
|
total: z.number().int(),
|
|
});
|
|
export type GeoEntryPage = z.infer<typeof GeoEntryPageSchema>;
|
|
|
|
export const GeoFileSchema = z.object({
|
|
categories: z.number().int(),
|
|
error: z.string().optional(),
|
|
kind: z.lazy(() => GeoKindSchema),
|
|
modifiedAt: z.number().int(),
|
|
name: z.string(),
|
|
size: z.number().int(),
|
|
});
|
|
export type GeoFile = z.infer<typeof GeoFileSchema>;
|
|
|
|
export const GeodataTokenIssueSchema = z.object({
|
|
code: z.string().optional(),
|
|
file: z.string().optional(),
|
|
reason: z.string(),
|
|
token: z.string(),
|
|
});
|
|
export type GeodataTokenIssue = z.infer<typeof GeodataTokenIssueSchema>;
|
|
|
|
export const HistoryOfSeedersSchema = z.object({
|
|
id: z.number().int(),
|
|
seederName: z.string(),
|
|
});
|
|
export type HistoryOfSeeders = z.infer<typeof HistoryOfSeedersSchema>;
|
|
|
|
export const HostSchema = z.object({
|
|
address: z.string(),
|
|
allowInsecure: z.boolean(),
|
|
alpn: z.array(z.string()),
|
|
createdAt: z.number().int(),
|
|
echConfigList: z.string(),
|
|
excludeFromSubTypes: z.array(z.string()),
|
|
finalMask: z.string(),
|
|
fingerprint: z.string(),
|
|
groupId: z.string(),
|
|
hostHeader: z.string(),
|
|
id: z.number().int(),
|
|
inboundId: z.number().int(),
|
|
isDisabled: z.boolean(),
|
|
isHidden: z.boolean(),
|
|
keepSniBlank: z.boolean(),
|
|
mihomoIpVersion: z.enum(['dual', 'ipv4', 'ipv6', 'ipv4-prefer', 'ipv6-prefer']),
|
|
mihomoX25519: z.boolean(),
|
|
muxParams: z.unknown(),
|
|
nodeGuids: z.array(z.string()).optional(),
|
|
overrideSniFromAddress: z.boolean(),
|
|
path: z.string(),
|
|
pinnedPeerCertSha256: z.array(z.string()),
|
|
port: z.number().int().min(0).max(65535),
|
|
remark: z.string().max(256),
|
|
security: z.enum(['same', 'tls', 'none', 'reality']),
|
|
serverDescription: z.string().max(64),
|
|
shuffleHost: z.boolean(),
|
|
sni: z.string(),
|
|
sockoptParams: z.unknown(),
|
|
sortOrder: z.number().int(),
|
|
tags: z.array(z.string()),
|
|
updatedAt: z.number().int(),
|
|
verifyPeerCertByName: z.string(),
|
|
vlessRoute: z.string(),
|
|
});
|
|
export type Host = z.infer<typeof HostSchema>;
|
|
|
|
export const HostGroupSchema = z.object({
|
|
allowInsecure: z.boolean(),
|
|
alpn: z.array(z.string()),
|
|
echConfigList: z.string(),
|
|
excludeFromSubTypes: z.array(z.string()),
|
|
finalMask: z.string(),
|
|
fingerprint: z.string(),
|
|
groupId: z.string(),
|
|
hostHeader: z.string(),
|
|
hosts: z.array(z.string()),
|
|
inboundIds: z.array(z.number().int()),
|
|
isDisabled: z.boolean(),
|
|
isHidden: z.boolean(),
|
|
keepSniBlank: z.boolean(),
|
|
mihomoIpVersion: z.enum(['dual', 'ipv4', 'ipv6', 'ipv4-prefer', 'ipv6-prefer']),
|
|
mihomoX25519: z.boolean(),
|
|
muxParams: z.string(),
|
|
nodeGuids: z.array(z.string()),
|
|
overrideSniFromAddress: z.boolean(),
|
|
path: z.string(),
|
|
pinnedPeerCertSha256: z.array(z.string()),
|
|
port: z.number().int().min(0).max(65535),
|
|
remark: z.string().max(256),
|
|
security: z.enum(['same', 'tls', 'none', 'reality']),
|
|
serverDescription: z.string().max(64),
|
|
shuffleHost: z.boolean(),
|
|
sni: z.string(),
|
|
sockoptParams: z.string(),
|
|
sortOrder: z.number().int(),
|
|
tags: z.array(z.string()),
|
|
verifyPeerCertByName: z.string(),
|
|
vlessRoute: z.string(),
|
|
});
|
|
export type HostGroup = z.infer<typeof HostGroupSchema>;
|
|
|
|
export const InboundSchema = z.object({
|
|
clientStats: z.array(z.lazy(() => ClientTrafficSchema)),
|
|
down: z.number().int(),
|
|
enable: z.boolean(),
|
|
expiryTime: z.number().int(),
|
|
fallbackParent: z.lazy(() => FallbackParentInfoSchema).nullable().optional(),
|
|
id: z.number().int(),
|
|
lastTrafficResetTime: z.number().int(),
|
|
listen: z.string(),
|
|
nodeId: z.number().int().nullable().optional(),
|
|
originNodeGuid: z.string().optional(),
|
|
port: z.number().int().min(0).max(65535),
|
|
protocol: z.enum(['vmess', 'vless', 'trojan', 'shadowsocks', 'wireguard', 'hysteria', 'http', 'mixed', 'tunnel', 'tun', 'mtproto']),
|
|
remark: z.string(),
|
|
settings: z.unknown(),
|
|
shareAddr: z.string(),
|
|
shareAddrStrategy: z.enum(['node', 'listen', 'custom']),
|
|
sniffing: z.unknown(),
|
|
streamSettings: z.unknown(),
|
|
subSortIndex: z.number().int().min(1),
|
|
tag: z.string(),
|
|
total: z.number().int(),
|
|
trafficReset: z.enum(['never', 'hourly', 'daily', 'weekly', 'monthly']),
|
|
trafficResetDay: z.number().int().min(1).max(31),
|
|
up: z.number().int(),
|
|
});
|
|
export type Inbound = z.infer<typeof InboundSchema>;
|
|
|
|
export const InboundClientIpsSchema = z.object({
|
|
clientEmail: z.string(),
|
|
id: z.number().int(),
|
|
ips: z.unknown(),
|
|
});
|
|
export type InboundClientIps = z.infer<typeof InboundClientIpsSchema>;
|
|
|
|
export const InboundFallbackSchema = z.object({
|
|
alpn: z.string(),
|
|
childId: z.number().int(),
|
|
dest: z.string(),
|
|
id: z.number().int(),
|
|
masterId: z.number().int(),
|
|
name: z.string(),
|
|
path: z.string(),
|
|
sortOrder: z.number().int(),
|
|
xver: z.number().int(),
|
|
});
|
|
export type InboundFallback = z.infer<typeof InboundFallbackSchema>;
|
|
|
|
export const InboundOptionSchema = z.object({
|
|
enable: z.boolean(),
|
|
id: z.number().int(),
|
|
listen: z.string().optional(),
|
|
mtprotoDomain: z.string().optional(),
|
|
nodeAddress: z.string().optional(),
|
|
nodeId: z.number().int().nullable().optional(),
|
|
port: z.number().int(),
|
|
protocol: z.string(),
|
|
remark: z.string(),
|
|
shareAddr: z.string().optional(),
|
|
shareAddrStrategy: z.string().optional(),
|
|
ssMethod: z.string(),
|
|
tag: z.string(),
|
|
tlsFlowCapable: z.boolean(),
|
|
wgDns: z.string().optional(),
|
|
wgMtu: z.number().int().optional(),
|
|
wgPublicKey: z.string().optional(),
|
|
});
|
|
export type InboundOption = z.infer<typeof InboundOptionSchema>;
|
|
|
|
export const MsgSchema = z.object({
|
|
msg: z.string(),
|
|
obj: z.unknown(),
|
|
success: z.boolean(),
|
|
});
|
|
export type Msg = z.infer<typeof MsgSchema>;
|
|
|
|
export const NodeSchema = z.object({
|
|
activeCount: z.number().int(),
|
|
address: z.string(),
|
|
allowPrivateAddress: z.boolean(),
|
|
basePath: z.string(),
|
|
clientCount: z.number().int(),
|
|
configDirty: z.boolean(),
|
|
configDirtyAt: z.number().int(),
|
|
cpuPct: z.number(),
|
|
createdAt: z.number().int(),
|
|
depletedCount: z.number().int(),
|
|
disabledCount: z.number().int(),
|
|
enable: z.boolean(),
|
|
guid: z.string(),
|
|
id: z.number().int(),
|
|
inboundCount: z.number().int(),
|
|
inboundSyncMode: z.enum(['all', 'selected']),
|
|
inboundTags: z.array(z.string()),
|
|
lastError: z.string(),
|
|
lastHeartbeat: z.number().int(),
|
|
latencyMs: z.number().int(),
|
|
memPct: z.number(),
|
|
name: z.string(),
|
|
netDown: z.number().int(),
|
|
netUp: z.number().int(),
|
|
onlineCount: z.number().int(),
|
|
outboundTag: z.string(),
|
|
panelVersion: z.string(),
|
|
parentGuid: z.string().optional(),
|
|
pinnedCertSha256: z.string(),
|
|
port: z.number().int().min(1).max(65535),
|
|
remark: z.string(),
|
|
scheme: z.enum(['http', 'https']),
|
|
status: z.string(),
|
|
tlsVerifyMode: z.enum(['verify', 'skip', 'pin', 'mtls']),
|
|
transitive: z.boolean().optional(),
|
|
updatedAt: z.number().int(),
|
|
uptimeSecs: z.number().int(),
|
|
xrayError: z.string(),
|
|
xrayState: z.string(),
|
|
xrayVersion: z.string(),
|
|
});
|
|
export type Node = z.infer<typeof NodeSchema>;
|
|
|
|
export const NodeMutationRequestSchema = z.object({
|
|
address: z.string(),
|
|
allowPrivateAddress: z.boolean(),
|
|
apiToken: z.string().nullable().optional(),
|
|
basePath: z.string(),
|
|
clearApiToken: z.boolean().optional(),
|
|
enable: z.boolean(),
|
|
id: z.number().int(),
|
|
inboundSyncMode: z.enum(['all', 'selected']),
|
|
inboundTags: z.array(z.string()),
|
|
name: z.string(),
|
|
outboundTag: z.string(),
|
|
pinnedCertSha256: z.string(),
|
|
port: z.number().int().min(1).max(65535),
|
|
remark: z.string(),
|
|
scheme: z.enum(['http', 'https']),
|
|
tlsVerifyMode: z.enum(['verify', 'skip', 'pin', 'mtls']),
|
|
});
|
|
export type NodeMutationRequest = z.infer<typeof NodeMutationRequestSchema>;
|
|
|
|
export const NodeViewSchema = z.object({
|
|
activeCount: z.number().int(),
|
|
address: z.string(),
|
|
allowPrivateAddress: z.boolean(),
|
|
basePath: z.string(),
|
|
clientCount: z.number().int(),
|
|
configDirty: z.boolean(),
|
|
configDirtyAt: z.number().int(),
|
|
cpuPct: z.number(),
|
|
createdAt: z.number().int(),
|
|
depletedCount: z.number().int(),
|
|
disabledCount: z.number().int(),
|
|
enable: z.boolean(),
|
|
guid: z.string(),
|
|
hasApiToken: z.boolean(),
|
|
id: z.number().int(),
|
|
inboundCount: z.number().int(),
|
|
inboundSyncMode: z.string(),
|
|
inboundTags: z.array(z.string()),
|
|
lastError: z.string(),
|
|
lastHeartbeat: z.number().int(),
|
|
latencyMs: z.number().int(),
|
|
memPct: z.number(),
|
|
name: z.string(),
|
|
netDown: z.number().int(),
|
|
netUp: z.number().int(),
|
|
onlineCount: z.number().int(),
|
|
outboundTag: z.string(),
|
|
panelVersion: z.string(),
|
|
parentGuid: z.string().optional(),
|
|
pinnedCertSha256: z.string(),
|
|
port: z.number().int(),
|
|
remark: z.string(),
|
|
scheme: z.string(),
|
|
status: z.string(),
|
|
tlsVerifyMode: z.string(),
|
|
transitive: z.boolean().optional(),
|
|
updatedAt: z.number().int(),
|
|
uptimeSecs: z.number().int(),
|
|
xrayError: z.string(),
|
|
xrayState: z.string(),
|
|
xrayVersion: z.string(),
|
|
});
|
|
export type NodeView = z.infer<typeof NodeViewSchema>;
|
|
|
|
export const OutboundTrafficsSchema = z.object({
|
|
down: z.number().int(),
|
|
id: z.number().int(),
|
|
tag: z.string(),
|
|
total: z.number().int(),
|
|
up: z.number().int(),
|
|
});
|
|
export type OutboundTraffics = z.infer<typeof OutboundTrafficsSchema>;
|
|
|
|
export const PanelUpdateStatusSchema = z.object({
|
|
exitCode: z.number().int(),
|
|
finishedAt: z.number().int(),
|
|
runId: z.string(),
|
|
state: z.string(),
|
|
});
|
|
export type PanelUpdateStatus = z.infer<typeof PanelUpdateStatusSchema>;
|
|
|
|
export const ProbeResultUISchema = z.object({
|
|
cpuPct: z.number(),
|
|
error: z.string(),
|
|
latencyMs: z.number().int(),
|
|
memPct: z.number(),
|
|
panelVersion: z.string(),
|
|
status: z.string(),
|
|
uptimeSecs: z.number().int(),
|
|
xrayError: z.string(),
|
|
xrayState: z.string(),
|
|
xrayVersion: z.string(),
|
|
});
|
|
export type ProbeResultUI = z.infer<typeof ProbeResultUISchema>;
|
|
|
|
export const RealityScanResultSchema = z.object({
|
|
alpn: z.string(),
|
|
certIssuer: z.string(),
|
|
certSubject: z.string(),
|
|
certValid: z.boolean(),
|
|
curveID: z.string(),
|
|
feasible: z.boolean(),
|
|
h2: z.boolean(),
|
|
host: z.string(),
|
|
ip: z.string(),
|
|
latencyMs: z.number().int(),
|
|
notAfter: z.string(),
|
|
port: z.number().int(),
|
|
reason: z.string(),
|
|
serverNames: z.array(z.string()),
|
|
target: z.string(),
|
|
tls13: z.boolean(),
|
|
tlsVersion: z.string(),
|
|
x25519: z.boolean(),
|
|
});
|
|
export type RealityScanResult = z.infer<typeof RealityScanResultSchema>;
|
|
|
|
export const SettingSchema = z.object({
|
|
id: z.number().int(),
|
|
key: z.string(),
|
|
value: z.string(),
|
|
});
|
|
export type Setting = z.infer<typeof SettingSchema>;
|
|
|
|
export const UserSchema = z.object({
|
|
id: z.number().int(),
|
|
password: z.string(),
|
|
username: z.string(),
|
|
});
|
|
export type User = z.infer<typeof UserSchema>;
|
|
|