Add home bypass mode for the Mac client
This commit is contained in:
@@ -17,6 +17,10 @@ import {
|
||||
readDeviceProfiles,
|
||||
writeDeviceProfiles,
|
||||
} from "./devices.js";
|
||||
import {
|
||||
readClientSettings,
|
||||
writeClientSettings,
|
||||
} from "./clientSettings.js";
|
||||
import { matchRoute, detectRuleConflicts } from "./routeMatcher.js";
|
||||
import { tcpPing, resolveHost } from "./ping.js";
|
||||
|
||||
@@ -602,6 +606,7 @@ function publicState() {
|
||||
proxyBindIp: settings.bindIp,
|
||||
tproxyPort: settings.appMode === "gateway" ? settings.tproxyPort : null,
|
||||
routingRuDirect: settings.routingRuDirect,
|
||||
clientSettings: readClientSettings(),
|
||||
configExists: fs.existsSync(settings.configPath),
|
||||
singboxRunning: Boolean(singboxProcess),
|
||||
singboxStartedAt,
|
||||
@@ -924,6 +929,33 @@ async function handleApi(req, res) {
|
||||
});
|
||||
}
|
||||
|
||||
if (req.method === "GET" && req.url === "/api/client-settings") {
|
||||
return sendJson(res, 200, {
|
||||
success: true,
|
||||
clientSettings: readClientSettings(),
|
||||
});
|
||||
}
|
||||
|
||||
if (req.method === "PUT" && req.url === "/api/client-settings") {
|
||||
const body = await readBody(req);
|
||||
const clientSettings = writeClientSettings(body.clientSettings || body);
|
||||
const prevState = readJson(settings.statePath, {});
|
||||
|
||||
if (
|
||||
settings.appMode === "client" &&
|
||||
prevState.selectedTag &&
|
||||
readJson(settings.subscriptionCachePath, null)?.config
|
||||
) {
|
||||
await applySelectedServer(prevState.selectedTag);
|
||||
}
|
||||
|
||||
return sendJson(res, 200, {
|
||||
success: true,
|
||||
clientSettings,
|
||||
singboxRunning: Boolean(singboxProcess),
|
||||
});
|
||||
}
|
||||
|
||||
if (req.method === "GET" && req.url === "/api/rule-sets") {
|
||||
return sendJson(res, 200, {
|
||||
success: true,
|
||||
|
||||
Reference in New Issue
Block a user