From ae0299287209e6d1dd0606c885ca087e82ed0e7d Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Tue, 18 Feb 2014 10:10:30 -0800 Subject: [PATCH] os: networkInterfaces include scopeid for ipv6 --- src/node_os.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/node_os.cc b/src/node_os.cc index 9c4796b700..0c78003683 100644 --- a/src/node_os.cc +++ b/src/node_os.cc @@ -50,6 +50,7 @@ using v8::Context; using v8::FunctionCallbackInfo; using v8::Handle; using v8::HandleScope; +using v8::Integer; using v8::Local; using v8::Number; using v8::Object; @@ -272,6 +273,12 @@ static void GetInterfaceAddresses(const FunctionCallbackInfo& args) { o->Set(FIXED_ONE_BYTE_STRING(node_isolate, "mac"), FIXED_ONE_BYTE_STRING(node_isolate, mac)); + if (interfaces[i].address.address4.sin_family == AF_INET6) { + uint32_t scopeid = interfaces[i].address.address6.sin6_scope_id; + o->Set(FIXED_ONE_BYTE_STRING(node_isolate, "scopeid"), + Integer::NewFromUnsigned(scopeid)); + } + const bool internal = interfaces[i].is_internal; o->Set(FIXED_ONE_BYTE_STRING(node_isolate, "internal"), internal ? True(node_isolate) : False(node_isolate));