From 44f3886456c82e024f507c3ac0d5de733fe1e5db Mon Sep 17 00:00:00 2001 From: Andrei Zeliankou Date: Mon, 4 Sep 2023 12:03:39 +0100 Subject: Version bump. --- docs/changes.xml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/docs/changes.xml b/docs/changes.xml index a1f4d466..85edc71b 100644 --- a/docs/changes.xml +++ b/docs/changes.xml @@ -5,6 +5,37 @@ + + + + +NGINX Unit updated to 1.32.0. + + + + + + + + + + + Date: Mon, 4 Sep 2023 14:06:21 +0100 Subject: Version file bump. Forgotten in f717dc15b47e. --- version | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version b/version index c08b9fd5..fa657bae 100644 --- a/version +++ b/version @@ -1,5 +1,5 @@ # Copyright (C) NGINX, Inc. -NXT_VERSION=1.31.0 -NXT_VERNUM=13100 +NXT_VERSION=1.32.0 +NXT_VERNUM=13200 -- cgit From 7dd5ad93a4c147b086a8d82ecb403f96981bb4ee Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Fri, 18 Aug 2023 12:12:27 +0200 Subject: Log: fixed typo. Scripted change: $ grep -ril recevied src/ | xargs sed -i s/recevied/received/ Reported-by: Closes: Cc: Cc: Timo Stark Signed-off-by: Alejandro Colomar Reviewed-by: Andrew Clayton Signed-off-by: Andrew Clayton --- src/nxt_conn_write.c | 2 +- src/nxt_main_process.c | 4 ++-- src/nxt_signal_handlers.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/nxt_conn_write.c b/src/nxt_conn_write.c index bcf9e8fa..714a3e15 100644 --- a/src/nxt_conn_write.c +++ b/src/nxt_conn_write.c @@ -97,7 +97,7 @@ nxt_conn_io_write(nxt_task_t *task, void *obj, void *data) if (sb.limit == 0) { /* * Postpone writing until next event poll to allow to - * process other recevied events and to get new events. + * process other received events and to get new events. */ c->write_timer.handler = nxt_conn_write_timer_handler; nxt_timer_add(engine, &c->write_timer, 0); diff --git a/src/nxt_main_process.c b/src/nxt_main_process.c index 6622f67e..3f317d5e 100644 --- a/src/nxt_main_process.c +++ b/src/nxt_main_process.c @@ -856,7 +856,7 @@ nxt_main_process_sigusr1_handler(nxt_task_t *task, void *obj, void *data) nxt_array_t *new_files; nxt_runtime_t *rt; - nxt_log(task, NXT_LOG_NOTICE, "signal %d (%s) recevied, %s", + nxt_log(task, NXT_LOG_NOTICE, "signal %d (%s) received, %s", (int) (uintptr_t) obj, data, "log files rotation"); rt = task->thread->runtime; @@ -1073,7 +1073,7 @@ nxt_main_process_sigchld_handler(nxt_task_t *task, void *obj, void *data) static void nxt_main_process_signal_handler(nxt_task_t *task, void *obj, void *data) { - nxt_trace(task, "signal signo:%d (%s) recevied, ignored", + nxt_trace(task, "signal signo:%d (%s) received, ignored", (int) (uintptr_t) obj, data); } diff --git a/src/nxt_signal_handlers.c b/src/nxt_signal_handlers.c index 69ae2bc4..63b38fab 100644 --- a/src/nxt_signal_handlers.c +++ b/src/nxt_signal_handlers.c @@ -31,7 +31,7 @@ const nxt_sig_event_t nxt_process_signals[] = { static void nxt_signal_handler(nxt_task_t *task, void *obj, void *data) { - nxt_trace(task, "signal signo:%d (%s) recevied, ignored", + nxt_trace(task, "signal signo:%d (%s) received, ignored", (int) (uintptr_t) obj, data); } -- cgit From c9961610ed5651bda63191465e70e8227c3ef711 Mon Sep 17 00:00:00 2001 From: Andrew Clayton Date: Wed, 6 Sep 2023 02:58:19 +0100 Subject: Fix build on musl libc with clang. As reported by @andypost on GitHub, if you try to build Unit on a system that uses musl libc (such as Alpine Linux) with clang then you get the following clang -c -pipe -fPIC -fvisibility=hidden -O -W -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -fstrict-aliasing -Wstrict-overflow=5 -Wmissing-prototypes -Werror -g -I src -I build/include \ \ \ -o build/src/nxt_socketpair.o \ -MMD -MF build/src/nxt_socketpair.dep -MT build/src/nxt_socketpair.o \ src/nxt_socketpair.c In file included from src/nxt_socketpair.c:8: src/nxt_socket_msg.h:138:17: error: comparison of integers of different signs: 'unsigned long' and 'long' [-Werror,-Wsign-compare] cmsg = CMSG_NXTHDR(&msg, cmsg)) ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/sys/socket.h:358:44: note: expanded from macro 'CMSG_NXTHDR' __CMSG_LEN(cmsg) + sizeof(struct cmsghdr) >= __MHDR_END(mhdr) - (unsigned char *)(cmsg) \ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from src/nxt_socketpair.c:8: src/nxt_socket_msg.h:177:17: error: comparison of integers of different signs: 'unsigned long' and 'long' [-Werror,-Wsign-compare] cmsg = CMSG_NXTHDR(&msg, cmsg)) ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/sys/socket.h:358:44: note: expanded from macro 'CMSG_NXTHDR' __CMSG_LEN(cmsg) + sizeof(struct cmsghdr) >= __MHDR_END(mhdr) - (unsigned char *)(cmsg) \ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2 errors generated. make: *** [build/Makefile:261: build/src/nxt_socketpair.o] Error 1 GCC works fine, it seems to have some smarts so that it doesn't give warnings on system header files. This seems to be a long standing issue with musl libc (bad casting in the CMSG_NXTHDR macro) and the workaround employed by several projects is to disable the -Wsign-compare clang warning for the code in question. So, that's what we do. We wrap the CMSG_NXTHDR macro in a function, so we can use the pre-processor in it to selectively disable the warning. Link: Link: Link: Link: Closes: Signed-off-by: Andrew Clayton --- src/nxt_socket_msg.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/nxt_socket_msg.h b/src/nxt_socket_msg.h index 04de1761..81617bd6 100644 --- a/src/nxt_socket_msg.h +++ b/src/nxt_socket_msg.h @@ -69,6 +69,20 @@ NXT_EXPORT ssize_t nxt_recvmsg(nxt_socket_t s, nxt_iobuf_t *iob, nxt_uint_t niob, nxt_recv_oob_t *oob); +nxt_inline struct cmsghdr * +NXT_CMSG_NXTHDR(struct msghdr *msgh, struct cmsghdr *cmsg) +{ +#if !defined(__GLIBC__) && defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wsign-compare" +#endif + return CMSG_NXTHDR(msgh, cmsg); +#if !defined(__GLIBC__) && defined(__clang__) +#pragma clang diagnostic pop +#endif +} + + nxt_inline void nxt_socket_msg_oob_init(nxt_send_oob_t *oob, int *fds) { @@ -135,7 +149,7 @@ nxt_socket_msg_oob_get_fds(nxt_recv_oob_t *oob, nxt_fd_t *fd) for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL; - cmsg = CMSG_NXTHDR(&msg, cmsg)) + cmsg = NXT_CMSG_NXTHDR(&msg, cmsg)) { size = cmsg->cmsg_len - CMSG_LEN(0); @@ -174,7 +188,7 @@ nxt_socket_msg_oob_get(nxt_recv_oob_t *oob, nxt_fd_t *fd, nxt_pid_t *pid) for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL; - cmsg = CMSG_NXTHDR(&msg, cmsg)) + cmsg = NXT_CMSG_NXTHDR(&msg, cmsg)) { size = cmsg->cmsg_len - CMSG_LEN(0); -- cgit From 76086d6d7a027ddf42d86897200a53d724fb4bb7 Mon Sep 17 00:00:00 2001 From: Andrew Clayton Date: Fri, 8 Sep 2023 21:51:25 +0100 Subject: Wasm: Allow to set the HTTP response status. This commit enables WebAssembly modules to set the HTTP response status to something other than the previously hard coded '200 OK'. To do this they can make a call to nxt_wasm_set_resp_status() providing the required status code. If this function isn't called the status code defaults to '200 OK'. The WebAssembly module can also return -1 from the request_handler function as a short cut to signal a '500 Internal Server Error'. Signed-off-by: Andrew Clayton --- src/wasm/nxt_rt_wasmtime.c | 25 +++++++++++++++++++++++-- src/wasm/nxt_wasm.c | 27 +++++++++++++++++++++++---- src/wasm/nxt_wasm.h | 4 +++- 3 files changed, 49 insertions(+), 7 deletions(-) diff --git a/src/wasm/nxt_rt_wasmtime.c b/src/wasm/nxt_rt_wasmtime.c index 99786b89..7f05fae0 100644 --- a/src/wasm/nxt_rt_wasmtime.c +++ b/src/wasm/nxt_rt_wasmtime.c @@ -102,6 +102,19 @@ nxt_wasm_send_headers(void *env, wasmtime_caller_t *caller, } +static wasm_trap_t * +nxt_wasm_set_resp_status(void *env, wasmtime_caller_t *caller, + const wasmtime_val_t *args, size_t nargs, + wasmtime_val_t *results, size_t nresults) +{ + nxt_wasm_ctx_t *ctx = env; + + ctx->status = args[0].of.i32; + + return NULL; +} + + static void nxt_wasmtime_execute_hook(const nxt_wasm_ctx_t *ctx, nxt_wasm_fh_t hook) { @@ -123,8 +136,8 @@ nxt_wasmtime_execute_hook(const nxt_wasm_ctx_t *ctx, nxt_wasm_fh_t hook) } -static void -nxt_wasmtime_execute_request(const nxt_wasm_ctx_t *ctx) +static int +nxt_wasmtime_execute_request(nxt_wasm_ctx_t *ctx) { int i = 0; wasm_trap_t *trap = NULL; @@ -142,7 +155,10 @@ nxt_wasmtime_execute_request(const nxt_wasm_ctx_t *ctx) nxt_wasmtime_err_msg(error, trap, "failed to call function [->wasm_request_handler]" ); + return -1; } + + return results[0].of.i32; } @@ -183,6 +199,11 @@ nxt_wasmtime_set_function_imports(nxt_wasm_ctx_t *ctx) .func = nxt_wasm_send_headers, .params = { WASM_I32 }, .ft = NXT_WASM_FT_1_0 + }, { + .func_name = "nxt_wasm_set_resp_status", + .func = nxt_wasm_set_resp_status, + .params = { WASM_I32 }, + .ft = NXT_WASM_FT_1_0 }, { } diff --git a/src/wasm/nxt_wasm.c b/src/wasm/nxt_wasm.c index 45a40b4b..796ea847 100644 --- a/src/wasm/nxt_wasm.c +++ b/src/wasm/nxt_wasm.c @@ -24,6 +24,11 @@ static nxt_wasm_ctx_t nxt_wasm_ctx; static const nxt_wasm_operations_t *nxt_wops; +enum { + NXT_WASM_HTTP_OK = 200, + NXT_WASM_HTTP_ERROR = 500 +}; + void nxt_wasm_do_response_end(nxt_wasm_ctx_t *ctx) @@ -48,7 +53,7 @@ nxt_wasm_do_send_headers(nxt_wasm_ctx_t *ctx, uint32_t offset) fields_len += rh->fields[i].name_len + rh->fields[i].value_len; } - nxt_unit_response_init(ctx->req, 200, rh->nfields, fields_len); + nxt_unit_response_init(ctx->req, ctx->status, rh->nfields, fields_len); for (i = 0; i < rh->nfields; i++) { const char *name; @@ -72,7 +77,7 @@ nxt_wasm_do_send_response(nxt_wasm_ctx_t *ctx, uint32_t offset) nxt_unit_request_info_t *req = ctx->req; if (!nxt_unit_response_is_init(req)) { - nxt_unit_response_init(req, 200, 0, 0); + nxt_unit_response_init(req, ctx->status, 0, 0); } resp = (nxt_wasm_response_t *)(nxt_wasm_ctx.baddr + offset); @@ -84,6 +89,7 @@ nxt_wasm_do_send_response(nxt_wasm_ctx_t *ctx, uint32_t offset) static void nxt_wasm_request_handler(nxt_unit_request_info_t *req) { + int err; size_t offset, read_bytes, content_sent, content_len; ssize_t bytes_read; nxt_unit_field_t *sf, *sf_end; @@ -149,8 +155,12 @@ nxt_wasm_request_handler(nxt_unit_request_info_t *req) wr->request_size = offset + bytes_read; + nxt_wasm_ctx.status = NXT_WASM_HTTP_OK; nxt_wasm_ctx.req = req; - nxt_wops->exec_request(&nxt_wasm_ctx); + err = nxt_wops->exec_request(&nxt_wasm_ctx); + if (err) { + goto out_err_500; + } if (content_len == content_sent) { goto request_done; @@ -168,9 +178,18 @@ nxt_wasm_request_handler(nxt_unit_request_info_t *req) wr->request_size = wr->content_sent = bytes_read; wr->total_content_sent = content_sent; - nxt_wops->exec_request(&nxt_wasm_ctx); + err = nxt_wops->exec_request(&nxt_wasm_ctx); + if (err) { + goto out_err_500; + } } while (content_sent < content_len); + goto request_done; + +out_err_500: + nxt_unit_response_init(req, NXT_WASM_HTTP_ERROR, 0, 0); + nxt_unit_request_done(req, NXT_UNIT_OK); + request_done: NXT_WASM_DO_HOOK(NXT_WASM_FH_REQUEST_END); } diff --git a/src/wasm/nxt_wasm.h b/src/wasm/nxt_wasm.h index cb9dbdfe..2748d764 100644 --- a/src/wasm/nxt_wasm.h +++ b/src/wasm/nxt_wasm.h @@ -118,12 +118,14 @@ struct nxt_wasm_ctx_s { size_t baddr_off; size_t response_off; + + uint16_t status; }; struct nxt_wasm_operations_s { int (*init)(nxt_wasm_ctx_t *ctx); void (*destroy)(const nxt_wasm_ctx_t *ctx); - void (*exec_request)(const nxt_wasm_ctx_t *ctx); + int (*exec_request)(nxt_wasm_ctx_t *ctx); void (*exec_hook)(const nxt_wasm_ctx_t *ctx, nxt_wasm_fh_t hook); }; -- cgit From d5efa5f11f38d4ca6c64374f848055611d4f315c Mon Sep 17 00:00:00 2001 From: Andrew Clayton Date: Thu, 14 Sep 2023 00:37:28 +0100 Subject: Wasm: Fix multiple successive calls to the request_handler. When trying to upload files to the luw-upload-reflector demo[0] above a certain size that would mean Unit would need to make more than two calls to the request_handler function in the Wasm module we would get the following error from wasmtime and the upload would stall on the third call to the request_handler WASMTIME ERROR: failed to call function [->wasm_request_handler] error while executing at wasm backtrace: 0: 0x5ce2 - !memcpy 1: 0x7df - luw_req_buf_append at /home/andrew/src/unit-wasm/src/c/libunit-wasm.c:308:14 2: 0x3a1 - luw_request_handler at /home/andrew/src/unit-wasm/examples/c/luw-upload-reflector.c:110:3 Caused by: wasm trap: out of bounds memory access This was due to ->content_off (the offset of where the actual body content starts in the request structure/memory) being some overly large value. This was largely down to me being an idiot! Before calling the loop that makes the calls to the request_handler we would calculate the new offset, which is now just the size of the request structure as we don't re-send all the HTTP meta data and headers etc. However because this value is in the request structure which is in the shared memory and we use this same memory for requests and responses, when we make a response we overwrite this request structure with the response structure, so our ->content_off is now some wacked out value when we make the next call to the request_handler. To fix this we just need to reset ->content_off each time round the loop. There's also no point in setting ->nfields to 0, it has the same issue as above, but doesn't get re-used by the Wasm module anyway. [0]: Signed-off-by: Andrew Clayton --- src/wasm/nxt_wasm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wasm/nxt_wasm.c b/src/wasm/nxt_wasm.c index 796ea847..92ed57ab 100644 --- a/src/wasm/nxt_wasm.c +++ b/src/wasm/nxt_wasm.c @@ -166,8 +166,7 @@ nxt_wasm_request_handler(nxt_unit_request_info_t *req) goto request_done; } - wr->nfields = 0; - wr->content_off = offset = sizeof(nxt_wasm_request_t); + offset = sizeof(nxt_wasm_request_t); do { read_bytes = nxt_min(content_len - content_sent, NXT_WASM_MEM_SIZE - offset); @@ -177,6 +176,7 @@ nxt_wasm_request_handler(nxt_unit_request_info_t *req) content_sent += bytes_read; wr->request_size = wr->content_sent = bytes_read; wr->total_content_sent = content_sent; + wr->content_off = offset; err = nxt_wops->exec_request(&nxt_wasm_ctx); if (err) { -- cgit From 0f630c3f604e76de370529907b51ad29dfdc4ecb Mon Sep 17 00:00:00 2001 From: Andrew Clayton Date: Thu, 14 Sep 2023 20:35:15 +0100 Subject: Wasm: Allow uploads larger than 4GiB. Currently Wasm modules are limited to a 32bit address space (until at least the memory64 work is completed). All the counters etc in the request structure were u32's. Which matched with 32bit memory limitation. However there is really no need to not allow >4GiB uploads that can be saved off to disk or some such. To do this we just need to increase the ->content_len & ->total_content_sent members to u64's. However because we need the request structure to have the exact same layout on 32bit (for Wasm modules) as it does on 64bit we need to re-jig the order of some of these members and add a four-byte padding member. Thus the request structure now looks like on 64bit (as shown by pahole(1)) struct nxt_wasm_request_s { uint32_t method_off; /* 0 4 */ uint32_t method_len; /* 4 4 */ uint32_t version_off; /* 8 4 */ uint32_t version_len; /* 12 4 */ uint32_t path_off; /* 16 4 */ uint32_t path_len; /* 20 4 */ uint32_t query_off; /* 24 4 */ uint32_t query_len; /* 28 4 */ uint32_t remote_off; /* 32 4 */ uint32_t remote_len; /* 36 4 */ uint32_t local_addr_off; /* 40 4 */ uint32_t local_addr_len; /* 44 4 */ uint32_t local_port_off; /* 48 4 */ uint32_t local_port_len; /* 52 4 */ uint32_t server_name_off; /* 56 4 */ uint32_t server_name_len; /* 60 4 */ /* --- cacheline 1 boundary (64 bytes) --- */ uint64_t content_len; /* 64 8 */ uint64_t total_content_sent; /* 72 8 */ uint32_t content_sent; /* 80 4 */ uint32_t content_off; /* 84 4 */ uint32_t request_size; /* 88 4 */ uint32_t nfields; /* 92 4 */ uint32_t tls; /* 96 4 */ char __pad[4]; /* 100 4 */ nxt_wasm_http_field_t fields[]; /* 104 0 */ /* size: 104, cachelines: 2, members: 25 */ /* last cacheline: 40 bytes */ }; and the same structure (taken from unit-wasm) compiled as 32bit struct luw_req { u32 method_off; /* 0 4 */ u32 method_len; /* 4 4 */ u32 version_off; /* 8 4 */ u32 version_len; /* 12 4 */ u32 path_off; /* 16 4 */ u32 path_len; /* 20 4 */ u32 query_off; /* 24 4 */ u32 query_len; /* 28 4 */ u32 remote_off; /* 32 4 */ u32 remote_len; /* 36 4 */ u32 local_addr_off; /* 40 4 */ u32 local_addr_len; /* 44 4 */ u32 local_port_off; /* 48 4 */ u32 local_port_len; /* 52 4 */ u32 server_name_off; /* 56 4 */ u32 server_name_len; /* 60 4 */ /* --- cacheline 1 boundary (64 bytes) --- */ u64 content_len; /* 64 8 */ u64 total_content_sent; /* 72 8 */ u32 content_sent; /* 80 4 */ u32 content_off; /* 84 4 */ u32 request_size; /* 88 4 */ u32 nr_fields; /* 92 4 */ u32 tls; /* 96 4 */ char __pad[4]; /* 100 4 */ struct luw_hdr_field fields[]; /* 104 0 */ /* size: 104, cachelines: 2, members: 25 */ /* last cacheline: 40 bytes */ }; We can see the structures have the same layout, same size and no padding. We need the __pad member as otherwise I saw gcc and clang on Alpine Linux automatically add the 'packed' attribute to the structure which made the two structures not match. Link: Link: Signed-off-by: Andrew Clayton --- src/wasm/nxt_wasm.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/wasm/nxt_wasm.h b/src/wasm/nxt_wasm.h index 2748d764..f78aef13 100644 --- a/src/wasm/nxt_wasm.h +++ b/src/wasm/nxt_wasm.h @@ -59,10 +59,10 @@ struct nxt_wasm_request_s { uint32_t server_name_off; uint32_t server_name_len; - uint32_t content_off; - uint32_t content_len; + uint64_t content_len; + uint64_t total_content_sent; uint32_t content_sent; - uint32_t total_content_sent; + uint32_t content_off; uint32_t request_size; @@ -70,6 +70,8 @@ struct nxt_wasm_request_s { uint32_t tls; + char __pad[4]; + nxt_wasm_http_field_t fields[]; }; -- cgit From e0c26757740fa7974af6e6592e35b5f2e00339fe Mon Sep 17 00:00:00 2001 From: Andrei Zeliankou Date: Tue, 26 Sep 2023 12:49:39 +0100 Subject: Node.js: response body chunk can now be a Uint8Array. Starting from Node.js 15.0.0 the chunk parameter of the response.write() can be a Uint8Array. This closes #870 issue on GitHub. --- src/nodejs/unit-http/http_server.js | 7 +++++-- test/node/write_array/app.js | 4 ++++ test/node/write_buffer/app.js | 2 +- test/test_node_application.py | 4 ++++ 4 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 test/node/write_array/app.js diff --git a/src/nodejs/unit-http/http_server.js b/src/nodejs/unit-http/http_server.js index 89964ec3..11651ed7 100644 --- a/src/nodejs/unit-http/http_server.js +++ b/src/nodejs/unit-http/http_server.js @@ -243,8 +243,11 @@ ServerResponse.prototype._writeBody = function(chunk, encoding, callback) { } if (chunk) { - if (typeof chunk !== 'string' && !(chunk instanceof Buffer)) { - throw new TypeError('First argument must be a string or Buffer'); + if (typeof chunk !== 'string' && !(chunk instanceof Buffer || + chunk instanceof Uint8Array)) { + throw new TypeError( + 'First argument must be a string, Buffer, ' + + 'or Uint8Array'); } if (typeof chunk === 'string') { diff --git a/test/node/write_array/app.js b/test/node/write_array/app.js new file mode 100644 index 00000000..b7abb3fc --- /dev/null +++ b/test/node/write_array/app.js @@ -0,0 +1,4 @@ +require('http').createServer(function (req, res) { + res.writeHead(200, {'Content-Length': 5, 'Content-Type': 'text/plain'}) + .end(new Uint8Array(Buffer.from('array', 'utf8'))); +}).listen(7080); diff --git a/test/node/write_buffer/app.js b/test/node/write_buffer/app.js index 506e8613..72e9c600 100644 --- a/test/node/write_buffer/app.js +++ b/test/node/write_buffer/app.js @@ -1,5 +1,5 @@ require('http').createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}) - .end(new Buffer([0x62, 0x75, 0x66, 0x66, 0x65, 0x72])); + .end(Buffer.from('buffer', 'utf8')); }).listen(7080); diff --git a/test/test_node_application.py b/test/test_node_application.py index e4226535..ab8aa8f8 100644 --- a/test/test_node_application.py +++ b/test/test_node_application.py @@ -149,6 +149,10 @@ def test_node_application_write_buffer(): assert client.get()['body'] == 'buffer', 'write buffer' +def test_node_application_write_array(): + client.load('write_array') + + assert client.get()['body'] == 'array', 'write array' def test_node_application_write_callback(temp_dir): client.load('write_callback') -- cgit From 2d0e502d2a69ad490e0633c59636e1115afa983d Mon Sep 17 00:00:00 2001 From: Andrei Zeliankou Date: Tue, 26 Sep 2023 12:49:39 +0100 Subject: Node.js: ServerRequest.destroy() implemented. This closes #871 issue on GitHub. --- src/nodejs/unit-http/http_server.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/nodejs/unit-http/http_server.js b/src/nodejs/unit-http/http_server.js index 11651ed7..0f00b47f 100644 --- a/src/nodejs/unit-http/http_server.js +++ b/src/nodejs/unit-http/http_server.js @@ -33,8 +33,17 @@ ServerResponse.prototype.statusMessage = undefined; ServerResponse.prototype.headers_len = 0; ServerResponse.prototype.headers_count = 0; ServerResponse.prototype.headersSent = false; +ServerResponse.prototype.destroyed = false; ServerResponse.prototype.finished = false; +ServerResponse.prototype.destroy = function destroy(error) { + if (!this.destroyed) { + this.destroyed = true; + } + + return this; +}; + ServerResponse.prototype._finish = function _finish() { this.headers = {}; this.headers_len = 0; -- cgit From b6216f0bb7c4e10afcec00c6660644ff32db0dfb Mon Sep 17 00:00:00 2001 From: Zhidao HONG Date: Thu, 28 Sep 2023 15:14:21 +0100 Subject: Java: fixed the calculation related to the response buffer. We need to take into account the size of the nxt_unit_response_t structure itself when calculating where to start appending data to in memory. Closes: Reported-by: Alejandro Colomar Reviewed-by: Andrew Clayton Signed-off-by: Andrew Clayton --- src/java/nxt_jni_Response.c | 7 ++++--- src/nxt_unit.c | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/java/nxt_jni_Response.c b/src/java/nxt_jni_Response.c index 2ccfd854..fa698ee8 100644 --- a/src/java/nxt_jni_Response.c +++ b/src/java/nxt_jni_Response.c @@ -334,7 +334,8 @@ nxt_java_get_response_info(jlong req_info_ptr, uint32_t extra_fields, - req->response->fields_count || extra_data > (uint32_t) (buf->end - buf->free)) { - p = buf->start + req->response_max_fields * sizeof(nxt_unit_field_t); + p = buf->start + sizeof(nxt_unit_response_t) + + req->response_max_fields * sizeof(nxt_unit_field_t); max_size = 2 * (buf->end - p); if (max_size > nxt_unit_buf_max()) { @@ -936,8 +937,8 @@ nxt_java_Response_reset(JNIEnv *env, jclass cls, jlong req_info_ptr) buf = req->response_buf; - buf->free = buf->start + req->response_max_fields - * sizeof(nxt_unit_field_t); + buf->free = buf->start + sizeof(nxt_unit_response_t) + + req->response_max_fields * sizeof(nxt_unit_field_t); } } diff --git a/src/nxt_unit.c b/src/nxt_unit.c index e1b1897a..b6291b2d 100644 --- a/src/nxt_unit.c +++ b/src/nxt_unit.c @@ -2148,7 +2148,8 @@ nxt_unit_response_realloc(nxt_unit_request_info_t *req, resp->status = req->response->status; resp->content_length = req->response->content_length; - p = buf->start + max_fields_count * sizeof(nxt_unit_field_t); + p = buf->start + sizeof(nxt_unit_response_t) + + max_fields_count * sizeof(nxt_unit_field_t); f = resp->fields; for (i = 0; i < req->response->fields_count; i++) { -- cgit From 7fac9087424e1f7c4b82bfb8426aca197f1f8904 Mon Sep 17 00:00:00 2001 From: Liam Crilly Date: Mon, 2 Oct 2023 09:43:57 +0100 Subject: Added routes array to the default configuration. The default configuration previously contained just a listeners and applications object. Since routes is now a principle configuration object, and a recommended way of configurating Unit, it is now included in the default configuration. This change benefits new users because it explicitly introduces the three principle configuration objects which leads more intuitively to the documentation. Experienced users may choose to ignore or delete routes. routes is defined as an array instead of an object because this change is designed to assist new users, where the simpler form of routes is easier to understand. --- src/nxt_controller.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/nxt_controller.c b/src/nxt_controller.c index 4e2e3749..eb814321 100644 --- a/src/nxt_controller.c +++ b/src/nxt_controller.c @@ -510,8 +510,9 @@ nxt_controller_conf_default(void) nxt_mp_t *mp; nxt_conf_value_t *conf; - static const nxt_str_t json - = nxt_string("{ \"listeners\": {}, \"applications\": {} }"); + static const nxt_str_t json = nxt_string( + "{ \"listeners\": {}, \"routes\": [], \"applications\": {} }" + ); mp = nxt_mp_create(1024, 128, 256, 32); -- cgit From 135160934ab39c9a9ee26f7c0322003c1546d7ad Mon Sep 17 00:00:00 2001 From: Andrei Zeliankou Date: Mon, 2 Oct 2023 15:59:00 +0100 Subject: Tests: added Java test with multiple headers. This test reproduce https://github.com/nginx/unit/issues/923. --- test/test_java_application.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/test_java_application.py b/test/test_java_application.py index a8814583..eefc5c79 100644 --- a/test/test_java_application.py +++ b/test/test_java_application.py @@ -875,6 +875,23 @@ def test_java_application_get_headers(): assert headers['X-Reply-0'] == 'blah', 'get headers' assert headers['X-Reply-1'] == 'blah', 'get headers 2' +def test_java_application_many_headers(): + client.load('get_headers') + + value = '0123456789' * 10 + + headers = client.get( + headers={ + 'X-Header': [value] * 100, + 'Content-Type': 'text/html', + 'Host': 'localhost', + 'Connection': 'close', + } + )['headers'] + + for i in range(0, 99): + assert headers[f'X-Reply-{i}'] == value, 'many headers' + def test_java_application_get_headers_empty(): client.load('get_headers') -- cgit From 9ad207057c620f234f01483bd3a39176945ec202 Mon Sep 17 00:00:00 2001 From: Liam Crilly Date: Tue, 3 Oct 2023 14:57:17 +0100 Subject: Tools: unitc quiet mode fix for macOS. head -c 0 does not work on macOS (invalid byte count) but tail(1) is happy to accept zero bytes, and does not have a performance penalty. --- tools/unitc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/unitc b/tools/unitc index 877e11d4..1db59faa 100755 --- a/tools/unitc +++ b/tools/unitc @@ -186,7 +186,7 @@ fi # Choose presentation style # if [ $QUIET -eq 1 ]; then - OUTPUT="head -c 0" # Equivalent to >/dev/null + OUTPUT="tail -c 0" # Equivalent to >/dev/null elif hash jq 2> /dev/null; then OUTPUT="jq" else -- cgit From 37b0f34fb5d6d6525a9d2ae097837324c2697d50 Mon Sep 17 00:00:00 2001 From: Andrei Zeliankou Date: Wed, 4 Oct 2023 12:53:03 +0100 Subject: Proxy mentioned in OpenAPI. --- docs/unit-openapi.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/unit-openapi.yaml b/docs/unit-openapi.yaml index 0301326d..00b8f27c 100644 --- a/docs/unit-openapi.yaml +++ b/docs/unit-openapi.yaml @@ -5887,6 +5887,7 @@ components: description: "An object whose options define a step's action." oneOf: - $ref: "#/components/schemas/configRouteStepActionPass" + - $ref: "#/components/schemas/configRouteStepActionProxy" - $ref: "#/components/schemas/configRouteStepActionReturn" - $ref: "#/components/schemas/configRouteStepActionShare" @@ -5903,6 +5904,20 @@ components: description: "Destination to which the action passes incoming requests." + #/config/routes/{stepIndex}/action/proxy + #/config/routes/{routeName}/{stepIndex}/action/proxy + configRouteStepActionProxy: + type: object + description: "An object whose single option defines a step's proxy + action." + required: + - proxy + properties: + proxy: + type: string + description: "Socket address of an HTTP server to where the request + is proxied." + #/config/routes/{stepIndex}/action/return #/config/routes/{routeName}/{stepIndex}/action/return configRouteStepActionReturn: -- cgit From 1617f2c04514309a8d19d73103c468af564ef3fd Mon Sep 17 00:00:00 2001 From: Liam Crilly Date: Wed, 4 Oct 2023 17:52:06 +0100 Subject: Docker: fix HTML escaping. --- pkg/docker/welcome.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/docker/welcome.html b/pkg/docker/welcome.html index 9c4f8281..89de39e1 100644 --- a/pkg/docker/welcome.html +++ b/pkg/docker/welcome.html @@ -35,7 +35,7 @@ on the Unix socket at /var/run/control.unit.sock inside the container.
To see the current configuration run:

