Discussion:
[PATCH] New directive to configure TLSv1.3 ciphers
Ramprasad Tamilselvan
2018-11-15 01:24:52 UTC
Permalink
# HG changeset patch
# User Ramprasad Tamilselvan <***@quantil.com>
# Date 1542241466 28800
# Wed Nov 14 16:24:26 2018 -0800
# Node ID 83b05772dbd657b31df16d712a64c908c371f0d9
# Parent 4698cede59ffa438bcae1fd6c5d8fec4d69b2c92
New directive to configure TLSv1.3 ciphers.

In openssl 1.1.1, a new API is introduced to configure ciphers
for TLSv1.3. A new directive ssl_ciphersuites will call the new
API to configure the ciphers for TLSv1.3.

diff -r 4698cede59ff -r 83b05772dbd6 src/event/ngx_event_openssl.c
--- a/src/event/ngx_event_openssl.c Mon Nov 12 16:29:30 2018 +0300
+++ b/src/event/ngx_event_openssl.c Wed Nov 14 16:24:26 2018 -0800
@@ -660,8 +660,20 @@

ngx_int_t
ngx_ssl_ciphers(ngx_conf_t *cf, ngx_ssl_t *ssl, ngx_str_t *ciphers,
- ngx_uint_t prefer_server_ciphers)
+ ngx_str_t *ciphersuites, ngx_uint_t prefer_server_ciphers)
{
+
+#if (OPENSSL_VERSION_NUMBER >= 0x10101000L)
+ /* set cipher as "" so that SSL_CTX_set_cipher_list can detect
+ * any invalid ciphers */
+ if (SSL_CTX_set_ciphersuites(ssl->ctx, (char *) "") == 0) {
+ ngx_ssl_error(NGX_LOG_EMERG, ssl->log, 0,
+ "SSL_CTX_set_ciphersuites(\"%V\") failed",
+ ciphersuites);
+ return NGX_ERROR;
+ }
+#endif
+
if (SSL_CTX_set_cipher_list(ssl->ctx, (char *) ciphers->data) == 0) {
ngx_ssl_error(NGX_LOG_EMERG, ssl->log, 0,
"SSL_CTX_set_cipher_list(\"%V\") failed",
@@ -669,6 +681,16 @@
return NGX_ERROR;
}

+#if (OPENSSL_VERSION_NUMBER >= 0x10101000L)
+ /* set ciphers for TLSv1.3 */
+ if (SSL_CTX_set_ciphersuites(ssl->ctx, (char *) ciphersuites->data) == 0) {
+ ngx_ssl_error(NGX_LOG_EMERG, ssl->log, 0,
+ "SSL_CTX_set_ciphersuites(\"%V\") failed",
+ ciphersuites);
+ return NGX_ERROR;
+ }
+#endif
+
if (prefer_server_ciphers) {
SSL_CTX_set_options(ssl->ctx, SSL_OP_CIPHER_SERVER_PREFERENCE);
}
diff -r 4698cede59ff -r 83b05772dbd6 src/event/ngx_event_openssl.h
--- a/src/event/ngx_event_openssl.h Mon Nov 12 16:29:30 2018 +0300
+++ b/src/event/ngx_event_openssl.h Wed Nov 14 16:24:26 2018 -0800
@@ -165,7 +165,7 @@
ngx_int_t ngx_ssl_certificate(ngx_conf_t *cf, ngx_ssl_t *ssl,
ngx_str_t *cert, ngx_str_t *key, ngx_array_t *passwords);
ngx_int_t ngx_ssl_ciphers(ngx_conf_t *cf, ngx_ssl_t *ssl, ngx_str_t *ciphers,
- ngx_uint_t prefer_server_ciphers);
+ ngx_str_t *ciphersuites, ngx_uint_t prefer_server_ciphers);
ngx_int_t ngx_ssl_client_certificate(ngx_conf_t *cf, ngx_ssl_t *ssl,
ngx_str_t *cert, ngx_int_t depth);
ngx_int_t ngx_ssl_trusted_certificate(ngx_conf_t *cf, ngx_ssl_t *ssl,
diff -r 4698cede59ff -r 83b05772dbd6 src/http/modules/ngx_http_grpc_module.c
--- a/src/http/modules/ngx_http_grpc_module.c Mon Nov 12 16:29:30 2018 +0300
+++ b/src/http/modules/ngx_http_grpc_module.c Wed Nov 14 16:24:26 2018 -0800
@@ -9,6 +9,9 @@
#include <ngx_core.h>
#include <ngx_http.h>

+#define NGX_DEFAULT_CIPHERSUITES "TLS_AES_256_GCM_SHA384" \
+ ":TLS_CHACHA20_POLY1305_SHA256" \
+ ":TLS_AES_128_GCM_SHA256"

typedef struct {
ngx_array_t *flushes;
@@ -31,6 +34,7 @@
ngx_uint_t ssl;
ngx_uint_t ssl_protocols;
ngx_str_t ssl_ciphers;
+ ngx_str_t ssl_ciphersuites;
ngx_uint_t ssl_verify_depth;
ngx_str_t ssl_trusted_certificate;
ngx_str_t ssl_crl;
@@ -365,6 +369,13 @@
offsetof(ngx_http_grpc_loc_conf_t, ssl_ciphers),
NULL },

+ { ngx_string("grpc_ssl_ciphersuites"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_str_slot,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ offsetof(ngx_http_grpc_loc_conf_t, ssl_ciphersuites),
+ NULL },
+
{ ngx_string("grpc_ssl_name"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
ngx_http_set_complex_value_slot,
@@ -4165,6 +4176,7 @@
* conf->ssl = 0;
* conf->ssl_protocols = 0;
* conf->ssl_ciphers = { 0, NULL };
+ * conf->ssl_ciphersuites = { 0, NULL };
* conf->ssl_trusted_certificate = { 0, NULL };
* conf->ssl_crl = { 0, NULL };
* conf->ssl_certificate = { 0, NULL };
@@ -4280,6 +4292,9 @@
ngx_conf_merge_str_value(conf->ssl_ciphers, prev->ssl_ciphers,
"DEFAULT");

+ ngx_conf_merge_str_value(conf->ssl_ciphersuites, prev->ssl_ciphersuites,
+ NGX_DEFAULT_CIPHERSUITES);
+
if (conf->upstream.ssl_name == NULL) {
conf->upstream.ssl_name = prev->upstream.ssl_name;
}
@@ -4673,7 +4688,8 @@
}
}

- if (ngx_ssl_ciphers(cf, glcf->upstream.ssl, &glcf->ssl_ciphers, 0)
+ if (ngx_ssl_ciphers(cf, glcf->upstream.ssl, &glcf->ssl_ciphers,
+ &glcf->ssl_ciphersuites, 0)
!= NGX_OK)
{
return NGX_ERROR;
diff -r 4698cede59ff -r 83b05772dbd6 src/http/modules/ngx_http_proxy_module.c
--- a/src/http/modules/ngx_http_proxy_module.c Mon Nov 12 16:29:30 2018 +0300
+++ b/src/http/modules/ngx_http_proxy_module.c Wed Nov 14 16:24:26 2018 -0800
@@ -9,6 +9,9 @@
#include <ngx_core.h>
#include <ngx_http.h>

+#define NGX_DEFAULT_CIPHERSUITES "TLS_AES_256_GCM_SHA384" \
+ ":TLS_CHACHA20_POLY1305_SHA256" \
+ ":TLS_AES_128_GCM_SHA256"

typedef struct {
ngx_array_t caches; /* ngx_http_file_cache_t * */
@@ -94,6 +97,7 @@
ngx_uint_t ssl;
ngx_uint_t ssl_protocols;
ngx_str_t ssl_ciphers;
+ ngx_str_t ssl_ciphersuites;
ngx_uint_t ssl_verify_depth;
ngx_str_t ssl_trusted_certificate;
ngx_str_t ssl_crl;
@@ -659,6 +663,13 @@
offsetof(ngx_http_proxy_loc_conf_t, ssl_ciphers),
NULL },

+ { ngx_string("proxy_ssl_ciphersuites"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_str_slot,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ offsetof(ngx_http_proxy_loc_conf_t, ssl_ciphersuites),
+ NULL },
+
{ ngx_string("proxy_ssl_name"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
ngx_http_set_complex_value_slot,
@@ -2825,6 +2836,7 @@
* conf->ssl = 0;
* conf->ssl_protocols = 0;
* conf->ssl_ciphers = { 0, NULL };
+ * conf->ssl_ciphersuites = { 0, NULL };
* conf->ssl_trusted_certificate = { 0, NULL };
* conf->ssl_crl = { 0, NULL };
* conf->ssl_certificate = { 0, NULL };
@@ -3208,6 +3220,9 @@
ngx_conf_merge_str_value(conf->ssl_ciphers, prev->ssl_ciphers,
"DEFAULT");

+ ngx_conf_merge_str_value(conf->ssl_ciphersuites, prev->ssl_ciphersuites,
+ NGX_DEFAULT_CIPHERSUITES);
+
if (conf->upstream.ssl_name == NULL) {
conf->upstream.ssl_name = prev->upstream.ssl_name;
}
@@ -4293,7 +4308,8 @@
}
}

- if (ngx_ssl_ciphers(cf, plcf->upstream.ssl, &plcf->ssl_ciphers, 0)
+ if (ngx_ssl_ciphers(cf, plcf->upstream.ssl, &plcf->ssl_ciphers,
+ &plcf->ssl_ciphersuites, 0)
!= NGX_OK)
{
return NGX_ERROR;
diff -r 4698cede59ff -r 83b05772dbd6 src/http/modules/ngx_http_ssl_module.c
--- a/src/http/modules/ngx_http_ssl_module.c Mon Nov 12 16:29:30 2018 +0300
+++ b/src/http/modules/ngx_http_ssl_module.c Wed Nov 14 16:24:26 2018 -0800
@@ -16,6 +16,9 @@

#define NGX_DEFAULT_CIPHERS "HIGH:!aNULL:!MD5"
#define NGX_DEFAULT_ECDH_CURVE "auto"
+#define NGX_DEFAULT_CIPHERSUITES "TLS_AES_256_GCM_SHA384" \
+ ":TLS_CHACHA20_POLY1305_SHA256" \
+ ":TLS_AES_128_GCM_SHA256"

#define NGX_HTTP_NPN_ADVERTISE "\x08http/1.1"

@@ -133,6 +136,13 @@
NGX_HTTP_SRV_CONF_OFFSET,
offsetof(ngx_http_ssl_srv_conf_t, ciphers),
NULL },
+
+ { ngx_string("ssl_ciphersuites"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_str_slot,
+ NGX_HTTP_SRV_CONF_OFFSET,
+ offsetof(ngx_http_ssl_srv_conf_t, ciphersuites),
+ NULL },

{ ngx_string("ssl_buffer_size"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
@@ -556,6 +566,7 @@
* sscf->trusted_certificate = { 0, NULL };
* sscf->crl = { 0, NULL };
* sscf->ciphers = { 0, NULL };
+ * sscf->ciphersuites = { 0, NULL };
* sscf->shm_zone = NULL;
* sscf->stapling_file = { 0, NULL };
* sscf->stapling_responder = { 0, NULL };
@@ -637,6 +648,9 @@

ngx_conf_merge_str_value(conf->ciphers, prev->ciphers, NGX_DEFAULT_CIPHERS);

+ ngx_conf_merge_str_value(conf->ciphersuites, prev->ciphersuites,
+ NGX_DEFAULT_CIPHERSUITES);
+
ngx_conf_merge_value(conf->stapling, prev->stapling, 0);
ngx_conf_merge_value(conf->stapling_verify, prev->stapling_verify, 0);
ngx_conf_merge_str_value(conf->stapling_file, prev->stapling_file, "");
@@ -734,7 +748,7 @@
return NGX_CONF_ERROR;
}

- if (ngx_ssl_ciphers(cf, &conf->ssl, &conf->ciphers,
+ if (ngx_ssl_ciphers(cf, &conf->ssl, &conf->ciphers, &conf->ciphersuites,
conf->prefer_server_ciphers)
!= NGX_OK)
{
diff -r 4698cede59ff -r 83b05772dbd6 src/http/modules/ngx_http_ssl_module.h
--- a/src/http/modules/ngx_http_ssl_module.h Mon Nov 12 16:29:30 2018 +0300
+++ b/src/http/modules/ngx_http_ssl_module.h Wed Nov 14 16:24:26 2018 -0800
@@ -44,6 +44,8 @@

ngx_str_t ciphers;

+ ngx_str_t ciphersuites;
+
ngx_array_t *passwords;

ngx_shm_zone_t *shm_zone;
diff -r 4698cede59ff -r 83b05772dbd6 src/http/modules/ngx_http_uwsgi_module.c
--- a/src/http/modules/ngx_http_uwsgi_module.c Mon Nov 12 16:29:30 2018 +0300
+++ b/src/http/modules/ngx_http_uwsgi_module.c Wed Nov 14 16:24:26 2018 -0800
@@ -11,6 +11,9 @@
#include <ngx_core.h>
#include <ngx_http.h>

+#define NGX_DEFAULT_CIPHERSUITES "TLS_AES_256_GCM_SHA384" \
+ ":TLS_CHACHA20_POLY1305_SHA256" \
+ ":TLS_AES_128_GCM_SHA256"

typedef struct {
ngx_array_t caches; /* ngx_http_file_cache_t * */
@@ -51,6 +54,7 @@
ngx_uint_t ssl;
ngx_uint_t ssl_protocols;
ngx_str_t ssl_ciphers;
+ ngx_str_t ssl_ciphersuites;
ngx_uint_t ssl_verify_depth;
ngx_str_t ssl_trusted_certificate;
ngx_str_t ssl_crl;
@@ -497,6 +501,13 @@
offsetof(ngx_http_uwsgi_loc_conf_t, ssl_ciphers),
NULL },

+ { ngx_string("uwsgi_ssl_ciphersuites"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_str_slot,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ offsetof(ngx_http_uwsgi_loc_conf_t, ssl_ciphersuites),
+ NULL },
+
{ ngx_string("uwsgi_ssl_name"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
ngx_http_set_complex_value_slot,
@@ -1773,6 +1784,9 @@
ngx_conf_merge_str_value(conf->ssl_ciphers, prev->ssl_ciphers,
"DEFAULT");

+ ngx_conf_merge_str_value(conf->ssl_ciphersuites, prev->ssl_ciphersuites,
+ NGX_DEFAULT_CIPHERSUITES);
+
if (conf->upstream.ssl_name == NULL) {
conf->upstream.ssl_name = prev->upstream.ssl_name;
}
@@ -2382,7 +2396,8 @@
}
}

- if (ngx_ssl_ciphers(cf, uwcf->upstream.ssl, &uwcf->ssl_ciphers, 0)
+ if (ngx_ssl_ciphers(cf, uwcf->upstream.ssl, &uwcf->ssl_ciphers,
+ &uwcf->ssl_ciphersuites, 0)
!= NGX_OK)
{
return NGX_ERROR;
diff -r 4698cede59ff -r 83b05772dbd6 src/mail/ngx_mail_ssl_module.c
--- a/src/mail/ngx_mail_ssl_module.c Mon Nov 12 16:29:30 2018 +0300
+++ b/src/mail/ngx_mail_ssl_module.c Wed Nov 14 16:24:26 2018 -0800
@@ -11,6 +11,9 @@


#define NGX_DEFAULT_CIPHERS "HIGH:!aNULL:!MD5"
+#define NGX_DEFAULT_CIPHERSUITES "TLS_AES_256_GCM_SHA384" \
+ ":TLS_CHACHA20_POLY1305_SHA256" \
+ ":TLS_AES_128_GCM_SHA256"
#define NGX_DEFAULT_ECDH_CURVE "auto"


@@ -126,6 +129,13 @@
offsetof(ngx_mail_ssl_conf_t, ciphers),
NULL },

+ { ngx_string("ssl_ciphersuites"),
+ NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_str_slot,
+ NGX_MAIL_SRV_CONF_OFFSET,
+ offsetof(ngx_mail_ssl_conf_t, ciphersuites),
+ NULL },
+
{ ngx_string("ssl_prefer_server_ciphers"),
NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_FLAG,
ngx_conf_set_flag_slot,
@@ -251,6 +261,7 @@
* scf->trusted_certificate = { 0, NULL };
* scf->crl = { 0, NULL };
* scf->ciphers = { 0, NULL };
+ * scf->ciphersuites = { 0, NULL };
* scf->shm_zone = NULL;
*/

@@ -316,6 +327,9 @@

ngx_conf_merge_str_value(conf->ciphers, prev->ciphers, NGX_DEFAULT_CIPHERS);

+ ngx_conf_merge_str_value(conf->ciphersuites, prev->ciphersuites,
+ NGX_DEFAULT_CIPHERSUITES);
+

conf->ssl.log = cf->log;

@@ -412,7 +426,7 @@
}
}

- if (ngx_ssl_ciphers(cf, &conf->ssl, &conf->ciphers,
+ if (ngx_ssl_ciphers(cf, &conf->ssl, &conf->ciphers, &conf->ciphersuites,
conf->prefer_server_ciphers)
!= NGX_OK)
{
diff -r 4698cede59ff -r 83b05772dbd6 src/mail/ngx_mail_ssl_module.h
--- a/src/mail/ngx_mail_ssl_module.h Mon Nov 12 16:29:30 2018 +0300
+++ b/src/mail/ngx_mail_ssl_module.h Wed Nov 14 16:24:26 2018 -0800
@@ -47,6 +47,8 @@

ngx_str_t ciphers;

+ ngx_str_t ciphersuites;
+
ngx_array_t *passwords;

ngx_shm_zone_t *shm_zone;
diff -r 4698cede59ff -r 83b05772dbd6 src/stream/ngx_stream_proxy_module.c
--- a/src/stream/ngx_stream_proxy_module.c Mon Nov 12 16:29:30 2018 +0300
+++ b/src/stream/ngx_stream_proxy_module.c Wed Nov 14 16:24:26 2018 -0800
@@ -9,6 +9,9 @@
#include <ngx_core.h>
#include <ngx_stream.h>

+#define NGX_DEFAULT_CIPHERSUITES "TLS_AES_256_GCM_SHA384" \
+ ":TLS_CHACHA20_POLY1305_SHA256" \
+ ":TLS_AES_128_GCM_SHA256"

typedef struct {
ngx_addr_t *addr;
@@ -39,6 +42,7 @@
ngx_flag_t ssl_session_reuse;
ngx_uint_t ssl_protocols;
ngx_str_t ssl_ciphers;
+ ngx_str_t ssl_ciphersuites;
ngx_stream_complex_value_t *ssl_name;
ngx_flag_t ssl_server_name;

@@ -268,6 +272,13 @@
offsetof(ngx_stream_proxy_srv_conf_t, ssl_ciphers),
NULL },

+ { ngx_string("proxy_ssl_ciphersuites"),
+ NGX_STREAM_MAIN_CONF|NGX_STREAM_SRV_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_str_slot,
+ NGX_STREAM_SRV_CONF_OFFSET,
+ offsetof(ngx_stream_proxy_srv_conf_t, ssl_ciphersuites),
+ NULL },
+
{ ngx_string("proxy_ssl_name"),
NGX_STREAM_MAIN_CONF|NGX_STREAM_SRV_CONF|NGX_CONF_TAKE1,
ngx_stream_set_complex_value_slot,
@@ -1945,6 +1956,7 @@
*
* conf->ssl_protocols = 0;
* conf->ssl_ciphers = { 0, NULL };
+ * conf->ssl_ciphersuites = { 0, NULL };
* conf->ssl_name = NULL;
* conf->ssl_trusted_certificate = { 0, NULL };
* conf->ssl_crl = { 0, NULL };
@@ -2038,6 +2050,9 @@

ngx_conf_merge_str_value(conf->ssl_ciphers, prev->ssl_ciphers, "DEFAULT");

+ ngx_conf_merge_str_value(conf->ssl_ciphersuites, prev->ssl_ciphersuites,
+ NGX_DEFAULT_CIPHERSUITES);
+
if (conf->ssl_name == NULL) {
conf->ssl_name = prev->ssl_name;
}
@@ -2115,7 +2130,9 @@
}
}

- if (ngx_ssl_ciphers(cf, pscf->ssl, &pscf->ssl_ciphers, 0) != NGX_OK) {
+ if (ngx_ssl_ciphers(cf, pscf->ssl, &pscf->ssl_ciphers,
+ &pscf->ssl_ciphersuites, 0)
+ != NGX_OK) {
return NGX_ERROR;
}

diff -r 4698cede59ff -r 83b05772dbd6 src/stream/ngx_stream_ssl_module.c
--- a/src/stream/ngx_stream_ssl_module.c Mon Nov 12 16:29:30 2018 +0300
+++ b/src/stream/ngx_stream_ssl_module.c Wed Nov 14 16:24:26 2018 -0800
@@ -15,6 +15,9 @@


#define NGX_DEFAULT_CIPHERS "HIGH:!aNULL:!MD5"
+#define NGX_DEFAULT_CIPHERSUITES "TLS_AES_256_GCM_SHA384" \
+ ":TLS_CHACHA20_POLY1305_SHA256" \
+ ":TLS_AES_128_GCM_SHA256"
#define NGX_DEFAULT_ECDH_CURVE "auto"


@@ -117,6 +120,13 @@
offsetof(ngx_stream_ssl_conf_t, ciphers),
NULL },

+ { ngx_string("ssl_ciphersuites"),
+ NGX_STREAM_MAIN_CONF|NGX_STREAM_SRV_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_str_slot,
+ NGX_STREAM_SRV_CONF_OFFSET,
+ offsetof(ngx_stream_ssl_conf_t, ciphersuites),
+ NULL },
+
{ ngx_string("ssl_verify_client"),
NGX_STREAM_MAIN_CONF|NGX_STREAM_SRV_CONF|NGX_CONF_TAKE1,
ngx_conf_set_enum_slot,
@@ -511,6 +521,7 @@
* scf->trusted_certificate = { 0, NULL };
* scf->crl = { 0, NULL };
* scf->ciphers = { 0, NULL };
+ * scf->ciphersuites = { 0, NULL };
* scf->shm_zone = NULL;
*/

@@ -573,6 +584,9 @@

ngx_conf_merge_str_value(conf->ciphers, prev->ciphers, NGX_DEFAULT_CIPHERS);

+ ngx_conf_merge_str_value(conf->ciphersuites, prev->ciphersuites,
+ NGX_DEFAULT_CIPHERSUITES);
+

conf->ssl.log = cf->log;

@@ -627,7 +641,7 @@
}

if (ngx_ssl_ciphers(cf, &conf->ssl, &conf->ciphers,
- conf->prefer_server_ciphers)
+ &conf->ciphersuites, conf->prefer_server_ciphers)
!= NGX_OK)
{
return NGX_CONF_ERROR;
diff -r 4698cede59ff -r 83b05772dbd6 src/stream/ngx_stream_ssl_module.h
--- a/src/stream/ngx_stream_ssl_module.h Mon Nov 12 16:29:30 2018 +0300
+++ b/src/stream/ngx_stream_ssl_module.h Wed Nov 14 16:24:26 2018 -0800
@@ -42,6 +42,8 @@

ngx_str_t ciphers;

+ ngx_str_t ciphersuites;
+
ngx_array_t *passwords;

ngx_shm_zone_t *shm_zone;
Maxim Dounin
2018-11-15 14:53:53 UTC
Permalink
Hello!
Post by Ramprasad Tamilselvan
# HG changeset patch
# Date 1542241466 28800
# Wed Nov 14 16:24:26 2018 -0800
# Node ID 83b05772dbd657b31df16d712a64c908c371f0d9
# Parent 4698cede59ffa438bcae1fd6c5d8fec4d69b2c92
New directive to configure TLSv1.3 ciphers.
In openssl 1.1.1, a new API is introduced to configure ciphers
for TLSv1.3. A new directive ssl_ciphersuites will call the new
API to configure the ciphers for TLSv1.3.
Thank you for your patch.

I do object introducing a new directive for this, see this ticket
for details:

https://trac.nginx.org/nginx/ticket/1529
--
Maxim Dounin
http://mdounin.ru/
Ramprasad Tamilselvan
2018-11-15 18:55:27 UTC
Permalink
Thanks for the clarification.
In this case, I think the patch is not required.

Regards,
Ramprasad
Send nginx-devel mailing list submissions to
To subscribe or unsubscribe via the World Wide Web, visit
http://mailman.nginx.org/mailman/listinfo/nginx-devel
or, via email, send a message with subject or body 'help' to
You can reach the person managing the list at
When replying, please edit your Subject line so it is more specific
than "Re: Contents of nginx-devel digest..."
1. [nginx] Core: free shared memory on cycle initialization
failure. (Ruslan Ermilov)
2. Re: [PATCH] New directive to configure TLSv1.3 ciphers
(Maxim Dounin)
3. [njs] console.time() and console.timeEnd() methods.
(Dmitry Volyntsev)
4. [njs] Fixed global objects. (Dmitry Volyntsev)
5. [njs] Improved handling of builtin objects. (Dmitry Volyntsev)
----------------------------------------------------------------------
Message: 1
Date: Thu, 15 Nov 2018 14:19:57 +0000
Subject: [nginx] Core: free shared memory on cycle initialization
failure.
Content-Type: text/plain; charset="us-ascii"
details: http://hg.nginx.org/nginx/rev/650574a44505
changeset: 7394:650574a44505
date: Thu Nov 15 15:28:54 2018 +0300
Core: free shared memory on cycle initialization failure.
src/core/ngx_cycle.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 64 insertions(+), 0 deletions(-)
diff -r 4698cede59ff -r 650574a44505 src/core/ngx_cycle.c
--- a/src/core/ngx_cycle.c Mon Nov 12 16:29:30 2018 +0300
+++ b/src/core/ngx_cycle.c Thu Nov 15 15:28:54 2018 +0300
}
}
+ /* free the newly created shared memory */
+
+ part = &cycle->shared_memory.part;
+ shm_zone = part->elts;
+
+ for (i = 0; /* void */ ; i++) {
+
+ if (i >= part->nelts) {
+ if (part->next == NULL) {
+ break;
+ }
+ part = part->next;
+ shm_zone = part->elts;
+ i = 0;
+ }
+
+ if (shm_zone[i].shm.addr == NULL) {
+ continue;
+ }
+
+ opart = &old_cycle->shared_memory.part;
+ oshm_zone = opart->elts;
+
+ for (n = 0; /* void */ ; n++) {
+
+ if (n >= opart->nelts) {
+ if (opart->next == NULL) {
+ break;
+ }
+ opart = opart->next;
+ oshm_zone = opart->elts;
+ n = 0;
+ }
+
+ if (shm_zone[i].shm.name.len != oshm_zone[n].shm.name.len) {
+ continue;
+ }
+
+ if (ngx_strncmp(shm_zone[i].shm.name.data,
+ oshm_zone[n].shm.name.data,
+ shm_zone[i].shm.name.len)
+ != 0)
+ {
+ continue;
+ }
+
+ if (shm_zone[i].tag == oshm_zone[n].tag
+ && shm_zone[i].shm.size == oshm_zone[n].shm.size
+ && !shm_zone[i].noreuse)
+ {
+ goto old_shm_zone_found;
+ }
+
+ break;
+ }
+
+ ngx_shm_free(&shm_zone[i].shm);
+
+
+ continue;
+ }
+
if (ngx_test_config) {
ngx_destroy_cycle_pools(&conf);
return NULL;
@@ -1274,6 +1337,7 @@ ngx_shared_memory_add(ngx_conf_t *cf, ng
shm_zone->data = NULL;
shm_zone->shm.log = cf->cycle->log;
+ shm_zone->shm.addr = NULL;
shm_zone->shm.size = size;
shm_zone->shm.name = *name;
shm_zone->shm.exists = 0;
------------------------------
Message: 2
Date: Thu, 15 Nov 2018 17:53:53 +0300
Subject: Re: [PATCH] New directive to configure TLSv1.3 ciphers
Content-Type: text/plain; charset=us-ascii
Hello!
Post by Ramprasad Tamilselvan
# HG changeset patch
# Date 1542241466 28800
# Wed Nov 14 16:24:26 2018 -0800
# Node ID 83b05772dbd657b31df16d712a64c908c371f0d9
# Parent 4698cede59ffa438bcae1fd6c5d8fec4d69b2c92
New directive to configure TLSv1.3 ciphers.
In openssl 1.1.1, a new API is introduced to configure ciphers
for TLSv1.3. A new directive ssl_ciphersuites will call the new
API to configure the ciphers for TLSv1.3.
Thank you for your patch.
I do object introducing a new directive for this, see this ticket
https://trac.nginx.org/nginx/ticket/1529
--
Maxim Dounin
http://mdounin.ru/
------------------------------
Message: 3
Date: Thu, 15 Nov 2018 17:32:02 +0000
Subject: [njs] console.time() and console.timeEnd() methods.
Content-Type: text/plain; charset="utf-8"
details: http://hg.nginx.org/njs/rev/46632012ac03
changeset: 653:46632012ac03
date: Wed Nov 14 18:14:49 2018 +0300
console.time() and console.timeEnd() methods.
This fixes #62 issue on Github.
njs/njs_shell.c | 86 ++++++++++++++++++++++++++++++++++++++++++++
njs/test/njs_expect_test.exp | 18 ++++++++-
2 files changed, 103 insertions(+), 1 deletions(-)
diff -r 7f0f7d149709 -r 46632012ac03 njs/njs_shell.c
--- a/njs/njs_shell.c Thu Nov 15 12:45:02 2018 +0300
+++ b/njs/njs_shell.c Wed Nov 14 18:14:49 2018 +0300
@@ -14,6 +14,7 @@
#include <fcntl.h>
#include <stdlib.h>
#include <sys/stat.h>
+#include <sys/time.h>
#include <locale.h>
#include <readline.h>
@@ -63,6 +64,10 @@ static njs_ret_t njs_ext_console_dump(nj
nxt_uint_t nargs, njs_index_t unused);
static njs_ret_t njs_ext_console_help(njs_vm_t *vm, njs_value_t *args,
nxt_uint_t nargs, njs_index_t unused);
+static njs_ret_t njs_ext_console_time(njs_vm_t *vm, njs_value_t *args,
+ nxt_uint_t nargs, njs_index_t unused);
+static njs_ret_t njs_ext_console_time_end(njs_vm_t *vm, njs_value_t *args,
+ nxt_uint_t nargs, njs_index_t unused);
static njs_external_t njs_ext_console[] = {
@@ -102,6 +107,30 @@ static njs_external_t njs_ext_console[]
NULL,
njs_ext_console_help,
0 },
+
+ { nxt_string("time"),
+ NJS_EXTERN_METHOD,
+ NULL,
+ 0,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ njs_ext_console_time,
+ 0 },
+
+ { nxt_string("timeEnd"),
+ NJS_EXTERN_METHOD,
+ NULL,
+ 0,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ njs_ext_console_time_end,
+ 0 },
};
static njs_external_t njs_externals[] = {
@@ -123,6 +152,9 @@ static njs_external_t njs_externals[] =
static njs_completion_t njs_completion;
+static struct timeval njs_console_time;
+
+
int
main(int argc, char **argv)
{
@@ -727,3 +759,57 @@ njs_ext_console_help(njs_vm_t *vm, njs_v
return NJS_OK;
}
+
+
+static njs_ret_t
+njs_ext_console_time(njs_vm_t *vm, njs_value_t *args, nxt_uint_t nargs,
+ njs_index_t unused)
+{
+ if (!njs_value_is_void(njs_arg(args, nargs, 1))) {
+ njs_vm_error(vm, "labels not implemented");
+ return NJS_ERROR;
+ }
+
+ vm->retval = njs_value_void;
+
+ gettimeofday(&njs_console_time, NULL);
+
+ return NJS_OK;
+}
+
+
+static njs_ret_t
+njs_ext_console_time_end(njs_vm_t *vm, njs_value_t *args, nxt_uint_t nargs,
+ njs_index_t unused)
+{
+ int64_t us, ms;
+ struct timeval tv;
+
+ gettimeofday(&tv, NULL);
+
+ if (!njs_value_is_void(njs_arg(args, nargs, 1))) {
+ njs_vm_error(vm, "labels not implemented");
+ return NJS_ERROR;
+ }
+
+ if (nxt_fast_path(njs_console_time.tv_sec || njs_console_time.tv_usec)) {
+
+ us = ((int64_t) tv.tv_sec - njs_console_time.tv_sec) * 1000000
+ + ((int64_t) tv.tv_usec - njs_console_time.tv_usec);
+
+ ms = us / 1000;
+ us = us % 1000;
+
+ printf("default: %" PRIu64 ".%03" PRIu64 "ms\n", ms, us);
+
+ njs_console_time.tv_sec = 0;
+ njs_console_time.tv_usec = 0;
+
+ } else {
+ printf("Timer \"default\" doesn?t exist.\n");
+ }
+
+ vm->retval = njs_value_void;
+
+ return NJS_OK;
+}
diff -r 7f0f7d149709 -r 46632012ac03 njs/test/njs_expect_test.exp
--- a/njs/test/njs_expect_test.exp Thu Nov 15 12:45:02 2018 +0300
+++ b/njs/test/njs_expect_test.exp Wed Nov 14 18:14:49 2018 +0300
@@ -80,7 +80,7 @@ njs_test {
# Global completions, multiple partial match
njs_test {
{"cons\t\t"
- "console*console.help*console.log*const"}
+ "console*console.help*console.time*const"}
}
njs_test {
@@ -190,6 +190,22 @@ njs_test {
"console.help()\r\nVM built-in objects:"}
}
+# console.time* functions
+njs_test {
+ {"console.time()\r\n"
+ "console.time()\r\nundefined\r\n>> "}
+ {"console.time(undefined)\r\n"
+ "console.time(undefined)\r\nundefined\r\n>> "}
+ {"console.timeEnd()\r\n"
+ "console.timeEnd()\r\ndefault: *.*ms\r\nundefined\r\n>> "}
+ {"console.time('a')\r\n"
+ "console.time('a')\r\nError: labels not implemented"}
+ {"console.timeEnd('a')\r\n"
+ "console.timeEnd('a')\r\nError: labels not implemented"}
+ {"console.timeEnd()\r\n"
+ "console.timeEnd()\r\nTimer \"default\" doesn?t exist."}
+}
+
njs_test {
{"console.ll()\r\n"
"console.ll()\r\nTypeError: 'll' is not a function"}
------------------------------
Message: 4
Date: Thu, 15 Nov 2018 17:32:02 +0000
Subject: [njs] Fixed global objects.
Content-Type: text/plain; charset="us-ascii"
details: http://hg.nginx.org/njs/rev/e11011d45499
changeset: 655:e11011d45499
date: Thu Nov 15 20:31:35 2018 +0300
Fixed global objects.
1) Making it extensible.
2) Adding default properties according to ES5.1:15.1.1.
njs/njs_builtin.c | 27 +++++++++++++++++++++++++--
njs/test/njs_unit_test.c | 30 ++++++++++++++++++++++++++++++
2 files changed, 55 insertions(+), 2 deletions(-)
diff -r 2711e84ede6a -r e11011d45499 njs/njs_builtin.c
--- a/njs/njs_builtin.c Wed Apr 04 17:38:10 2018 +0300
+++ b/njs/njs_builtin.c Thu Nov 15 20:31:35 2018 +0300
@@ -276,6 +276,7 @@ njs_builtin_objects_create(njs_vm_t *vm)
}
object->shared = 1;
+ object->extensible = 1;
object++;
}
@@ -1118,8 +1119,30 @@ const njs_object_init_t njs_njs_object_
};
+static const njs_object_prop_t njs_global_this_object_properties[] =
+{
+ {
+ .type = NJS_PROPERTY,
+ .name = njs_string("NaN"),
+ .value = njs_value(NJS_NUMBER, 0, NAN),
+ },
+
+ {
+ .type = NJS_PROPERTY,
+ .name = njs_string("Infinity"),
+ .value = njs_value(NJS_NUMBER, 0, INFINITY),
+ },
+
+ {
+ .type = NJS_PROPERTY,
+ .name = njs_string("undefined"),
+ .value = njs_value(NJS_VOID, 0, NAN),
+ },
+};
+
+
const njs_object_init_t njs_global_this_init = {
nxt_string("this"),
- NULL,
- 0
+ njs_global_this_object_properties,
+ nxt_nitems(njs_global_this_object_properties)
};
diff -r 2711e84ede6a -r e11011d45499 njs/test/njs_unit_test.c
--- a/njs/test/njs_unit_test.c Wed Apr 04 17:38:10 2018 +0300
+++ b/njs/test/njs_unit_test.c Thu Nov 15 20:31:35 2018 +0300
@@ -6488,6 +6488,33 @@ static njs_unit_test_t njs_test[] =
{ nxt_string("this"),
nxt_string("[object Object]") },
+ { nxt_string("this.a = 1; this.a"),
+ nxt_string("1") },
+
+ { nxt_string("this.undefined = 42"),
+ nxt_string("TypeError: Cannot assign to read-only property 'undefined' of object") },
+
+ { nxt_string("this.Infinity = 42"),
+ nxt_string("TypeError: Cannot assign to read-only property 'Infinity' of object") },
+
+ { nxt_string("this.NaN = 42"),
+ nxt_string("TypeError: Cannot assign to read-only property 'NaN' of object") },
+
+ { nxt_string("typeof this.undefined"),
+ nxt_string("undefined") },
+
+ { nxt_string("typeof this.Infinity"),
+ nxt_string("number") },
+
+ { nxt_string("this.Infinity + 1"),
+ nxt_string("Infinity") },
+
+ { nxt_string("typeof this.NaN"),
+ nxt_string("number") },
+
+ { nxt_string("this.NaN + 1"),
+ nxt_string("NaN") },
+
{ nxt_string("njs"),
nxt_string("[object Object]") },
@@ -9177,6 +9204,9 @@ static njs_unit_test_t njs_test[] =
{ nxt_string("Math"),
nxt_string("[object Object]") },
+ { nxt_string("Math.x = function (x) {return 2*x;}; Math.x(3)"),
+ nxt_string("6") },
+
{ nxt_string("isNaN"),
nxt_string("[object Function]") },
------------------------------
Message: 5
Date: Thu, 15 Nov 2018 17:32:02 +0000
Subject: [njs] Improved handling of builtin objects.
Content-Type: text/plain; charset="us-ascii"
details: http://hg.nginx.org/njs/rev/2711e84ede6a
changeset: 654:2711e84ede6a
date: Wed Apr 04 17:38:10 2018 +0300
Improved handling of builtin objects.
The handling of njs_object_init_t arrays is unified across
njs_builtin.c functions.
njs/njs_builtin.c | 939 +++++++++++++++++++--------------------
njs/njs_crypto.c | 12 +
njs/njs_fs.c | 6 +
njs/njs_module.c | 16 -
njs/njs_module.h | 1 -
njs/njs_shell.c | 19 +-
njs/njs_vm.h | 7 -
njs/test/njs_expect_test.exp | 5 +
njs/test/njs_interactive_test.c | 5 +
9 files changed, 499 insertions(+), 511 deletions(-)
diff -r 46632012ac03 -r 2711e84ede6a njs/njs_builtin.c
--- a/njs/njs_builtin.c Wed Nov 14 18:14:49 2018 +0300
+++ b/njs/njs_builtin.c Wed Apr 04 17:38:10 2018 +0300
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Dmitry Volyntsev
* Copyright (C) NGINX, Inc.
*/
@@ -23,25 +24,30 @@ typedef struct {
} njs_function_init_t;
-static nxt_int_t njs_builtin_completions(njs_vm_t *vm, size_t *size,
- nxt_str_t *completions);
+static njs_ret_t njs_prototype_function(njs_vm_t *vm, njs_value_t *args,
+ nxt_uint_t nargs, njs_index_t unused);
static nxt_array_t *njs_vm_expression_completions(njs_vm_t *vm,
nxt_str_t *expression);
static nxt_array_t *njs_object_completions(njs_vm_t *vm, njs_object_t *object);
+
const njs_object_init_t njs_njs_object_init;
+const njs_object_init_t njs_global_this_init;
+
const njs_object_init_t *njs_object_init[] = {
- NULL, /* global this */
+ &njs_global_this_init, /* global this */
&njs_njs_object_init, /* global njs object */
&njs_math_object_init, /* Math */
&njs_json_object_init, /* JSON */
+ NULL
};
const njs_object_init_t *njs_module_init[] = {
&njs_fs_object_init, /* fs */
- &njs_crypto_object_init /* crypto */
+ &njs_crypto_object_init, /* crypto */
+ NULL
};
@@ -64,6 +70,7 @@ const njs_object_init_t *njs_prototype_
&njs_syntax_error_prototype_init,
&njs_type_error_prototype_init,
&njs_uri_error_prototype_init,
+ NULL
};
@@ -87,6 +94,7 @@ const njs_object_init_t *njs_construc
&njs_type_error_constructor_init,
&njs_uri_error_constructor_init,
&njs_memory_error_constructor_init,
+ NULL
};
@@ -103,7 +111,8 @@ const njs_object_init_t *njs_function
&njs_decode_uri_component_function_init,
&njs_require_function_init,
&njs_set_timeout_function_init,
- &njs_clear_timeout_function_init
+ &njs_clear_timeout_function_init,
+ NULL
};
@@ -143,102 +152,95 @@ const njs_object_prop_t njs_arguments_o
};
-static njs_ret_t
-njs_prototype_function(njs_vm_t *vm, njs_value_t *args, nxt_uint_t nargs,
- njs_index_t unused)
-{
- vm->retval = njs_value_void;
+const njs_function_init_t njs_native_constructors[] = {
+ /* SunC does not allow empty array initialization. */
+ { njs_object_constructor, { 0 } },
+ { njs_array_constructor, { 0 } },
+ { njs_boolean_constructor, { 0 } },
+ { njs_number_constructor, { NJS_SKIP_ARG, NJS_NUMBER_ARG } },
+ { njs_string_constructor, { NJS_SKIP_ARG, NJS_STRING_ARG } },
+ { njs_function_constructor, { 0 } },
+ { njs_regexp_constructor,
+ { NJS_SKIP_ARG, NJS_STRING_ARG, NJS_STRING_ARG } },
+ { njs_date_constructor, { 0 } },
+ { njs_hash_constructor, { NJS_SKIP_ARG, NJS_STRING_ARG } },
+ { njs_hmac_constructor, { NJS_SKIP_ARG, NJS_STRING_ARG,
+ NJS_STRING_ARG } },
+ { njs_error_constructor, { NJS_SKIP_ARG, NJS_STRING_ARG } },
+ { njs_eval_error_constructor, { NJS_SKIP_ARG, NJS_STRING_ARG } },
+ { njs_internal_error_constructor,
+ { NJS_SKIP_ARG, NJS_STRING_ARG } },
+ { njs_range_error_constructor,
+ { NJS_SKIP_ARG, NJS_STRING_ARG } },
+ { njs_reference_error_constructor, { NJS_SKIP_ARG, NJS_STRING_ARG } },
+ { njs_syntax_error_constructor,
+ { NJS_SKIP_ARG, NJS_STRING_ARG } },
+ { njs_type_error_constructor, { NJS_SKIP_ARG, NJS_STRING_ARG } },
+ { njs_uri_error_constructor, { NJS_SKIP_ARG, NJS_STRING_ARG } },
+ { njs_memory_error_constructor, { NJS_SKIP_ARG, NJS_STRING_ARG } },
+};
+
+const njs_object_prototype_t njs_prototype_values[] = {
+ /*
+ * GCC 4 complains about uninitialized .shared field,
+ * if the .type field is initialized as .object.type.
+ */
+ { .object = { .type = NJS_OBJECT } },
+ { .object = { .type = NJS_ARRAY } },
- return NXT_OK;
-}
+ /*
+ * The .object.type field must be initialzed after the .value field,
+ * otherwise SunC 5.9 treats the .value as .object.value or so.
+ */
+ { .object_value = { .value = njs_value(NJS_BOOLEAN, 0, 0.0),
+ .object = { .type = NJS_OBJECT_BOOLEAN } } },
+
+ { .object_value = { .value = njs_value(NJS_NUMBER, 0, 0.0),
+ .object = { .type = NJS_OBJECT_NUMBER } } },
+
+ { .object_value = { .value = njs_string(""),
+ .object = { .type = NJS_OBJECT_STRING } } },
+
+ { .function = { .native = 1,
+ .args_offset = 1,
+ .u.native = njs_prototype_function,
+ .object = { .type = NJS_FUNCTION } } },
+
+ { .object = { .type = NJS_REGEXP } },
+
+ { .date = { .time = NAN,
+ .object = { .type = NJS_DATE } } },
+
+ { .object_value = { .value = njs_value(NJS_DATA, 0, 0.0),
+ .object = { .type = NJS_OBJECT } } },
+
+ { .object_value = { .value = njs_value(NJS_DATA, 0, 0.0),
+ .object = { .type = NJS_OBJECT } } },
+
+ { .object = { .type = NJS_OBJECT_ERROR } },
+ { .object = { .type = NJS_OBJECT_EVAL_ERROR } },
+ { .object = { .type = NJS_OBJECT_INTERNAL_ERROR } },
+ { .object = { .type = NJS_OBJECT_RANGE_ERROR } },
+ { .object = { .type = NJS_OBJECT_REF_ERROR } },
+ { .object = { .type = NJS_OBJECT_SYNTAX_ERROR } },
+ { .object = { .type = NJS_OBJECT_TYPE_ERROR } },
+ { .object = { .type = NJS_OBJECT_URI_ERROR } },
+ { .object = { .type = NJS_OBJECT_INTERNAL_ERROR } },
+};
+
nxt_int_t
njs_builtin_objects_create(njs_vm_t *vm)
{
- nxt_int_t ret;
- nxt_uint_t i;
- njs_module_t *module;
- njs_object_t *objects;
- njs_function_t *functions, *constructors;
- nxt_lvlhsh_query_t lhq;
- njs_object_prototype_t *prototypes;
-
- static const njs_object_prototype_t prototype_values[] = {
- /*
- * GCC 4 complains about uninitialized .shared field,
- * if the .type field is initialized as .object.type.
- */
- { .object = { .type = NJS_OBJECT } },
- { .object = { .type = NJS_ARRAY } },
-
- /*
- * The .object.type field must be initialzed after the .value field,
- * otherwise SunC 5.9 treats the .value as .object.value or so.
- */
- { .object_value = { .value = njs_value(NJS_BOOLEAN, 0, 0.0),
- .object = { .type = NJS_OBJECT_BOOLEAN } } },
-
- { .object_value = { .value = njs_value(NJS_NUMBER, 0, 0.0),
- .object = { .type = NJS_OBJECT_NUMBER } } },
-
- { .object_value = { .value = njs_string(""),
- .object = { .type = NJS_OBJECT_STRING } } },
-
- { .function = { .native = 1,
- .args_offset = 1,
- .u.native = njs_prototype_function,
- .object = { .type = NJS_FUNCTION } } },
-
- { .object = { .type = NJS_REGEXP } },
-
- { .date = { .time = NAN,
- .object = { .type = NJS_DATE } } },
-
- { .object_value = { .value = njs_value(NJS_DATA, 0, 0.0),
- .object = { .type = NJS_OBJECT } } },
-
- { .object_value = { .value = njs_value(NJS_DATA, 0, 0.0),
- .object = { .type = NJS_OBJECT } } },
-
- { .object = { .type = NJS_OBJECT_ERROR } },
- { .object = { .type = NJS_OBJECT_EVAL_ERROR } },
- { .object = { .type = NJS_OBJECT_INTERNAL_ERROR } },
- { .object = { .type = NJS_OBJECT_RANGE_ERROR } },
- { .object = { .type = NJS_OBJECT_REF_ERROR } },
- { .object = { .type = NJS_OBJECT_SYNTAX_ERROR } },
- { .object = { .type = NJS_OBJECT_TYPE_ERROR } },
- { .object = { .type = NJS_OBJECT_URI_ERROR } },
- { .object = { .type = NJS_OBJECT_INTERNAL_ERROR } },
- };
-
- static const njs_function_init_t native_constructors[] = {
- /* SunC does not allow empty array initialization. */
- { njs_object_constructor, { 0 } },
- { njs_array_constructor, { 0 } },
- { njs_boolean_constructor, { 0 } },
- { njs_number_constructor, { NJS_SKIP_ARG, NJS_NUMBER_ARG } },
- { njs_string_constructor, { NJS_SKIP_ARG, NJS_STRING_ARG } },
- { njs_function_constructor, { 0 } },
- { njs_regexp_constructor,
- { NJS_SKIP_ARG, NJS_STRING_ARG, NJS_STRING_ARG } },
- { njs_date_constructor, { 0 } },
- { njs_hash_constructor, { NJS_SKIP_ARG, NJS_STRING_ARG } },
- { njs_hmac_constructor, { NJS_SKIP_ARG, NJS_STRING_ARG,
- NJS_STRING_ARG } },
- { njs_error_constructor, { NJS_SKIP_ARG, NJS_STRING_ARG } },
- { njs_eval_error_constructor, { NJS_SKIP_ARG, NJS_STRING_ARG } },
- { njs_internal_error_constructor,
- { NJS_SKIP_ARG, NJS_STRING_ARG } },
- { njs_range_error_constructor,
- { NJS_SKIP_ARG, NJS_STRING_ARG } },
- { njs_reference_error_constructor, { NJS_SKIP_ARG, NJS_STRING_ARG } },
- { njs_syntax_error_constructor,
- { NJS_SKIP_ARG, NJS_STRING_ARG } },
- { njs_type_error_constructor, { NJS_SKIP_ARG, NJS_STRING_ARG } },
- { njs_uri_error_constructor, { NJS_SKIP_ARG, NJS_STRING_ARG } },
- { njs_memory_error_constructor, { NJS_SKIP_ARG, NJS_STRING_ARG } },
- };
+ nxt_int_t ret;
+ njs_module_t *module;
+ njs_object_t *object;
+ njs_function_t *func;
+ nxt_lvlhsh_query_t lhq;
+ njs_object_prototype_t *prototype;
+ const njs_object_init_t *obj, **p;
+ const njs_function_init_t *f;
static const njs_object_prop_t function_prototype_property = {
.type = NJS_PROPERTY_HANDLER,
@@ -246,6 +248,8 @@ njs_builtin_objects_create(njs_vm_t *vm)
.value = njs_prop_handler(njs_function_prototype_create),
};
+ static const nxt_str_t sandbox_key = nxt_string("sandbox");
+
ret = njs_object_hash_create(vm, &vm->shared->function_prototype_hash,
&function_prototype_property, 1);
if (nxt_slow_path(ret != NXT_OK)) {
@@ -259,48 +263,57 @@ njs_builtin_objects_create(njs_vm_t *vm)
return NXT_ERROR;
}
- objects = vm->shared->objects;
+ object = vm->shared->objects;
+
+ for (p = njs_object_init; *p != NULL; p++) {
+ obj = *p;
- for (i = NJS_OBJECT_THIS; i < NJS_OBJECT_MAX; i++) {
- if (njs_object_init[i] != NULL) {
- ret = njs_object_hash_create(vm, &objects[i].shared_hash,
- njs_object_init[i]->properties,
- njs_object_init[i]->items);
- if (nxt_slow_path(ret != NXT_OK)) {
- return NXT_ERROR;
- }
+ ret = njs_object_hash_create(vm, &object->shared_hash,
+ obj->properties, obj->items);
+
+ if (nxt_slow_path(ret != NXT_OK)) {
+ return NXT_ERROR;
}
- objects[i].shared = 1;
+ object->shared = 1;
+
+ object++;
}
lhq.replace = 0;
- lhq.proto = &njs_modules_hash_proto;
lhq.pool = vm->mem_cache_pool;
- for (i = NJS_MODULE_FS; i < NJS_MODULE_MAX; i++) {
- if (vm->options.sandbox && !njs_sandbox_module(i)) {
- continue;
- }
+ for (p = njs_module_init; *p != NULL; p++) {
+ obj = *p;
module = nxt_mem_cache_zalloc(vm->mem_cache_pool, sizeof(njs_module_t));
if (nxt_slow_path(module == NULL)) {
return NJS_ERROR;
}
- module->name = njs_module_init[i]->name;
-
ret = njs_object_hash_create(vm, &module->object.shared_hash,
- njs_module_init[i]->properties,
- njs_module_init[i]->items);
+ obj->properties, obj->items);
if (nxt_slow_path(ret != NXT_OK)) {
return NXT_ERROR;
}
+ if (vm->options.sandbox) {
+ lhq.key = sandbox_key;
+ lhq.key_hash = nxt_djb_hash(sandbox_key.start, sandbox_key.length);
+ lhq.proto = &njs_object_hash_proto;
+
+ ret = nxt_lvlhsh_find(&module->object.shared_hash, &lhq);
+ if (nxt_fast_path(ret != NXT_OK)) {
+ continue;
+ }
+ }
+
+ module->name = obj->name;
module->object.shared = 1;
lhq.key = module->name;
lhq.key_hash = nxt_djb_hash(lhq.key.start, lhq.key.length);
+ lhq.proto = &njs_modules_hash_proto;
lhq.value = module;
ret = nxt_lvlhsh_insert(&vm->modules_hash, &lhq);
@@ -309,73 +322,88 @@ njs_builtin_objects_create(njs_vm_t *vm)
}
}
- functions = vm->shared->functions;
+ f = njs_native_functions;
+ func = vm->shared->functions;
- for (i = NJS_FUNCTION_EVAL; i < NJS_FUNCTION_MAX; i++) {
- if (njs_function_init[i]->items != 0) {
- ret = njs_object_hash_create(vm, &functions[i].object.shared_hash,
- njs_function_init[i]->properties,
- njs_function_init[i]->items);
- if (nxt_slow_path(ret != NXT_OK)) {
- return NXT_ERROR;
- }
+ for (p = njs_function_init; *p != NULL; p++) {
+ obj = *p;
+
+ ret = njs_object_hash_create(vm, &func->object.shared_hash,
+ obj->properties, obj->items);
+ if (nxt_slow_path(ret != NXT_OK)) {
+ return NXT_ERROR;
}
- functions[i].object.shared = 1;
- functions[i].object.extensible = 1;
- functions[i].native = 1;
- functions[i].args_offset = 1;
- functions[i].u.native = njs_native_functions[i].native;
- functions[i].args_types[0] = njs_native_functions[i].args_types[0];
- functions[i].args_types[1] = njs_native_functions[i].args_types[1];
- functions[i].args_types[2] = njs_native_functions[i].args_types[2];
- functions[i].args_types[3] = njs_native_functions[i].args_types[3];
- functions[i].args_types[4] = njs_native_functions[i].args_types[4];
+ func->object.shared = 1;
+ func->object.extensible = 1;
+ func->native = 1;
+ func->args_offset = 1;
+
+ func->u.native = f->native;
+ memcpy(func->args_types, f->args_types, NJS_ARGS_TYPES_MAX);
+
+ f++;
+ func++;
}
- prototypes = vm->shared->prototypes;
+ prototype = vm->shared->prototypes;
+ memcpy(prototype, njs_prototype_values, sizeof(njs_prototype_values));
- for (i = NJS_PROTOTYPE_OBJECT; i < NJS_PROTOTYPE_MAX; i++) {
- prototypes[i] = prototype_values[i];
+ for (p = njs_prototype_init; *p != NULL; p++) {
+ obj = *p;
- ret = njs_object_hash_create(vm, &prototypes[i].object.shared_hash,
- njs_prototype_init[i]->properties,
- njs_prototype_init[i]->items);
+ ret = njs_object_hash_create(vm, &prototype->object.shared_hash,
+ obj->properties, obj->items);
if (nxt_slow_path(ret != NXT_OK)) {
return NXT_ERROR;
}
+
+ prototype++;
}
- prototypes[NJS_PROTOTYPE_REGEXP].regexp.pattern =
+ vm->shared->prototypes[NJS_PROTOTYPE_REGEXP].regexp.pattern =
vm->shared->empty_regexp_pattern;
- constructors = vm->shared->constructors;
+ f = njs_native_constructors;
+ func = vm->shared->constructors;
+
+ for (p = njs_constructor_init; *p != NULL; p++) {
+ obj = *p;
- for (i = NJS_CONSTRUCTOR_OBJECT; i < NJS_CONSTRUCTOR_MAX; i++) {
- constructors[i].object.shared = 0;
- constructors[i].object.extensible = 1;
- constructors[i].native = 1;
- constructors[i].ctor = 1;
- constructors[i].args_offset = 1;
- constructors[i].u.native = native_constructors[i].native;
- constructors[i].args_types[0] = native_constructors[i].args_types[0];
- constructors[i].args_types[1] = native_constructors[i].args_types[1];
- constructors[i].args_types[2] = native_constructors[i].args_types[2];
- constructors[i].args_types[3] = native_constructors[i].args_types[3];
- constructors[i].args_types[4] = native_constructors[i].args_types[4];
+ func->object.shared = 0;
+ func->object.extensible = 1;
+ func->native = 1;
+ func->ctor = 1;
+ func->args_offset = 1;
- ret = njs_object_hash_create(vm, &constructors[i].object.shared_hash,
- njs_constructor_init[i]->properties,
- njs_constructor_init[i]->items);
+ func->u.native = f->native;
+
+ memcpy(func->args_types, f->args_types, NJS_ARGS_TYPES_MAX);
+
+ ret = njs_object_hash_create(vm, &func->object.shared_hash,
+ obj->properties, obj->items);
if (nxt_slow_path(ret != NXT_OK)) {
return NXT_ERROR;
}
+
+ f++;
+ func++;
}
return NXT_OK;
}
+static njs_ret_t
+njs_prototype_function(njs_vm_t *vm, njs_value_t *args, nxt_uint_t nargs,
+ njs_index_t unused)
+{
+ vm->retval = njs_value_void;
+
+ return NXT_OK;
+}
+
+
/*
* Object(),
* Object.__proto__ -> Function_Prototype,
@@ -493,53 +521,15 @@ njs_builtin_objects_clone(njs_vm_t *vm)
}
-nxt_array_t *
-njs_vm_completions(njs_vm_t *vm, nxt_str_t *expression)
+static size_t
+njs_builtin_completions_size(njs_vm_t *vm)
{
- size_t size;
- nxt_array_t *completions;
-
- if (expression == NULL) {
- if (njs_builtin_completions(vm, &size, NULL) != NXT_OK) {
- return NULL;
- }
-
- completions = nxt_array_create(size, sizeof(nxt_str_t),
- &njs_array_mem_proto,
- vm->mem_cache_pool);
-
- if (nxt_slow_path(completions == NULL)) {
- return NULL;
- }
-
- if (njs_builtin_completions(vm, &size, completions->start) != NXT_OK) {
- return NULL;
- }
-
- completions->items = size;
-
- return completions;
- }
-
- return njs_vm_expression_completions(vm, expression);
-}
-
-
-static nxt_int_t
-njs_builtin_completions(njs_vm_t *vm, size_t *size, nxt_str_t *completions)
-{
- char *compl;
- size_t n, len;
- nxt_str_t string;
- nxt_uint_t i, k;
- njs_object_t *objects;
- njs_keyword_t *keyword;
- njs_function_t *constructors;
- njs_object_prop_t *prop;
- nxt_lvlhsh_each_t lhe, lhe_prop;
- njs_extern_value_t *ev;
- const njs_extern_t *ext_proto, *ext_prop;
- njs_object_prototype_t *prototypes;
+ nxt_uint_t n;
+ njs_keyword_t *keyword;
+ nxt_lvlhsh_each_t lhe, lhe_prop;
+ njs_extern_value_t *ev;
+ const njs_extern_t *ext_proto, *ext_prop;
+ const njs_object_init_t **p;
n = 0;
@@ -552,123 +542,147 @@ njs_builtin_completions(njs_vm_t *vm, si
break;
}
- if (completions != NULL) {
- completions[n++] = keyword->name;
+ n++;
+ }
+
+ for (p = njs_object_init; *p != NULL; p++) {
+ n += (*p)->items;
+ }
+
+ for (p = njs_prototype_init; *p != NULL; p++) {
+ n += (*p)->items;
+ }
+
+ for (p = njs_constructor_init; *p != NULL; p++) {
+ n += (*p)->items;
+ }
+
+ nxt_lvlhsh_each_init(&lhe, &njs_extern_value_hash_proto);
- } else {
+ for ( ;; ) {
+ ev = nxt_lvlhsh_each(&vm->externals_hash, &lhe);
+
+ if (ev == NULL) {
+ break;
+ }
+
+ ext_proto = ev->value.external.proto;
+
+ nxt_lvlhsh_each_init(&lhe_prop, &njs_extern_hash_proto);
+
+ n++;
+
+ for ( ;; ) {
+ ext_prop = nxt_lvlhsh_each(&ext_proto->hash, &lhe_prop);
+
+ if (ext_prop == NULL) {
+ break;
+ }
+
n++;
}
}
- objects = vm->shared->objects;
+ return n;
+}
+
- for (i = NJS_OBJECT_THIS; i < NJS_OBJECT_MAX; i++) {
- if (njs_object_init[i] == NULL) {
- continue;
+static nxt_array_t *
+njs_builtin_completions(njs_vm_t *vm, nxt_array_t *array)
+{
+ char *compl;
+ size_t n, len;
+ nxt_str_t string, *completions;
+ nxt_uint_t i, k;
+ njs_keyword_t *keyword;
+ nxt_lvlhsh_each_t lhe, lhe_prop;
+ njs_extern_value_t *ev;
+ const njs_extern_t *ext_proto, *ext_prop;
+ const njs_object_prop_t *prop;
+ const njs_object_init_t *obj, **p;
+
+ n = 0;
+ completions = array->start;
+
+ nxt_lvlhsh_each_init(&lhe, &njs_keyword_hash_proto);
+
+ for ( ;; ) {
+ keyword = nxt_lvlhsh_each(&vm->shared->keywords_hash, &lhe);
+
+ if (keyword == NULL) {
+ break;
}
- nxt_lvlhsh_each_init(&lhe, &njs_object_hash_proto);
+ completions[n++] = keyword->name;
+ }
+
+ for (p = njs_object_init; *p != NULL; p++) {
+ obj = *p;
- for ( ;; ) {
- prop = nxt_lvlhsh_each(&objects[i].shared_hash, &lhe);
+ for (i = 0; i < obj->items; i++) {
+ prop = &obj->properties[i];
+ njs_string_get(&prop->name, &string);
+ len = obj->name.length + string.length + 2;
- if (prop == NULL) {
- break;
+ compl = nxt_mem_cache_zalloc(vm->mem_cache_pool, len);
+ if (compl == NULL) {
+ return NULL;
}
- if (completions != NULL) {
- njs_string_get(&prop->name, &string);
- len = njs_object_init[i]->name.length + string.length + 2;
+ snprintf(compl, len, "%s.%s", obj->name.start, string.start);
+
+ completions[n].length = len;
+ completions[n++].start = (u_char *) compl;
+ }
+ }
+
+ for (p = njs_prototype_init; *p != NULL; p++) {
+ obj = *p;
+
+ for (i = 0; i < obj->items; i++) {
+ prop = &obj->properties[i];
+ njs_string_get(&prop->name, &string);
+ len = string.length + 2;
- compl = nxt_mem_cache_zalloc(vm->mem_cache_pool, len);
- if (compl == NULL) {
- return NXT_ERROR;
+ compl = nxt_mem_cache_zalloc(vm->mem_cache_pool, len);
+ if (compl == NULL) {
+ return NULL;
+ }
+
+ snprintf(compl, len, ".%s", string.start);
+
+ for (k = 0; k < n; k++) {
+ if (strncmp((char *) completions[k].start, compl, len)
+ == 0)
+ {
+ break;
}
+ }
- snprintf(compl, len, "%s.%s", njs_object_init[i]->name.start,
- string.start);
-
+ if (k == n) {
completions[n].length = len;
completions[n++].start = (u_char *) compl;
-
- } else {
- n++;
}
}
}
- prototypes = vm->shared->prototypes;
-
- for (i = NJS_PROTOTYPE_OBJECT; i < NJS_PROTOTYPE_MAX; i++) {
- nxt_lvlhsh_each_init(&lhe, &njs_object_hash_proto);
+ for (p = njs_constructor_init; *p != NULL; p++) {
+ obj = *p;
- for ( ;; ) {
- prop = nxt_lvlhsh_each(&prototypes[i].object.shared_hash, &lhe);
+ for (i = 0; i < obj->items; i++) {
+ prop = &obj->properties[i];
+ njs_string_get(&prop->name, &string);
+ len = obj->name.length + string.length + 2;
- if (prop == NULL) {
- break;
+ compl = nxt_mem_cache_zalloc(vm->mem_cache_pool, len);
+ if (compl == NULL) {
+ return NULL;
}
- if (completions != NULL) {
- njs_string_get(&prop->name, &string);
- len = string.length + 2;
-
- compl = nxt_mem_cache_zalloc(vm->mem_cache_pool, len);
- if (compl == NULL) {
- return NXT_ERROR;
- }
-
- snprintf(compl, len, ".%s", string.start);
-
- for (k = 0; k < n; k++) {
- if (strncmp((char *) completions[k].start, compl, len)
- == 0)
- {
- break;
- }
- }
-
- if (k == n) {
- completions[n].length = len;
- completions[n++].start = (u_char *) compl;
- }
-
- } else {
- n++;
- }
- }
- }
+ snprintf(compl, len, "%s.%s", obj->name.start, string.start);
- constructors = vm->shared->constructors;
-
- for (i = NJS_CONSTRUCTOR_OBJECT; i < NJS_CONSTRUCTOR_MAX; i++) {
- nxt_lvlhsh_each_init(&lhe, &njs_object_hash_proto);
-
- for ( ;; ) {
- prop = nxt_lvlhsh_each(&constructors[i].object.shared_hash, &lhe);
-
- if (prop == NULL) {
- break;
- }
-
- if (completions != NULL) {
- njs_string_get(&prop->name, &string);
- len = njs_constructor_init[i]->name.length + string.length + 2;
-
- compl = nxt_mem_cache_zalloc(vm->mem_cache_pool, len);
- if (compl == NULL) {
- return NXT_ERROR;
- }
-
- snprintf(compl, len, "%s.%s",
- njs_constructor_init[i]->name.start, string.start);
-
- completions[n].length = len;
- completions[n++].start = (u_char *) compl;
-
- } else {
- n++;
- }
+ completions[n].length = len;
+ completions[n++].start = (u_char *) compl;
}
}
@@ -685,21 +699,16 @@ njs_builtin_completions(njs_vm_t *vm, si
nxt_lvlhsh_each_init(&lhe_prop, &njs_extern_hash_proto);
- if (completions != NULL) {
- len = ev->name.length + 1;
- compl = nxt_mem_cache_zalloc(vm->mem_cache_pool, len);
- if (compl == NULL) {
- return NXT_ERROR;
- }
+ len = ev->name.length + 1;
+ compl = nxt_mem_cache_zalloc(vm->mem_cache_pool, len);
+ if (compl == NULL) {
+ return NULL;
+ }
- snprintf(compl, len, "%.*s", (int) ev->name.length, ev->name.start);
+ snprintf(compl, len, "%.*s", (int) ev->name.length, ev->name.start);
- completions[n].length = len;
- completions[n++].start = (u_char *) compl;
-
- } else {
- n++;
- }
+ completions[n].length = len;
+ completions[n++].start = (u_char *) compl;
for ( ;; ) {
ext_prop = nxt_lvlhsh_each(&ext_proto->hash, &lhe_prop);
@@ -708,31 +717,48 @@ njs_builtin_completions(njs_vm_t *vm, si
break;
}
- if (completions != NULL) {
- len = ev->name.length + ev->name.length + 2;
- compl = nxt_mem_cache_zalloc(vm->mem_cache_pool, len);
- if (compl == NULL) {
- return NXT_ERROR;
- }
+ len = ev->name.length + ev->name.length + 2;
+ compl = nxt_mem_cache_zalloc(vm->mem_cache_pool, len);
+ if (compl == NULL) {
+ return NULL;
+ }
- snprintf(compl, len, "%.*s.%.*s", (int) ev->name.length,
- ev->name.start, (int) ext_prop->name.length,
- ext_prop->name.start);
+ snprintf(compl, len, "%.*s.%.*s", (int) ev->name.length,
+ ev->name.start, (int) ext_prop->name.length,
+ ext_prop->name.start);
- completions[n].length = len;
- completions[n++].start = (u_char *) compl;
-
- } else {
- n++;
- }
+ completions[n].length = len;
+ completions[n++].start = (u_char *) compl;
}
}
- if (size) {
- *size = n;
+ array->items = n;
+
+ return array;
+}
+
+
+nxt_array_t *
+njs_vm_completions(njs_vm_t *vm, nxt_str_t *expression)
+{
+ size_t size;
+ nxt_array_t *completions;
+
+ if (expression == NULL) {
+ size = njs_builtin_completions_size(vm);
+
+ completions = nxt_array_create(size, sizeof(nxt_str_t),
+ &njs_array_mem_proto,
+ vm->mem_cache_pool);
+
+ if (nxt_slow_path(completions == NULL)) {
+ return NULL;
+ }
+
+ return njs_builtin_completions(vm, completions);
}
- return NXT_OK;
+ return njs_vm_expression_completions(vm, expression);
}
@@ -911,185 +937,135 @@ njs_object_completions(njs_vm_t *vm, njs
}
-nxt_int_t
-njs_builtin_match_native_function(njs_vm_t *vm, njs_function_t *function,
- nxt_str_t *name)
+static nxt_int_t
+njs_builtin_match(const njs_object_init_t **objects, njs_function_t *function,
+ const njs_object_prop_t **prop, const njs_object_init_t **object)
{
- char *buf;
- size_t len;
- nxt_str_t string;
- nxt_uint_t i;
- njs_module_t *module;
- njs_object_t *objects;
- njs_function_t *constructors;
- njs_object_prop_t *prop;
- nxt_lvlhsh_each_t lhe, lhe_prop;
- njs_object_prototype_t *prototypes;
+ nxt_uint_t i;
+ const njs_object_init_t *o, **p;
+ const njs_object_prop_t *pr;
- objects = vm->shared->objects;
-
- for (i = NJS_OBJECT_THIS; i < NJS_OBJECT_MAX; i++) {
- if (njs_object_init[i] == NULL) {
- continue;
- }
-
- nxt_lvlhsh_each_init(&lhe, &njs_object_hash_proto);
+ for (p = objects; *p != NULL; p++) {
+ o = *p;
- for ( ;; ) {
- prop = nxt_lvlhsh_each(&objects[i].shared_hash, &lhe);
+ for (i = 0; i < o->items; i++) {
+ pr = &o->properties[i];
- if (prop == NULL) {
- break;
- }
-
- if (!njs_is_function(&prop->value)) {
+ if (pr->type != NJS_METHOD) {
continue;
}
- if (function == prop->value.data.u.function) {
- njs_string_get(&prop->name, &string);
- len = njs_object_init[i]->name.length + string.length
- + sizeof(".");
-
- buf = nxt_mem_cache_zalloc(vm->mem_cache_pool, len);
- if (buf == NULL) {
- return NXT_ERROR;
- }
-
- snprintf(buf, len, "%s.%s", njs_object_init[i]->name.start,
- string.start);
-
- name->length = len;
- name->start = (u_char *) buf;
-
- return NXT_OK;
- }
- }
- }
-
- prototypes = vm->shared->prototypes;
-
- for (i = NJS_PROTOTYPE_OBJECT; i < NJS_PROTOTYPE_MAX; i++) {
- nxt_lvlhsh_each_init(&lhe, &njs_object_hash_proto);
-
- for ( ;; ) {
- prop = nxt_lvlhsh_each(&prototypes[i].object.shared_hash, &lhe);
-
- if (prop == NULL) {
- break;
- }
-
- if (!njs_is_function(&prop->value)) {
+ if (function != pr->value.data.u.function) {
continue;
}
- if (function == prop->value.data.u.function) {
- njs_string_get(&prop->name, &string);
- len = njs_prototype_init[i]->name.length + string.length
- + sizeof(".prototype.");
-
- buf = nxt_mem_cache_zalloc(vm->mem_cache_pool, len);
- if (buf == NULL) {
- return NXT_ERROR;
- }
-
- snprintf(buf, len, "%s.prototype.%s",
- njs_prototype_init[i]->name.start, string.start);
-
- name->length = len;
- name->start = (u_char *) buf;
-
- return NXT_OK;
- }
- }
- }
-
- constructors = vm->shared->constructors;
-
- for (i = NJS_CONSTRUCTOR_OBJECT; i < NJS_CONSTRUCTOR_MAX; i++) {
- nxt_lvlhsh_each_init(&lhe, &njs_object_hash_proto);
-
- for ( ;; ) {
- prop = nxt_lvlhsh_each(&constructors[i].object.shared_hash, &lhe);
-
- if (prop == NULL) {
- break;
- }
-
- if (!njs_is_function(&prop->value)) {
- continue;
- }
-
- if (function == prop->value.data.u.function) {
- njs_string_get(&prop->name, &string);
------------------------------
Subject: Digest Footer
_______________________________________________
nginx-devel mailing list
http://mailman.nginx.org/mailman/listinfo/nginx-devel
------------------------------
End of nginx-devel Digest, Vol 109, Issue 15
********************************************
Ramprasad Tamilselvan
2018-11-15 20:17:15 UTC
Permalink
I have a question regarding the ticket.
What if different TLSv1.3 ciphers need to be configured in different server blocks?
In this case, changing openssl.conf will not help right.

Thanks,
Ramprasad
Send nginx-devel mailing list submissions to
To subscribe or unsubscribe via the World Wide Web, visit
http://mailman.nginx.org/mailman/listinfo/nginx-devel
or, via email, send a message with subject or body 'help' to
You can reach the person managing the list at
When replying, please edit your Subject line so it is more specific
than "Re: Contents of nginx-devel digest..."
1. Re: [PATCH] New directive to configure TLSv1.3 ciphers
(Ramprasad Tamilselvan)
----------------------------------------------------------------------
Message: 1
Date: Thu, 15 Nov 2018 10:55:27 -0800
Subject: Re: [PATCH] New directive to configure TLSv1.3 ciphers
Content-Type: text/plain; charset=us-ascii
Thanks for the clarification.
In this case, I think the patch is not required.
Regards,
Ramprasad
Send nginx-devel mailing list submissions to
To subscribe or unsubscribe via the World Wide Web, visit
http://mailman.nginx.org/mailman/listinfo/nginx-devel
or, via email, send a message with subject or body 'help' to
You can reach the person managing the list at
When replying, please edit your Subject line so it is more specific
than "Re: Contents of nginx-devel digest..."
1. [nginx] Core: free shared memory on cycle initialization
failure. (Ruslan Ermilov)
2. Re: [PATCH] New directive to configure TLSv1.3 ciphers
(Maxim Dounin)
3. [njs] console.time() and console.timeEnd() methods.
(Dmitry Volyntsev)
4. [njs] Fixed global objects. (Dmitry Volyntsev)
5. [njs] Improved handling of builtin objects. (Dmitry Volyntsev)
----------------------------------------------------------------------
Message: 1
Date: Thu, 15 Nov 2018 14:19:57 +0000
Subject: [nginx] Core: free shared memory on cycle initialization
failure.
Content-Type: text/plain; charset="us-ascii"
details: http://hg.nginx.org/nginx/rev/650574a44505
changeset: 7394:650574a44505
date: Thu Nov 15 15:28:54 2018 +0300
Core: free shared memory on cycle initialization failure.
src/core/ngx_cycle.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 64 insertions(+), 0 deletions(-)
diff -r 4698cede59ff -r 650574a44505 src/core/ngx_cycle.c
--- a/src/core/ngx_cycle.c Mon Nov 12 16:29:30 2018 +0300
+++ b/src/core/ngx_cycle.c Thu Nov 15 15:28:54 2018 +0300
}
}
+ /* free the newly created shared memory */
+
+ part = &cycle->shared_memory.part;
+ shm_zone = part->elts;
+
+ for (i = 0; /* void */ ; i++) {
+
+ if (i >= part->nelts) {
+ if (part->next == NULL) {
+ break;
+ }
+ part = part->next;
+ shm_zone = part->elts;
+ i = 0;
+ }
+
+ if (shm_zone[i].shm.addr == NULL) {
+ continue;
+ }
+
+ opart = &old_cycle->shared_memory.part;
+ oshm_zone = opart->elts;
+
+ for (n = 0; /* void */ ; n++) {
+
+ if (n >= opart->nelts) {
+ if (opart->next == NULL) {
+ break;
+ }
+ opart = opart->next;
+ oshm_zone = opart->elts;
+ n = 0;
+ }
+
+ if (shm_zone[i].shm.name.len != oshm_zone[n].shm.name.len) {
+ continue;
+ }
+
+ if (ngx_strncmp(shm_zone[i].shm.name.data,
+ oshm_zone[n].shm.name.data,
+ shm_zone[i].shm.name.len)
+ != 0)
+ {
+ continue;
+ }
+
+ if (shm_zone[i].tag == oshm_zone[n].tag
+ && shm_zone[i].shm.size == oshm_zone[n].shm.size
+ && !shm_zone[i].noreuse)
+ {
+ goto old_shm_zone_found;
+ }
+
+ break;
+ }
+
+ ngx_shm_free(&shm_zone[i].shm);
+
+
+ continue;
+ }
+
if (ngx_test_config) {
ngx_destroy_cycle_pools(&conf);
return NULL;
@@ -1274,6 +1337,7 @@ ngx_shared_memory_add(ngx_conf_t *cf, ng
shm_zone->data = NULL;
shm_zone->shm.log = cf->cycle->log;
+ shm_zone->shm.addr = NULL;
shm_zone->shm.size = size;
shm_zone->shm.name = *name;
shm_zone->shm.exists = 0;
------------------------------
Message: 2
Date: Thu, 15 Nov 2018 17:53:53 +0300
Subject: Re: [PATCH] New directive to configure TLSv1.3 ciphers
Content-Type: text/plain; charset=us-ascii
Hello!
Post by Ramprasad Tamilselvan
# HG changeset patch
# Date 1542241466 28800
# Wed Nov 14 16:24:26 2018 -0800
# Node ID 83b05772dbd657b31df16d712a64c908c371f0d9
# Parent 4698cede59ffa438bcae1fd6c5d8fec4d69b2c92
New directive to configure TLSv1.3 ciphers.
In openssl 1.1.1, a new API is introduced to configure ciphers
for TLSv1.3. A new directive ssl_ciphersuites will call the new
API to configure the ciphers for TLSv1.3.
Thank you for your patch.
I do object introducing a new directive for this, see this ticket
https://trac.nginx.org/nginx/ticket/1529
--
Maxim Dounin
http://mdounin.ru/
------------------------------
Message: 3
Date: Thu, 15 Nov 2018 17:32:02 +0000
Subject: [njs] console.time() and console.timeEnd() methods.
Content-Type: text/plain; charset="utf-8"
details: http://hg.nginx.org/njs/rev/46632012ac03
changeset: 653:46632012ac03
date: Wed Nov 14 18:14:49 2018 +0300
console.time() and console.timeEnd() methods.
This fixes #62 issue on Github.
njs/njs_shell.c | 86 ++++++++++++++++++++++++++++++++++++++++++++
njs/test/njs_expect_test.exp | 18 ++++++++-
2 files changed, 103 insertions(+), 1 deletions(-)
diff -r 7f0f7d149709 -r 46632012ac03 njs/njs_shell.c
--- a/njs/njs_shell.c Thu Nov 15 12:45:02 2018 +0300
+++ b/njs/njs_shell.c Wed Nov 14 18:14:49 2018 +0300
@@ -14,6 +14,7 @@
#include <fcntl.h>
#include <stdlib.h>
#include <sys/stat.h>
+#include <sys/time.h>
#include <locale.h>
#include <readline.h>
@@ -63,6 +64,10 @@ static njs_ret_t njs_ext_console_dump(nj
nxt_uint_t nargs, njs_index_t unused);
static njs_ret_t njs_ext_console_help(njs_vm_t *vm, njs_value_t *args,
nxt_uint_t nargs, njs_index_t unused);
+static njs_ret_t njs_ext_console_time(njs_vm_t *vm, njs_value_t *args,
+ nxt_uint_t nargs, njs_index_t unused);
+static njs_ret_t njs_ext_console_time_end(njs_vm_t *vm, njs_value_t *args,
+ nxt_uint_t nargs, njs_index_t unused);
static njs_external_t njs_ext_console[] = {
@@ -102,6 +107,30 @@ static njs_external_t njs_ext_console[]
NULL,
njs_ext_console_help,
0 },
+
+ { nxt_string("time"),
+ NJS_EXTERN_METHOD,
+ NULL,
+ 0,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ njs_ext_console_time,
+ 0 },
+
+ { nxt_string("timeEnd"),
+ NJS_EXTERN_METHOD,
+ NULL,
+ 0,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ njs_ext_console_time_end,
+ 0 },
};
static njs_external_t njs_externals[] = {
@@ -123,6 +152,9 @@ static njs_external_t njs_externals[] =
static njs_completion_t njs_completion;
+static struct timeval njs_console_time;
+
+
int
main(int argc, char **argv)
{
@@ -727,3 +759,57 @@ njs_ext_console_help(njs_vm_t *vm, njs_v
return NJS_OK;
}
+
+
+static njs_ret_t
+njs_ext_console_time(njs_vm_t *vm, njs_value_t *args, nxt_uint_t nargs,
+ njs_index_t unused)
+{
+ if (!njs_value_is_void(njs_arg(args, nargs, 1))) {
+ njs_vm_error(vm, "labels not implemented");
+ return NJS_ERROR;
+ }
+
+ vm->retval = njs_value_void;
+
+ gettimeofday(&njs_console_time, NULL);
+
+ return NJS_OK;
+}
+
+
+static njs_ret_t
+njs_ext_console_time_end(njs_vm_t *vm, njs_value_t *args, nxt_uint_t nargs,
+ njs_index_t unused)
+{
+ int64_t us, ms;
+ struct timeval tv;
+
+ gettimeofday(&tv, NULL);
+
+ if (!njs_value_is_void(njs_arg(args, nargs, 1))) {
+ njs_vm_error(vm, "labels not implemented");
+ return NJS_ERROR;
+ }
+
+ if (nxt_fast_path(njs_console_time.tv_sec || njs_console_time.tv_usec)) {
+
+ us = ((int64_t) tv.tv_sec - njs_console_time.tv_sec) * 1000000
+ + ((int64_t) tv.tv_usec - njs_console_time.tv_usec);
+
+ ms = us / 1000;
+ us = us % 1000;
+
+ printf("default: %" PRIu64 ".%03" PRIu64 "ms\n", ms, us);
+
+ njs_console_time.tv_sec = 0;
+ njs_console_time.tv_usec = 0;
+
+ } else {
+ printf("Timer \"default\" doesn?t exist.\n");
+ }
+
+ vm->retval = njs_value_void;
+
+ return NJS_OK;
+}
diff -r 7f0f7d149709 -r 46632012ac03 njs/test/njs_expect_test.exp
--- a/njs/test/njs_expect_test.exp Thu Nov 15 12:45:02 2018 +0300
+++ b/njs/test/njs_expect_test.exp Wed Nov 14 18:14:49 2018 +0300
@@ -80,7 +80,7 @@ njs_test {
# Global completions, multiple partial match
njs_test {
{"cons\t\t"
- "console*console.help*console.log*const"}
+ "console*console.help*console.time*const"}
}
njs_test {
@@ -190,6 +190,22 @@ njs_test {
"console.help()\r\nVM built-in objects:"}
}
+# console.time* functions
+njs_test {
+ {"console.time()\r\n"
+ "console.time()\r\nundefined\r\n>> "}
+ {"console.time(undefined)\r\n"
+ "console.time(undefined)\r\nundefined\r\n>> "}
+ {"console.timeEnd()\r\n"
+ "console.timeEnd()\r\ndefault: *.*ms\r\nundefined\r\n>> "}
+ {"console.time('a')\r\n"
+ "console.time('a')\r\nError: labels not implemented"}
+ {"console.timeEnd('a')\r\n"
+ "console.timeEnd('a')\r\nError: labels not implemented"}
+ {"console.timeEnd()\r\n"
+ "console.timeEnd()\r\nTimer \"default\" doesn?t exist."}
+}
+
njs_test {
{"console.ll()\r\n"
"console.ll()\r\nTypeError: 'll' is not a function"}
------------------------------
Message: 4
Date: Thu, 15 Nov 2018 17:32:02 +0000
Subject: [njs] Fixed global objects.
Content-Type: text/plain; charset="us-ascii"
details: http://hg.nginx.org/njs/rev/e11011d45499
changeset: 655:e11011d45499
date: Thu Nov 15 20:31:35 2018 +0300
Fixed global objects.
1) Making it extensible.
2) Adding default properties according to ES5.1:15.1.1.
njs/njs_builtin.c | 27 +++++++++++++++++++++++++--
njs/test/njs_unit_test.c | 30 ++++++++++++++++++++++++++++++
2 files changed, 55 insertions(+), 2 deletions(-)
diff -r 2711e84ede6a -r e11011d45499 njs/njs_builtin.c
--- a/njs/njs_builtin.c Wed Apr 04 17:38:10 2018 +0300
+++ b/njs/njs_builtin.c Thu Nov 15 20:31:35 2018 +0300
@@ -276,6 +276,7 @@ njs_builtin_objects_create(njs_vm_t *vm)
}
object->shared = 1;
+ object->extensible = 1;
object++;
}
@@ -1118,8 +1119,30 @@ const njs_object_init_t njs_njs_object_
};
+static const njs_object_prop_t njs_global_this_object_properties[] =
+{
+ {
+ .type = NJS_PROPERTY,
+ .name = njs_string("NaN"),
+ .value = njs_value(NJS_NUMBER, 0, NAN),
+ },
+
+ {
+ .type = NJS_PROPERTY,
+ .name = njs_string("Infinity"),
+ .value = njs_value(NJS_NUMBER, 0, INFINITY),
+ },
+
+ {
+ .type = NJS_PROPERTY,
+ .name = njs_string("undefined"),
+ .value = njs_value(NJS_VOID, 0, NAN),
+ },
+};
+
+
const njs_object_init_t njs_global_this_init = {
nxt_string("this"),
- NULL,
- 0
+ njs_global_this_object_properties,
+ nxt_nitems(njs_global_this_object_properties)
};
diff -r 2711e84ede6a -r e11011d45499 njs/test/njs_unit_test.c
--- a/njs/test/njs_unit_test.c Wed Apr 04 17:38:10 2018 +0300
+++ b/njs/test/njs_unit_test.c Thu Nov 15 20:31:35 2018 +0300
@@ -6488,6 +6488,33 @@ static njs_unit_test_t njs_test[] =
{ nxt_string("this"),
nxt_string("[object Object]") },
+ { nxt_string("this.a = 1; this.a"),
+ nxt_string("1") },
+
+ { nxt_string("this.undefined = 42"),
+ nxt_string("TypeError: Cannot assign to read-only property 'undefined' of object") },
+
+ { nxt_string("this.Infinity = 42"),
+ nxt_string("TypeError: Cannot assign to read-only property 'Infinity' of object") },
+
+ { nxt_string("this.NaN = 42"),
+ nxt_string("TypeError: Cannot assign to read-only property 'NaN' of object") },
+
+ { nxt_string("typeof this.undefined"),
+ nxt_string("undefined") },
+
+ { nxt_string("typeof this.Infinity"),
+ nxt_string("number") },
+
+ { nxt_string("this.Infinity + 1"),
+ nxt_string("Infinity") },
+
+ { nxt_string("typeof this.NaN"),
+ nxt_string("number") },
+
+ { nxt_string("this.NaN + 1"),
+ nxt_string("NaN") },
+
{ nxt_string("njs"),
nxt_string("[object Object]") },
@@ -9177,6 +9204,9 @@ static njs_unit_test_t njs_test[] =
{ nxt_string("Math"),
nxt_string("[object Object]") },
+ { nxt_string("Math.x = function (x) {return 2*x;}; Math.x(3)"),
+ nxt_string("6") },
+
{ nxt_string("isNaN"),
nxt_string("[object Function]") },
------------------------------
Message: 5
Date: Thu, 15 Nov 2018 17:32:02 +0000
Subject: [njs] Improved handling of builtin objects.
Content-Type: text/plain; charset="us-ascii"
details: http://hg.nginx.org/njs/rev/2711e84ede6a
changeset: 654:2711e84ede6a
date: Wed Apr 04 17:38:10 2018 +0300
Improved handling of builtin objects.
The handling of njs_object_init_t arrays is unified across
njs_builtin.c functions.
njs/njs_builtin.c | 939 +++++++++++++++++++--------------------
njs/njs_crypto.c | 12 +
njs/njs_fs.c | 6 +
njs/njs_module.c | 16 -
njs/njs_module.h | 1 -
njs/njs_shell.c | 19 +-
njs/njs_vm.h | 7 -
njs/test/njs_expect_test.exp | 5 +
njs/test/njs_interactive_test.c | 5 +
9 files changed, 499 insertions(+), 511 deletions(-)
diff -r 46632012ac03 -r 2711e84ede6a njs/njs_builtin.c
--- a/njs/njs_builtin.c Wed Nov 14 18:14:49 2018 +0300
+++ b/njs/njs_builtin.c Wed Apr 04 17:38:10 2018 +0300
@@ -1,6 +1,7 @@
/*
* Copyright (C) Igor Sysoev
+ * Copyright (C) Dmitry Volyntsev
* Copyright (C) NGINX, Inc.
*/
@@ -23,25 +24,30 @@ typedef struct {
} njs_function_init_t;
-static nxt_int_t njs_builtin_completions(njs_vm_t *vm, size_t *size,
- nxt_str_t *completions);
+static njs_ret_t njs_prototype_function(njs_vm_t *vm, njs_value_t *args,
+ nxt_uint_t nargs, njs_index_t unused);
static nxt_array_t *njs_vm_expression_completions(njs_vm_t *vm,
nxt_str_t *expression);
static nxt_array_t *njs_object_completions(njs_vm_t *vm, njs_object_t *object);
+
const njs_object_init_t njs_njs_object_init;
+const njs_object_init_t njs_global_this_init;
+
const njs_object_init_t *njs_object_init[] = {
- NULL, /* global this */
+ &njs_global_this_init, /* global this */
&njs_njs_object_init, /* global njs object */
&njs_math_object_init, /* Math */
&njs_json_object_init, /* JSON */
+ NULL
};
const njs_object_init_t *njs_module_init[] = {
&njs_fs_object_init, /* fs */
- &njs_crypto_object_init /* crypto */
+ &njs_crypto_object_init, /* crypto */
+ NULL
};
@@ -64,6 +70,7 @@ const njs_object_init_t *njs_prototype_
&njs_syntax_error_prototype_init,
&njs_type_error_prototype_init,
&njs_uri_error_prototype_init,
+ NULL
};
@@ -87,6 +94,7 @@ const njs_object_init_t *njs_construc
&njs_type_error_constructor_init,
&njs_uri_error_constructor_init,
&njs_memory_error_constructor_init,
+ NULL
};
@@ -103,7 +111,8 @@ const njs_object_init_t *njs_function
&njs_decode_uri_component_function_init,
&njs_require_function_init,
&njs_set_timeout_function_init,
- &njs_clear_timeout_function_init
+ &njs_clear_timeout_function_init,
+ NULL
};
@@ -143,102 +152,95 @@ const njs_object_prop_t njs_arguments_o
};
-static njs_ret_t
-njs_prototype_function(njs_vm_t *vm, njs_value_t *args, nxt_uint_t nargs,
- njs_index_t unused)
-{
- vm->retval = njs_value_void;
+const njs_function_init_t njs_native_constructors[] = {
+ /* SunC does not allow empty array initialization. */
+ { njs_object_constructor, { 0 } },
+ { njs_array_constructor, { 0 } },
+ { njs_boolean_constructor, { 0 } },
+ { njs_number_constructor, { NJS_SKIP_ARG, NJS_NUMBER_ARG } },
+ { njs_string_constructor, { NJS_SKIP_ARG, NJS_STRING_ARG } },
+ { njs_function_constructor, { 0 } },
+ { njs_regexp_constructor,
+ { NJS_SKIP_ARG, NJS_STRING_ARG, NJS_STRING_ARG } },
+ { njs_date_constructor, { 0 } },
+ { njs_hash_constructor, { NJS_SKIP_ARG, NJS_STRING_ARG } },
+ { njs_hmac_constructor, { NJS_SKIP_ARG, NJS_STRING_ARG,
+ NJS_STRING_ARG } },
+ { njs_error_constructor, { NJS_SKIP_ARG, NJS_STRING_ARG } },
+ { njs_eval_error_constructor, { NJS_SKIP_ARG, NJS_STRING_ARG } },
+ { njs_internal_error_constructor,
+ { NJS_SKIP_ARG, NJS_STRING_ARG } },
+ { njs_range_error_constructor,
+ { NJS_SKIP_ARG, NJS_STRING_ARG } },
+ { njs_reference_error_constructor, { NJS_SKIP_ARG, NJS_STRING_ARG } },
+ { njs_syntax_error_constructor,
+ { NJS_SKIP_ARG, NJS_STRING_ARG } },
+ { njs_type_error_constructor, { NJS_SKIP_ARG, NJS_STRING_ARG } },
+ { njs_uri_error_constructor, { NJS_SKIP_ARG, NJS_STRING_ARG } },
+ { njs_memory_error_constructor, { NJS_SKIP_ARG, NJS_STRING_ARG } },
+};
+
+const njs_object_prototype_t njs_prototype_values[] = {
+ /*
+ * GCC 4 complains about uninitialized .shared field,
+ * if the .type field is initialized as .object.type.
+ */
+ { .object = { .type = NJS_OBJECT } },
+ { .object = { .type = NJS_ARRAY } },
- return NXT_OK;
-}
+ /*
+ * The .object.type field must be initialzed after the .value field,
+ * otherwise SunC 5.9 treats the .value as .object.value or so.
+ */
+ { .object_value = { .value = njs_value(NJS_BOOLEAN, 0, 0.0),
+ .object = { .type = NJS_OBJECT_BOOLEAN } } },
+
+ { .object_value = { .value = njs_value(NJS_NUMBER, 0, 0.0),
+ .object = { .type = NJS_OBJECT_NUMBER } } },
+
+ { .object_value = { .value = njs_string(""),
+ .object = { .type = NJS_OBJECT_STRING } } },
+
+ { .function = { .native = 1,
+ .args_offset = 1,
+ .u.native = njs_prototype_function,
+ .object = { .type = NJS_FUNCTION } } },
+
+ { .object = { .type = NJS_REGEXP } },
+
+ { .date = { .time = NAN,
+ .object = { .type = NJS_DATE } } },
+
+ { .object_value = { .value = njs_value(NJS_DATA, 0, 0.0),
+ .object = { .type = NJS_OBJECT } } },
+
+ { .object_value = { .value = njs_value(NJS_DATA, 0, 0.0),
+ .object = { .type = NJS_OBJECT } } },
+
+ { .object = { .type = NJS_OBJECT_ERROR } },
+ { .object = { .type = NJS_OBJECT_EVAL_ERROR } },
+ { .object = { .type = NJS_OBJECT_INTERNAL_ERROR } },
+ { .object = { .type = NJS_OBJECT_RANGE_ERROR } },
+ { .object = { .type = NJS_OBJECT_REF_ERROR } },
+ { .object = { .type = NJS_OBJECT_SYNTAX_ERROR } },
+ { .object = { .type = NJS_OBJECT_TYPE_ERROR } },
+ { .object = { .type = NJS_OBJECT_URI_ERROR } },
+ { .object = { .type = NJS_OBJECT_INTERNAL_ERROR } },
+};
+
nxt_int_t
njs_builtin_objects_create(njs_vm_t *vm)
{
- nxt_int_t ret;
- nxt_uint_t i;
- njs_module_t *module;
- njs_object_t *objects;
- njs_function_t *functions, *constructors;
- nxt_lvlhsh_query_t lhq;
- njs_object_prototype_t *prototypes;
-
- static const njs_object_prototype_t prototype_values[] = {
- /*
- * GCC 4 complains about uninitialized .shared field,
- * if the .type field is initialized as .object.type.
- */
- { .object = { .type = NJS_OBJECT } },
- { .object = { .type = NJS_ARRAY } },
-
- /*
- * The .object.type field must be initialzed after the .value field,
- * otherwise SunC 5.9 treats the .value as .object.value or so.
- */
- { .object_value = { .value = njs_value(NJS_BOOLEAN, 0, 0.0),
- .object = { .type = NJS_OBJECT_BOOLEAN } } },
-
- { .object_value = { .value = njs_value(NJS_NUMBER, 0, 0.0),
- .object = { .type = NJS_OBJECT_NUMBER } } },
-
- { .object_value = { .value = njs_string(""),
- .object = { .type = NJS_OBJECT_STRING } } },
-
- { .function = { .native = 1,
- .args_offset = 1,
- .u.native = njs_prototype_function,
- .object = { .type = NJS_FUNCTION } } },
-
- { .object = { .type = NJS_REGEXP } },
-
- { .date = { .time = NAN,
- .object = { .type = NJS_DATE } } },
-
- { .object_value = { .value = njs_value(NJS_DATA, 0, 0.0),
- .object = { .type = NJS_OBJECT } } },
-
- { .object_value = { .value = njs_value(NJS_DATA, 0, 0.0),
- .object = { .type = NJS_OBJECT } } },
-
- { .object = { .type = NJS_OBJECT_ERROR } },
- { .object = { .type = NJS_OBJECT_EVAL_ERROR } },
- { .object = { .type = NJS_OBJECT_INTERNAL_ERROR } },
- { .object = { .type = NJS_OBJECT_RANGE_ERROR } },
- { .object = { .type = NJS_OBJECT_REF_ERROR } },
- { .object = { .type = NJS_OBJECT_SYNTAX_ERROR } },
- { .object = { .type = NJS_OBJECT_TYPE_ERROR } },
- { .object = { .type = NJS_OBJECT_URI_ERROR } },
- { .object = { .type = NJS_OBJECT_INTERNAL_ERROR } },
- };
-
- static const njs_function_init_t native_constructors[] = {
- /* SunC does not allow empty array initialization. */
- { njs_object_constructor, { 0 } },
- { njs_array_constructor, { 0 } },
- { njs_boolean_constructor, { 0 } },
- { njs_number_constructor, { NJS_SKIP_ARG, NJS_NUMBER_ARG } },
- { njs_string_constructor, { NJS_SKIP_ARG, NJS_STRING_ARG } },
- { njs_function_constructor, { 0 } },
- { njs_regexp_constructor,
- { NJS_SKIP_ARG, NJS_STRING_ARG, NJS_STRING_ARG } },
- { njs_date_constructor, { 0 } },
- { njs_hash_constructor, { NJS_SKIP_ARG, NJS_STRING_ARG } },
- { njs_hmac_constructor, { NJS_SKIP_ARG, NJS_STRING_ARG,
- NJS_STRING_ARG } },
- { njs_error_constructor, { NJS_SKIP_ARG, NJS_STRING_ARG } },
- { njs_eval_error_constructor, { NJS_SKIP_ARG, NJS_STRING_ARG } },
- { njs_internal_error_constructor,
- { NJS_SKIP_ARG, NJS_STRING_ARG } },
- { njs_range_error_constructor,
- { NJS_SKIP_ARG, NJS_STRING_ARG } },
- { njs_reference_error_constructor, { NJS_SKIP_ARG, NJS_STRING_ARG } },
- { njs_syntax_error_constructor,
- { NJS_SKIP_ARG, NJS_STRING_ARG } },
- { njs_type_error_constructor, { NJS_SKIP_ARG, NJS_STRING_ARG } },
- { njs_uri_error_constructor, { NJS_SKIP_ARG, NJS_STRING_ARG } },
- { njs_memory_error_constructor, { NJS_SKIP_ARG, NJS_STRING_ARG } },
- };
+ nxt_int_t ret;
+ njs_module_t *module;
+ njs_object_t *object;
+ njs_function_t *func;
+ nxt_lvlhsh_query_t lhq;
+ njs_object_prototype_t *prototype;
+ const njs_object_init_t *obj, **p;
+ const njs_function_init_t *f;
static const njs_object_prop_t function_prototype_property = {
.type = NJS_PROPERTY_HANDLER,
@@ -246,6 +248,8 @@ njs_builtin_objects_create(njs_vm_t *vm)
.value = njs_prop_handler(njs_function_prototype_create),
};
+ static const nxt_str_t sandbox_key = nxt_string("sandbox");
+
ret = njs_object_hash_create(vm, &vm->shared->function_prototype_hash,
&function_prototype_property, 1);
if (nxt_slow_path(ret != NXT_OK)) {
@@ -259,48 +263,57 @@ njs_builtin_objects_create(njs_vm_t *vm)
return NXT_ERROR;
}
- objects = vm->shared->objects;
+ object = vm->shared->objects;
+
+ for (p = njs_object_init; *p != NULL; p++) {
+ obj = *p;
- for (i = NJS_OBJECT_THIS; i < NJS_OBJECT_MAX; i++) {
- if (njs_object_init[i] != NULL) {
- ret = njs_object_hash_create(vm, &objects[i].shared_hash,
- njs_object_init[i]->properties,
- njs_object_init[i]->items);
- if (nxt_slow_path(ret != NXT_OK)) {
- return NXT_ERROR;
- }
+ ret = njs_object_hash_create(vm, &object->shared_hash,
+ obj->properties, obj->items);
+
+ if (nxt_slow_path(ret != NXT_OK)) {
+ return NXT_ERROR;
}
- objects[i].shared = 1;
+ object->shared = 1;
+
+ object++;
}
lhq.replace = 0;
- lhq.proto = &njs_modules_hash_proto;
lhq.pool = vm->mem_cache_pool;
- for (i = NJS_MODULE_FS; i < NJS_MODULE_MAX; i++) {
- if (vm->options.sandbox && !njs_sandbox_module(i)) {
- continue;
- }
+ for (p = njs_module_init; *p != NULL; p++) {
+ obj = *p;
module = nxt_mem_cache_zalloc(vm->mem_cache_pool, sizeof(njs_module_t));
if (nxt_slow_path(module == NULL)) {
return NJS_ERROR;
}
- module->name = njs_module_init[i]->name;
-
ret = njs_object_hash_create(vm, &module->object.shared_hash,
- njs_module_init[i]->properties,
- njs_module_init[i]->items);
+ obj->properties, obj->items);
if (nxt_slow_path(ret != NXT_OK)) {
return NXT_ERROR;
}
+ if (vm->options.sandbox) {
+ lhq.key = sandbox_key;
+ lhq.key_hash = nxt_djb_hash(sandbox_key.start, sandbox_key.length);
+ lhq.proto = &njs_object_hash_proto;
+
+ ret = nxt_lvlhsh_find(&module->object.shared_hash, &lhq);
+ if (nxt_fast_path(ret != NXT_OK)) {
+ continue;
+ }
+ }
+
+ module->name = obj->name;
module->object.shared = 1;
lhq.key = module->name;
lhq.key_hash = nxt_djb_hash(lhq.key.start, lhq.key.length);
+ lhq.proto = &njs_modules_hash_proto;
lhq.value = module;
ret = nxt_lvlhsh_insert(&vm->modules_hash, &lhq);
@@ -309,73 +322,88 @@ njs_builtin_objects_create(njs_vm_t *vm)
}
}
- functions = vm->shared->functions;
+ f = njs_native_functions;
+ func = vm->shared->functions;
- for (i = NJS_FUNCTION_EVAL; i < NJS_FUNCTION_MAX; i++) {
- if (njs_function_init[i]->items != 0) {
- ret = njs_object_hash_create(vm, &functions[i].object.shared_hash,
- njs_function_init[i]->properties,
- njs_function_init[i]->items);
- if (nxt_slow_path(ret != NXT_OK)) {
- return NXT_ERROR;
- }
+ for (p = njs_function_init; *p != NULL; p++) {
+ obj = *p;
+
+ ret = njs_object_hash_create(vm, &func->object.shared_hash,
+ obj->properties, obj->items);
+ if (nxt_slow_path(ret != NXT_OK)) {
+ return NXT_ERROR;
}
- functions[i].object.shared = 1;
- functions[i].object.extensible = 1;
- functions[i].native = 1;
- functions[i].args_offset = 1;
- functions[i].u.native = njs_native_functions[i].native;
- functions[i].args_types[0] = njs_native_functions[i].args_types[0];
- functions[i].args_types[1] = njs_native_functions[i].args_types[1];
- functions[i].args_types[2] = njs_native_functions[i].args_types[2];
- functions[i].args_types[3] = njs_native_functions[i].args_types[3];
- functions[i].args_types[4] = njs_native_functions[i].args_types[4];
+ func->object.shared = 1;
+ func->object.extensible = 1;
+ func->native = 1;
+ func->args_offset = 1;
+
+ func->u.native = f->native;
+ memcpy(func->args_types, f->args_types, NJS_ARGS_TYPES_MAX);
+
+ f++;
+ func++;
}
- prototypes = vm->shared->prototypes;
+ prototype = vm->shared->prototypes;
+ memcpy(prototype, njs_prototype_values, sizeof(njs_prototype_values));
- for (i = NJS_PROTOTYPE_OBJECT; i < NJS_PROTOTYPE_MAX; i++) {
- prototypes[i] = prototype_values[i];
+ for (p = njs_prototype_init; *p != NULL; p++) {
+ obj = *p;
- ret = njs_object_hash_create(vm, &prototypes[i].object.shared_hash,
- njs_prototype_init[i]->properties,
- njs_prototype_init[i]->items);
+ ret = njs_object_hash_create(vm, &prototype->object.shared_hash,
+ obj->properties, obj->items);
if (nxt_slow_path(ret != NXT_OK)) {
return NXT_ERROR;
}
+
+ prototype++;
}
- prototypes[NJS_PROTOTYPE_REGEXP].regexp.pattern =
+ vm->shared->prototypes[NJS_PROTOTYPE_REGEXP].regexp.pattern =
vm->shared->empty_regexp_pattern;
- constructors = vm->shared->constructors;
+ f = njs_native_constructors;
+ func = vm->shared->constructors;
+
+ for (p = njs_constructor_init; *p != NULL; p++) {
+ obj = *p;
- for (i = NJS_CONSTRUCTOR_OBJECT; i < NJS_CONSTRUCTOR_MAX; i++) {
- constructors[i].object.shared = 0;
- constructors[i].object.extensible = 1;
- constructors[i].native = 1;
- constructors[i].ctor = 1;
- constructors[i].args_offset = 1;
- constructors[i].u.native = native_constructors[i].native;
- constructors[i].args_types[0] = native_constructors[i].args_types[0];
- constructors[i].args_types[1] = native_constructors[i].args_types[1];
- constructors[i].args_types[2] = native_constructors[i].args_types[2];
- constructors[i].args_types[3] = native_constructors[i].args_types[3];
- constructors[i].args_types[4] = native_constructors[i].args_types[4];
+ func->object.shared = 0;
+ func->object.extensible = 1;
+ func->native = 1;
+ func->ctor = 1;
+ func->args_offset = 1;
- ret = njs_object_hash_create(vm, &constructors[i].object.shared_hash,
- njs_constructor_init[i]->properties,
- njs_constructor_init[i]->items);
+ func->u.native = f->native;
+
+ memcpy(func->args_types, f->args_types, NJS_ARGS_TYPES_MAX);
+
+ ret = njs_object_hash_create(vm, &func->object.shared_hash,
+ obj->properties, obj->items);
if (nxt_slow_path(ret != NXT_OK)) {
return NXT_ERROR;
}
+
+ f++;
+ func++;
}
return NXT_OK;
}
+static njs_ret_t
+njs_prototype_function(njs_vm_t *vm, njs_value_t *args, nxt_uint_t nargs,
+ njs_index_t unused)
+{
+ vm->retval = njs_value_void;
+
+ return NXT_OK;
+}
+
+
/*
* Object(),
* Object.__proto__ -> Function_Prototype,
@@ -493,53 +521,15 @@ njs_builtin_objects_clone(njs_vm_t *vm)
}
-nxt_array_t *
-njs_vm_completions(njs_vm_t *vm, nxt_str_t *expression)
+static size_t
+njs_builtin_completions_size(njs_vm_t *vm)
{
- size_t size;
- nxt_array_t *completions;
-
- if (expression == NULL) {
- if (njs_builtin_completions(vm, &size, NULL) != NXT_OK) {
- return NULL;
- }
-
- completions = nxt_array_create(size, sizeof(nxt_str_t),
- &njs_array_mem_proto,
- vm->mem_cache_pool);
-
- if (nxt_slow_path(completions == NULL)) {
- return NULL;
- }
-
- if (njs_builtin_completions(vm, &size, completions->start) != NXT_OK) {
- return NULL;
- }
-
- completions->items = size;
-
- return completions;
- }
-
- return njs_vm_expression_completions(vm, expression);
-}
-
-
-static nxt_int_t
-njs_builtin_completions(njs_vm_t *vm, size_t *size, nxt_str_t *completions)
-{
- char *compl;
- size_t n, len;
- nxt_str_t string;
- nxt_uint_t i, k;
- njs_object_t *objects;
- njs_keyword_t *keyword;
- njs_function_t *constructors;
- njs_object_prop_t *prop;
- nxt_lvlhsh_each_t lhe, lhe_prop;
- njs_extern_value_t *ev;
- const njs_extern_t *ext_proto, *ext_prop;
- njs_object_prototype_t *prototypes;
+ nxt_uint_t n;
+ njs_keyword_t *keyword;
+ nxt_lvlhsh_each_t lhe, lhe_prop;
+ njs_extern_value_t *ev;
+ const njs_extern_t *ext_proto, *ext_prop;
+ const njs_object_init_t **p;
n = 0;
@@ -552,123 +542,147 @@ njs_builtin_completions(njs_vm_t *vm, si
break;
}
- if (completions != NULL) {
- completions[n++] = keyword->name;
+ n++;
+ }
+
+ for (p = njs_object_init; *p != NULL; p++) {
+ n += (*p)->items;
+ }
+
+ for (p = njs_prototype_init; *p != NULL; p++) {
+ n += (*p)->items;
+ }
+
+ for (p = njs_constructor_init; *p != NULL; p++) {
+ n += (*p)->items;
+ }
+
+ nxt_lvlhsh_each_init(&lhe, &njs_extern_value_hash_proto);
- } else {
+ for ( ;; ) {
+ ev = nxt_lvlhsh_each(&vm->externals_hash, &lhe);
+
+ if (ev == NULL) {
+ break;
+ }
+
+ ext_proto = ev->value.external.proto;
+
+ nxt_lvlhsh_each_init(&lhe_prop, &njs_extern_hash_proto);
+
+ n++;
+
+ for ( ;; ) {
+ ext_prop = nxt_lvlhsh_each(&ext_proto->hash, &lhe_prop);
+
+ if (ext_prop == NULL) {
+ break;
+ }
+
n++;
}
}
- objects = vm->shared->objects;
+ return n;
+}
+
- for (i = NJS_OBJECT_THIS; i < NJS_OBJECT_MAX; i++) {
- if (njs_object_init[i] == NULL) {
- continue;
+static nxt_array_t *
+njs_builtin_completions(njs_vm_t *vm, nxt_array_t *array)
+{
+ char *compl;
+ size_t n, len;
+ nxt_str_t string, *completions;
+ nxt_uint_t i, k;
+ njs_keyword_t *keyword;
+ nxt_lvlhsh_each_t lhe, lhe_prop;
+ njs_extern_value_t *ev;
+ const njs_extern_t *ext_proto, *ext_prop;
+ const njs_object_prop_t *prop;
+ const njs_object_init_t *obj, **p;
+
+ n = 0;
+ completions = array->start;
+
+ nxt_lvlhsh_each_init(&lhe, &njs_keyword_hash_proto);
+
+ for ( ;; ) {
+ keyword = nxt_lvlhsh_each(&vm->shared->keywords_hash, &lhe);
+
+ if (keyword == NULL) {
+ break;
}
- nxt_lvlhsh_each_init(&lhe, &njs_object_hash_proto);
+ completions[n++] = keyword->name;
+ }
+
+ for (p = njs_object_init; *p != NULL; p++) {
+ obj = *p;
- for ( ;; ) {
- prop = nxt_lvlhsh_each(&objects[i].shared_hash, &lhe);
+ for (i = 0; i < obj->items; i++) {
+ prop = &obj->properties[i];
+ njs_string_get(&prop->name, &string);
+ len = obj->name.length + string.length + 2;
- if (prop == NULL) {
- break;
+ compl = nxt_mem_cache_zalloc(vm->mem_cache_pool, len);
+ if (compl == NULL) {
+ return NULL;
}
- if (completions != NULL) {
- njs_string_get(&prop->name, &string);
- len = njs_object_init[i]->name.length + string.length + 2;
+ snprintf(compl, len, "%s.%s", obj->name.start, string.start);
+
+ completions[n].length = len;
+ completions[n++].start = (u_char *) compl;
+ }
+ }
+
+ for (p = njs_prototype_init; *p != NULL; p++) {
+ obj = *p;
+
+ for (i = 0; i < obj->items; i++) {
+ prop = &obj->properties[i];
+ njs_string_get(&prop->name, &string);
+ len = string.length + 2;
- compl = nxt_mem_cache_zalloc(vm->mem_cache_pool, len);
- if (compl == NULL) {
- return NXT_ERROR;
+ compl = nxt_mem_cache_zalloc(vm->mem_cache_pool, len);
+ if (compl == NULL) {
+ return NULL;
+ }
+
+ snprintf(compl, len, ".%s", string.start);
+
+ for (k = 0; k < n; k++) {
+ if (strncmp((char *) completions[k].start, compl, len)
+ == 0)
+ {
+ break;
}
+ }
- snprintf(compl, len, "%s.%s", njs_object_init[i]->name.start,
- string.start);
-
+ if (k == n) {
completions[n].length = len;
completions[n++].start = (u_char *) compl;
-
- } else {
- n++;
}
}
}
- prototypes = vm->shared->prototypes;
-
- for (i = NJS_PROTOTYPE_OBJECT; i < NJS_PROTOTYPE_MAX; i++) {
- nxt_lvlhsh_each_init(&lhe, &njs_object_hash_proto);
+ for (p = njs_constructor_init; *p != NULL; p++) {
+ obj = *p;
- for ( ;; ) {
- prop = nxt_lvlhsh_each(&prototypes[i].object.shared_hash, &lhe);
+ for (i = 0; i < obj->items; i++) {
+ prop = &obj->properties[i];
+ njs_string_get(&prop->name, &string);
+ len = obj->name.length + string.length + 2;
- if (prop == NULL) {
- break;
+ compl = nxt_mem_cache_zalloc(vm->mem_cache_pool, len);
+ if (compl == NULL) {
+ return NULL;
}
- if (completions != NULL) {
- njs_string_get(&prop->name, &string);
- len = string.length + 2;
-
- compl = nxt_mem_cache_zalloc(vm->mem_cache_pool, len);
- if (compl == NULL) {
- return NXT_ERROR;
- }
-
- snprintf(compl, len, ".%s", string.start);
-
- for (k = 0; k < n; k++) {
- if (strncmp((char *) completions[k].start, compl, len)
- == 0)
- {
- break;
- }
- }
-
- if (k == n) {
- completions[n].length = len;
- completions[n++].start = (u_char *) compl;
- }
-
- } else {
- n++;
- }
- }
- }
+ snprintf(compl, len, "%s.%s", obj->name.start, string.start);
- constructors = vm->shared->constructors;
-
- for (i = NJS_CONSTRUCTOR_OBJECT; i < NJS_CONSTRUCTOR_MAX; i++) {
- nxt_lvlhsh_each_init(&lhe, &njs_object_hash_proto);
-
- for ( ;; ) {
- prop = nxt_lvlhsh_each(&constructors[i].object.shared_hash, &lhe);
-
- if (prop == NULL) {
- break;
- }
-
- if (completions != NULL) {
- njs_string_get(&prop->name, &string);
- len = njs_constructor_init[i]->name.length + string.length + 2;
-
- compl = nxt_mem_cache_zalloc(vm->mem_cache_pool, len);
- if (compl == NULL) {
- return NXT_ERROR;
- }
-
- snprintf(compl, len, "%s.%s",
- njs_constructor_init[i]->name.start, string.start);
-
- completions[n].length = len;
- completions[n++].start = (u_char *) compl;
-
- } else {
- n++;
- }
+ completions[n].length = len;
+ completions[n++].start = (u_char *) compl;
}
}
@@ -685,21 +699,16 @@ njs_builtin_completions(njs_vm_t *vm, si
nxt_lvlhsh_each_init(&lhe_prop, &njs_extern_hash_proto);
- if (completions != NULL) {
- len = ev->name.length + 1;
- compl = nxt_mem_cache_zalloc(vm->mem_cache_pool, len);
- if (compl == NULL) {
- return NXT_ERROR;
- }
+ len = ev->name.length + 1;
+ compl = nxt_mem_cache_zalloc(vm->mem_cache_pool, len);
+ if (compl == NULL) {
+ return NULL;
+ }
- snprintf(compl, len, "%.*s", (int) ev->name.length, ev->name.start);
+ snprintf(compl, len, "%.*s", (int) ev->name.length, ev->name.start);
- completions[n].length = len;
- completions[n++].start = (u_char *) compl;
-
- } else {
- n++;
- }
+ completions[n].length = len;
+ completions[n++].start = (u_char *) compl;
for ( ;; ) {
ext_prop = nxt_lvlhsh_each(&ext_proto->hash, &lhe_prop);
@@ -708,31 +717,48 @@ njs_builtin_completions(njs_vm_t *vm, si
break;
}
- if (completions != NULL) {
- len = ev->name.length + ev->name.length + 2;
- compl = nxt_mem_cache_zalloc(vm->mem_cache_pool, len);
- if (compl == NULL) {
- return NXT_ERROR;
- }
+ len = ev->name.length + ev->name.length + 2;
+ compl = nxt_mem_cache_zalloc(vm->mem_cache_pool, len);
+ if (compl == NULL) {
+ return NULL;
+ }
- snprintf(compl, len, "%.*s.%.*s", (int) ev->name.length,
- ev->name.start, (int) ext_prop->name.length,
- ext_prop->name.start);
+ snprintf(compl, len, "%.*s.%.*s", (int) ev->name.length,
+ ev->name.start, (int) ext_prop->name.length,
+ ext_prop->name.start);
- completions[n].length = len;
- completions[n++].start = (u_char *) compl;
-
- } else {
- n++;
- }
+ completions[n].length = len;
+ completions[n++].start = (u_char *) compl;
}
}
- if (size) {
- *size = n;
+ array->items = n;
+
+ return array;
+}
+
+
+nxt_array_t *
+njs_vm_completions(njs_vm_t *vm, nxt_str_t *expression)
+{
+ size_t size;
+ nxt_array_t *completions;
+
+ if (expression == NULL) {
+ size = njs_builtin_completions_size(vm);
+
+ completions = nxt_array_create(size, sizeof(nxt_str_t),
+ &njs_array_mem_proto,
+ vm->mem_cache_pool);
+
+ if (nxt_slow_path(completions == NULL)) {
+ return NULL;
+ }
+
+ return njs_builtin_completions(vm, completions);
}
- return NXT_OK;
+ return njs_vm_expression_completions(vm, expression);
}
@@ -911,185 +937,135 @@ njs_object_completions(njs_vm_t *vm, njs
}
-nxt_int_t
-njs_builtin_match_native_function(njs_vm_t *vm, njs_function_t *function,
- nxt_str_t *name)
+static nxt_int_t
+njs_builtin_match(const njs_object_init_t **objects, njs_function_t *function,
+ const njs_object_prop_t **prop, const njs_object_init_t **object)
{
- char *buf;
- size_t len;
- nxt_str_t string;
- nxt_uint_t i;
- njs_module_t *module;
- njs_object_t *objects;
- njs_function_t *constructors;
- njs_object_prop_t *prop;
- nxt_lvlhsh_each_t lhe, lhe_prop;
- njs_object_prototype_t *prototypes;
+ nxt_uint_t i;
+ const njs_object_init_t *o, **p;
+ const njs_object_prop_t *pr;
- objects = vm->shared->objects;
-
- for (i = NJS_OBJECT_THIS; i < NJS_OBJECT_MAX; i++) {
- if (njs_object_init[i] == NULL) {
- continue;
- }
-
- nxt_lvlhsh_each_init(&lhe, &njs_object_hash_proto);
+ for (p = objects; *p != NULL; p++) {
+ o = *p;
- for ( ;; ) {
- prop = nxt_lvlhsh_each(&objects[i].shared_hash, &lhe);
+ for (i = 0; i < o->items; i++) {
+ pr = &o->properties[i];
- if (prop == NULL) {
- break;
- }
-
- if (!njs_is_function(&prop->value)) {
+ if (pr->type != NJS_METHOD) {
continue;
}
- if (function == prop->value.data.u.function) {
- njs_string_get(&prop->name, &string);
- len = njs_object_init[i]->name.length + string.length
- + sizeof(".");
-
- buf = nxt_mem_cache_zalloc(vm->mem_cache_pool, len);
- if (buf == NULL) {
- return NXT_ERROR;
- }
-
- snprintf(buf, len, "%s.%s", njs_object_init[i]->name.start,
- string.start);
-
- name->length = len;
- name->start = (u_char *) buf;
-
- return NXT_OK;
- }
- }
- }
-
- prototypes = vm->shared->prototypes;
-
- for (i = NJS_PROTOTYPE_OBJECT; i < NJS_PROTOTYPE_MAX; i++) {
- nxt_lvlhsh_each_init(&lhe, &njs_object_hash_proto);
-
- for ( ;; ) {
- prop = nxt_lvlhsh_each(&prototypes[i].object.shared_hash, &lhe);
-
- if (prop == NULL) {
- break;
- }
-
- if (!njs_is_function(&prop->value)) {
+ if (function != pr->value.data.u.function) {
continue;
}
- if (function == prop->value.data.u.function) {
- njs_string_get(&prop->name, &string);
- len = njs_prototype_init[i]->name.length + string.length
- + sizeof(".prototype.");
-
- buf = nxt_mem_cache_zalloc(vm->mem_cache_pool, len);
- if (buf == NULL) {
- return NXT_ERROR;
- }
-
- snprintf(buf, len, "%s.prototype.%s",
- njs_prototype_init[i]->name.start, string.start);
-
- name->length = len;
- name->start = (u_char *) buf;
-
- return NXT_OK;
- }
- }
- }
-
- constructors = vm->shared->constructors;
-
- for (i = NJS_CONSTRUCTOR_OBJECT; i < NJS_CONSTRUCTOR_MAX; i++) {
- nxt_lvlhsh_each_init(&lhe, &njs_object_hash_proto);
-
- for ( ;; ) {
- prop = nxt_lvlhsh_each(&constructors[i].object.shared_hash, &lhe);
-
- if (prop == NULL) {
- break;
- }
-
- if (!njs_is_function(&prop->value)) {
- continue;
- }
-
- if (function == prop->value.data.u.function) {
- njs_string_get(&prop->name, &string);
------------------------------
Subject: Digest Footer
_______________________________________________
nginx-devel mailing list
http://mailman.nginx.org/mailman/listinfo/nginx-devel
------------------------------
End of nginx-devel Digest, Vol 109, Issue 15
********************************************
------------------------------
Subject: Digest Footer
_______________________________________________
nginx-devel mailing list
http://mailman.nginx.org/mailman/listinfo/nginx-devel
------------------------------
End of nginx-devel Digest, Vol 109, Issue 17
********************************************
Maxim Dounin
2018-11-16 11:51:53 UTC
Permalink
Hello!
Post by Ramprasad Tamilselvan
I have a question regarding the ticket.
What if different TLSv1.3 ciphers need to be configured in different server blocks?
In this case, changing openssl.conf will not help right.
Sure, configuring ciphers via openssl.conf is at most workaround,
and does not cover all possible use cases. The best solution
would be to patch OpenSSL to support configuration of TLSv1.3
ciphers via SSL_CTX_set_cipher_list().
--
Maxim Dounin
http://mdounin.ru/
Loading...