@@ -248,6 +248,33 @@ static void GetInterfaceAddresses(const FunctionCallbackInfo<Value>& args) {
248
248
}
249
249
250
250
251
+ static void GetOnLineStatus (const FunctionCallbackInfo<Value>& args) {
252
+ Environment* env = Environment::GetCurrent (args);
253
+ uv_interface_address_t * interfaces;
254
+ int count, i;
255
+
256
+ int err = uv_interface_addresses (&interfaces, &count);
257
+
258
+ if (err == UV_ENOSYS) return args.GetReturnValue ().Set (false );
259
+
260
+ if (err) {
261
+ CHECK_GE (args.Length (), 1 );
262
+ env->CollectUVExceptionInfo (
263
+ args[args.Length () - 1 ], errno, " uv_interface_addresses" );
264
+ return args.GetReturnValue ().Set (false );
265
+ }
266
+
267
+ for (i = 0 ; i < count; i++) {
268
+ if (interfaces[i].is_internal == false ) {
269
+ return args.GetReturnValue ().Set (true );
270
+ }
271
+ }
272
+
273
+ uv_free_interface_addresses (interfaces, count);
274
+ return args.GetReturnValue ().Set (false );
275
+ }
276
+
277
+
251
278
static void GetHomeDirectory (const FunctionCallbackInfo<Value>& args) {
252
279
Environment* env = Environment::GetCurrent (args);
253
280
char buf[PATH_MAX];
@@ -403,6 +430,7 @@ void Initialize(Local<Object> target,
403
430
SetMethod (context, target, " getPriority" , GetPriority);
404
431
SetMethod (
405
432
context, target, " getAvailableParallelism" , GetAvailableParallelism);
433
+ SetMethod (context, target, " getOnLineStatus" , GetOnLineStatus);
406
434
SetMethod (context, target, " getOSInformation" , GetOSInformation);
407
435
target
408
436
->Set (context,
@@ -419,6 +447,7 @@ void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
419
447
registry->Register (GetFreeMemory);
420
448
registry->Register (GetCPUInfo);
421
449
registry->Register (GetInterfaceAddresses);
450
+ registry->Register (GetOnLineStatus);
422
451
registry->Register (GetHomeDirectory);
423
452
registry->Register (GetUserInfo);
424
453
registry->Register (SetPriority);
0 commit comments