Skip to content

Commit

Permalink
✨ feat(config): Protocol type
Browse files Browse the repository at this point in the history
  • Loading branch information
web-ppanel committed Dec 7, 2024
1 parent 0327b73 commit a3b45b4
Show file tree
Hide file tree
Showing 6 changed files with 8,016 additions and 2,695 deletions.
20 changes: 18 additions & 2 deletions apps/admin/services/admin/typings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,17 @@ declare namespace API {
data?: Record<string, any>;
};

type SecurityConfig = {
server_address?: string;
server_name?: string;
server_port?: number;
fingerprint?: string;
private_key?: string;
public_key?: string;
short_id?: string;
allow_insecure?: boolean;
};

type Server = {
id: number;
name: string;
Expand Down Expand Up @@ -665,6 +676,11 @@ declare namespace API {
updated_at: number;
};

type TLSConfig = {
server_name?: string;
allow_insecure?: boolean;
};

type TosConfig = {
tos_content: string;
};
Expand Down Expand Up @@ -873,7 +889,7 @@ declare namespace API {
network: string;
transport: Record<string, any>;
security: string;
security_config: Record<string, any>;
security_config: SecurityConfig;
xtls: string;
enable_relay: boolean;
relay_host: string;
Expand All @@ -884,7 +900,7 @@ declare namespace API {
host: string;
port: number;
enable_tls: boolean;
tls_config: Record<string, any>;
tls_config: TLSConfig;
network: string;
transport: Record<string, any>;
enable_relay: boolean;
Expand Down
21 changes: 19 additions & 2 deletions apps/admin/services/common/typings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ declare namespace API {
user: number;
node: number;
country: number;
protocol: string[];
};

type GetSubscriptionResponse = {
Expand Down Expand Up @@ -216,6 +217,17 @@ declare namespace API {
data?: Record<string, any>;
};

type SecurityConfig = {
server_address?: string;
server_name?: string;
server_port?: number;
fingerprint?: string;
private_key?: string;
public_key?: string;
short_id?: string;
allow_insecure?: boolean;
};

type SendCodeRequest = {
email: string;
type: number;
Expand Down Expand Up @@ -328,6 +340,11 @@ declare namespace API {
updated_at: number;
};

type TLSConfig = {
server_name?: string;
allow_insecure?: boolean;
};

type TosConfig = {
tos_content: string;
};
Expand Down Expand Up @@ -436,7 +453,7 @@ declare namespace API {
network: string;
transport: Record<string, any>;
security: string;
security_config: Record<string, any>;
security_config: SecurityConfig;
xtls: string;
enable_relay: boolean;
relay_host: string;
Expand All @@ -447,7 +464,7 @@ declare namespace API {
host: string;
port: number;
enable_tls: boolean;
tls_config: Record<string, any>;
tls_config: TLSConfig;
network: string;
transport: Record<string, any>;
enable_relay: boolean;
Expand Down
48 changes: 31 additions & 17 deletions apps/user/app/(main)/(user)/dashboard/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { QRCodeCanvas } from 'qrcode.react';
import { useState } from 'react';

import useGlobalStore from '@/config/use-global';
import { getStat } from '@/services/common/common';
import Renewal from '../order/renewal';
import ResetTraffic from '../order/reset-traffic';
import Subscribe from '../subscribe/page';
Expand Down Expand Up @@ -67,6 +68,17 @@ export default function Page() {
}
};

const { data } = useQuery({
queryKey: ['getStat'],
queryFn: async () => {
const { data } = await getStat({
skipErrorHandler: true,
});
return data.data;
},
refetchOnWindowFocus: false,
});

return (
<div className='flex min-h-[calc(100vh-64px-58px-32px-114px)] w-full flex-col gap-4 overflow-hidden'>
<Announcement />
Expand All @@ -91,23 +103,25 @@ export default function Page() {
))}
</TabsList>
</Tabs>
<Tabs
value={protocol}
onValueChange={setProtocol}
className='w-full max-w-full md:w-auto'
>
<TabsList className='flex *:flex-auto'>
{['all', 'ss', 'vmess', 'vless', 'trojan'].map((item) => (
<TabsTrigger
value={item === 'all' ? '' : item}
key={item}
className='px-1 uppercase lg:px-3'
>
{item}
</TabsTrigger>
))}
</TabsList>
</Tabs>
{data?.protocol && data?.protocol.length > 1 && (
<Tabs
value={protocol}
onValueChange={setProtocol}
className='w-full max-w-full md:w-auto'
>
<TabsList className='flex *:flex-auto'>
{['all', ...(data?.protocol || [])].map((item) => (
<TabsTrigger
value={item === 'all' ? '' : item}
key={item}
className='px-1 uppercase lg:px-3'
>
{item}
</TabsTrigger>
))}
</TabsList>
</Tabs>
)}
</div>
{userSubscribe.map((item) => (
<Card key={item.id}>
Expand Down
21 changes: 19 additions & 2 deletions apps/user/services/common/typings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ declare namespace API {
user: number;
node: number;
country: number;
protocol: string[];
};

type GetSubscriptionResponse = {
Expand Down Expand Up @@ -216,6 +217,17 @@ declare namespace API {
data?: Record<string, any>;
};

type SecurityConfig = {
server_address?: string;
server_name?: string;
server_port?: number;
fingerprint?: string;
private_key?: string;
public_key?: string;
short_id?: string;
allow_insecure?: boolean;
};

type SendCodeRequest = {
email: string;
type: number;
Expand Down Expand Up @@ -328,6 +340,11 @@ declare namespace API {
updated_at: number;
};

type TLSConfig = {
server_name?: string;
allow_insecure?: boolean;
};

type TosConfig = {
tos_content: string;
};
Expand Down Expand Up @@ -436,7 +453,7 @@ declare namespace API {
network: string;
transport: Record<string, any>;
security: string;
security_config: Record<string, any>;
security_config: SecurityConfig;
xtls: string;
enable_relay: boolean;
relay_host: string;
Expand All @@ -447,7 +464,7 @@ declare namespace API {
host: string;
port: number;
enable_tls: boolean;
tls_config: Record<string, any>;
tls_config: TLSConfig;
network: string;
transport: Record<string, any>;
enable_relay: boolean;
Expand Down
20 changes: 18 additions & 2 deletions apps/user/services/user/typings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,17 @@ declare namespace API {
data?: Record<string, any>;
};

type SecurityConfig = {
server_address?: string;
server_name?: string;
server_port?: number;
fingerprint?: string;
private_key?: string;
public_key?: string;
short_id?: string;
allow_insecure?: boolean;
};

type Server = {
id: number;
name: string;
Expand Down Expand Up @@ -468,6 +479,11 @@ declare namespace API {
updated_at: number;
};

type TLSConfig = {
server_name?: string;
allow_insecure?: boolean;
};

type TosConfig = {
tos_content: string;
};
Expand Down Expand Up @@ -577,7 +593,7 @@ declare namespace API {
network: string;
transport: Record<string, any>;
security: string;
security_config: Record<string, any>;
security_config: SecurityConfig;
xtls: string;
enable_relay: boolean;
relay_host: string;
Expand All @@ -588,7 +604,7 @@ declare namespace API {
host: string;
port: number;
enable_tls: boolean;
tls_config: Record<string, any>;
tls_config: TLSConfig;
network: string;
transport: Record<string, any>;
enable_relay: boolean;
Expand Down
Loading

0 comments on commit a3b45b4

Please sign in to comment.