mirror of
https://github.com/pezkuwichain/pezkuwi-wallet-android.git
synced 2026-11-20 01:26:11 +00:00
Fetch .kurd content from our own gateway first, and believe a proven absence (#39)
ipfs.io and dweb.link now send trustless (?format=car) requests on to trustless-gateway.link, which only finds content announced over HTTP: for the dks.news package our node pins and serves it answered 525/526. The built-in list now starts with ipfs.pezkuwichain.io, a trustless-only gateway serving just what our node pins; the public two stay as fallbacks. Every block is still checked against the root, so the order changes reachability, not trust. A trustless gateway answers a path that is not there with 200 and the directory blocks that lack it. The fetcher took that for "no answer" and the reader saw Unavailable for a plain 404. A missing block throws in the reader, so a null from a verified CAR means the name is absent: it is now NotFound in one request.
This commit is contained in:
1 parent
8cbde5c422
commit
cb74f8cde0
2 files changed
+20
-3
No files matched your search
+10
-3
@@ -54,8 +54,13 @@ class RealKurdGateways(
|
||||
|
||||
const val LIST_URL = "https://raw.githubusercontent.com/pezkuwichain/pezkuwi-wallet-utils/master/kurd/gateways.json"
|
||||
|
||||
/** Measured reachable from Türkiye (architecture, M0); our own mirrors join through the signed list. */
|
||||
val BUILT_IN = listOf("https://ipfs.io", "https://dweb.link")
|
||||
/**
|
||||
* Ours first: since 2026 ipfs.io and dweb.link send `?format=car` on to trustless-gateway.link,
|
||||
* which finds only content announced over HTTP (measured 2026-11-06: 525/526 for a site our
|
||||
* node pins and serves). The two stay as fallbacks; both were measured reachable from Türkiye
|
||||
* (architecture, M0). More mirrors join through the signed list.
|
||||
*/
|
||||
val BUILT_IN = listOf("https://ipfs.pezkuwichain.io", "https://ipfs.io", "https://dweb.link")
|
||||
|
||||
private const val TAG = "KurdGateways"
|
||||
|
||||
@@ -130,7 +135,9 @@ class KurdContentFetcher(
|
||||
private suspend fun read(gateway: String, root: Cid, path: List<String>): Lookup? {
|
||||
val car = source.car(gateway, root, path)
|
||||
if (car != null) {
|
||||
val entry = UnixFsReader(VerifiedBlocks.fromCar(car), maxFileSize).read(root, path) ?: return null
|
||||
// A missing block throws; null means the verified directories on the way lack the name,
|
||||
// which is how a trustless gateway answers for a path that is not there
|
||||
val entry = UnixFsReader(VerifiedBlocks.fromCar(car), maxFileSize).read(root, path) ?: return Lookup.Absent
|
||||
return Lookup.Found(entry)
|
||||
}
|
||||
|
||||
|
||||
+10
@@ -38,6 +38,16 @@ class KurdContentFetcherTest {
|
||||
assertSame(KurdContentFetcher.Result.NotFound, KurdContentFetcher(gateways("https://one"), honest).fetch(root, listOf("subdir", "missing.txt")))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `a gateway proving the name absent in one answer is believed`() = runBlocking {
|
||||
// Kubo's trustless gateway answers a missing path with the directory blocks that lack it
|
||||
val asked = mutableListOf<List<String>>()
|
||||
val source = CarSource { _, _, path -> asked += path; car }
|
||||
|
||||
assertSame(KurdContentFetcher.Result.NotFound, KurdContentFetcher(gateways("https://one"), source).fetch(root, listOf("subdir", "missing.txt")))
|
||||
assertEquals(listOf(listOf("subdir", "missing.txt")), asked)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `a directory is served through its index and without one is not found`() = runBlocking {
|
||||
val source = CarSource { _, _, path -> if (path.lastOrNull() == KurdContentFetcher.INDEX) null else car }
|
||||
|
||||
Reference in new issue
Block a user