mirror of https://github.com/aredn/aredn.git
Use new ucode zlib library (#1629)
This commit is contained in:
parent
bd68cd18b9
commit
61eca9449c
|
@ -160,6 +160,7 @@ CONFIG_PACKAGE_ubi-utils=y
|
|||
CONFIG_PACKAGE_ucode-mod-log=y
|
||||
CONFIG_PACKAGE_ucode-mod-math=y
|
||||
CONFIG_PACKAGE_ucode-mod-resolv=y
|
||||
CONFIG_PACKAGE_ucode-mod-zlib=y
|
||||
CONFIG_PACKAGE_uhttpd=y
|
||||
CONFIG_PACKAGE_uhttpd-mod-ucode=y
|
||||
CONFIG_PACKAGE_vtun=y
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
import * as hardware from "aredn.hardware";
|
||||
|
||||
export const debug = true;
|
||||
export const debug = false;
|
||||
|
||||
export const application = "/app";
|
||||
export let preload = true;
|
||||
|
|
|
@ -39,6 +39,7 @@ import * as math from "math";
|
|||
import * as uci from "uci";
|
||||
import * as ubus from "ubus";
|
||||
import * as log from "log";
|
||||
import * as zlib from "zlib";
|
||||
import * as lucihttp from "lucihttp";
|
||||
import * as configuration from "aredn.configuration";
|
||||
import * as hardware from "aredn.hardware";
|
||||
|
@ -575,31 +576,15 @@ global.handle_request = function(env)
|
|||
res = `<div><b>ERROR: ${e.message}</b><div><pre>${e.stacktrace[0].context}</pre></div>`;
|
||||
}
|
||||
if (!response.override) {
|
||||
let datafile = null;
|
||||
let gzip = false;
|
||||
if (env.HTTP_ACCEPT_ENCODING && index(env.HTTP_ACCEPT_ENCODING, "gzip") !== -1 && config.compress) {
|
||||
const r = fs.open("/dev/urandom");
|
||||
if (r) {
|
||||
const rid = r.read(8);
|
||||
r.close();
|
||||
datafile = `/tmp/uhttpd.${hexenc(rid)}`;
|
||||
const x = fs.open(datafile, "wx");
|
||||
if (x) {
|
||||
x.write(res);
|
||||
x.close();
|
||||
const z = fs.popen("exec /bin/gzip -c " + datafile);
|
||||
res = z.read("all");
|
||||
z.close();
|
||||
fs.unlink(datafile);
|
||||
}
|
||||
else {
|
||||
datafile = null;
|
||||
}
|
||||
}
|
||||
gzip = true;
|
||||
res = zlib.deflate(res, true);
|
||||
}
|
||||
response.headers["Content-Length"] = `${length(res)}`;
|
||||
uhttpd.send(
|
||||
`Status: ${response.statusCode} OK\r\n`,
|
||||
(datafile ? `Content-Encoding: gzip\r\n` : ``),
|
||||
(gzip ? `Content-Encoding: gzip\r\n` : ``),
|
||||
join("", map(keys(response.headers), k => k + ": " + response.headers[k] + "\r\n")),
|
||||
"\r\n",
|
||||
res
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
--- a/package/utils/ucode/Makefile
|
||||
+++ b/package/utils/ucode/Makefile
|
||||
@@ -174,6 +174,10 @@
|
||||
uloop, ULOOP_SUPPORT, +libubox, \
|
||||
The uloop module allows ucode scripts to interact with OpenWrt uloop event loop implementation.))
|
||||
|
||||
+$(eval $(call UcodeModule, \
|
||||
+ zlib, ZLIB_SUPPORT, +zlib, \
|
||||
+ The zlib plugin implements compression.))
|
||||
+
|
||||
$(eval $(call BuildPackage,libucode))
|
||||
$(eval $(call BuildPackage,ucode))
|
||||
|
|
@ -45,6 +45,7 @@
|
|||
752-mikrotik-nand-revert.patch
|
||||
753-ubiquiti-2ac.patch
|
||||
760-uhttp-ucode.patch
|
||||
761-ucode-zlib.patch
|
||||
800-upgrade-compatibility.patch
|
||||
801-mikrotik-lhg-variants.patch
|
||||
802-gpio-typo.patch
|
||||
|
|
Loading…
Reference in New Issue