Усилить безопасность веб-интерфейса
This commit is contained in:
@@ -10,6 +10,10 @@ const BRAND_IMAGE_PATHS = [
|
||||
path.join(ROOT_DIR, 'crank-community.png'),
|
||||
path.resolve(ROOT_DIR, '..', '..', 'crank-community.png'),
|
||||
];
|
||||
const FONT_FILES = [
|
||||
['@fontsource/inter', 'inter', ['400', '500', '600', '700']],
|
||||
['@fontsource/jetbrains-mono', 'jetbrains-mono', ['400', '500']],
|
||||
];
|
||||
|
||||
const BUNDLES = {
|
||||
'protected-core': {
|
||||
@@ -136,6 +140,20 @@ function copyDirectory(source, destination) {
|
||||
}
|
||||
}
|
||||
|
||||
function copyFonts() {
|
||||
FONT_FILES.forEach(function([packageName, family, weights]) {
|
||||
weights.forEach(function(weight) {
|
||||
['latin', 'cyrillic'].forEach(function(subset) {
|
||||
var fileName = `${family}-${subset}-${weight}-normal.woff2`;
|
||||
copyFile(
|
||||
path.join(ROOT_DIR, 'node_modules', packageName, 'files', fileName),
|
||||
path.join(DIST_DIR, 'fonts', fileName)
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function readSource(relativePath) {
|
||||
return fs.readFileSync(sourcePath(relativePath), 'utf8');
|
||||
}
|
||||
@@ -191,6 +209,7 @@ async function main() {
|
||||
}
|
||||
|
||||
copyDirectory(path.join(ROOT_DIR, 'css'), path.join(DIST_DIR, 'css'));
|
||||
copyFonts();
|
||||
copyDirectory(path.join(ROOT_DIR, 'data'), path.join(DIST_DIR, 'data'));
|
||||
ensureDirectory(path.join(DIST_DIR, 'html', 'wizard'));
|
||||
[
|
||||
|
||||
@@ -119,8 +119,18 @@ function proxyRequest(request, response) {
|
||||
},
|
||||
},
|
||||
(proxyResponse) => {
|
||||
if (response.destroyed || response.writableEnded) {
|
||||
proxyResponse.resume();
|
||||
return;
|
||||
}
|
||||
response.writeHead(proxyResponse.statusCode || 502, proxyResponse.headers);
|
||||
pipeline(proxyResponse, response, () => {});
|
||||
proxyResponse.on('error', function() {
|
||||
if (!response.destroyed) response.destroy();
|
||||
});
|
||||
response.on('close', function() {
|
||||
if (!proxyResponse.destroyed) proxyResponse.destroy();
|
||||
});
|
||||
proxyResponse.pipe(response);
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user