feat: add yacd_secret_key support for ws

This commit is contained in:
divocat
2025-11-06 16:52:08 +02:00
parent ac4d7570f3
commit c67aadf267
5 changed files with 29 additions and 5 deletions

View File

@@ -731,10 +731,18 @@ async function getDashboardSections() {
};
}
// src/podkop/methods/custom/getClashApiSecret.ts
async function getClashApiSecret() {
const sections = await getConfigSections();
const settings = sections.find((section) => section[".type"] === "settings");
return settings?.yacd_secret_key || "";
}
// src/podkop/methods/custom/index.ts
var CustomPodkopMethods = {
getConfigSections,
getDashboardSections
getDashboardSections,
getClashApiSecret
};
// src/constants.ts
@@ -1876,8 +1884,9 @@ async function fetchDashboardSections() {
});
}
async function connectToClashSockets() {
const clashApiSecret = await getClashApiSecret();
socket.subscribe(
`${getClashWsUrl()}/traffic?token=`,
`${getClashWsUrl()}/traffic?token=${clashApiSecret}`,
(msg) => {
const parsedMsg = JSON.parse(msg);
store.set({
@@ -1904,7 +1913,7 @@ async function connectToClashSockets() {
}
);
socket.subscribe(
`${getClashWsUrl()}/connections?token=`,
`${getClashWsUrl()}/connections?token=${clashApiSecret}`,
(msg) => {
const parsedMsg = JSON.parse(msg);
store.set({