Skip to content

Commit afcbffa

Browse files
lideljamiew
authored andcommitted
feat: subdomain gateways and Origin isolation check (#78)
This adds two known public gateways that support Origin isolation and Origin flag next to each gateway License: MIT Signed-off-by: Marcin Rataj <[email protected]>
1 parent ed5fc55 commit afcbffa

File tree

3 files changed

+42
-10
lines changed

3 files changed

+42
-10
lines changed

README.md

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
# ipfs/public-gateway-checker
22

3-
Checks which public IPFS gateways are online or not.
4-
5-
NOTE: All of these (except gateway.ipfs.io and ipfs.io) are hosted by third-parties and should be treated as such.
3+
> Checks which public IPFS gateways are online or not.
64
75
You can view this website on GitHub Pages: https://ipfs.github.io/public-gateway-checker/
86

9-
Here's a screenshot:
7+
[![screenshot_2019-12-14.png](https://ipfs.io/ipfs/QmX53EdPJxH377WHfwH8wV3tu8Zzjq9ojgQS6U82JRM6bd?filename=screenshot_2019-12-14.png)](https://ipfs.github.io/public-gateway-checker/)
108

11-
[![screenshot](https://ipfs.io/ipfs/QmY261PdTRv3eKgxqCfgAbKkCrSxdCerfjjPoc3Arq9C5q)](https://ipfs.github.io/public-gateway-checker/)
9+
**NOTE:** All of these (except `ipfs.io` and `dweb.link`) are hosted by third-parties and should be treated as such.
1210

13-
A CLI version `ipfg` is available here: https://github.com/JayBrown/Tools/tree/master/ipfg
11+
12+
## Adding a new public gateway
1413

1514
If you'd like to add a new public gateway, please edit `gateways.json` and submit a pull request.
15+
16+
17+
## Command line
18+
19+
A CLI version `ipfg` is available here: https://github.com/JayBrown/Tools/tree/master/ipfg

app.js

+30-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const HASH_TO_TEST = 'Qmaisz6NMhDB51cCvNWa1GMS7LU1pAxdF4Ld6Ft9kZEP2a';
2-
const SCRIPT_HASH = 'QmYHbXzTCbjavphzqrTe7zYYMW8HyeuMLNcLbqiUkj9TAH';
1+
const HASH_TO_TEST = 'bafybeifx7yeb55armcsxwwitkymga5xf53dxiarykms3ygqic223w5sk3m';
2+
const SCRIPT_HASH = 'bafybeietzsezxbgeeyrmwicylb5tpvf7yutrm3bxrfaoulaituhbi7q6yi';
33
const HASH_STRING = 'Hello from IPFS Gateway Checker';
44

55
// checker is the program root, it contains all involved objects
@@ -112,6 +112,29 @@ Cors.prototype.onerror = function() {
112112
};
113113
// ////////////////////////////////////////////////////////////////////////////////////
114114

115+
// ////////////////////////////////////////////////////////////////////////////////////
116+
// ORIGIN
117+
let Origin = function(parent) {
118+
this.parent = parent;
119+
120+
this.tag = document.createElement("span");
121+
this.tag.textContent = ' ORIGIN: 🕑 - ';
122+
};
123+
124+
Origin.prototype.check = function() {
125+
const cidInSubdomain = this.parent.gateway.startsWith('https://:hash.ipfs.');
126+
if (cidInSubdomain) {
127+
this.tag.textContent = ' ORIGIN: ✅ - ';
128+
} else {
129+
this.onerror();
130+
}
131+
};
132+
133+
Origin.prototype.onerror = function() {
134+
this.tag.textContent = ' ORIGIN: ❌ - ';
135+
};
136+
// ////////////////////////////////////////////////////////////////////////////////////
137+
115138
// ////////////////////////////////////////////////////////////////////////////////////
116139
// NODE
117140
let Node = function(parent, gateway, index) {
@@ -125,6 +148,9 @@ let Node = function(parent, gateway, index) {
125148
this.cors = new Cors(this);
126149
this.tag.append(this.cors.tag);
127150

151+
this.origin = new Origin(this);
152+
this.tag.append(this.origin.tag);
153+
128154
this.link = document.createElement("span");
129155
this.link.textContent = gateway.replace(':hash', HASH_TO_TEST);
130156
this.tag.append(this.link);
@@ -141,6 +167,7 @@ Node.prototype.check = function() {
141167
this.checkingTime = performance.now();
142168
this.status.check();
143169
this.cors.check();
170+
this.origin.check();
144171
};
145172

146173
Node.prototype.checked = function() {
@@ -149,7 +176,7 @@ Node.prototype.checked = function() {
149176

150177
let gatewayTitle = this.gateway.split(":hash")[0];
151178
let gatewayAndHash = this.gateway.replace(':hash', HASH_TO_TEST);
152-
this.link.innerHTML = `<a title="${gatewayTitle}"href="${gatewayAndHash}"target="_blank">${gatewayAndHash}</a>`;
179+
this.link.innerHTML = `<a title="${gatewayTitle}" href="${gatewayAndHash}#x-ipfs-companion-no-redirect" target="_blank">${gatewayAndHash}</a>`;
153180

154181
if (!this.tested) {
155182
let ms = (performance.now() - this.checkingTime).toFixed(2);
@@ -178,4 +205,3 @@ function checkGateways (gateways) {
178205
fetch('./gateways.json')
179206
.then(res => res.json())
180207
.then(gateways => checkGateways(gateways));
181-

gateways.json

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[
22
"https://ipfs.io/ipfs/:hash",
3+
"https://:hash.ipfs.dweb.link",
34
"https://gateway.ipfs.io/ipfs/:hash",
45
"https://ipfs.infura.io/ipfs/:hash",
56
"https://rx14.co.uk/ipfs/:hash",
@@ -17,6 +18,7 @@
1718
"https://gateway.blocksec.com/ipfs/:hash",
1819
"https://ipfs.renehsz.com/ipfs/:hash",
1920
"https://cloudflare-ipfs.com/ipfs/:hash",
21+
"https://:hash.ipfs.cf-ipfs.com",
2022
"https://ipns.co/:hash",
2123
"https://ipfs.mrh.io/ipfs/:hash",
2224
"https://gateway.originprotocol.com/ipfs/:hash",

0 commit comments

Comments
 (0)