summaryrefslogtreecommitdiff
path: root/src/api/configs.ts
diff options
context:
space:
mode:
authoryaling888 <[email protected]>2022-05-06 06:03:30 +0800
committeryaling888 <[email protected]>2022-05-06 06:03:30 +0800
commit078fc54886ff8ff307dccda0cfb60afef83c3294 (patch)
treec3f3839be7f8aa0b90289be12f38f618eb67ed9e /src/api/configs.ts
parentdafd4486f17fcd72ac86578854886a807b0c4748 (diff)
feat: add reload config-file & flush fake-ip pool to config page
Diffstat (limited to 'src/api/configs.ts')
-rw-r--r--src/api/configs.ts16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/api/configs.ts b/src/api/configs.ts
index 69b02d4..e084261 100644
--- a/src/api/configs.ts
+++ b/src/api/configs.ts
@@ -3,6 +3,7 @@ import { ClashGeneralConfig } from 'src/store/types';
import { ClashAPIConfig } from 'src/types';
const endpoint = '/configs';
+const flushFakeIPPoolEndpoint = '/cache/fakeip/flush';
export async function fetchConfigs(apiConfig: ClashAPIConfig) {
const { url, init } = getURLAndInit(apiConfig);
@@ -30,3 +31,18 @@ export async function updateConfigs(
const body = JSON.stringify(configsPatchWorkaround(o));
return await fetch(url + endpoint, { ...init, body, method: 'PATCH' });
}
+
+export async function reloadConfigs(
+ apiConfig: ClashAPIConfig
+) {
+ const { url, init } = getURLAndInit(apiConfig);
+ const body = '{"path": "", "payload": ""}';
+ return await fetch(url + endpoint + '?force=true', { ...init, body, method: 'PUT' });
+}
+
+export async function flushFakeIPPool(
+ apiConfig: ClashAPIConfig
+) {
+ const { url, init } = getURLAndInit(apiConfig);
+ return await fetch(url + flushFakeIPPoolEndpoint, { ...init, method: 'POST' });
+}