From 078fc54886ff8ff307dccda0cfb60afef83c3294 Mon Sep 17 00:00:00 2001 From: yaling888 <73897884+yaling888@users.noreply.github.com> Date: Fri, 6 May 2022 06:03:30 +0800 Subject: feat: add reload config-file & flush fake-ip pool to config page --- src/api/configs.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/api/configs.ts') 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' }); +} -- cgit v1.3.1