feat: add dockerized 3proxy control plane backend
This commit is contained in:
87
src/shared/contracts.ts
Normal file
87
src/shared/contracts.ts
Normal file
@@ -0,0 +1,87 @@
|
||||
import type { ServiceState } from '../lib/3proxy';
|
||||
|
||||
export type ServiceProtocol = 'socks5' | 'http';
|
||||
export type ServiceCommand = 'socks' | 'proxy' | 'admin';
|
||||
|
||||
export interface DailyTrafficBucket {
|
||||
day: string;
|
||||
bytes: number;
|
||||
share: number;
|
||||
}
|
||||
|
||||
export interface ProxyServiceRecord {
|
||||
id: string;
|
||||
name: string;
|
||||
command: ServiceCommand;
|
||||
protocol: ServiceProtocol;
|
||||
description: string;
|
||||
port: number;
|
||||
enabled: boolean;
|
||||
assignable: boolean;
|
||||
}
|
||||
|
||||
export interface ProxyUserRecord {
|
||||
id: string;
|
||||
username: string;
|
||||
password: string;
|
||||
serviceId: string;
|
||||
status: Exclude<ServiceState, 'paused'>;
|
||||
usedBytes: number;
|
||||
quotaBytes: number | null;
|
||||
paused?: boolean;
|
||||
}
|
||||
|
||||
export interface ControlPlaneState {
|
||||
service: {
|
||||
versionLabel: string;
|
||||
lastEvent: string;
|
||||
startedAt: string | null;
|
||||
};
|
||||
traffic: {
|
||||
totalBytes: number;
|
||||
liveConnections: number;
|
||||
activeUsers: number;
|
||||
daily: DailyTrafficBucket[];
|
||||
};
|
||||
userRecords: ProxyUserRecord[];
|
||||
system: {
|
||||
publicHost: string;
|
||||
configMode: string;
|
||||
reloadMode: string;
|
||||
storageMode: string;
|
||||
services: ProxyServiceRecord[];
|
||||
};
|
||||
}
|
||||
|
||||
export interface DashboardSnapshot {
|
||||
service: {
|
||||
status: ServiceState;
|
||||
pidLabel: string;
|
||||
versionLabel: string;
|
||||
uptimeLabel: string;
|
||||
lastEvent: string;
|
||||
};
|
||||
traffic: ControlPlaneState['traffic'];
|
||||
users: {
|
||||
total: number;
|
||||
live: number;
|
||||
nearQuota: number;
|
||||
exceeded: number;
|
||||
};
|
||||
attention: Array<{
|
||||
level: Exclude<ServiceState, 'idle' | 'paused'>;
|
||||
title: string;
|
||||
message: string;
|
||||
}>;
|
||||
userRecords: ProxyUserRecord[];
|
||||
system: ControlPlaneState['system'] & {
|
||||
previewConfig: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface CreateUserInput {
|
||||
username: string;
|
||||
password: string;
|
||||
serviceId: string;
|
||||
quotaMb: number | null;
|
||||
}
|
||||
Reference in New Issue
Block a user