fix(utf8): закрыть lossy-границы конфигурации и API

This commit is contained in:
2026-09-07 17:25:27 +05:00
parent ab788725cf
commit af9f476658
38 changed files with 759 additions and 159 deletions
+2 -1
View File
@@ -8,6 +8,7 @@
*/
import { parseUpstreamHashes } from "../src/build/hysteriaRelease";
import { readText } from "../src/lib/fs";
function fail(message: string): never {
console.error(`[hy2xs-build] ERROR: ${message}`);
@@ -47,7 +48,7 @@ function parseArgs(argv: string[]): { file: string; asset: string } {
const { file, asset } = parseArgs(Bun.argv.slice(2));
try {
const text = await Bun.file(file).text();
const text = await readText(file);
process.stdout.write(`${parseUpstreamHashes(text, asset)}\n`);
} catch (error) {
fail(error instanceof Error ? error.message : String(error));
@@ -12,6 +12,7 @@
import { parseRuntimeEnv } from "../src/config/env";
import { HYSTERIA_OBFS_TYPES } from "../src/config/profile";
import { readText } from "../src/lib/fs";
import { hysteriaConfigTemplatePath, renderHysteriaConfig } from "../src/steps/config";
import type { RuntimeContext } from "../src/types/context";
@@ -138,7 +139,7 @@ async function main(): Promise<void> {
overrides.HY2XS_HYSTERIA_TRAFFIC_STATS_PORT = options.trafficStatsPort;
}
const sourceEnv = await Bun.file(options.configPath).text();
const sourceEnv = await readText(options.configPath);
const config = parseRuntimeEnv(overrideEnv(sourceEnv, overrides));
const context = {
@@ -160,7 +161,7 @@ async function main(): Promise<void> {
hysteriaResolution: "compat-gate"
} satisfies RuntimeContext;
const template = await Bun.file(options.templatePath).text();
const template = await readText(options.templatePath);
await Bun.write(options.outPath, renderHysteriaConfig(context, template));
}