JavaScript Restrictor
Browser extension that improves privacy and security
|
This file contains common functions for Network Boundary Shield. More...
Functions | |
function | isIPV4 (url) |
function | isIPV6 (url) |
function | isIPV4Private (ipAddr) |
function | isIPV6Private (ipAddr) |
function | parseCSV (csv, ipv4) |
function | CSVToArray (strData) |
function | expandIPV6 (ip6addr) |
function | checkWhitelist (hostname) |
function | notifyBlockedRequest (origin, target, resource) |
function | messageListener ({message, site}, sender) |
The event listener, hooked up to the webExtension onMessage event. More... | |
function | commonMessageListener (message, sender) |
Variables | |
var | localIPV4DNSZones |
var | localIPV6DNSZones |
var | doNotBlockHosts = new Object() |
let | readFile |
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 checkWhitelist | ( | hostname | ) |
Check if the hostname or any of it's domains is whitelisted.
hostname | Any hostname (subdomains allowed). |
function commonMessageListener | ( | 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 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. |
\seealso https://github.com/polcak/jsrestrictor/issues/125 and the tempral white listing of 0.0.0.0 until we provide a checkbox for notifications.
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. |
\seealso https://github.com/polcak/jsrestrictor/issues/125 and the tempral white listing of 0.0.0.0 until we provide a checkbox for notifications.
function messageListener | ( | {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 notifyBlockedRequest | ( | origin, | |
target, | |||
resource | |||
) |
Creates and presents notification to the user. Works with webExtensions notification API. Creates notification about blocked request.
origin | Origin of the request. |
target | Target of the request. |
resource | Type of the resource. |
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. |
var doNotBlockHosts = new Object() |
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.
let readFile |
The function for reading a locally stored csv file.
_path | String with a fully-qualified URL. E.g.: moz-extension://2c127fa4-62c7-7e4f-90e5-472b45eecfdc/beasts/frog.dat |