Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
ab2432a
started adding nat64 prefix
BPplays Sep 30, 2024
e220656
started adding nat64 prefix
BPplays Sep 30, 2024
5fd6264
changed html
BPplays Sep 30, 2024
b7c239c
testing ipv6 parse
BPplays Oct 2, 2024
639f134
fixed v6 addr parsing
BPplays Oct 2, 2024
89f75b9
fixed v6 addr parsing
BPplays Oct 2, 2024
9e44eaf
test split
BPplays Oct 2, 2024
563affb
fixed v6 addr parsing
BPplays Oct 2, 2024
3cb31c5
fixed v6 addr parsing
BPplays Oct 2, 2024
18e26e6
fixed v6 addr parsing
BPplays Oct 3, 2024
417345b
fixed v6 addr parsing, and removed old code
BPplays Oct 3, 2024
c3eee91
added error handling
BPplays Oct 3, 2024
91017d6
added error handling
BPplays Oct 3, 2024
1dcab11
removed old code
BPplays Oct 3, 2024
e0ec07b
started adding nat64 foramtting
BPplays Oct 3, 2024
d4e7fe9
started adding nat64 foramtting
BPplays Oct 3, 2024
8472c01
started adding nat64 foramtting
BPplays Oct 3, 2024
b0b65c3
started adding nat64 foramtting
BPplays Oct 3, 2024
dae435a
started adding nat64 foramtting
BPplays Oct 3, 2024
1238a26
added v4 rendering
BPplays Oct 4, 2024
7d8c1b9
made popup render nat64 style
BPplays Oct 4, 2024
1d592cb
changed dismiss to onmousedown instead of onclick
BPplays Oct 4, 2024
2f23b20
changed html input sytle
BPplays Oct 4, 2024
9cea0a5
added proper option for nat64
BPplays Oct 4, 2024
925e2ce
added proper option for nat64
BPplays Oct 4, 2024
3c615f5
started adding nat64hex option
BPplays Oct 5, 2024
8aaa352
started adding nat64hex option
BPplays Oct 5, 2024
eb57d6b
started adding nat64hex option
BPplays Oct 5, 2024
a385621
changed onmousedown for hex opt
BPplays Oct 5, 2024
a6b8097
changed onmousedown for hex opt
BPplays Oct 5, 2024
7feb17c
changed onmousedown for hex opt
BPplays Oct 6, 2024
0a0cd0a
changed onmousedown for hex opt
BPplays Oct 6, 2024
1e327b2
changed var names
BPplays Oct 6, 2024
7887759
changed var names
BPplays Oct 6, 2024
b7b75e9
changed var names
BPplays Oct 6, 2024
3fde604
changed opt formatting
BPplays Oct 6, 2024
6c88d99
changed opt formatting
BPplays Oct 6, 2024
34c072b
added css radio buttons
BPplays Oct 8, 2024
2342744
added css radio buttons
BPplays Oct 8, 2024
4a78284
changed accent colr
BPplays Oct 8, 2024
8d5cf51
changed easing functions
BPplays Oct 8, 2024
fab7651
changed easing functions
BPplays Oct 8, 2024
1b49940
changed easing functions
BPplays Oct 8, 2024
f8455ad
changed radio buttons to onmousedown first test
BPplays Oct 9, 2024
32f4780
removed unused code
BPplays Oct 9, 2024
cbff208
moved input handling
BPplays Oct 9, 2024
e08bfe6
moved input handling
BPplays Oct 9, 2024
c5ee186
changed easing functions
BPplays Oct 9, 2024
ff4b601
started testing auto nat64 det
BPplays Oct 9, 2024
b984a81
changed light mode styling
BPplays Oct 9, 2024
9ccc002
started styling table
BPplays Oct 9, 2024
199593c
started styling table
BPplays Oct 9, 2024
8945053
changed to use middle sep in table instead of border
BPplays Oct 9, 2024
ed221a2
changed to use middle sep in table instead of border
BPplays Oct 9, 2024
f250f11
changed to default nat64 prefix
BPplays Oct 10, 2024
bcacb38
testing readme change
BPplays Oct 10, 2024
4b04649
testing readme change
BPplays Oct 10, 2024
d670718
added warning to reload pages
BPplays Oct 10, 2024
1213986
changed light theme and fixed warning
BPplays Oct 10, 2024
c4b5461
changed address parser
BPplays Oct 10, 2024
dce9834
changed address parser
BPplays Oct 10, 2024
0e8c4fa
changed address parser
BPplays Oct 10, 2024
dd35073
changed readme wording
BPplays Oct 10, 2024
0851fa7
changed readme wording
BPplays Oct 10, 2024
250d130
move stuff from methods to funcs
BPplays Oct 10, 2024
8e6d87d
changed wording for opts
BPplays Oct 10, 2024
dd9039a
removed unused styles and changed font to just use browser selecte sa…
BPplays Oct 10, 2024
7c7a2bb
removed unused styles
BPplays Oct 10, 2024
90dcbd5
added checks for user input nat64 addresses
BPplays Oct 11, 2024
7e5a225
added checks for user input nat64 addresses
BPplays Oct 11, 2024
c9c1138
fixed typo
BPplays Oct 11, 2024
637bf5e
fixed typo
BPplays Oct 11, 2024
2bec162
added more debug logging
BPplays Oct 11, 2024
6ce63dc
changed log wording
BPplays Oct 11, 2024
41c009e
changed var name
BPplays Oct 11, 2024
4045814
changed opt formatting
BPplays Oct 11, 2024
4d0d0e1
changed color styling
BPplays Oct 11, 2024
7ce87ea
changed color styling
BPplays Oct 11, 2024
22c7def
changed color styling
BPplays Oct 11, 2024
98e8993
changed styling
BPplays Oct 11, 2024
9fcb784
fixed firefox clearing nat64 prefix on error
BPplays Oct 11, 2024
523730c
small fix
BPplays Oct 11, 2024
e18794b
small fix
BPplays Oct 11, 2024
054beb5
small fix
BPplays Oct 11, 2024
6ec1975
fixed light theme contrast
BPplays Oct 11, 2024
fc11439
changed addrVersion() to use isValidIPv6Addr. this might need more te…
BPplays Oct 12, 2024
86c47cc
optimized addrVersion()
BPplays Oct 12, 2024
937f5d1
removed unused unfinished auto nat64 mode
BPplays Oct 12, 2024
2523405
removed unused unfinished auto nat64 mode
BPplays Oct 12, 2024
4b25657
added more logging
BPplays Oct 12, 2024
1b23a69
optimized code and chagned formatting
BPplays Oct 12, 2024
9d29599
removed prefix for ipv6 nat64 entry problems as it's obvious enough f…
BPplays Oct 12, 2024
83b8d0f
changed spacing
BPplays Oct 12, 2024
bb81672
janky fixed scrollbar randomly appearing on resize
BPplays Oct 12, 2024
28f4bd7
janky fixed scrollbar randomly appearing on resize
BPplays Oct 12, 2024
734a92f
janky fixed scrollbar randomly appearing on resize
BPplays Oct 12, 2024
72f9770
maybe fixed. scrollbar issues seem to be caused by an off by one erro…
BPplays Oct 12, 2024
a70409e
fixed scrollbar ocilation by adding delay to turn on
BPplays Oct 13, 2024
4159959
changed func name
BPplays Oct 13, 2024
2488355
changed spacing
BPplays Oct 13, 2024
efa1b66
fixed small css error
BPplays Oct 13, 2024
ae7c621
changed wording of note
BPplays Oct 13, 2024
abd60ed
small ui change
BPplays Oct 13, 2024
da06e55
added more tests for valid ipv6 addresses
BPplays Oct 15, 2024
a236183
changed ux for dismiss button to reflect the fact that it discards ch…
BPplays Oct 15, 2024
8b3c7f0
added ipv4 hex renderer
BPplays Oct 17, 2024
84adeb2
added ipv4 hex renderer
BPplays Oct 17, 2024
133db19
added options for ipv4 format
BPplays Oct 18, 2024
96998f5
added option for nat64 formatting
BPplays Oct 18, 2024
2f6ce59
changes scrollbar stuff and formatting
BPplays Oct 18, 2024
b3e69a1
fixed nat64 output bug
BPplays Oct 21, 2024
f872e0d
fixed nat64 output bug
BPplays Oct 21, 2024
295e8db
fixed dumb bug
BPplays Oct 24, 2024
22a8641
changed popup styling
BPplays Nov 13, 2024
fdd15f4
changed wording on options menu
BPplays Nov 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,11 @@ chrome: prepare
cp -f ${MANIFEST_C} ${MANIFEST}
zip -9j ${BUILDDIR}${NAME}-${VERSION_C}.zip -j src/*

rm -rf ${BUILDDIR}${NAME}-${VERSION_C}
cp -f ${MANIFEST_C} ${MANIFEST}
# zip -9j ${BUILDDIR}${NAME}-${VERSION_C}.zip -j src/*
mkdir -p ${BUILDDIR}${NAME}-${VERSION_C}-unpacked-chrome
cp -r src/* ${BUILDDIR}${NAME}-${VERSION_C}-unpacked-chrome/

clean:
rm -rf ${BUILDDIR}
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,21 @@ https://chrome.google.com/webstore/detail/ipvfoo/ecanpcehffngcegjmadlcijfolapgga
-->

## Add to Firefox
https://addons.mozilla.org/addon/ipvfoo/
https://addons.mozilla.org/addon/ipvfoo/

<picture><img src="https://badgen.net/amo/v/ipvfoo"></picture>
<picture><img src="https://badgen.net/amo/users/ipvfoo"></picture>
<picture><img src="https://badgen.net/amo/rating/ipvfoo"></picture>

## Add to Edge
https://microsoftedge.microsoft.com/addons/detail/ipvfoo/dphnkggpaicipkljebciobedeiaiofod
https://microsoftedge.microsoft.com/addons/detail/ipvfoo/dphnkggpaicipkljebciobedeiaiofod
*(You can also run the Chrome version on Edge, as they are identical.)*

## Safari?

IPvFoo cannot be [ported to Safari](https://github.com/pmarks-net/ipvfoo/issues/39) because the `webRequest` API does not report IP addresses. In theory, a Safari extension could do its own DNS lookups over HTTPS, but such behavior is beyond the scope of IPvFoo.

## troubleshooting
### ipv4-only sites are shown as ipv6 when using nat64
set 'NAT64 Prefix' in the extension options

89 changes: 71 additions & 18 deletions src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,7 @@ const TAB_DEAD = 2;
// RequestFilter for webRequest events.
const FILTER_ALL_URLS = { urls: ["<all_urls>"] };

// Distinguish IP address and domain name characters.
// Note that IP6_CHARS must not match "beef.de"
const IP4_CHARS = /^[0-9.]+$/;
const IP6_CHARS = /^[0-9A-Fa-f]*:[0-9A-Fa-f:.]*$/;
const DNS_CHARS = /^[0-9A-Za-z._-]+$/;


const SECONDS = 1000; // to milliseconds

Expand Down Expand Up @@ -318,7 +314,7 @@ class TabInfo extends SaveableEntry {
this.save();
}

addDomain(domain, addr, flags) {
addDomain(domain, addr, flags, nat64addr = "") {
let d = this.domains[domain];
if (!d) {
// Limit the number of domains per page, to avoid wasting RAM.
Expand All @@ -327,7 +323,7 @@ class TabInfo extends SaveableEntry {
return;
}
d = this.domains[domain] =
new DomainInfo(this, domain, addr || "(lost)", flags);
new DomainInfo(this, domain, addr || "(lost)", flags, nat64addr);
d.countUp();
} else {
const oldAddr = d.addr;
Expand Down Expand Up @@ -360,14 +356,19 @@ class TabInfo extends SaveableEntry {
let tooltip = "";
for (const [domain, d] of Object.entries(this.domains)) {
if (domain == this.mainDomain) {
pattern = d.addrVersion();
let [addrVer, _] = d.addrVersion();
pattern = addrVer;

if (IS_MOBILE) {
tooltip = d.addr; // Limited tooltip space on Android.
} else {

tooltip = `${d.addr}\n${NAME_VERSION}`;
}
} else {
switch (d.addrVersion()) {
let [addrVer, _] = d.addrVersion();

switch (addrVer) {
case "4": has4 = true; break;
case "6": has6 = true; break;
}
Expand Down Expand Up @@ -430,12 +431,14 @@ class TabInfo extends SaveableEntry {
const tuples = [mainTuple];
for (const domain of domains) {
const d = this.domains[domain];
let [addrVer, _] = d.addrVersion();
if (domain == mainTuple[0]) {
mainTuple[1] = d.addr;
mainTuple[2] = d.addrVersion();
mainTuple[2] = addrVer;
mainTuple[3] = d.flags;
mainTuple[4] = d.renderAddr();
} else {
tuples.push([domain, d.addr, d.addrVersion(), d.flags]);
tuples.push([domain, d.addr, addrVer, d.flags, d.renderAddr()]);
}
}
return tuples;
Expand All @@ -448,23 +451,30 @@ class TabInfo extends SaveableEntry {
// Perhaps this.domains was cleared during the request's lifetime.
return null;
}
return [domain, d.addr, d.addrVersion(), d.flags];

let [addrVer, _] = d.addrVersion();
return [domain, d.addr, addrVer, d.flags, d.renderAddr()];
}
}

class DomainInfo {
tabInfo;
domain;

addr;
flags;
nat64Addr;
nat64AddrBitsCIDR;
isNat64;

flags;
count = 0; // count of active requests
inhibitZero = false;

constructor(tabInfo, domain, addr, flags) {
constructor(tabInfo, domain, addr, flags, nat64addr = "") {
this.tabInfo = tabInfo;
this.domain = domain;
this.addr = addr;
this.getNat64Addr(nat64addr)
this.flags = flags;
}

Expand All @@ -478,15 +488,56 @@ class DomainInfo {
return new DomainInfo(tabInfo, domain, addr, flags);
}

renderAddr() {
let [ver, nat64] = this.addrVersion(this.addr)
this.isNat64 = nat64
if (ver === "4" && !nat64) {
if (options["ipv4Format"] !== "dotDecimal") {
let parseV4 = parseIPv4WithCidr(this.addr)
return renderIPv4(parseV4.addr);
}

}

if (this.isNat64) {
let bits = parseIPv6WithCIDR(this.addr)
return renderIPv6(bits.addr, true)
}
return this.addr

}

getNat64Addr(addr = "") {
if (addr === "") {
this.nat64Addr = options['nat64Prefix'];
} else {
this.nat64Addr = addr
}

this.nat64AddrBitsCIDR = parseIPv6WithCIDR(this.nat64Addr, 96);
let [_, nat64] = this.addrVersion(this.addr)
this.isNat64 = nat64
}




// In theory, we should be using a full-blown subnet parser/matcher here,
// but let's keep it simple and stick with text for now.
addrVersion() {
if (this.addr) {
if (/^64:ff9b::/.test(this.addr)) return "4"; // RFC6052
if (this.addr.indexOf(".") >= 0) return "4";
if (this.addr.indexOf(":") >= 0) return "6";
if (this.addr.indexOf(".") >= 0) return ["4", false];


let [isValidV6, problem] = isValidIPv6Addr(this.addr);
debugLog(problem)

if (isValidV6) {
if (inAddrRange(parseIPv6WithCIDR(this.addr, -1, true), this.nat64AddrBitsCIDR)) return ["4", true]; // RFC6052
return ["6", false];
}
}
return "?";
return ["?", false];
}

async countUp() {
Expand Down Expand Up @@ -530,6 +581,8 @@ class RequestInfo extends SaveableEntry {
if (!this.domain) {
continue; // still waiting for onResponseStarted
}


tabInfo.addDomain(this.domain, null, 0);
}
if (Object.keys(this.tabIdToBorn).length == 0) {
Expand Down
Loading