0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
Commit Graph

10182 Commits

Author SHA1 Message Date
Trevor Livingston
bf5e2f246e tls: checkServerIdentity option
Allow overriding `checkServerIdentity` function, when connecting to a
TLS server.

Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-09-09 17:15:50 +01:00
Ben Noordhuis
06526a2a93 src: remove Environment::GetCurrentChecked()
There is only one call site that uses it and that can do the checks
itself.  Removes ~15 lines of code.

Reviewed-by: Trevor Norris <trev.norris@gmail.com>
2014-09-05 09:54:10 -07:00
Ben Noordhuis
299cf84490 lib: unexport http.parsers
Unexport the http.parsers freelist.  It was originally exported by Ryan
in commit 0003c701 but the commit log doesn't mention why and it's never
been documented.  It's unclear if there are any users.

The lifecycle of parser objects changed recently and it seems better to
not let people shoot themselves in the foot so easily.

If it turns out there are actually users, we can always re-export it
again - probably under a slightly different name, to force people to
update their code to the new way of things.

Reviewed-by: Trevor Norris <trev.norris@gmail.com>
2014-09-05 09:34:43 -07:00
Ben Noordhuis
150d6f1249 lib: http: poison parser references after freeing
Make it a little harder to slip in use-after-free bugs by nulling out
references to the parser object after handing it off to freeParser().

Reviewed-by: Trevor Norris <trev.norris@gmail.com>
2014-09-05 09:34:37 -07:00
Ben Noordhuis
8e6706ea95 src: update and expand comments in base-object.h
It's safe to call BaseObject::object() from your destructor _unless_
the handle is weak; then it's the weak callback that is calling your
destructor and the object will have been released by the time the
destructor runs.

Reviewed-by: Trevor Norris <trev.norris@gmail.com>
2014-09-05 09:34:27 -07:00
Ben Noordhuis
b33a47ef47 lib, src: don't make http parser handles weak
Weak handles put strain on the garbage collector and the parser handle
doesn't need to be weak in the first place.  This change should improve
GC times on busy servers a little.

Reviewed-by: Trevor Norris <trev.norris@gmail.com>
2014-09-05 09:34:15 -07:00
Ben Noordhuis
1e99486cc8 src: add ClearWrap() to util.h
Counterpart to Wrap(), clears the previously assigned internal field.
Will be used in an upcoming commit.

Reviewed-by: Trevor Norris <trev.norris@gmail.com>
2014-09-05 09:33:58 -07:00
Ben Noordhuis
de9a444ab4 src: fix handle leak in Parser::Execute()
Fix a resource leak where an intermediate Local<Context> handle in
Environment::GetCurrent() got leaked into whatever HandleScope was
further up the stack.

Reviewed-by: Trevor Norris <trev.norris@gmail.com>
2014-09-05 09:33:49 -07:00
Majid Arif Siddiqui
176f0bd3df lib: improved forEach object performance
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
2014-09-05 09:19:32 -07:00
cjihrig
86bb7fa5cd test: listen on exclusive port in cluster workers
Test that listening on exclusive ports with the cluster module works
correctly.

Reviewed-by: Trevor Norris <trev.norris@gmail.com>
2014-09-04 15:18:48 -07:00
cjihrig
029cfc12a0 net,dgram: workers can listen on exclusive ports
Allow cluster workers to listen on exclusive ports for TCP and UDP,
instead of forcing all calls to go through the cluster master.

Fixes: #3856
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
Reviewed-by: Fedor Indutny <fedor@indutny.com>
2014-09-03 15:16:16 -07:00
Trevor Norris
9b8837b355 src: be more intelligent about use of "arguments"
Use 'use strict' when there are named arguments and the arguments object
is passed to apply(). Also pass named arguments to call() when the named
argument is modified by the function.

Suggested in
https://github.com/joyent/node/pull/8302#issuecomment-54331801

