foreseen

A text-based gemini browser with prefetching.
git clone git://git.laack.co/foreseen.git
Log | Files | Refs | README | LICENSE

commit 3ed1cfb557aa71bfe419d092f4cbbc3d53f41851
parent 2ff3222900b5f8429d175fcbff736ea935678a17
Author: Andrew Laack <andrew@laack.co>
Date:   Fri, 25 Sep 2026 20:29:43 -0500

Improvements to caching with certs (don't prefetch at the very least)

Diffstat:
MTODO.txt | 19+++++++++++++++----
Minclude/browser.hpp | 2+-
Msrc/browser.cpp | 16+++++++++++++++-
3 files changed, 31 insertions(+), 6 deletions(-)

diff --git a/TODO.txt b/TODO.txt @@ -1,7 +1,3 @@ -- Certificate support? - - Be able to: - - use a certificate - - detect cert changes w/ tofu - saving files - footprints mode - download all files to disk for sites you access @@ -34,3 +30,18 @@ - horizontal scroll when lines are too long? - make unordered list items indent correctly - first line is normal, subsequent lines should have 2 spaces prefixing them + +--- + +- Certificate support + - Be able to: + x use a certificate (done) + - detect cert changes w/ tofu + - notify users about certificate requests (6x messages) + - in these cases we should just inform users of such things. + - handle caching + - prefetching should be disabled when passing certs + - this should be configured on the basis of a domain then + - two things here: + - we shouldn't prefetch for cert requests / domains + - we shouldn't use prefetched when we add a cert where we didn't have one before. diff --git a/include/browser.hpp b/include/browser.hpp @@ -46,7 +46,7 @@ class Browser { std::vector<Line*> toLines(Site* site); void followLinkNumber(int linkToFollow); std::vector<Link>* getLinkLines(); - + Identity getIdentity(uri uriInput); void justCacheSite(Link link); void goBack(); void goForward(); diff --git a/src/browser.cpp b/src/browser.cpp @@ -26,6 +26,11 @@ void dispatch(std::vector<Link>* targets, Browser& b, int threadIdx) { std::vector<Link>& refT = *targets; for(int i = 0 ; i < refT.size() && i < SITE_CACHE_LIMIT; ++i) { auto& target = refT[i]; + + auto id = b.getIdentity(target.getLinkDestination()); + if(id.crtPath != "" || id.keyPath != "") { + continue; // don't try to prefetch for domains we normally pass a cert to. + } b.justCacheSite(target); } b.setDone(threadIdx); @@ -109,12 +114,16 @@ void Browser::goToSite(std::string url, bool addToHistory, bool refresh) { Site* site = nullptr; + + + + Identity id = identityManager.getIdentityForURI(destination->getLinkDestination()); + if(urlString.find("gemini://") != -1 && !refresh) { site = findInCacheAndPromoteIfRelevant(urlString); } if(site == nullptr) { - Identity id = identityManager.getIdentityForURI(destination->getLinkDestination()); site = client.fetchSite(*destination, id.crtPath, id.keyPath); } @@ -161,6 +170,11 @@ void Browser::goToSite(std::string url, bool addToHistory, bool refresh) { tryCacheTargets(); } +Identity Browser::getIdentity(uri uriInput) { + return this->identityManager.getIdentityForURI(uriInput); +} + + void Browser::justCacheSite(Link link) { auto client = GeminiClient{};