JavaScript Restrictor
Browser extension that improves privacy and security
|
This file contains common functions for Network Boundary Shield. More...
Functions | |
function | nbsLoadConfiguration () |
function | isIPV4 (url) |
function | isIPV6 (url) |
function | isIPV4Private (ipAddr) |
function | isIPV6Private (ipAddr) |
function | parseCSV (csv, ipv4) |
function | CSVToArray (strData) |
function | expandIPV6 (ip6addr) |
function | isNbsWhitelisted (hostname) |
function | notifyBlockedRequest (origin, target, tabId) |
function | clearNbsNotification (tabId) |
function async | createCumulativeNotification (tabId) |
function | showNbsNotification (tabId) |
function | nbsMessageListener ({message, site}, sender) |
The event listener, hooked up to the webExtension onMessage event. | |
function | nbsSettingsListener (message) |
The event listener, hooked up to the webExtension onMessage event. | |
function | nbsCommonMessageListener (message, sender) |
Variables | |
var | localIPV4DNSZones |
var | localIPV6DNSZones |
var | doNotBlockHosts = {} |
var | nbsSettings = {} |
var | nbsNotifications = {} |
const | NBS_DEF_SETTINGS |
This file contains common functions for Network Boundary Shield.
This file contains basic logic of the NBS, NBS global variables and objects, functions for reading and parsing CSV files, and functions for identifying and processing IP addresses and checking IP ranges.
function clearNbsNotification | ( | tabId | ) |
Clear notification data for the tab.
tabId | Tab ID of notification. |
function async createCumulativeNotification | ( | tabId | ) |
Create second notification containing a summary of accumulated data. This notification is shown after the initial one if a page continues to access local network.
tabId | Integer number representing ID of browser tab. |
function CSVToArray | ( | strData | ) |
Auxillary function for parsing CSV files. Converts CSV to array.
strData | Loaded CSV file as a string. |
function expandIPV6 | ( | ip6addr | ) |
Function for expanding shorten ipv6 addresses.
ip6addr | Valid ipv6 address. |
function isIPV4 | ( | url | ) |
Checks validity of IPv4 addresses.
url | An URL that may or may not contains an IPv4 address instead of a domain name. |
function isIPV4Private | ( | ipAddr | ) |
Checks whether the ipAddr is found in IPv4 localZones. If the IPv4 address is found in any IPv4 local zone, it means that this IPv4 address is private. IPv4 local zone is e.g. 192.168.000.000/16.
ipAddr | Valid IPv4 address. |
function isIPV6 | ( | url | ) |
Checks validity IPV6 address.
url | An URL that may or may not contains an IPv6 address instead of a domain name. |
function isIPV6Private | ( | ipAddr | ) |
Checks whether the ipAddr is found in IPv6 localZones. If the IPv6 address is found in any IPv6 local zone, it means that this IPv6 address is private. IPv6 local zone is e.g. fe80::/10.
ipAddr | Valid IPv6 address. |
function isNbsWhitelisted | ( | hostname | ) |
Check if the hostname or any of it's domains is whitelisted.
hostname | Any hostname (subdomains allowed). |
function nbsCommonMessageListener | ( | message, | |
sender | |||
) |
Event listener hooked up to webExtensions onMessage event. Does appropriate action based on message (e.g. Turn on/off the NBS, add/remove a site to/from whitelist, ...).
message | Receives full message. |
sender | Sender of the message. |
function nbsLoadConfiguration | ( | ) |
The function that loads module configuration from sync storage.
function nbsMessageListener | ( | {message, site}, | |
sender | |||
) |
The event listener, hooked up to the webExtension onMessage event.
The listener sends message response which contains information if the current site is whitelisted or not.
message | Receives full message (destructured as {message, site}). |
sender | Sender of the message. |
function nbsSettingsListener | ( | message | ) |
The event listener, hooked up to the webExtension onMessage event.
The listener sends message response which contains information about cuurent module settings.
message | Receives full message. |
function notifyBlockedRequest | ( | origin, | |
target, | |||
tabId | |||
) |
Log data about NBS blocking in context of tabs. This data will be used for notification creation.
origin | Origin of the request. |
target | Target of the request. |
tabId | Tab ID of blocked request. |
function parseCSV | ( | csv, | |
ipv4 | |||
) |
Function for parsing CSV files obtained from IANA. It strips .IN-ADDR and .IP6 from zones and comma delimiter, merges them into array by CSV rows.
csv | CSV obtained from IANA. |
ipv4 | Boolean, saying whether the csv is IPv4 CSV or IPv6. |
function showNbsNotification | ( | tabId | ) |
Creates and presents notification about blocked requests.
tabId | Integer number representing ID of browser tab. |
var doNotBlockHosts = {} |
Associtive array of hosts, that are currently among trusted "do not blocked" hosts.
var localIPV4DNSZones |
Locally served IPV4 DNS zones loaded from IANA.
var localIPV6DNSZones |
Locally served IPV6 DNS zones loaded from IANA.
const NBS_DEF_SETTINGS |
Definition of settings supported by this module.
var nbsNotifications = {} |
Object holding active notifications of this module.
var nbsSettings = {} |
Associtive array of settings supported by this module.