feat(xray): add the XDRIVE transport

xray-core v26.10.10 tunnels a stream through files in shared cloud
storage ("network": "xdrive"): Google Drive, a local folder, or any HTTP
storage API described by a template. The panel could not select it, and
the stream schema rejected a pasted xdrive stream outright.

The inbound and outbound forms now offer XDRIVE with one shared editor:
service, folder, the three Google Drive secrets in the order the core
reads them, a template JSON editor with its {secretN} values, the
optional domain front (the stream-level address/port the storage client
dials), and the core's tuning knobs with their defaults as placeholders.
Switching an inbound to XDRIVE resets security to none, because the
core would otherwise read the inbound's TLS/REALITY as the storage API's
client TLS.

XDRIVE has no share-link format, and a link carrying the storage
secrets would print them into every QR code, so both link generators
emit none for it; the JSON subscription already passes the stream
through intact, and Clash drops the unknown transport.
This commit is contained in:
MHSanaei
2026-10-11 08:21:08 +02:00
parent 73a028f52d
commit ca5983595b
34 changed files with 848 additions and 19 deletions
@@ -1,5 +1,7 @@
import { z } from 'zod';
import { PortSchema } from '@/schemas/primitives';
import { ExternalProxyEntrySchema } from './external-proxy';
import { FinalMaskStreamSettingsSchema } from './finalmask';
import { GrpcStreamSettingsSchema } from './grpc';
@@ -9,6 +11,7 @@ import { KcpStreamSettingsSchema } from './kcp';
import { SockoptStreamSettingsSchema } from './sockopt';
import { TcpStreamSettingsSchema } from './tcp';
import { WsStreamSettingsSchema } from './ws';
import { XDriveStreamSettingsSchema } from './xdrive';
import { XHttpStreamSettingsSchema } from './xhttp';
export * from './external-proxy';
@@ -20,6 +23,7 @@ export * from './kcp';
export * from './sockopt';
export * from './tcp';
export * from './ws';
export * from './xdrive';
export * from './xhttp';
export const NetworkSchema = z.enum([
@@ -30,6 +34,7 @@ export const NetworkSchema = z.enum([
'httpupgrade',
'xhttp',
'hysteria',
'xdrive',
]);
export type Network = z.infer<typeof NetworkSchema>;
@@ -53,6 +58,13 @@ const TransportNetworkSettingsSchema = z.discriminatedUnion('network', [
}),
z.object({ network: z.literal('xhttp'), xhttpSettings: XHttpStreamSettingsSchema }),
z.object({ network: z.literal('hysteria'), hysteriaSettings: HysteriaStreamSettingsSchema }),
// The stream-level address/port is the domain front XDRIVE dials for its storage API.
z.object({
network: z.literal('xdrive'),
xdriveSettings: XDriveStreamSettingsSchema,
address: z.string().optional(),
port: PortSchema.optional(),
}),
]);
// Wireguard (always a UDP listener) and Tunnel (dokodemo-door) expose no
@@ -0,0 +1,26 @@
import { z } from 'zod';
// XDRIVE tunnels the stream through files in shared cloud storage, so both ends
// carry the same service, folder and secrets. Zero/absent tuning knobs take the
// core's defaults; segmentBytes and concurrency are capped there at 16 MiB / 64.
export const XDriveServiceSchema = z.enum(['Google Drive', 'local', 'template']);
export type XDriveService = z.infer<typeof XDriveServiceSchema>;
const MillisSchema = z.number().int().min(0);
export const XDriveStreamSettingsSchema = z.object({
service: XDriveServiceSchema.default('Google Drive'),
remoteFolder: z.string().default(''),
// Google Drive takes exactly three, in order: ClientID, ClientSecret, RefreshToken.
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(),
});
export type XDriveStreamSettings = z.infer<typeof XDriveStreamSettingsSchema>;