url: change hostname regex to negate invalid chars

Regarding joyent/node#8520

This changes hostname validation from a whitelist regex approach
to a blacklist regex approach as described in https://url.spec.whatwg.org/#host-parsing.

url.parse misinterpreted `https://good.com+.evil.org/`
as `https://good.com/+.evil.org/`.  If we use url.parse to check the
validity of the hostname, the test passes, but in the browser the
user is redirected to the evil.org website.
doc: set logical umask in process.umask example

0644 seems to be the desired mode for new files (as it is a very weird
umask), and to achieve that the correct umask would be 0022.

PR-URL: https://github.com/joyent/node/pull/8039
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
node: fix bad assert

It was my mistake to change an assert check. This changes it back to how
the assert was originally done.

Fixes: c131c1f "modules: adding load linked modules feature"
Signed-off-by: Trevor Norris <trev.norris@gmail.com>
src: remove async listener

Async listener will have minor reimplementation in a future commit in
the form of hooks for user implemented API. Though for simplicity of
testing it's being completely removed first.

PR-URL: https://github.com/joyent/node/pull/8110
async-wrap: move MakeCallback to .cc

MakeCallback is too large a function to have as an inline. Correct that
by moving it to a .cc file.

PR-URL: https://github.com/joyent/node/pull/8110
node, async-wrap: remove MakeDomainCallback

A lot of code duplication for the removal of a single if statement is
not worth the added code complexity.

Also fixed using v8::Value::As<T>() before verifying the type of the
Value. Casting to an incorrect type will cause V8 to abort in debug
mode.

PR-URL: https://github.com/joyent/node/pull/8110
node: fix throws before timer module is loaded

An edge case could occur when the setImmediate() in _fatalException()
would fire before the timers module had been loaded globally and cause
Node to crash.

PR-URL: https://github.com/joyent/node/pull/8110
src: all wrap's now use actual FunctionTemplate

Instead of just creating a new Object to contain the connection
information, instantiate a new instance of a FunctionTemplate. This will
allow future improvements for debugging and performance probes.

Additionally class providers have been clarified such that the
"provider" field in req_wrap.h is no longer optional.

PR-URL: https://github.com/joyent/node/pull/8110
src: remove unnecessary template parameter

PR-URL: https://github.com/joyent/node/pull/8110
async-wrap: expose async-wrap as binding

Expose basic hooks for AsyncWrap via the async_wrap binding. Right now
only the PROVIDER types are exposed. This is a preliminary step before
more functionality is added.

PR-URL: https://github.com/joyent/node/pull/8110
async-wrap: explicitly pass parent

When instantiating a new AsyncWrap allow the parent AsyncWrap to be
passed. This is useful for cases like TCP incoming connections, so the
connection can be tied to the server receiving the connection.

Because the current architecture instantiates the *Wrap inside a
v8::FunctionCallback, the parent pointer is currently wrapped inside a
new v8::External every time and passed as an argument. A future
optimization would be to add the v8::External as the data field when
creating the v8::FunctionTemplate, change the pointer just before making
the call then NULL'ing it out afterwards. Though this will only knock
off an estimated 80ns, and the added code complexity is high. So not
worth doing until the current approach is proven to be a bottleneck.

PR-URL: https://github.com/joyent/node/pull/8110
async-wrap: add event hooks

Call a user-defined callback at specific points in the lifetime of an
asynchronous event. Which are on instantiation, just before/after the
callback has been run. If the error callback also throws an exception
there will be no mercy and the application will be forced to shutdown.

Currently these only tie into AsyncWrap, meaning no call to a hook
callback will be made for timers or process.nextTick() events. Though
those will be added in a future commit.

Here are a few notes on how to make the hooks work:

- The "this" of all event hook callbacks is the request object.
- The zero field (kCallInitHook) of the flags object passed to
  setupHooks() must be set != 0 before the init callback will be called.
- In the "init" callback the property "_asyncQueue" must be attached to
  the request object. e.g.

  function initHook() {
    this._asyncQueue = {};
  }

- DO NOT inspect the properties of the object in the init callback.
  Since the object is in the middle of being instantiated there are some
  cases when a getter is not complete, and doing so will cause Node to
  crash.

PR-URL: https://github.com/joyent/node/pull/8110