From e8bb5a622d0c1895b1768a90d0b422ec084db73f Mon Sep 17 00:00:00 2001 From: Ophestra Date: Sun, 7 Jun 2026 17:15:27 +0900 Subject: internal/rosa: mirror service via external cache This provides an authenticated implementation of the external cache. Signed-off-by: Ophestra --- cmd/mbf/cache.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'cmd/mbf/cache.go') diff --git a/cmd/mbf/cache.go b/cmd/mbf/cache.go index 0452a3e1..b683326f 100644 --- a/cmd/mbf/cache.go +++ b/cmd/mbf/cache.go @@ -2,6 +2,7 @@ package main import ( "context" + "net/http" "os" "path/filepath" "testing" @@ -9,6 +10,7 @@ import ( "hakurei.app/check" "hakurei.app/container" "hakurei.app/internal/pkg" + "hakurei.app/internal/rosa" "hakurei.app/message" ) @@ -30,7 +32,7 @@ type cache struct { // Loaded artifact of [rosa.QEMU]. qemu pkg.Artifact - base string + base, mirror string } // open opens the underlying [pkg.Cache]. @@ -86,6 +88,21 @@ func (cache *cache) open() (err error) { } done <- struct{}{} + if cache.mirror != "" { + var pub []byte + pub, err = os.ReadFile(base.Append("ed25519.pub").String()) + if err != nil { + cache.c.Close() + return + } + var r rosa.Remote + if r, err = rosa.NewRemote(cache.mirror, pub, http.DefaultClient); err != nil { + cache.c.Close() + return err + } + cache.c.SetExternal(r) + } + if cache.qemu != nil { var pathname *check.Absolute pathname, _, err = cache.c.Cure(cache.qemu) -- cgit v1.3.1