-
docker exec -ti  curl --unix-socket /var/run/control.unit.sock http://localhost/config
+
docker exec -ti <containerID> curl --unix-socket /var/run/control.unit.sock http://localhost/config

-- cgit From 30142d2a3c862eef0a32805ee3907535ada32c71 Mon Sep 17 00:00:00 2001 From: Andrew Clayton Date: Thu, 5 Oct 2023 00:36:00 +0100 Subject: HTTP: Fix URL with query string rewrite. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On Github, @rlandgrebe reported an issue when trying to rewrite URLs that contained query strings. With the PHP language module we were in fact segfaulting (SIGSEGV) in libphp [93960.462952] unitd[20940]: segfault at 7f307cef6476 ip 00007f2f81a94577 sp 00007fff28a777d0 error 4 in libphp-8.2.so[7f2f818df000+2fd000] likely on CPU 0 (core 0, socket 0) #0 0x00007f2abd494577 in php_default_treat_data (arg=1, str=0x0, destArray=) at /usr/src/debug/php-8.2.10-1.fc38.x86_64/main/php_variables.c:488 488 if (c_var && *c_var) { (gdb) p c_var $1 = 0x7f2bb8880676 This was when trying to get the query string which somehow is pointing off into the woods. This gdb debug session when doing rewrite basically shows the core of the issue (gdb) x /64bs req->fields ... 0x7f7eaaaa8090: "GET" 0x7f7eaaaa8094: "HTTP/1.1" 0x7f7eaaaa809d: "::1" 0x7f7eaaaa80a1: "::1" 0x7f7eaaaa80a5: "8080" 0x7f7eaaaa80aa: "localhost" 0x7f7eaaaa80b4: "/test?q=a" 0x7f7eaaaa80be: "/test" ... (gdb) p target_pos $4 = (void *) 0x7f7eaaaa80b4 (gdb) p query_pos $6 = (void *) 0x7f7eaaaa6af6 (gdb) p r->args->start $8 = (u_char *) 0x7f7ea4002b02 "q=a HTTP/1.1\r\nHost: localhost:8080\r\nUser-Agent: curl/8.0.1\r\nAccept: */*\r\n\r\n" (gdb) p r->target.start $9 = (u_char *) 0x7f7ea40040c0 "/test?q=a" That last address, 0x7f7ea40040c0, looks out of wack, it should be smaller than r->args->start. That results in a calculation in nxt_router_prepare_msg() if (r->args->start != NULL) { query_pos = nxt_pointer_to(target_pos, r->args->start - r->target.start); nxt_unit_sptr_set(&req->query, query_pos); } else { that goes negative that then is stored in req->query.offset which is a uint32_t and so wraps backwards from UINT_MAX to give us an offset of a little under 4GiB, hence the above invalid memory access. All this happens due to in nxt_http_rewrite() if we have a URL with a query string, we create a new memory allocation to store the transformed URL and query string. We set r->target to point to this new allocation, but we also need to point r->args->start to the start of the query string in this new allocation. Reported-by: René Landgrebe Tested-by: René Landgrebe Tested-by: Liam Crilly Fixes: 14d6d97b ("HTTP: added basic URI rewrite.") Closes: Signed-off-by: Andrew Clayton --- src/nxt_http_rewrite.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/nxt_http_rewrite.c b/src/nxt_http_rewrite.c index ae5c865a..fb216eeb 100644 --- a/src/nxt_http_rewrite.c +++ b/src/nxt_http_rewrite.c @@ -93,6 +93,7 @@ nxt_http_rewrite(nxt_task_t *task, nxt_http_request_t *r) nxt_memcpy(p, r->args->start, r->args->length); r->target = target; + r->args->start = p; } r->path = nxt_mp_alloc(r->mem_pool, sizeof(nxt_str_t)); -- cgit From c905d0d393378de2fa44d3e21d2bf317a6c3245c Mon Sep 17 00:00:00 2001 From: "Sergey A. Osokin" Date: Fri, 6 Oct 2023 12:22:03 -0400 Subject: Update third-party components for the Java module. --- auto/modules/java | 6 +++--- auto/modules/java_jar.sha512 | 26 +++++++++++++------------- test/unit/applications/lang/java.py | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/auto/modules/java b/auto/modules/java index 7c39eb37..e8814711 100644 --- a/auto/modules/java +++ b/auto/modules/java @@ -238,7 +238,7 @@ cat << END > $NXT_JAVA_JARS static const char *nxt_java_system_jars[] = { END -NXT_TOMCAT_VERSION=9.0.75 +NXT_TOMCAT_VERSION=9.0.80 NXT_JAR_VERSION=$NXT_TOMCAT_VERSION @@ -284,7 +284,7 @@ static const char *nxt_java_unit_jars[] = { "$NXT_UNIT_JAR", END -NXT_JAR_VERSION=9.4.51.v20230217 +NXT_JAR_VERSION=9.4.52.v20230823 NXT_JAR_NAMESPACE=org/eclipse/jetty/ NXT_JAR_NAME=jetty-util @@ -297,7 +297,7 @@ NXT_JAR_NAME=jetty-http . auto/modules/java_get_jar NXT_JAR_NAME=classgraph -NXT_JAR_VERSION=4.8.158 +NXT_JAR_VERSION=4.8.162 NXT_JAR_NAMESPACE=io/github/classgraph/ . auto/modules/java_get_jar diff --git a/auto/modules/java_jar.sha512 b/auto/modules/java_jar.sha512 index da08f786..77b14902 100644 --- a/auto/modules/java_jar.sha512 +++ b/auto/modules/java_jar.sha512 @@ -1,14 +1,14 @@ -00dc1aedae7cb6600b4b27ac7ec0234981a23a8c6f03dc1881304b7d999d94f0fdaa51e0008288740d9890b34f41462e8ed82c76f36a18bd45eabbb8084ec8d4 classgraph-4.8.158.jar +a117092f4ab77ef89b3b83a45b9e33c0360cb18098df17da77e5d765a6b5cea1fae6190399217236c0d970f2b3603bc8f408c2471cf8854de1282dba7525c335 classgraph-4.8.162.jar ab441acf5551a7dc81c353eaccb3b3df9e89a48987294d19e39acdb83a5b640fcdff7414cee29f5b96eaa8826647f1d5323e185018fe33a64c402d69c73c9158 ecj-3.26.0.jar -606d0446a948c7a349cba5415d079bd054e43a8a09727c8300865f38678c5101642ecafa777d5f979bde1bd520543a4cf83348fcd9a444e6681cf773eb3c5824 jetty-http-9.4.51.v20230217.jar -e9d3f7104214a16435d077eb53d943130b3a85bf9e8a48b9e40a7ad063ca3cca69324e03f21202e66fc5fd864c3cb09cd1857eff8d682c69398b4d75c1a430c6 jetty-server-9.4.51.v20230217.jar -12725e106000d6ef672c474e467d7c976c3913b2d39a92e7304cc30d0e0d1f92575227d2c2201b97ca50f39cba81ac8b79bccb2b32b63d758ac4e192173c3f62 jetty-util-9.4.51.v20230217.jar -b802b595d796285653c3c1b3d870295767afc6d4f857d439d579b7261dc8d015c948cd900e93ebc0ad706d1c74600645d3a18caef4f040a7085ff0e9f6cb4e44 tomcat-api-9.0.75.jar -90cc3c2847782b6854bc0549e7bdfda2e92feac726285718aa4083baef597e472e7f3712257790107fa9306263f645fcc17344a8209415d10a75f4f4cfa30b04 tomcat-el-api-9.0.75.jar -c23a0db30c5d77a518c7cd0afebe6c59600b45e03651409788acb91fa652752960f6e21ac15a233b433dbe290028d00ac72c4cd2856880f4d4ba9ef227692d7a tomcat-jasper-9.0.75.jar -06fb8c0d49945437900be1cc8fd8d8123a7bf6599e7755aa6c7963a65d46aea444661de532ce0e6c0573ecd12def2d5d1e7942ecace9c7c3a39e232373f3fd6b tomcat-jasper-el-9.0.75.jar -7dbaacd7f0490c8f0062eb12cd244acc9c51ee72d1c60ad841ac61905cd46b5d477b01c97019ba6e93a6b27de3e3438c620fb156cec3d6ece36f37918a6ee5bd tomcat-jsp-api-9.0.75.jar -05c15c5c6877b39aed4457e5ea7992819c28dc148a2442a149a8d5ee294a62042eebd2f3846acdd70b08d531d95cdcc8cfcd7b64fb8b046aa5639e7901505131 tomcat-juli-9.0.75.jar -92a44f8970746976a63351d45f84c7963127bd21db0af834a7d38dcfb3c29450398cb4b466636dfb3d8e764093c612eb2938af22ac2098171bac201ad6bcc320 tomcat-servlet-api-9.0.75.jar -6794c0d6d5780ca09fdbaf801c1475f227b799c809a46195c0fd1f9792303fb6d0aa6e49ac049337863bdb512c390334470210294364b7af25d86355f7fd0605 tomcat-util-9.0.75.jar -e97c90c857a5c814518f3da10d8c09c900417421d81ad500ad338ac10c6b7dc8338b486d2338f5cebea6fa33c9803fd2c06cf35c44b1b5b720331943f2e22de3 tomcat-util-scan-9.0.75.jar +ffda81c96d699d43cf3835a923535cbf412441f8df781509d6a4d1714fcffb2654122923da2af0c213826d66d088cf84c7a86f02a085d0e3dd5ba3563f4914c3 jetty-http-9.4.52.v20230823.jar +95ec9eff8d539070e22b14abec31cc7b21bb364cbf4b42e2b59be68987352ccab14505e430e178e605a0017059b566a2c69b30dc8f803530a0e1d9099e7df79a jetty-server-9.4.52.v20230823.jar +3cd7f520e278c3cf80009a433f22a02ed079e63e550f06e3973968d43bd16a99c6d38e98131247b78205f43b15981adbebb86dd97e01c78ebe3de7a65b157c4b jetty-util-9.4.52.v20230823.jar +3990feba477074d837d087c8495138e11411658c26fda6f0776e389edde4b4dda1604be9448de2b15d701360a61911d216ee949e0639329ab7909d636a2376c0 tomcat-api-9.0.80.jar +c4d114db1be4b1d009dd78379479dd0f3d79fdcc166e3c9eee4badefbd3ac465a2b99d0096cad9a2ff97687b2d3cfc1fad38cb3487086e7865e822195f9d3f64 tomcat-el-api-9.0.80.jar +21d67d16624e983b5912bce027c17f4a54aea20165e80462b88031a0ca17159460648de87f75d0c0d0adecabe4c370e8156b5d3972892d9195a21494b858f9c3 tomcat-jasper-9.0.80.jar +e6aece959e512a80e3bd80b2d3fb5f405ce1806b87ceb54878200690bc9dd53ef9a5bf2eb1603f313e8ecdc36fc64501a582329c523479c28434c3490ec84f38 tomcat-jasper-el-9.0.80.jar +630534d59878418b9d998bed275d9915a48a676b31ba4a68942e3e75a76edd624ad63a17abd6ee8ee88d4248fce4d47df46b2d7dd5455080d818c1cfb6b7e7d1 tomcat-jsp-api-9.0.80.jar +41245efa39cf733447ce569c3bf7865f9912a8e91cd8d6d3c844739079b355f3ce3df3ff6bcce12bfb7e7b8a524a83877e786055c17250bfbf93b6396069f8db tomcat-juli-9.0.80.jar +923459bf6041b461c27466146ae7dace71a28fcaff697255b3b2ed2aa375404646bfb78074237a44b3a5bb3447d0a7493c0d4ebbecf445a90d6ffefd56ce842a tomcat-servlet-api-9.0.80.jar +e04470294c0159c4dac3808e86ec25c3e97542316528a82da58bdfd75d1034ef442095a8a99527e04c5af9977b9ec9462c2fc193188a1c11f9083c7f24552261 tomcat-util-9.0.80.jar +333c204b91f4223e1a508dff8f9d7d890fc2728569763037294f77cbc1f3ba24d006e7041b28d267a9616a0503235219451697dc1d65b2986547022a038e2f16 tomcat-util-scan-9.0.80.jar diff --git a/test/unit/applications/lang/java.py b/test/unit/applications/lang/java.py index a253aea5..eb7e0b7e 100644 --- a/test/unit/applications/lang/java.py +++ b/test/unit/applications/lang/java.py @@ -53,7 +53,7 @@ class ApplicationJava(ApplicationProto): os.makedirs(classes_path) classpath = ( - f'{option.current_dir}/build/tomcat-servlet-api-9.0.75.jar' + f'{option.current_dir}/build/tomcat-servlet-api-9.0.80.jar' ) ws_jars = glob.glob( -- cgit From 9c8b9a46a42d47b29453eefc4c5dd325f59e46b4 Mon Sep 17 00:00:00 2001 From: Zhidao HONG Date: Tue, 10 Oct 2023 14:30:02 +0800 Subject: Refactored nxt_vsprintf(). --- src/nxt_sprintf.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/nxt_sprintf.c b/src/nxt_sprintf.c index 9c8e27ed..875f43a5 100644 --- a/src/nxt_sprintf.c +++ b/src/nxt_sprintf.c @@ -156,7 +156,8 @@ nxt_vsprintf(u_char *buf, u_char *end, const char *fmt, va_list args) p = va_arg(args, const u_char *); if (nxt_slow_path(p == NULL)) { - goto copy; + buf = nxt_cpymem(buf, null, nxt_length(null)); + continue; } while (*p != '\0' && buf < end) { @@ -174,6 +175,11 @@ nxt_vsprintf(u_char *buf, u_char *end, const char *fmt, va_list args) fmt++; p = va_arg(args, const u_char *); + if (nxt_slow_path(p == NULL)) { + buf = nxt_cpymem(buf, null, nxt_length(null)); + continue; + } + goto copy; } @@ -556,14 +562,7 @@ nxt_vsprintf(u_char *buf, u_char *end, const char *fmt, va_list args) copy: - if (nxt_slow_path(p == NULL)) { - p = null; - length = nxt_length(null); - - } else { - length = nxt_min((size_t) (end - buf), length); - } - + length = nxt_min((size_t) (end - buf), length); buf = nxt_cpymem(buf, p, length); continue; } -- cgit From 599b035a544ea27e9fe76cb79f7d672ef114c2d2 Mon Sep 17 00:00:00 2001 From: Liam Crilly Date: Tue, 10 Oct 2023 15:06:36 +0100 Subject: Tools: unitc YAML mode. Added --format option to manage configuration in other formats. Initially, YAML is the only supported conversion format. JSON/YAML conversion is performed with yq(1). Suggested by: Torstein Krause Johansen Closes: #958 --- tools/README.md | 4 ++++ tools/unitc | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 55 insertions(+), 7 deletions(-) diff --git a/tools/README.md b/tools/README.md index 1a631e10..0bb80985 100644 --- a/tools/README.md +++ b/tools/README.md @@ -37,12 +37,16 @@ web page with NGINX Unit. | _HTTP method_ | It is usually not required to specify a HTTP method. `GET` is used to read the configuration. `PUT` is used when making configuration changes unless a specific method is provided. | `edit` | Opens **URI** in the default editor for interactive configuration. The [jq](https://stedolan.github.io/jq/) tool is required for this option. | `INSERT` | A _virtual_ HTTP method that prepends data when the URI specifies an existing array. The [jq](https://stedolan.github.io/jq/) tool is required for this option. +| `-f` \| `--format YAML` | Convert configuration data to/from YAML format. The [yq](https://github.com/mikefarah/yq) tool is required for this option. | `-q` \| `--quiet` | No output to stdout. Options are case insensitive and can appear in any order. For example, a redundant part of the configuration can be identified by its URI, and followed by `delete` in a subsequent command. +Options may be combined. For example, `edit -f yaml` will open the +configuration URI in a text editor, in YAML format. + ### Local Configuration For local instances of Unit, the control socket is automatically detected. The error log is monitored; when changes occur, new log entries are shown. diff --git a/tools/unitc b/tools/unitc index 1db59faa..e0e725ec 100755 --- a/tools/unitc +++ b/tools/unitc @@ -10,6 +10,7 @@ REMOTE=0 SHOW_LOG=1 NOLOG=0 QUIET=0 +CONVERT=0 URI="" SSH_CMD="" METHOD=PUT @@ -18,6 +19,30 @@ CONF_FILES=() while [ $# -gt 0 ]; do OPTION=$(echo $1 | tr '[a-z]' '[A-Z]') case $OPTION in + "-F" | "--FORMAT") + case $(echo $2 | tr '[a-z]' '[A-Z]') in + "YAML") + CONVERT=1 + if hash yq 2> /dev/null; then + CONVERT_TO_JSON="yq eval -P --output-format=json" + CONVERT_FROM_JSON="yq eval -P --output-format=yaml" + else + echo "${0##*/}: ERROR: yq(1) is required to use YAML format; install at " + exit 1 + fi + ;; + "") + echo "${0##*/}: ERROR: Must specify configuration format" + exit 1 + ;; + *) + echo "${0##*/}: ERROR: Invalid format ($2)" + exit 1 + ;; + esac + shift; shift + ;; + "-H" | "--HELP") shift ;; @@ -45,15 +70,22 @@ while [ $# -gt 0 ]; do *) if [ -f $1 ] && [ -r $1 ]; then CONF_FILES+=($1) + if [ "${1##*.}" = "yaml" ]; then + echo "${0##*/}: INFO: converting $1 to JSON" + shift; set -- "--format" "yaml" "$@" # Apply the command line option + else + shift + fi elif [ "${1:0:1}" = "/" ] || [ "${1:0:4}" = "http" ] && [ "$URI" = "" ]; then URI=$1 + shift elif [ "${1:0:6}" = "ssh://" ]; then UNIT_CTRL=$1 + shift else echo "${0##*/}: ERROR: Invalid option ($1)" exit 1 fi - shift ;; esac done @@ -67,16 +99,18 @@ USAGE: ${0##*/} [options] URI • URI is for Unit's control API target, e.g. /config • A local Unit control socket is detected unless a remote one is specified. • Configuration data is read from stdin. +• All options are case-insensitive (excluding filenames and URIs). General options - filename … # Read configuration data from files instead of stdin - HTTP method # Default=GET, or PUT with config data (case-insensitive) - EDIT # Opens the URI contents in \$EDITOR - INSERT # Virtual HTTP method to prepend data to an existing array - -q | --quiet # No output to stdout + filename … # Read configuration data from files instead of stdin + HTTP method # Default=GET, or PUT when config data is present + EDIT # Opens the URI contents in \$EDITOR + INSERT # Virtual HTTP method; prepend data to an array + -f | --format YAML # Convert configuration data to/from YAML format + -q | --quiet # No output to stdout Local options - -l | --nolog # Do not monitor the error log after applying config changes + -l | --nolog # Do not monitor the Unit log file after config changes Remote options ssh://[user@]remote_host[:port]/path/to/control.socket # Remote Unix socket @@ -187,6 +221,8 @@ fi # if [ $QUIET -eq 1 ]; then OUTPUT="tail -c 0" # Equivalent to >/dev/null +elif [ $CONVERT -eq 1 ]; then + OUTPUT=$CONVERT_FROM_JSON elif hash jq 2> /dev/null; then OUTPUT="jq" else @@ -224,6 +260,10 @@ if [ -t 0 ] && [ ${#CONF_FILES[@]} -eq 0 ]; then $SSH_CMD curl -fsSX DELETE $UNIT_CTRL$URI 2> /tmp/${0##*/}.$$ && \ printf "%s" "$(< $EDIT_FILENAME.js)" | $SSH_CMD curl -fX PUT --data-binary @- $UNIT_CTRL$URI 2> /tmp/${0##*/}.$$ && \ $SSH_CMD curl -X PUT --data-binary @/tmp/${0##*/}.$$_js_module $UNIT_CTRL/config/settings/js_module 2> /tmp/${0##*/}.$$ + elif [ $CONVERT -eq 1 ]; then + $CONVERT_FROM_JSON < $EDIT_FILENAME > $EDIT_FILENAME.yaml + $EDITOR $EDIT_FILENAME.yaml || exit 2 + $CONVERT_TO_JSON < $EDIT_FILENAME.yaml | $SSH_CMD curl -X PUT --data-binary @- $UNIT_CTRL$URI 2> /tmp/${0##*/}.$$ | $OUTPUT else tr -d '\r' < $EDIT_FILENAME > $EDIT_FILENAME.json # Remove carriage-return from newlines $EDITOR $EDIT_FILENAME.json || exit 2 @@ -249,6 +289,10 @@ else exit 3 fi else + if [ $CONVERT -eq 1 ]; then + cat ${CONF_FILES[@]} | $CONVERT_TO_JSON > /tmp/${0##*/}.$$_json + CONF_FILES=(/tmp/${0##*/}.$$_json) + fi cat ${CONF_FILES[@]} | $SSH_CMD curl -X $METHOD --data-binary @- $UNIT_CTRL$URI 2> /tmp/${0##*/}.$$ | $OUTPUT fi fi -- cgit From d1a9069852b78e43aa4e0265cf193743019f41be Mon Sep 17 00:00:00 2001 From: "Sergey A. Osokin" Date: Tue, 10 Oct 2023 11:55:44 -0400 Subject: Update third-party components for the Java module. --- auto/modules/java | 4 ++-- auto/modules/java_jar.sha512 | 24 ++++++++++++------------ test/unit/applications/lang/java.py | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/auto/modules/java b/auto/modules/java index e8814711..b1bc43ea 100644 --- a/auto/modules/java +++ b/auto/modules/java @@ -238,7 +238,7 @@ cat << END > $NXT_JAVA_JARS static const char *nxt_java_system_jars[] = { END -NXT_TOMCAT_VERSION=9.0.80 +NXT_TOMCAT_VERSION=9.0.81 NXT_JAR_VERSION=$NXT_TOMCAT_VERSION @@ -284,7 +284,7 @@ static const char *nxt_java_unit_jars[] = { "$NXT_UNIT_JAR", END -NXT_JAR_VERSION=9.4.52.v20230823 +NXT_JAR_VERSION=9.4.53.v20231009 NXT_JAR_NAMESPACE=org/eclipse/jetty/ NXT_JAR_NAME=jetty-util diff --git a/auto/modules/java_jar.sha512 b/auto/modules/java_jar.sha512 index 77b14902..cceb6bc0 100644 --- a/auto/modules/java_jar.sha512 +++ b/auto/modules/java_jar.sha512 @@ -1,14 +1,14 @@ a117092f4ab77ef89b3b83a45b9e33c0360cb18098df17da77e5d765a6b5cea1fae6190399217236c0d970f2b3603bc8f408c2471cf8854de1282dba7525c335 classgraph-4.8.162.jar ab441acf5551a7dc81c353eaccb3b3df9e89a48987294d19e39acdb83a5b640fcdff7414cee29f5b96eaa8826647f1d5323e185018fe33a64c402d69c73c9158 ecj-3.26.0.jar -ffda81c96d699d43cf3835a923535cbf412441f8df781509d6a4d1714fcffb2654122923da2af0c213826d66d088cf84c7a86f02a085d0e3dd5ba3563f4914c3 jetty-http-9.4.52.v20230823.jar -95ec9eff8d539070e22b14abec31cc7b21bb364cbf4b42e2b59be68987352ccab14505e430e178e605a0017059b566a2c69b30dc8f803530a0e1d9099e7df79a jetty-server-9.4.52.v20230823.jar -3cd7f520e278c3cf80009a433f22a02ed079e63e550f06e3973968d43bd16a99c6d38e98131247b78205f43b15981adbebb86dd97e01c78ebe3de7a65b157c4b jetty-util-9.4.52.v20230823.jar -3990feba477074d837d087c8495138e11411658c26fda6f0776e389edde4b4dda1604be9448de2b15d701360a61911d216ee949e0639329ab7909d636a2376c0 tomcat-api-9.0.80.jar -c4d114db1be4b1d009dd78379479dd0f3d79fdcc166e3c9eee4badefbd3ac465a2b99d0096cad9a2ff97687b2d3cfc1fad38cb3487086e7865e822195f9d3f64 tomcat-el-api-9.0.80.jar -21d67d16624e983b5912bce027c17f4a54aea20165e80462b88031a0ca17159460648de87f75d0c0d0adecabe4c370e8156b5d3972892d9195a21494b858f9c3 tomcat-jasper-9.0.80.jar -e6aece959e512a80e3bd80b2d3fb5f405ce1806b87ceb54878200690bc9dd53ef9a5bf2eb1603f313e8ecdc36fc64501a582329c523479c28434c3490ec84f38 tomcat-jasper-el-9.0.80.jar -630534d59878418b9d998bed275d9915a48a676b31ba4a68942e3e75a76edd624ad63a17abd6ee8ee88d4248fce4d47df46b2d7dd5455080d818c1cfb6b7e7d1 tomcat-jsp-api-9.0.80.jar -41245efa39cf733447ce569c3bf7865f9912a8e91cd8d6d3c844739079b355f3ce3df3ff6bcce12bfb7e7b8a524a83877e786055c17250bfbf93b6396069f8db tomcat-juli-9.0.80.jar -923459bf6041b461c27466146ae7dace71a28fcaff697255b3b2ed2aa375404646bfb78074237a44b3a5bb3447d0a7493c0d4ebbecf445a90d6ffefd56ce842a tomcat-servlet-api-9.0.80.jar -e04470294c0159c4dac3808e86ec25c3e97542316528a82da58bdfd75d1034ef442095a8a99527e04c5af9977b9ec9462c2fc193188a1c11f9083c7f24552261 tomcat-util-9.0.80.jar -333c204b91f4223e1a508dff8f9d7d890fc2728569763037294f77cbc1f3ba24d006e7041b28d267a9616a0503235219451697dc1d65b2986547022a038e2f16 tomcat-util-scan-9.0.80.jar +867afb0e69ab225a3d57c0eda4e773ca2f41dcc6eb294e14aef4d69441314bee88221081f9edc6289b9e4a99184804b60c32f4443c8ff96eb34d6508b348b755 jetty-http-9.4.53.v20231009.jar +aca14debabc0cc40e154d4de4de404c383c4611e9f2482911e17d9072f0941cef8a88511d5d49d70946e65872e1bc8d395b9401b2ec91132553d782d99140ce3 jetty-server-9.4.53.v20231009.jar +429b269e21c6e7bf86ba8a8b71569e3abf61b06ace9dd064a9c80af4282227e910a8d20be86ef6581895ff283a5aa4711bbb238de45dc7628f494624879c4d49 jetty-util-9.4.53.v20231009.jar +3479e544b3e68d0a7c8d88ba583b545c67dfeaece59df3529845fec889a8c239396a0887b9ed623579d9cdb6fb64774e0de9b73980eb2de3f6e4464032c29f30 tomcat-api-9.0.81.jar +4dee91fe73ddac9ef0a0796e75cfc37fc4ee7434bad3049a87c6c50dde66e45262d7c5453520dd6bb3d7881a80ef6f88e613f032b97ac996d575efa78cdfe08a tomcat-el-api-9.0.81.jar +3754aa87fdce984d9cd092e8681ec8eed89622aa202b5bcfe1f0b309a899e7f4e32877622f00a8ad41cb5579425861ed62671a2c98ed9c943613e5f2332af1ad tomcat-jasper-9.0.81.jar +654770a128633c6ca4eb1bec05501a0533f4d1727f1dc6782e4f93b8b4271b57723502e05c24fe4fde9195c9a95459ef404b764666e71ee06c39e430e5f7a3ca tomcat-jasper-el-9.0.81.jar +70978984ca6298ea28d11505a6006c9eea696c67a307817322b71f12d817e63c75f54b1ea0370decab3558a407189036fe246f8c4f6d995ad214a000966d99c0 tomcat-jsp-api-9.0.81.jar +d22f5c849ccf960e6b1a6f4266e0fd520220b88c8a7244abc4caa2e91f641db03bcc6c31c2ee496a2feeb3661f1346c17e6224128fbbf1fd60d0ad1334be7fe5 tomcat-juli-9.0.81.jar +2c6b39ee300c48f9c378ea9933190beb278b4bd975d77b1302bef12efc709d861087b002408befd71472867a2463cbbfeaf21cf3b0bdd36a5896020a0b275479 tomcat-servlet-api-9.0.81.jar +9892f391d0c80ae5f692e8bfcc41bacedc23f4aa75e0517f44aa358000dcb9f47a9b4328cdaf76300fa2f281ad7e81b5aa130f73847c3ba31029410663294b6e tomcat-util-9.0.81.jar +97a96c69a8516c9a02aff0d73958f29fa84e4aaeec4b0f2c4b4403c18c0cb4068e809a907d1d9686632dc04469901f681e79b5ed8c56c44135f215071d055baf tomcat-util-scan-9.0.81.jar diff --git a/test/unit/applications/lang/java.py b/test/unit/applications/lang/java.py index eb7e0b7e..4b55a922 100644 --- a/test/unit/applications/lang/java.py +++ b/test/unit/applications/lang/java.py @@ -53,7 +53,7 @@ class ApplicationJava(ApplicationProto): os.makedirs(classes_path) classpath = ( - f'{option.current_dir}/build/tomcat-servlet-api-9.0.80.jar' + f'{option.current_dir}/build/tomcat-servlet-api-9.0.81.jar' ) ws_jars = glob.glob( -- cgit From 01d185cb52af8879aeeab04765eff439feec664c Mon Sep 17 00:00:00 2001 From: Andrew Clayton Date: Wed, 27 Sep 2023 21:25:09 +0100 Subject: Wasm: Re-add a removed 'const' qualifier in nxt_rt_wasmtime.c. This was inadvertently removed in 76086d6d ("Wasm: Allow to set the HTTP response status.") Fixes: 76086d6d ("Wasm: Allow to set the HTTP response status.") Signed-off-by: Andrew Clayton --- src/wasm/nxt_rt_wasmtime.c | 2 +- src/wasm/nxt_wasm.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wasm/nxt_rt_wasmtime.c b/src/wasm/nxt_rt_wasmtime.c index 7f05fae0..bf0b0a0f 100644 --- a/src/wasm/nxt_rt_wasmtime.c +++ b/src/wasm/nxt_rt_wasmtime.c @@ -137,7 +137,7 @@ nxt_wasmtime_execute_hook(const nxt_wasm_ctx_t *ctx, nxt_wasm_fh_t hook) static int -nxt_wasmtime_execute_request(nxt_wasm_ctx_t *ctx) +nxt_wasmtime_execute_request(const nxt_wasm_ctx_t *ctx) { int i = 0; wasm_trap_t *trap = NULL; diff --git a/src/wasm/nxt_wasm.h b/src/wasm/nxt_wasm.h index f78aef13..6bc3ae35 100644 --- a/src/wasm/nxt_wasm.h +++ b/src/wasm/nxt_wasm.h @@ -127,7 +127,7 @@ struct nxt_wasm_ctx_s { struct nxt_wasm_operations_s { int (*init)(nxt_wasm_ctx_t *ctx); void (*destroy)(const nxt_wasm_ctx_t *ctx); - int (*exec_request)(nxt_wasm_ctx_t *ctx); + int (*exec_request)(const nxt_wasm_ctx_t *ctx); void (*exec_hook)(const nxt_wasm_ctx_t *ctx, nxt_wasm_fh_t hook); }; -- cgit From c433a3c9145cd9e16ca61caa5bd7df159020b972 Mon Sep 17 00:00:00 2001 From: Andrei Zeliankou Date: Wed, 11 Oct 2023 15:21:09 +0100 Subject: Rewrite and response headers mentioned in OpenAPI. --- docs/unit-openapi.yaml | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/docs/unit-openapi.yaml b/docs/unit-openapi.yaml index 00b8f27c..784ed640 100644 --- a/docs/unit-openapi.yaml +++ b/docs/unit-openapi.yaml @@ -1,6 +1,6 @@ openapi: 3.0.0 info: - title: "NGINX Unit 1.30.0" + title: "NGINX Unit 1.31.0" description: "NGINX Unit is a lightweight and versatile application runtime that provides the essential components for your web application as a single open-source server: running application code, serving static assets, @@ -5904,6 +5904,12 @@ components: description: "Destination to which the action passes incoming requests." + rewrite: + $ref: "#/components/schemas/configRouteStepActionRewrite" + + response_headers: + $ref: "#/components/schemas/configRouteStepActionResponseHeaders" + #/config/routes/{stepIndex}/action/proxy #/config/routes/{routeName}/{stepIndex}/action/proxy configRouteStepActionProxy: @@ -5918,6 +5924,12 @@ components: description: "Socket address of an HTTP server to where the request is proxied." + rewrite: + $ref: "#/components/schemas/configRouteStepActionRewrite" + + response_headers: + $ref: "#/components/schemas/configRouteStepActionResponseHeaders" + #/config/routes/{stepIndex}/action/return #/config/routes/{routeName}/{stepIndex}/action/return configRouteStepActionReturn: @@ -5937,6 +5949,12 @@ components: type: string description: "URI; used if the return value implies redirection." + rewrite: + $ref: "#/components/schemas/configRouteStepActionRewrite" + + response_headers: + $ref: "#/components/schemas/configRouteStepActionResponseHeaders" + #/config/routes/{stepIndex}/action/share #/config/routes/{routeName}/{stepIndex}/action/share configRouteStepActionShare: @@ -5979,6 +5997,28 @@ components: description: "Turns on and off mount point resolution." default: true + rewrite: + $ref: "#/components/schemas/configRouteStepActionRewrite" + + response_headers: + $ref: "#/components/schemas/configRouteStepActionResponseHeaders" + + #/config/routes/{stepIndex}/action/rewrite + #/config/routes/{routeName}/{stepIndex}/action/rewrite + configRouteStepActionRewrite: + type: string + description: "Updates the URI of the incoming request before the action + is applied." + + #/config/routes/{stepIndex}/action/response_headers + #/config/routes/{routeName}/{stepIndex}/action/response_headers + configRouteStepActionResponseHeaders: + type: object + description: "Updates the header fields of Unit’s response before the + action is taken." + additionalProperties: + type: string + # /config/listeners/ configListeners: type: object -- cgit From e78ada01402a1d2e658d752cbdcc8f2602ef8826 Mon Sep 17 00:00:00 2001 From: Andrei Zeliankou Date: Wed, 11 Oct 2023 16:42:55 +0100 Subject: Tests: added PHP test with rewrite and query string. This test reproduces https://github.com/nginx/unit/issues/964. --- test/test_php_application.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/test/test_php_application.py b/test/test_php_application.py index 6c1f227b..17440909 100644 --- a/test/test_php_application.py +++ b/test/test_php_application.py @@ -171,6 +171,36 @@ def test_php_application_query_string_empty(): assert resp['headers']['Query-String'] == '', 'query string empty' +def test_php_application_query_string_rewrite(): + assert 'success' in client.conf( + { + "listeners": {"*:7080": {"pass": "routes"}}, + "routes": [ + { + "action": { + "rewrite": "/new", + "pass": "applications/query_string", + }, + }, + ], + "applications": { + "query_string": { + "type": client.get_application_type(), + "processes": {"spare": 0}, + "root": f"{option.test_dir}/php/query_string", + "script": "index.php", + } + }, + }, + ) + + assert client.get(url='/old')['status'] == 200 + + resp = client.get(url='/old?arg=val') + assert resp['status'] == 200 + assert resp['headers']['Query-String'] == 'arg=val' + + def test_php_application_fastcgi_finish_request(findall, unit_pid): client.load('fastcgi_finish_request') -- cgit From 43f140dfd318378f330ff019bb2a37c94d8f885c Mon Sep 17 00:00:00 2001 From: Liam Crilly Date: Mon, 16 Oct 2023 10:32:19 +0100 Subject: Tools: unitc Docker mode. Introduces a new remote host scheme docker:// that specifies a local container ID. By default, the control socket is assumed to be in the default location, as per the Docker Official Images for Unit. If not, the path to the control socket can be appended to the container ID. --- tools/README.md | 18 ++++++++++++++---- tools/unitc | 46 +++++++++++++++++++++++++++++----------------- 2 files changed, 43 insertions(+), 21 deletions(-) diff --git a/tools/README.md b/tools/README.md index 0bb80985..883bc107 100644 --- a/tools/README.md +++ b/tools/README.md @@ -55,10 +55,9 @@ The error log is monitored; when changes occur, new log entries are shown. |---------|-| | `-l` \| `--nolog` | Do not monitor the error log after configuration changes. -#### Examples +#### Local Examples ```shell unitc /config -unitc /control/applications/my_app/restart unitc /config < unitconf.json echo '{"*:8080": {"pass": "routes"}}' | unitc /config/listeners unitc /config/applications/my_app DELETE @@ -68,10 +67,12 @@ unitc /certificates/bundle cert.pem key.pem ### Remote Configuration For remote instances of NGINX Unit, the control socket on the remote host can be set with the `$UNIT_CTRL` environment variable. The remote control socket -can be accessed over TCP or SSH, depending on the type of control socket: +can be accessed over TCP, SSH, or Docker containers on the host, depending on +the type of control socket: * `ssh://[user@]remote_host[:ssh_port]/path/to/control.socket` * `http://remote_host:unit_control_port` + * `docker://container_ID[/path/to/control.socket]` > **Note:** SSH is recommended for remote confguration. Consider the > [security implications](https://unit.nginx.org/howto/security/#secure-socket-and-state) @@ -81,8 +82,9 @@ can be accessed over TCP or SSH, depending on the type of control socket: |---------|-| | `ssh://…` | Specify the remote Unix control socket on the command line. | `http://…`*URI* | For remote TCP control sockets, the URI may include the protocol, hostname, and port. +| `docker://…` | Specify the local container ID/name. The default Unix control socket can be overridden. -#### Examples +#### Remote Examples ```shell unitc http://192.168.0.1:8080/status UNIT_CTRL=http://192.168.0.1:8080 unitc /status @@ -93,4 +95,12 @@ cat catchall_route.json | unitc POST /config/routes echo '{"match":{"uri":"/wp-admin/*"},"action":{"return":403}}' | unitc INSERT /config/routes ``` +#### Docker Examples +```shell +unitc docker://d43251184c54 /config +echo '{"http": {"log_route": true}}' | unitc docker://d43251184c54 /settings +unitc docker://f4f3d9e918e6/root/unit.sock /control/applications/my_app/restart +UNIT_CTRL=docker://4d0431488982 unitc /status/requests/total +``` + --- diff --git a/tools/unitc b/tools/unitc index e0e725ec..e671f384 100755 --- a/tools/unitc +++ b/tools/unitc @@ -12,7 +12,7 @@ NOLOG=0 QUIET=0 CONVERT=0 URI="" -SSH_CMD="" +RPC_CMD="" METHOD=PUT CONF_FILES=() @@ -82,6 +82,9 @@ while [ $# -gt 0 ]; do elif [ "${1:0:6}" = "ssh://" ]; then UNIT_CTRL=$1 shift + elif [ "${1:0:9}" = "docker://" ]; then + UNIT_CTRL=$1 + shift else echo "${0##*/}: ERROR: Invalid option ($1)" exit 1 @@ -115,9 +118,10 @@ Local options Remote options ssh://[user@]remote_host[:port]/path/to/control.socket # Remote Unix socket http://remote_host:port/URI # Remote TCP socket + docker://container_ID[/non-default/control.socket] # Container on host - A remote Unit control socket may also be defined with the \$UNIT_CTRL - environment variable as http://remote_host:port -OR- ssh://… (as above) + A remote Unit instance may also be defined with the \$UNIT_CTRL environment + variable as http://remote_host:port or ssh://… or docker://… (as above). __EOF__ exit 1 @@ -133,8 +137,16 @@ if [ "$UNIT_CTRL" = "" ]; then fi elif [ "${UNIT_CTRL:0:6}" = "ssh://" ]; then REMOTE=1 - SSH_CMD="ssh $(echo $UNIT_CTRL | cut -f1-3 -d/)" + RPC_CMD="ssh $(echo $UNIT_CTRL | cut -f1-3 -d/)" UNIT_CTRL="--unix-socket /$(echo $UNIT_CTRL | cut -f4- -d/) _" +elif [ "${UNIT_CTRL:0:9}" = "docker://" ]; then + RPC_CMD="docker exec -i $(echo $UNIT_CTRL | cut -f3 -d/)" + DOCKSOCK=/$(echo "$UNIT_CTRL" | cut -f4- -d/) + if [ "$DOCKSOCK" = "/" ]; then + DOCKSOCK="/var/run/control.unit.sock" # Use default location if no path + fi + UNIT_CTRL="--unix-socket $DOCKSOCK _" + REMOTE=1 elif [ "${URI:0:1}" = "/" ]; then REMOTE=1 fi @@ -241,11 +253,11 @@ fi # if [ -t 0 ] && [ ${#CONF_FILES[@]} -eq 0 ]; then if [ "$METHOD" = "DELETE" ]; then - $SSH_CMD curl -X $METHOD $UNIT_CTRL$URI 2> /tmp/${0##*/}.$$ | $OUTPUT + $RPC_CMD curl -X $METHOD $UNIT_CTRL$URI 2> /tmp/${0##*/}.$$ | $OUTPUT elif [ "$METHOD" = "EDIT" ]; then EDITOR=$(test "$EDITOR" && printf '%s' "$EDITOR" || command -v editor || command -v vim || echo vi) EDIT_FILENAME=/tmp/${0##*/}.$$${URI//\//_} - $SSH_CMD curl -fsS $UNIT_CTRL$URI > $EDIT_FILENAME || exit 2 + $RPC_CMD curl -fsS $UNIT_CTRL$URI > $EDIT_FILENAME || exit 2 if [ "${URI:0:12}" = "/js_modules/" ]; then if ! hash jq 2> /dev/null; then echo "${0##*/}: ERROR: jq(1) is required to edit JavaScript modules; install at " @@ -255,23 +267,23 @@ if [ -t 0 ] && [ ${#CONF_FILES[@]} -eq 0 ]; then EDIT_FILE=$EDIT_FILENAME.js $EDITOR $EDIT_FILENAME.js || exit 2 # Remove the references, delete old config, push new config+reference - $SSH_CMD curl -fsS $UNIT_CTRL/config/settings/js_module > /tmp/${0##*/}.$$_js_module && \ - $SSH_CMD curl -X DELETE $UNIT_CTRL/config/settings/js_module && \ - $SSH_CMD curl -fsSX DELETE $UNIT_CTRL$URI 2> /tmp/${0##*/}.$$ && \ - printf "%s" "$(< $EDIT_FILENAME.js)" | $SSH_CMD curl -fX PUT --data-binary @- $UNIT_CTRL$URI 2> /tmp/${0##*/}.$$ && \ - $SSH_CMD curl -X PUT --data-binary @/tmp/${0##*/}.$$_js_module $UNIT_CTRL/config/settings/js_module 2> /tmp/${0##*/}.$$ + $RPC_CMD curl -fsS $UNIT_CTRL/config/settings/js_module > /tmp/${0##*/}.$$_js_module && \ + $RPC_CMD curl -X DELETE $UNIT_CTRL/config/settings/js_module && \ + $RPC_CMD curl -fsSX DELETE $UNIT_CTRL$URI 2> /tmp/${0##*/}.$$ && \ + printf "%s" "$(< $EDIT_FILENAME.js)" | $RPC_CMD curl -fX PUT --data-binary @- $UNIT_CTRL$URI 2> /tmp/${0##*/}.$$ && \ + $RPC_CMD curl -X PUT --data-binary @/tmp/${0##*/}.$$_js_module $UNIT_CTRL/config/settings/js_module 2> /tmp/${0##*/}.$$ elif [ $CONVERT -eq 1 ]; then $CONVERT_FROM_JSON < $EDIT_FILENAME > $EDIT_FILENAME.yaml $EDITOR $EDIT_FILENAME.yaml || exit 2 - $CONVERT_TO_JSON < $EDIT_FILENAME.yaml | $SSH_CMD curl -X PUT --data-binary @- $UNIT_CTRL$URI 2> /tmp/${0##*/}.$$ | $OUTPUT + $CONVERT_TO_JSON < $EDIT_FILENAME.yaml | $RPC_CMD curl -X PUT --data-binary @- $UNIT_CTRL$URI 2> /tmp/${0##*/}.$$ | $OUTPUT else tr -d '\r' < $EDIT_FILENAME > $EDIT_FILENAME.json # Remove carriage-return from newlines $EDITOR $EDIT_FILENAME.json || exit 2 - $SSH_CMD curl -X PUT --data-binary @$EDIT_FILENAME.json $UNIT_CTRL$URI 2> /tmp/${0##*/}.$$ | $OUTPUT + $RPC_CMD curl -X PUT --data-binary @$EDIT_FILENAME.json $UNIT_CTRL$URI 2> /tmp/${0##*/}.$$ | $OUTPUT fi else SHOW_LOG=$(echo $URI | grep -c ^/control/) - $SSH_CMD curl $UNIT_CTRL$URI 2> /tmp/${0##*/}.$$ | $OUTPUT + $RPC_CMD curl $UNIT_CTRL$URI 2> /tmp/${0##*/}.$$ | $OUTPUT fi else if [ "$METHOD" = "INSERT" ]; then @@ -281,9 +293,9 @@ else fi NEW_ELEMENT=$(cat ${CONF_FILES[@]}) echo $NEW_ELEMENT | jq > /dev/null || exit $? # Test the input is valid JSON before proceeding - OLD_ARRAY=$($SSH_CMD curl -s $UNIT_CTRL$URI) + OLD_ARRAY=$($RPC_CMD curl -s $UNIT_CTRL$URI) if [ "$(echo $OLD_ARRAY | jq -r type)" = "array" ]; then - echo $OLD_ARRAY | jq ". |= [$NEW_ELEMENT] + ." | $SSH_CMD curl -X PUT --data-binary @- $UNIT_CTRL$URI 2> /tmp/${0##*/}.$$ | $OUTPUT + echo $OLD_ARRAY | jq ". |= [$NEW_ELEMENT] + ." | $RPC_CMD curl -X PUT --data-binary @- $UNIT_CTRL$URI 2> /tmp/${0##*/}.$$ | $OUTPUT else echo "${0##*/}: ERROR: the INSERT method expects an array" exit 3 @@ -293,7 +305,7 @@ else cat ${CONF_FILES[@]} | $CONVERT_TO_JSON > /tmp/${0##*/}.$$_json CONF_FILES=(/tmp/${0##*/}.$$_json) fi - cat ${CONF_FILES[@]} | $SSH_CMD curl -X $METHOD --data-binary @- $UNIT_CTRL$URI 2> /tmp/${0##*/}.$$ | $OUTPUT + cat ${CONF_FILES[@]} | $RPC_CMD curl -X $METHOD --data-binary @- $UNIT_CTRL$URI 2> /tmp/${0##*/}.$$ | $OUTPUT fi fi -- cgit From f1ce2a5ac2ba3266d525544445366fae538d7194 Mon Sep 17 00:00:00 2001 From: Konstantin Pavlov Date: Tue, 26 Sep 2023 16:14:21 -0700 Subject: Node.js: provide reasonable default paths for macOS. --- src/nodejs/unit-http/binding_pub.gyp | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/nodejs/unit-http/binding_pub.gyp b/src/nodejs/unit-http/binding_pub.gyp index 3c39933a..3dadf4a5 100644 --- a/src/nodejs/unit-http/binding_pub.gyp +++ b/src/nodejs/unit-http/binding_pub.gyp @@ -7,9 +7,28 @@ ['OS=="mac"', { 'xcode_settings': { 'GCC_ENABLE_CPP_EXCEPTIONS': 'YES' - } - }] - ], + }, + 'conditions': [ + [ 'target_arch=="arm64"', { + 'include_dirs': [ + '/opt/homebrew/include' + ], + 'libraries' : [ + '-L/opt/homebrew/lib', + '-lunit' + ], + }], + ['target_arch=="x64"', { + 'include_dirs': [ + '/usr/local/include', + ], + 'libraries' : [ + '-L/usr/local/lib', + '-lunit' + ], + }] + ]} + ]], 'sources': ["unit.cpp", "addon.cpp"], 'libraries': ["-lunit"] }] -- cgit From b99e26567fb36ba65321aed51dfa4d9764b88ed2 Mon Sep 17 00:00:00 2001 From: Konstantin Pavlov Date: Fri, 13 Oct 2023 12:12:23 -0700 Subject: contrib: updated njs to 0.8.1. --- pkg/contrib/src/njs/SHA512SUMS | 2 +- pkg/contrib/src/njs/version | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/contrib/src/njs/SHA512SUMS b/pkg/contrib/src/njs/SHA512SUMS index ad8e180c..3c3ce210 100644 --- a/pkg/contrib/src/njs/SHA512SUMS +++ b/pkg/contrib/src/njs/SHA512SUMS @@ -1 +1 @@ -200f3ae1e1909f0d8086e2fbfbd6b8654e596f3ad2e4cf4d863e201cfcb2f86a419fa9061067cbededf6a8c792c1a5ecf60c3a4c983af044c179bb9fe619eea5 njs-0.8.0.tar.gz +5038b4cd9e18de89c9cf7fe7b25a0a8a03c51cfb20b6ee5085e68f885113b104092baf5ac8fe80e9d1611b2f75e47448753e6b327bef2e706ea46f2d6299f927 njs-0.8.1.tar.gz diff --git a/pkg/contrib/src/njs/version b/pkg/contrib/src/njs/version index 8c9ee6ba..73c524fb 100644 --- a/pkg/contrib/src/njs/version +++ b/pkg/contrib/src/njs/version @@ -1 +1 @@ -NJS_VERSION := 0.8.0 +NJS_VERSION := 0.8.1 -- cgit From 5265b7e0580edee488c07e0cc2953d88ae2aed1b Mon Sep 17 00:00:00 2001 From: "Sergey A. Osokin" Date: Tue, 17 Oct 2023 13:43:51 -0400 Subject: Update third-party components for the Java module. --- auto/modules/java | 2 +- auto/modules/java_jar.sha512 | 18 +++++++++--------- test/unit/applications/lang/java.py | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/auto/modules/java b/auto/modules/java index b1bc43ea..53f99f7e 100644 --- a/auto/modules/java +++ b/auto/modules/java @@ -238,7 +238,7 @@ cat << END > $NXT_JAVA_JARS static const char *nxt_java_system_jars[] = { END -NXT_TOMCAT_VERSION=9.0.81 +NXT_TOMCAT_VERSION=9.0.82 NXT_JAR_VERSION=$NXT_TOMCAT_VERSION diff --git a/auto/modules/java_jar.sha512 b/auto/modules/java_jar.sha512 index cceb6bc0..e0a648af 100644 --- a/auto/modules/java_jar.sha512 +++ b/auto/modules/java_jar.sha512 @@ -3,12 +3,12 @@ ab441acf5551a7dc81c353eaccb3b3df9e89a48987294d19e39acdb83a5b640fcdff7414cee29f5b 867afb0e69ab225a3d57c0eda4e773ca2f41dcc6eb294e14aef4d69441314bee88221081f9edc6289b9e4a99184804b60c32f4443c8ff96eb34d6508b348b755 jetty-http-9.4.53.v20231009.jar aca14debabc0cc40e154d4de4de404c383c4611e9f2482911e17d9072f0941cef8a88511d5d49d70946e65872e1bc8d395b9401b2ec91132553d782d99140ce3 jetty-server-9.4.53.v20231009.jar 429b269e21c6e7bf86ba8a8b71569e3abf61b06ace9dd064a9c80af4282227e910a8d20be86ef6581895ff283a5aa4711bbb238de45dc7628f494624879c4d49 jetty-util-9.4.53.v20231009.jar -3479e544b3e68d0a7c8d88ba583b545c67dfeaece59df3529845fec889a8c239396a0887b9ed623579d9cdb6fb64774e0de9b73980eb2de3f6e4464032c29f30 tomcat-api-9.0.81.jar -4dee91fe73ddac9ef0a0796e75cfc37fc4ee7434bad3049a87c6c50dde66e45262d7c5453520dd6bb3d7881a80ef6f88e613f032b97ac996d575efa78cdfe08a tomcat-el-api-9.0.81.jar -3754aa87fdce984d9cd092e8681ec8eed89622aa202b5bcfe1f0b309a899e7f4e32877622f00a8ad41cb5579425861ed62671a2c98ed9c943613e5f2332af1ad tomcat-jasper-9.0.81.jar -654770a128633c6ca4eb1bec05501a0533f4d1727f1dc6782e4f93b8b4271b57723502e05c24fe4fde9195c9a95459ef404b764666e71ee06c39e430e5f7a3ca tomcat-jasper-el-9.0.81.jar -70978984ca6298ea28d11505a6006c9eea696c67a307817322b71f12d817e63c75f54b1ea0370decab3558a407189036fe246f8c4f6d995ad214a000966d99c0 tomcat-jsp-api-9.0.81.jar -d22f5c849ccf960e6b1a6f4266e0fd520220b88c8a7244abc4caa2e91f641db03bcc6c31c2ee496a2feeb3661f1346c17e6224128fbbf1fd60d0ad1334be7fe5 tomcat-juli-9.0.81.jar -2c6b39ee300c48f9c378ea9933190beb278b4bd975d77b1302bef12efc709d861087b002408befd71472867a2463cbbfeaf21cf3b0bdd36a5896020a0b275479 tomcat-servlet-api-9.0.81.jar -9892f391d0c80ae5f692e8bfcc41bacedc23f4aa75e0517f44aa358000dcb9f47a9b4328cdaf76300fa2f281ad7e81b5aa130f73847c3ba31029410663294b6e tomcat-util-9.0.81.jar -97a96c69a8516c9a02aff0d73958f29fa84e4aaeec4b0f2c4b4403c18c0cb4068e809a907d1d9686632dc04469901f681e79b5ed8c56c44135f215071d055baf tomcat-util-scan-9.0.81.jar +ee33bc0020ce5be2fbdb52352fb9b2846dc5898b2190e46b2a8efdfdb16a33a83538731a6d7eeeb91c7b81e8d1e022b15924fa30ee1e9770a9f9adf96989ffd7 tomcat-api-9.0.82.jar +dfb4a37dddf4bc4e9a41a1381544c81e3962a63833f024236d1ed28eabe8daae77cd79466881177ce9f729efad2f5169e9cf8a9e45c820b775c3a9223d258e6f tomcat-el-api-9.0.82.jar +db764d29d882458d8cc2aeded7b25b6129eeeb7d9ec5b77d380ca14add659a8c12f233802a5e8dfa287a1c1b9dbfd6a12fa053ec506443bde0dce9fb36081782 tomcat-jasper-9.0.82.jar +bcc9ffc0f4d50defb0fdb12c2f9a8bd89fd8758f768c2495baa9c0e77a0ae08f3e610f6893ecd30843cfda6021120d9886aab3e377309ded68cd83f3d32b654a tomcat-jasper-el-9.0.82.jar +d2d9154b622b18ef190146631984188d6353ad2cb3c6ec1922387c76ae4d279a511d76680271f29b861ee18b444894ed66e5e41030e0beb265bf47eecc1a3a81 tomcat-jsp-api-9.0.82.jar +e1c92251e2e1cd5fc99d304399fbb13af50b7d86e56ffca59edb85934474df2b8dd6b4ea3d949cc1d7cc21e673094a044b22d05bc45e540c9a0a211974ebee5c tomcat-juli-9.0.82.jar +7d30076e306403c243ed4d802fca6de7e827e7f6cef8827353fff4514bee484ff71abc61597fd92b63470c6477bb26c398d4cd9b293f059e0ff94156f0210106 tomcat-servlet-api-9.0.82.jar +b06b112011526911b08849093d61a4d4337283f4a54dee2d4f8f4ce55687eabdf5df97b9326e1430fe7cd4d043a16076e86c1354cc2661c19e87918c4635e3d1 tomcat-util-9.0.82.jar +dfe0beac3b4b8466454fb790e9dd7a17b97e62edb0f5caaaedab0360b32a0536b7d788f3d5511eb47ea3abca4f5751ab32c814c73dbf465529898d78b69fb8d6 tomcat-util-scan-9.0.82.jar diff --git a/test/unit/applications/lang/java.py b/test/unit/applications/lang/java.py index 4b55a922..dc6d2bfc 100644 --- a/test/unit/applications/lang/java.py +++ b/test/unit/applications/lang/java.py @@ -53,7 +53,7 @@ class ApplicationJava(ApplicationProto): os.makedirs(classes_path) classpath = ( - f'{option.current_dir}/build/tomcat-servlet-api-9.0.81.jar' + f'{option.current_dir}/build/tomcat-servlet-api-9.0.82.jar' ) ws_jars = glob.glob( -- cgit From d51f7def1442ff7519e14263559e3483a9a28f93 Mon Sep 17 00:00:00 2001 From: Liam Crilly Date: Wed, 18 Oct 2023 22:26:13 +0100 Subject: Tools: unitc remote mode edit fix. Previously, the edit method created a temporary file that was then sent to curl(1) as --data-binary @filename.tmp. This did not work with remote instances because the temporary file is not on the remote host. The edit method now passes the configuration to curl(1) using stdin, the same way as for all other configuration changes. --- tools/unitc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/unitc b/tools/unitc index e671f384..4ab5f663 100755 --- a/tools/unitc +++ b/tools/unitc @@ -271,7 +271,7 @@ if [ -t 0 ] && [ ${#CONF_FILES[@]} -eq 0 ]; then $RPC_CMD curl -X DELETE $UNIT_CTRL/config/settings/js_module && \ $RPC_CMD curl -fsSX DELETE $UNIT_CTRL$URI 2> /tmp/${0##*/}.$$ && \ printf "%s" "$(< $EDIT_FILENAME.js)" | $RPC_CMD curl -fX PUT --data-binary @- $UNIT_CTRL$URI 2> /tmp/${0##*/}.$$ && \ - $RPC_CMD curl -X PUT --data-binary @/tmp/${0##*/}.$$_js_module $UNIT_CTRL/config/settings/js_module 2> /tmp/${0##*/}.$$ + cat /tmp/${0##*/}.$$_js_module | $RPC_CMD curl -X PUT --data-binary @- $UNIT_CTRL/config/settings/js_module 2> /tmp/${0##*/}.$$ elif [ $CONVERT -eq 1 ]; then $CONVERT_FROM_JSON < $EDIT_FILENAME > $EDIT_FILENAME.yaml $EDITOR $EDIT_FILENAME.yaml || exit 2 @@ -279,7 +279,7 @@ if [ -t 0 ] && [ ${#CONF_FILES[@]} -eq 0 ]; then else tr -d '\r' < $EDIT_FILENAME > $EDIT_FILENAME.json # Remove carriage-return from newlines $EDITOR $EDIT_FILENAME.json || exit 2 - $RPC_CMD curl -X PUT --data-binary @$EDIT_FILENAME.json $UNIT_CTRL$URI 2> /tmp/${0##*/}.$$ | $OUTPUT + cat $EDIT_FILENAME.json | $RPC_CMD curl -X PUT --data-binary @- $UNIT_CTRL$URI 2> /tmp/${0##*/}.$$ | $OUTPUT fi else SHOW_LOG=$(echo $URI | grep -c ^/control/) -- cgit From b47415fb72acfd063be6dcd084cecf31178a02cd Mon Sep 17 00:00:00 2001 From: Andrei Zeliankou Date: Thu, 19 Oct 2023 11:41:25 +0100 Subject: Prepearing for 1.31.1 release. --- docs/changes.xml | 6 +++--- docs/unit-openapi.yaml | 2 +- version | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/changes.xml b/docs/changes.xml index 85edc71b..00282868 100644 --- a/docs/changes.xml +++ b/docs/changes.xml @@ -16,20 +16,20 @@ unit-jsc14 unit-jsc15 unit-jsc16 unit-jsc17 unit-jsc18 unit-jsc19 unit-jsc20 unit-wasm" - ver="1.32.0" rev="1" + ver="1.31.1" rev="1" date="" time="" packager="Nginx Packaging <nginx-packaging@f5.com>"> -NGINX Unit updated to 1.32.0. +NGINX Unit updated to 1.31.1.
- diff --git a/docs/unit-openapi.yaml b/docs/unit-openapi.yaml index 784ed640..4ce26fa0 100644 --- a/docs/unit-openapi.yaml +++ b/docs/unit-openapi.yaml @@ -1,6 +1,6 @@ openapi: 3.0.0 info: - title: "NGINX Unit 1.31.0" + title: "NGINX Unit 1.31.1" description: "NGINX Unit is a lightweight and versatile application runtime that provides the essential components for your web application as a single open-source server: running application code, serving static assets, diff --git a/version b/version index fa657bae..3de0f8d3 100644 --- a/version +++ b/version @@ -1,5 +1,5 @@ # Copyright (C) NGINX, Inc. -NXT_VERSION=1.32.0 -NXT_VERNUM=13200 +NXT_VERSION=1.31.1 +NXT_VERNUM=13101 -- cgit From f5d2088a5c7d8240d4229b358ef1d8a9089e00f0 Mon Sep 17 00:00:00 2001 From: Andrei Zeliankou Date: Thu, 19 Oct 2023 11:42:05 +0100 Subject: Edited changes.xml for the 1.31.1 release. --- docs/changes.xml | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/docs/changes.xml b/docs/changes.xml index 00282868..a48abecb 100644 --- a/docs/changes.xml +++ b/docs/changes.xml @@ -33,6 +33,64 @@ NGINX Unit updated to 1.31.1. date="" time="" packager="Nginx Packaging <nginx-packaging@f5.com>"> + + +allow to set the HTTP response status in Wasm module. + + + + + +allow uploads larger than 4GiB in Wasm module. + + + + + +application process could crash while rewriting URLs with query strings. + + + + + +requests larger than about 64MiB could cause error in Wasm module. + + + + + +when using many headers in Java module some of them could be +corrupted due to memory realocation issue. + + + + + +ServerRequest.destroy() implemented in Node.js module to make it compatible +with some frameworks that might use it. + + + + + +chunk argument of ServerResponse.write() can now be a Uint8Array to improve +compatibility with Node.js 15.0.0 and above. + + + + + +Node.JS unit-http NPM module now has appropriate default paths for +macOS/arm64 systems. + + + + + +build on musl libc with clang. + + + -- cgit From 6736841acc113cae7c2358a8f926446e8da791c1 Mon Sep 17 00:00:00 2001 From: Andrei Zeliankou Date: Thu, 19 Oct 2023 11:44:18 +0100 Subject: Added version 1.31.1 CHANGES. --- CHANGES | 27 +++++++++++++++++++++++++++ docs/changes.xml | 4 ++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index a0e4410e..b16751ae 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,31 @@ +Changes with Unit 1.31.1 19 Oct 2023 + + *) Feature: allow to set the HTTP response status in Wasm module. + + *) Feature: allow uploads larger than 4GiB in Wasm module. + + *) Bugfix: application process could crash while rewriting URLs with + query strings. + + *) Bugfix: requests larger than about 64MiB could cause error in Wasm + module. + + *) Bugfix: when using many headers in Java module some of them could be + corrupted due to memory realocation issue. + + *) Bugfix: ServerRequest.destroy() implemented in Node.js module to make + it compatible with some frameworks that might use it. + + *) Bugfix: chunk argument of ServerResponse.write() can now be a + Uint8Array to improve compatibility with Node.js 15.0.0 and above. + + *) Bugfix: Node.JS unit-http NPM module now has appropriate default + paths for macOS/arm64 systems. + + *) Bugfix: build on musl libc with clang. + + Changes with Unit 1.31.0 31 Aug 2023 *) Change: if building with njs, version 0.8.0 or later is now required. diff --git a/docs/changes.xml b/docs/changes.xml index a48abecb..cd28bec3 100644 --- a/docs/changes.xml +++ b/docs/changes.xml @@ -17,7 +17,7 @@ unit-jsc19 unit-jsc20 unit-wasm" ver="1.31.1" rev="1" - date="" time="" + date="2023-10-19" time="18:00:00 +0300" packager="Nginx Packaging <nginx-packaging@f5.com>"> @@ -30,7 +30,7 @@ NGINX Unit updated to 1.31.1. -- cgit From 09ab626b13a027a4d3f8b5dcdcdba3e8eee76977 Mon Sep 17 00:00:00 2001 From: Andrei Zeliankou Date: Tue, 17 Oct 2023 14:15:38 +0000 Subject: Generated Dockerfiles for Unit 1.31.1. --- pkg/docker/Dockerfile.go1.20 | 4 ++-- pkg/docker/Dockerfile.go1.21 | 4 ++-- pkg/docker/Dockerfile.jsc11 | 4 ++-- pkg/docker/Dockerfile.minimal | 4 ++-- pkg/docker/Dockerfile.node18 | 4 ++-- pkg/docker/Dockerfile.node20 | 4 ++-- pkg/docker/Dockerfile.perl5.36 | 4 ++-- pkg/docker/Dockerfile.perl5.38 | 4 ++-- pkg/docker/Dockerfile.php8.2 | 4 ++-- pkg/docker/Dockerfile.python3.11 | 4 ++-- pkg/docker/Dockerfile.ruby3.2 | 4 ++-- pkg/docker/Dockerfile.wasm | 4 ++-- 12 files changed, 24 insertions(+), 24 deletions(-) diff --git a/pkg/docker/Dockerfile.go1.20 b/pkg/docker/Dockerfile.go1.20 index 98f6d92f..53379dd1 100644 --- a/pkg/docker/Dockerfile.go1.20 +++ b/pkg/docker/Dockerfile.go1.20 @@ -6,7 +6,7 @@ LABEL org.opencontainers.image.url="https://unit.nginx.org" LABEL org.opencontainers.image.source="https://github.com/nginx/unit" LABEL org.opencontainers.image.documentation="https://unit.nginx.org/installation/#docker-images" LABEL org.opencontainers.image.vendor="NGINX Docker Maintainers " -LABEL org.opencontainers.image.version="1.31.0" +LABEL org.opencontainers.image.version="1.31.1" RUN set -ex \ && savedAptMark="$(apt-mark showmanual)" \ @@ -15,7 +15,7 @@ RUN set -ex \ && mkdir -p /usr/lib/unit/modules /usr/lib/unit/debug-modules \ && mkdir -p /usr/src/unit \ && cd /usr/src/unit \ - && hg clone -u 1.31.0-1 https://hg.nginx.org/unit \ + && hg clone -u 1.31.1-1 https://hg.nginx.org/unit \ && cd unit \ && NCPU="$(getconf _NPROCESSORS_ONLN)" \ && DEB_HOST_MULTIARCH="$(dpkg-architecture -q DEB_HOST_MULTIARCH)" \ diff --git a/pkg/docker/Dockerfile.go1.21 b/pkg/docker/Dockerfile.go1.21 index 18d3cc7b..a90dc115 100644 --- a/pkg/docker/Dockerfile.go1.21 +++ b/pkg/docker/Dockerfile.go1.21 @@ -6,7 +6,7 @@ LABEL org.opencontainers.image.url="https://unit.nginx.org" LABEL org.opencontainers.image.source="https://github.com/nginx/unit" LABEL org.opencontainers.image.documentation="https://unit.nginx.org/installation/#docker-images" LABEL org.opencontainers.image.vendor="NGINX Docker Maintainers " -LABEL org.opencontainers.image.version="1.31.0" +LABEL org.opencontainers.image.version="1.31.1" RUN set -ex \ && savedAptMark="$(apt-mark showmanual)" \ @@ -15,7 +15,7 @@ RUN set -ex \ && mkdir -p /usr/lib/unit/modules /usr/lib/unit/debug-modules \ && mkdir -p /usr/src/unit \ && cd /usr/src/unit \ - && hg clone -u 1.31.0-1 https://hg.nginx.org/unit \ + && hg clone -u 1.31.1-1 https://hg.nginx.org/unit \ && cd unit \ && NCPU="$(getconf _NPROCESSORS_ONLN)" \ && DEB_HOST_MULTIARCH="$(dpkg-architecture -q DEB_HOST_MULTIARCH)" \ diff --git a/pkg/docker/Dockerfile.jsc11 b/pkg/docker/Dockerfile.jsc11 index e7a057bd..2844c813 100644 --- a/pkg/docker/Dockerfile.jsc11 +++ b/pkg/docker/Dockerfile.jsc11 @@ -6,7 +6,7 @@ LABEL org.opencontainers.image.url="https://unit.nginx.org" LABEL org.opencontainers.image.source="https://github.com/nginx/unit" LABEL org.opencontainers.image.documentation="https://unit.nginx.org/installation/#docker-images" LABEL org.opencontainers.image.vendor="NGINX Docker Maintainers " -LABEL org.opencontainers.image.version="1.31.0" +LABEL org.opencontainers.image.version="1.31.1" RUN set -ex \ && savedAptMark="$(apt-mark showmanual)" \ @@ -15,7 +15,7 @@ RUN set -ex \ && mkdir -p /usr/lib/unit/modules /usr/lib/unit/debug-modules \ && mkdir -p /usr/src/unit \ && cd /usr/src/unit \ - && hg clone -u 1.31.0-1 https://hg.nginx.org/unit \ + && hg clone -u 1.31.1-1 https://hg.nginx.org/unit \ && cd unit \ && NCPU="$(getconf _NPROCESSORS_ONLN)" \ && DEB_HOST_MULTIARCH="$(dpkg-architecture -q DEB_HOST_MULTIARCH)" \ diff --git a/pkg/docker/Dockerfile.minimal b/pkg/docker/Dockerfile.minimal index 8c5ce0d5..4b585480 100644 --- a/pkg/docker/Dockerfile.minimal +++ b/pkg/docker/Dockerfile.minimal @@ -6,7 +6,7 @@ LABEL org.opencontainers.image.url="https://unit.nginx.org" LABEL org.opencontainers.image.source="https://github.com/nginx/unit" LABEL org.opencontainers.image.documentation="https://unit.nginx.org/installation/#docker-images" LABEL org.opencontainers.image.vendor="NGINX Docker Maintainers " -LABEL org.opencontainers.image.version="1.31.0" +LABEL org.opencontainers.image.version="1.31.1" RUN set -ex \ && savedAptMark="$(apt-mark showmanual)" \ @@ -15,7 +15,7 @@ RUN set -ex \ && mkdir -p /usr/lib/unit/modules /usr/lib/unit/debug-modules \ && mkdir -p /usr/src/unit \ && cd /usr/src/unit \ - && hg clone -u 1.31.0-1 https://hg.nginx.org/unit \ + && hg clone -u 1.31.1-1 https://hg.nginx.org/unit \ && cd unit \ && NCPU="$(getconf _NPROCESSORS_ONLN)" \ && DEB_HOST_MULTIARCH="$(dpkg-architecture -q DEB_HOST_MULTIARCH)" \ diff --git a/pkg/docker/Dockerfile.node18 b/pkg/docker/Dockerfile.node18 index 735342dd..4ac18847 100644 --- a/pkg/docker/Dockerfile.node18 +++ b/pkg/docker/Dockerfile.node18 @@ -6,7 +6,7 @@ LABEL org.opencontainers.image.url="https://unit.nginx.org" LABEL org.opencontainers.image.source="https://github.com/nginx/unit" LABEL org.opencontainers.image.documentation="https://unit.nginx.org/installation/#docker-images" LABEL org.opencontainers.image.vendor="NGINX Docker Maintainers " -LABEL org.opencontainers.image.version="1.31.0" +LABEL org.opencontainers.image.version="1.31.1" RUN set -ex \ && savedAptMark="$(apt-mark showmanual)" \ @@ -15,7 +15,7 @@ RUN set -ex \ && mkdir -p /usr/lib/unit/modules /usr/lib/unit/debug-modules \ && mkdir -p /usr/src/unit \ && cd /usr/src/unit \ - && hg clone -u 1.31.0-1 https://hg.nginx.org/unit \ + && hg clone -u 1.31.1-1 https://hg.nginx.org/unit \ && cd unit \ && NCPU="$(getconf _NPROCESSORS_ONLN)" \ && DEB_HOST_MULTIARCH="$(dpkg-architecture -q DEB_HOST_MULTIARCH)" \ diff --git a/pkg/docker/Dockerfile.node20 b/pkg/docker/Dockerfile.node20 index f291ccfc..f783ba72 100644 --- a/pkg/docker/Dockerfile.node20 +++ b/pkg/docker/Dockerfile.node20 @@ -6,7 +6,7 @@ LABEL org.opencontainers.image.url="https://unit.nginx.org" LABEL org.opencontainers.image.source="https://github.com/nginx/unit" LABEL org.opencontainers.image.documentation="https://unit.nginx.org/installation/#docker-images" LABEL org.opencontainers.image.vendor="NGINX Docker Maintainers " -LABEL org.opencontainers.image.version="1.31.0" +LABEL org.opencontainers.image.version="1.31.1" RUN set -ex \ && savedAptMark="$(apt-mark showmanual)" \ @@ -15,7 +15,7 @@ RUN set -ex \ && mkdir -p /usr/lib/unit/modules /usr/lib/unit/debug-modules \ && mkdir -p /usr/src/unit \ && cd /usr/src/unit \ - && hg clone -u 1.31.0-1 https://hg.nginx.org/unit \ + && hg clone -u 1.31.1-1 https://hg.nginx.org/unit \ && cd unit \ && NCPU="$(getconf _NPROCESSORS_ONLN)" \ && DEB_HOST_MULTIARCH="$(dpkg-architecture -q DEB_HOST_MULTIARCH)" \ diff --git a/pkg/docker/Dockerfile.perl5.36 b/pkg/docker/Dockerfile.perl5.36 index 2db7506d..8cc5d9e2 100644 --- a/pkg/docker/Dockerfile.perl5.36 +++ b/pkg/docker/Dockerfile.perl5.36 @@ -6,7 +6,7 @@ LABEL org.opencontainers.image.url="https://unit.nginx.org" LABEL org.opencontainers.image.source="https://github.com/nginx/unit" LABEL org.opencontainers.image.documentation="https://unit.nginx.org/installation/#docker-images" LABEL org.opencontainers.image.vendor="NGINX Docker Maintainers " -LABEL org.opencontainers.image.version="1.31.0" +LABEL org.opencontainers.image.version="1.31.1" RUN set -ex \ && savedAptMark="$(apt-mark showmanual)" \ @@ -15,7 +15,7 @@ RUN set -ex \ && mkdir -p /usr/lib/unit/modules /usr/lib/unit/debug-modules \ && mkdir -p /usr/src/unit \ && cd /usr/src/unit \ - && hg clone -u 1.31.0-1 https://hg.nginx.org/unit \ + && hg clone -u 1.31.1-1 https://hg.nginx.org/unit \ && cd unit \ && NCPU="$(getconf _NPROCESSORS_ONLN)" \ && DEB_HOST_MULTIARCH="$(dpkg-architecture -q DEB_HOST_MULTIARCH)" \ diff --git a/pkg/docker/Dockerfile.perl5.38 b/pkg/docker/Dockerfile.perl5.38 index bd653cb1..531188fe 100644 --- a/pkg/docker/Dockerfile.perl5.38 +++ b/pkg/docker/Dockerfile.perl5.38 @@ -6,7 +6,7 @@ LABEL org.opencontainers.image.url="https://unit.nginx.org" LABEL org.opencontainers.image.source="https://github.com/nginx/unit" LABEL org.opencontainers.image.documentation="https://unit.nginx.org/installation/#docker-images" LABEL org.opencontainers.image.vendor="NGINX Docker Maintainers " -LABEL org.opencontainers.image.version="1.31.0" +LABEL org.opencontainers.image.version="1.31.1" RUN set -ex \ && savedAptMark="$(apt-mark showmanual)" \ @@ -15,7 +15,7 @@ RUN set -ex \ && mkdir -p /usr/lib/unit/modules /usr/lib/unit/debug-modules \ && mkdir -p /usr/src/unit \ && cd /usr/src/unit \ - && hg clone -u 1.31.0-1 https://hg.nginx.org/unit \ + && hg clone -u 1.31.1-1 https://hg.nginx.org/unit \ && cd unit \ && NCPU="$(getconf _NPROCESSORS_ONLN)" \ && DEB_HOST_MULTIARCH="$(dpkg-architecture -q DEB_HOST_MULTIARCH)" \ diff --git a/pkg/docker/Dockerfile.php8.2 b/pkg/docker/Dockerfile.php8.2 index bd27a4dd..5783bf6c 100644 --- a/pkg/docker/Dockerfile.php8.2 +++ b/pkg/docker/Dockerfile.php8.2 @@ -6,7 +6,7 @@ LABEL org.opencontainers.image.url="https://unit.nginx.org" LABEL org.opencontainers.image.source="https://github.com/nginx/unit" LABEL org.opencontainers.image.documentation="https://unit.nginx.org/installation/#docker-images" LABEL org.opencontainers.image.vendor="NGINX Docker Maintainers " -LABEL org.opencontainers.image.version="1.31.0" +LABEL org.opencontainers.image.version="1.31.1" RUN set -ex \ && savedAptMark="$(apt-mark showmanual)" \ @@ -15,7 +15,7 @@ RUN set -ex \ && mkdir -p /usr/lib/unit/modules /usr/lib/unit/debug-modules \ && mkdir -p /usr/src/unit \ && cd /usr/src/unit \ - && hg clone -u 1.31.0-1 https://hg.nginx.org/unit \ + && hg clone -u 1.31.1-1 https://hg.nginx.org/unit \ && cd unit \ && NCPU="$(getconf _NPROCESSORS_ONLN)" \ && DEB_HOST_MULTIARCH="$(dpkg-architecture -q DEB_HOST_MULTIARCH)" \ diff --git a/pkg/docker/Dockerfile.python3.11 b/pkg/docker/Dockerfile.python3.11 index cdc96434..b5e81b6c 100644 --- a/pkg/docker/Dockerfile.python3.11 +++ b/pkg/docker/Dockerfile.python3.11 @@ -6,7 +6,7 @@ LABEL org.opencontainers.image.url="https://unit.nginx.org" LABEL org.opencontainers.image.source="https://github.com/nginx/unit" LABEL org.opencontainers.image.documentation="https://unit.nginx.org/installation/#docker-images" LABEL org.opencontainers.image.vendor="NGINX Docker Maintainers " -LABEL org.opencontainers.image.version="1.31.0" +LABEL org.opencontainers.image.version="1.31.1" RUN set -ex \ && savedAptMark="$(apt-mark showmanual)" \ @@ -15,7 +15,7 @@ RUN set -ex \ && mkdir -p /usr/lib/unit/modules /usr/lib/unit/debug-modules \ && mkdir -p /usr/src/unit \ && cd /usr/src/unit \ - && hg clone -u 1.31.0-1 https://hg.nginx.org/unit \ + && hg clone -u 1.31.1-1 https://hg.nginx.org/unit \ && cd unit \ && NCPU="$(getconf _NPROCESSORS_ONLN)" \ && DEB_HOST_MULTIARCH="$(dpkg-architecture -q DEB_HOST_MULTIARCH)" \ diff --git a/pkg/docker/Dockerfile.ruby3.2 b/pkg/docker/Dockerfile.ruby3.2 index 8b870756..c417a327 100644 --- a/pkg/docker/Dockerfile.ruby3.2 +++ b/pkg/docker/Dockerfile.ruby3.2 @@ -6,7 +6,7 @@ LABEL org.opencontainers.image.url="https://unit.nginx.org" LABEL org.opencontainers.image.source="https://github.com/nginx/unit" LABEL org.opencontainers.image.documentation="https://unit.nginx.org/installation/#docker-images" LABEL org.opencontainers.image.vendor="NGINX Docker Maintainers " -LABEL org.opencontainers.image.version="1.31.0" +LABEL org.opencontainers.image.version="1.31.1" RUN set -ex \ && savedAptMark="$(apt-mark showmanual)" \ @@ -15,7 +15,7 @@ RUN set -ex \ && mkdir -p /usr/lib/unit/modules /usr/lib/unit/debug-modules \ && mkdir -p /usr/src/unit \ && cd /usr/src/unit \ - && hg clone -u 1.31.0-1 https://hg.nginx.org/unit \ + && hg clone -u 1.31.1-1 https://hg.nginx.org/unit \ && cd unit \ && NCPU="$(getconf _NPROCESSORS_ONLN)" \ && DEB_HOST_MULTIARCH="$(dpkg-architecture -q DEB_HOST_MULTIARCH)" \ diff --git a/pkg/docker/Dockerfile.wasm b/pkg/docker/Dockerfile.wasm index 852bc5d0..e45f020f 100644 --- a/pkg/docker/Dockerfile.wasm +++ b/pkg/docker/Dockerfile.wasm @@ -6,7 +6,7 @@ LABEL org.opencontainers.image.url="https://unit.nginx.org" LABEL org.opencontainers.image.source="https://github.com/nginx/unit" LABEL org.opencontainers.image.documentation="https://unit.nginx.org/installation/#docker-images" LABEL org.opencontainers.image.vendor="NGINX Docker Maintainers " -LABEL org.opencontainers.image.version="1.31.0" +LABEL org.opencontainers.image.version="1.31.1" RUN set -ex \ && savedAptMark="$(apt-mark showmanual)" \ @@ -15,7 +15,7 @@ RUN set -ex \ && mkdir -p /usr/lib/unit/modules /usr/lib/unit/debug-modules \ && mkdir -p /usr/src/unit \ && cd /usr/src/unit \ - && hg clone -u 1.31.0-1 https://hg.nginx.org/unit \ + && hg clone -u 1.31.1-1 https://hg.nginx.org/unit \ && cd unit \ && NCPU="$(getconf _NPROCESSORS_ONLN)" \ && DEB_HOST_MULTIARCH="$(dpkg-architecture -q DEB_HOST_MULTIARCH)" \ -- cgit From fb33ec86a3b6ca6a844dfa6980bb9e083094abec Mon Sep 17 00:00:00 2001 From: Andrei Zeliankou Date: Thu, 19 Oct 2023 11:47:22 +0100 Subject: Unit 1.31.1 release. --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 976c55be..8e6743d1 100644 --- a/.hgtags +++ b/.hgtags @@ -40,3 +40,4 @@ ea073fb3cb75abfb4be5dc12402de73e0c20da60 1.28.0 fa0227b7f62691a186d752ace475868de49e9fce 1.29.1 2692a5823c403a4e209681943e32a4907317d14b 1.30.0 3a9046dca2a6c51ee2df2cabdf69cb9a83e7a1e6 1.31.0 +25aafe2ff61e0424b3245f4e3d40eb1fa7611063 1.31.1 -- cgit