Harden server state and config persistence
This commit is contained in:
@@ -2,6 +2,7 @@ import crypto from 'node:crypto';
|
||||
import fs from 'node:fs';
|
||||
import { settings } from './config.js';
|
||||
import { HarborError } from '../shared/errors.js';
|
||||
import { atomicWriteFile } from './services/stateStore.js';
|
||||
|
||||
const PROXY_TYPES = new Set(['vless', 'vmess', 'trojan', 'shadowsocks', 'hysteria2']);
|
||||
|
||||
@@ -11,7 +12,7 @@ export function getHwid() {
|
||||
return fs.readFileSync(settings.hwidPath, 'utf8').trim();
|
||||
}
|
||||
const hwid = crypto.randomBytes(8).toString('hex');
|
||||
fs.writeFileSync(settings.hwidPath, hwid, 'utf8');
|
||||
atomicWriteFile(settings.hwidPath, hwid);
|
||||
return hwid;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user