Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions fe-app-podkop/src/podkop/methods/custom/getDashboardSections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,32 @@ export async function getDashboardSections(): Promise<IGetDashboardSectionsRespo
};
}

if (section.proxy_config_type === 'subscription') {
const outbound = proxies.find(
(proxy) => proxy.code === `${section['.name']}-out`,
);

const proxyDisplayName =
getProxyUrlName(section.subscription_proxy_link) ||
outbound?.value?.name ||
'';

return {
withTagSelect: false,
code: outbound?.code || section['.name'],
displayName: section['.name'],
outbounds: [
{
code: outbound?.code || section['.name'],
displayName: proxyDisplayName,
latency: outbound?.value?.history?.[0]?.delay || 0,
type: outbound?.value?.type || '',
selected: true,
},
],
};
}

if (section.proxy_config_type === 'selector') {
const selector = proxies.find(
(proxy) => proxy.code === `${section['.name']}-out`,
Expand Down
5 changes: 5 additions & 0 deletions fe-app-podkop/src/podkop/methods/shell/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,9 @@ export const PodkopShellMethods = {
callBaseMethod<Podkop.GetSystemInfo>(
Podkop.AvailableMethods.GET_SYSTEM_INFO,
),
getSubscriptionOutbounds: async (subscriptionUrl: string) =>
callBaseMethod<Podkop.SubscriptionOutbound[]>(
Podkop.AvailableMethods.GET_SUBSCRIPTION_OUTBOUNDS,
[subscriptionUrl],
),
};
15 changes: 15 additions & 0 deletions fe-app-podkop/src/podkop/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export namespace Podkop {
SHOW_SING_BOX_CONFIG = 'show_sing_box_config',
CHECK_LOGS = 'check_logs',
GET_SYSTEM_INFO = 'get_system_info',
GET_SUBSCRIPTION_OUTBOUNDS = 'get_subscription_outbounds',
}

export enum AvailableClashAPIMethods {
Expand Down Expand Up @@ -107,6 +108,13 @@ export namespace Podkop {
proxy_string: string;
}

export interface ConfigProxySubscriptionSection {
connection_type: 'proxy';
proxy_config_type: 'subscription';
subscription_url: string;
subscription_proxy_link: string;
}

export interface ConfigProxyOutboundSection {
connection_type: 'proxy';
proxy_config_type: 'outbound';
Expand All @@ -130,6 +138,7 @@ export namespace Podkop {
| ConfigProxyUrlTestSection
| ConfigProxySelectorSection
| ConfigProxyUrlSection
| ConfigProxySubscriptionSection
| ConfigProxyOutboundSection
| ConfigVpnSection
| ConfigBlockSection
Expand Down Expand Up @@ -210,6 +219,12 @@ export namespace Podkop {
device_model: string;
}

export interface SubscriptionOutbound {
id: number;
url: string;
name?: string;
}

export interface GetClashApiProxyLatency {
delay: number;
message?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,7 @@ var Podkop;
AvailableMethods2["SHOW_SING_BOX_CONFIG"] = "show_sing_box_config";
AvailableMethods2["CHECK_LOGS"] = "check_logs";
AvailableMethods2["GET_SYSTEM_INFO"] = "get_system_info";
AvailableMethods2["GET_SUBSCRIPTION_OUTBOUNDS"] = "get_subscription_outbounds";
})(AvailableMethods = Podkop2.AvailableMethods || (Podkop2.AvailableMethods = {}));
let AvailableClashAPIMethods;
((AvailableClashAPIMethods2) => {
Expand Down Expand Up @@ -696,6 +697,10 @@ var PodkopShellMethods = {
checkLogs: async () => callBaseMethod(Podkop.AvailableMethods.CHECK_LOGS),
getSystemInfo: async () => callBaseMethod(
Podkop.AvailableMethods.GET_SYSTEM_INFO
),
getSubscriptionOutbounds: async (subscriptionUrl) => callBaseMethod(
Podkop.AvailableMethods.GET_SUBSCRIPTION_OUTBOUNDS,
[subscriptionUrl]
)
};

Expand Down Expand Up @@ -762,6 +767,26 @@ async function getDashboardSections() {
]
};
}
if (section.proxy_config_type === "subscription") {
const outbound = proxies.find(
(proxy) => proxy.code === `${section[".name"]}-out`
);
const proxyDisplayName = getProxyUrlName(section.subscription_proxy_link) || outbound?.value?.name || "";
return {
withTagSelect: false,
code: outbound?.code || section[".name"],
displayName: section[".name"],
outbounds: [
{
code: outbound?.code || section[".name"],
displayName: proxyDisplayName,
latency: outbound?.value?.history?.[0]?.delay || 0,
type: outbound?.value?.type || "",
selected: true
}
]
};
}
if (section.proxy_config_type === "selector") {
const selector = proxies.find(
(proxy) => proxy.code === `${section[".name"]}-out`
Expand Down
Loading