Confirmed in
https://github.com/joyent/node/pull/8302#issuecomment-54364818

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
2014-09-03 14:24:50 -07:00
Fedor Indutny
73631bbcc8 tls: support multiple keys/certs
Required to serve website with both ECDSA/RSA certificates.
2014-09-03 17:36:54 +04:00
Fedor Indutny
7343c77cdb tls_wrap: fix use after free
Do not free TLSCallbacks from StreamWrap. TLSCallbacks is bound to a V8
object and should be collected by V8's GC.
2014-09-03 17:36:54 +04:00
Fedor Indutny
68c14d6923 crypto: use less memory for storing keys
Use `BIO_new_mem_buf` where possible to reduce memory usage and
initialization costs.
2014-09-03 17:36:32 +04:00
Jackson Tian
4bd396a9bf net: Improve Socket.prototype.write()
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
2014-09-03 04:43:01 -07:00
Trevor Norris
a054f8eb29 stream_wrap: Add support to write binary strings
node::StringBytes::Write() has appropriate support to write strings with
'binary' encoding. So expose that API through StreamWrap and allow
inheriting classes to use it.

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
2014-09-03 03:36:17 -07:00
Trevor Norris
81a9739108 node,async-wrap: verify domain enter/exit are set
The REPL global object lazy loads modules by placing getters for each.
This causes MakeDomainCallback() to be run if a native module is loaded
from the REPL, but if the domain module hasn't been loaded then there
are no enter/exit callbacks to be called. Causing an assert() to fail.

Fix the issue by conditionally running the callback instead of asserting
it is available. Also add "addon" test to verify the fix.

Fixes: #8231
Signed-off-by: Trevor Norris <trev.norris@gmail.com>
2014-09-02 11:30:45 -07:00
Jesús Leganés Combarro "piranna
cdc01faed2 configure: generate a fully statically linked exec
Allow to create an executable with no external dynamic libraries, also the
ones from the system. This is somewhat dependent of the used C lib, for
example glibc has some internal dynamic libraries loaded by itself, but for
other ones like eglibc or dietlib, this would produce a true static linked
executable. This can be of interest for embebers or resource constraints
platforms, but the main reason for this is to allow to use a Javascript
file as Linux kernel 'init' on NodeOS.

Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-09-02 22:20:52 +04:00
Julien Gilli
90d1147b8b cluster: centralize removal from workers list.
Currently, cluster workers can be removed from the workers list in three
different places:
- In the exit event handler for the worker process.
- In the disconnect event handler of the worker process.
- In the disconnect event handler of the cluster master.

However, handles for a given worker are cleaned up only in one of these
places: in the cluster master's disconnect event handler.

Because these events happen asynchronously, it is possible that the
workers list is empty before we even clean up one handle. This makes
the assert that makes sure that no handle is left when the workers
list is empty fail.

This commit removes the worker from the cluster.workers list only when
the worker is dead _and_ disconnected, at which point we're sure that
its associated handles are cleaned up.

Fixes #8191 and #8192.

Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-09-02 22:14:04 +04:00
Brian White
fcfe820481 crypto: unsigned value can't be negative
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-09-02 17:41:30 +04:00
Brian White
16b0a3393e crypto: avoid memory leak
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-09-02 17:41:21 +04:00
Jackson Tian
92419f8762 src: reading/owner/onread/onconnection for tcp
Initialize fields to avoid Hidden Class creation in runtime.

Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-09-02 16:20:56 +04:00
Isaac Burns
53fc14c569 crypto: wrap ECDH constants in HAVE_OPENSSL
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-09-01 19:30:13 +04:00
Shigeki Ohtsu
f6877f37b2 tls: add DHE-RSA-AES128-SHA256 to the def ciphers
`!EDH` is also removed from the list in the discussion of #8272

Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-08-29 00:36:51 +04:00
Shigeki Ohtsu
0dfedb7127 tls, crypto: add DHE support
In case of an invalid DH parameter file, it is sliently discarded. To
use auto DH parameter in a server and DHE key length check in a
client, we need to wait for the next release of OpenSSL-1.0.2.

Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-08-29 00:36:48 +04:00
Fedor Indutny
6e453fad87 crypto: introduce ECDH 2014-08-29 00:27:09 +04:00
Jackson Tian
f7d6147e43 src: Add function name for .byteLength/.compare
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-08-27 14:13:31 +04:00
Fedor Indutny
6adf3ecebb crypto: allow padding in RSA methods
Reviewed-By: Trevor Norris <trevnorris@gmail.com>
2014-08-27 00:24:57 +04:00
Fedor Indutny
8a7d7f8b2b crypto: fix memory leak in Connection::New
Do not create `SSL` instance twice, `SSL_new` is called from `SSLBase`
constructor anyway.

Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-08-23 23:22:23 +04:00
Jackson Tian
c0f30f6058 http: avoid create difference hidden class
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
2014-08-21 16:29:52 -07:00
Chris Dickinson
4ef2a5a672 net,stream: add isPaused, don't read() when paused
net Sockets were calling read(0) to start reading, without
checking to see if they were paused first. This would result
in paused Socket objects keeping the event loop alive.

