summaryrefslogtreecommitdiff
path: root/src/tcp_wrap.cc
diff options
context:
space:
mode:
authorOuyang Yadong <oyydoibh@gmail.com>2018-10-21 15:59:38 +0800
committerOuyang Yadong <oyydoibh@gmail.com>2018-11-22 21:45:08 +0800
commit33a25b29a4d654f5c2a5c74725862bccb2fcccfb (patch)
treea963b15bcba72cabfb317cbb00e47ff33753fbd9 /src/tcp_wrap.cc
parent91748dd89c652939d52f38b94afe9eae4eb8fd5d (diff)
downloadandroid-node-v8-33a25b29a4d654f5c2a5c74725862bccb2fcccfb.tar.gz
android-node-v8-33a25b29a4d654f5c2a5c74725862bccb2fcccfb.tar.bz2
android-node-v8-33a25b29a4d654f5c2a5c74725862bccb2fcccfb.zip
net,dgram: add ipv6Only option for net and dgram
For TCP servers, the dual-stack support is enable by default, i.e. binding host "::" will also make "0.0.0.0" bound. This commit add ipv6Only option in `net.Server.listen()` and `dgram.createSocket()` methods which allows to disable dual-stack support. Support for cluster module is also provided in this commit. Fixes: https://github.com/nodejs/node/issues/17664 PR-URL: https://github.com/nodejs/node/pull/23798 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/tcp_wrap.cc')
-rw-r--r--src/tcp_wrap.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/tcp_wrap.cc b/src/tcp_wrap.cc
index e1316b42cd..504fda3de6 100644
--- a/src/tcp_wrap.cc
+++ b/src/tcp_wrap.cc
@@ -127,6 +127,7 @@ void TCPWrap::Initialize(Local<Object> target,
Local<Object> constants = Object::New(env->isolate());
NODE_DEFINE_CONSTANT(constants, SOCKET);
NODE_DEFINE_CONSTANT(constants, SERVER);
+ NODE_DEFINE_CONSTANT(constants, UV_TCP_IPV6ONLY);
target->Set(context,
env->constants_string(),
constants).FromJust();
@@ -252,13 +253,15 @@ void TCPWrap::Bind6(const FunctionCallbackInfo<Value>& args) {
Environment* env = wrap->env();
node::Utf8Value ip6_address(env->isolate(), args[0]);
int port;
+ unsigned int flags;
if (!args[1]->Int32Value(env->context()).To(&port)) return;
+ if (!args[2]->Uint32Value(env->context()).To(&flags)) return;
sockaddr_in6 addr;
int err = uv_ip6_addr(*ip6_address, port, &addr);
if (err == 0) {
err = uv_tcp_bind(&wrap->handle_,
reinterpret_cast<const sockaddr*>(&addr),
- 0);
+ flags);
}
args.GetReturnValue().Set(err);
}