Bump xtls/xray-core to 676eaf66f8f0 (v26.11.9) and the three binary pins (DockerInit.sh, release.yml Linux + Windows) in lockstep, so the vendored config loader and the child binary validate the same config. The same go.mod also moves the go directive to 1.27.4 and golang.org/x/crypto to v0.58.1-0.20261009181718-2f1f834330b2; the core pulls in refraction-networking/utls 20261108164504, xtls/reality 20261108101329 and klauspost/cpuid v2.4.2. XDRIVE now caps concurrency at 256 instead of 64 (#7340), so the schema comment quoting the cap follows.
54 lines
2.6 KiB
TypeScript
54 lines
2.6 KiB
TypeScript
import { z } from 'zod';
|
|
|
|
// Both XDRIVE ends carry the same service, folder and secrets; an absent tuning knob takes
|
|
// the core's default (segmentBytes and concurrency are capped there at 16 MiB / 256).
|
|
export const XDriveServiceSchema = z.enum(['google-drive', 'local', 'template', 's3']);
|
|
export type XDriveService = z.infer<typeof XDriveServiceSchema>;
|
|
|
|
// xray-core 26.10.17 (#7182) renamed "Google Drive" and reads the old name only as a deprecated alias.
|
|
const canonicalXDriveService = (value: unknown) =>
|
|
value === 'Google Drive' ? 'google-drive' : value;
|
|
|
|
const XDriveServiceInputSchema = z.preprocess(canonicalXDriveService, XDriveServiceSchema);
|
|
|
|
/** Lifts a stored stream's legacy service name before an editor reads it unparsed. */
|
|
export function liftLegacyXDriveService(stream: Record<string, unknown>): void {
|
|
const xdrive = stream.xdriveSettings;
|
|
if (!xdrive || typeof xdrive !== 'object' || Array.isArray(xdrive)) return;
|
|
const settings = xdrive as Record<string, unknown>;
|
|
const service = canonicalXDriveService(settings.service);
|
|
if (service !== settings.service) stream.xdriveSettings = { ...settings, service };
|
|
}
|
|
|
|
const MillisSchema = z.number().int().min(0);
|
|
|
|
// S3-compatible storage (xray-core 26.10.31, #7231); an unset pathStyle means path-style addressing.
|
|
export const XDriveS3Schema = z.object({
|
|
endpoint: z.string().optional(),
|
|
region: z.string().optional(),
|
|
bucket: z.string().optional(),
|
|
pathStyle: z.boolean().optional(),
|
|
});
|
|
|
|
export const XDriveStreamSettingsSchema = z.object({
|
|
service: XDriveServiceInputSchema.default('google-drive'),
|
|
remoteFolder: z.string().default(''),
|
|
// Google Drive takes exactly three, in order: ClientID, ClientSecret, RefreshToken; S3 takes
|
|
// AccessKeyID, SecretAccessKey and an optional SessionToken.
|
|
secrets: z.array(z.string()).default([]),
|
|
segmentBytes: z.number().int().min(0).optional(),
|
|
flushIntervalMs: MillisSchema.optional(),
|
|
pollIntervalMs: MillisSchema.optional(),
|
|
maxPollIntervalMs: MillisSchema.optional(),
|
|
sessionTtlSeconds: z.number().int().min(0).optional(),
|
|
concurrency: z.number().int().min(0).optional(),
|
|
eagerWindowMs: MillisSchema.optional(),
|
|
holeTimeoutMs: MillisSchema.optional(),
|
|
template: z.record(z.string(), z.unknown()).optional(),
|
|
s3: XDriveS3Schema.optional(),
|
|
// Client XMUX (xray-core 26.10.21); left unset, the core sizes it per service, so no
|
|
// defaults are filled in here. A JSON subscription hands an inbound's value to clients.
|
|
xmux: z.record(z.string(), z.unknown()).optional(),
|
|
});
|
|
export type XDriveStreamSettings = z.infer<typeof XDriveStreamSettingsSchema>;
|