11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ciconst { 61cb0ef41Sopenharmony_ci BlockList, 71cb0ef41Sopenharmony_ci} = require('net'); 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ciconst { 101cb0ef41Sopenharmony_ci ok, 111cb0ef41Sopenharmony_ci notStrictEqual, 121cb0ef41Sopenharmony_ci} = require('assert'); 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_ciconst blocklist = new BlockList(); 151cb0ef41Sopenharmony_ciblocklist.addAddress('123.123.123.123'); 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_ciconst mc = new MessageChannel(); 181cb0ef41Sopenharmony_ci 191cb0ef41Sopenharmony_cimc.port1.onmessage = common.mustCall(({ data }) => { 201cb0ef41Sopenharmony_ci notStrictEqual(data, blocklist); 211cb0ef41Sopenharmony_ci ok(data.check('123.123.123.123')); 221cb0ef41Sopenharmony_ci ok(!data.check('123.123.123.124')); 231cb0ef41Sopenharmony_ci 241cb0ef41Sopenharmony_ci data.addAddress('123.123.123.124'); 251cb0ef41Sopenharmony_ci ok(blocklist.check('123.123.123.124')); 261cb0ef41Sopenharmony_ci ok(data.check('123.123.123.124')); 271cb0ef41Sopenharmony_ci 281cb0ef41Sopenharmony_ci mc.port1.close(); 291cb0ef41Sopenharmony_ci}); 301cb0ef41Sopenharmony_ci 311cb0ef41Sopenharmony_cimc.port2.postMessage(blocklist); 32