Fixes #8200

Reviewed-by: Trevor Norris <trev.norris@gmail.com>
2014-08-20 13:58:12 -07:00
cjihrig
5086d6ef94 dns: throw if hostname is not string or falsey
Fix assertion failure from poor argument parsing logic introduced in
6ea5d16. Add tests to make sure arguments are properly parsed.

Fixes: 6ea5d16 "dns: always set variable family in lookup()"
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
2014-08-20 13:51:09 -07:00
Ben Noordhuis
437c2f4383 node: add missing Isolate::Scope at startup
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
2014-08-19 10:28:06 -07:00
Yazhong Liu
7be96f5285 src: add missing Isolate arguments
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
2014-08-19 10:23:20 -07:00
Alex Kocharin
b9960eefc2 http: fix bailout for writeHead
Reported-by: Jackson Tian <shyvo1987@gmail.com>
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
2014-08-18 16:21:03 -07:00
Fedor Indutny
9134a3bf41 gyp: preserve v8dbg syms on freebsd too 2014-08-17 14:17:30 +04:00
Alexis Campailla
0d357fa135 test: fix dns test
Fix a few issues in test/internet/test-dns.js:
- 'hint' should be 'hints'
- reverse name lookup is not guaranteed to return 'localhost'
- V4MAPPED hint requires IPV6 address family

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
2014-08-13 11:44:20 -07:00
Julien Gilli
0565d52a71 tests: don't assume IPv4 only in remote addr tests
Tests in test-net-remote-address-port.js assume that client and server
sockets always use IPv4. However, depending on the OS and the network
interfaces setup, this is not true. This change makes the test consider
that both IPv4 or IPv6 sockets are valid

Fixes #8096.

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
2014-08-13 11:44:15 -07:00
Fedor Indutny
c7b42fe2e5 test: check ipv6 support before testing it
fix #7983
fix #8049

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
2014-08-13 11:43:58 -07:00
Julien Gilli
f5f5bd76e6 tests: do not hardcode service name in test-dns.
Instead of hard-coding http service name in test-dns, retrieve it from
/etc/services. This is not ideal, but it's still better than hard-coding
it.

Fixes #8047.

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
2014-08-13 11:43:41 -07:00
Julien Gilli
7d1860a678 tests: fix invalid hints flags dns test.
1 is actually a valid flag on SmartOS. More generally, hints flags'
values are defined by the underlying native flags, and these can have
different values on different systems.

Using (ADDRCONFIG | V4MAPPED) + 1 ensure that the flag will be invalid,
since it will always be different from ADDRCONFIG, V4MAPPED, ADDRCONFIG
| V4MAPPED,  0 and any other combination of even flags.

Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
2014-08-13 11:43:09 -07:00
Cheng Zhao
44743eaf24 src: change kIsolateSlot to 3
The slot 0 and 1 had already been taken by "gin" and "blink" in Chrome,
and the size of isolate's slots is 4 by default, so using 3 should hopefully
make node work independently when embedded into other application.

Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-08-13 13:58:51 +04:00
Trevor Norris
807acf7f98 src: require EventEmitter via NativeModule
Fixes a recent change causing test-process-kill-pid.js to fail.

Fixes: 931cbc1 "lib: don't use emitter.listeners(type).length"
Signed-off-by: Trevor Norris <trev.norris@gmail.com>
2014-08-12 21:50:21 -07:00
Jackson Tian
a8845ebd45 dgram: remove new keyword from errnoException
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
2014-08-12 21:43:20 -07:00
Kyle Robinson Young
00004160a1 doc: typo fixes on stream, tls and http
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
2014-08-12 21:04:41 -07:00
Ezequiel Rabinovich
678ead2608 querystring: remove prepended ? from query field
Fixes an issue that caused the first querystring to be parsed prepending
a "?" in the first variable name on relative urls with no #fragment

Reviewed-by: Trevor Norris <trev.norris@gmail.com>
2014-08-12 20:38:30 -07:00
Jackson Tian
931cbc175f lib: don't use emitter.listeners(type).length
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
2014-08-12 15:57:13 -07:00
Trevor Norris
0718426506 node: set names for prototype methods
Fix issue where output of a native prototype method would simply print
[Function]. It will now print [Function: name].

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
2014-08-11 17:10:43 -07:00
seishun
42bda05af8 crypto: add RSA encryption
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-08-11 22:00:34 +04:00