Mirrors and interzone mirrors check the IPFS swarm too
Its publish and entry node get their own section whatever the network situation, so the swarm can be checked before choosing it. Preflight uses the same probe. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
100ba9e05c
commit
30c23a26f7
9 files changed
+64
-19
No files matched your search
+10
-1
@@ -232,7 +232,7 @@ func Check(args []string) error {
|
||||
func Mirrors(args []string) error {
|
||||
fs := flag.NewFlagSet("mirrors", flag.ExitOnError)
|
||||
fs.Usage = func() {
|
||||
fmt.Fprintln(fs.Output(), "Usage: interzone mirrors\n\nTests every known mirror in Iran for OS packages, Docker Engine and PyPI, and\nshows which distros each one carries. OS mirrors count for a distro only\nif its security or update indexes are fresh; PyPI mirrors must list\nansible-core.")
|
||||
fmt.Fprintln(fs.Output(), "Usage: interzone mirrors\n\nTests every known mirror in Iran for OS packages, Docker Engine and PyPI, and\nshows which distros each one carries. OS mirrors count for a distro only\nif its security or update indexes are fresh; PyPI mirrors must list\nansible-core. Also checks interzone's IPFS swarm: its newest signed\npublish, and whether an entry node answers.")
|
||||
}
|
||||
parse(fs, args)
|
||||
fmt.Println(muted.Render("Testing " + fmt.Sprint(len(config.KnownMirrors)) + " mirrors…"))
|
||||
@@ -256,6 +256,15 @@ func Mirrors(args []string) error {
|
||||
fmt.Printf(" %s %-58s %s\n", icon, r.Mirror.URL, style.Render(fmt.Sprintf("%s (%.1fs)", r.Detail, r.Took.Seconds())))
|
||||
}
|
||||
fmt.Println()
|
||||
fmt.Println(head.Render("==> interzone's IPFS swarm"))
|
||||
for _, c := range deploy.ProbeIPFS() {
|
||||
icon, style := good.Render("✓"), muted
|
||||
if !c.OK {
|
||||
icon, style = bad.Render("✗"), bad
|
||||
}
|
||||
fmt.Printf(" %s %-58s %s\n", icon, c.Name+" "+c.Target, style.Render(c.Detail))
|
||||
}
|
||||
fmt.Println()
|
||||
fmt.Printf("%d of %d mirrors work.\n", working, len(config.KnownMirrors))
|
||||
if working == 0 {
|
||||
return ErrFailed
|
||||
|
||||
+27
-10
@@ -45,18 +45,11 @@ func Preflight(c *config.Config) []Check {
|
||||
})
|
||||
}
|
||||
s := c.Sources
|
||||
swarm := make(chan []Check, 1)
|
||||
if s.IPFS {
|
||||
add("IPFS publish", ipfs.IndexURL, func(ctx context.Context) (string, error) {
|
||||
idx, err := indexFromWeb(ctx)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return "signed, from " + idx.Created, nil
|
||||
})
|
||||
add("IPFS entry node", "infamous.g0th.ir", func(ctx context.Context) (string, error) {
|
||||
return ipfsEntryReachable(ctx)
|
||||
})
|
||||
go func() { swarm <- ProbeIPFS() }()
|
||||
} else {
|
||||
swarm <- nil
|
||||
add("Playbook git", s.PlaybookGit, func(ctx context.Context) (string, error) { return gitReachable(ctx, s.PlaybookGit) })
|
||||
}
|
||||
if s.RolesGitBase != "" && !s.IPFS {
|
||||
@@ -98,6 +91,30 @@ func Preflight(c *config.Config) []Check {
|
||||
}(i, p)
|
||||
}
|
||||
wg.Wait()
|
||||
return append(out, <-swarm...)
|
||||
}
|
||||
|
||||
// ProbeIPFS checks interzone's swarm from here: the newest publish, and
|
||||
// whether an entry node answers.
|
||||
func ProbeIPFS() []Check {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 12*time.Second)
|
||||
defer cancel()
|
||||
out := []Check{{Name: "IPFS publish", Target: ipfs.IndexURL}, {Name: "IPFS entry node", Target: "infamous.g0th.ir"}}
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
defer close(done)
|
||||
if idx, err := indexFromWeb(ctx); err != nil {
|
||||
out[0].Detail = err.Error()
|
||||
} else {
|
||||
out[0].OK, out[0].Detail = true, "signed, from "+idx.Created
|
||||
}
|
||||
}()
|
||||
d, err := ipfsEntryReachable(ctx)
|
||||
out[1].OK, out[1].Detail = err == nil, d
|
||||
if err != nil {
|
||||
out[1].Detail = err.Error()
|
||||
}
|
||||
<-done
|
||||
return out
|
||||
}
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ func CheckSources(c *config.Config) []Check {
|
||||
var out []Check
|
||||
for _, ch := range Preflight(c) {
|
||||
switch ch.Name {
|
||||
case "Local tool", "Playbook git", "Roles git mirror":
|
||||
case "Local tool", "Playbook git", "Roles git mirror", "IPFS publish", "IPFS entry node": // the swarm has its own section
|
||||
continue
|
||||
}
|
||||
out = append(out, ch)
|
||||
|
||||
@@ -238,6 +238,7 @@ func openMirrors(a *App) {
|
||||
},
|
||||
Sources: []deploy.Check{{Name: "Container registry", Target: a.cfg.Sources.RegistryPrefix, OK: true, Detail: "HTTP 200"}},
|
||||
Known: []deploy.MirrorResult{{Mirror: config.KnownMirrors[0], OK: true, Detail: "fresh", Took: 120 * time.Millisecond}},
|
||||
IPFS: []deploy.Check{{Name: "IPFS publish", Target: "https://infamous.g0th.ir/.ipfs/", OK: true, Detail: "signed, from 2026-10-29T21:57:16Z"}},
|
||||
ImgErr: "the images are worked out from the playbook on the server; set it up first",
|
||||
}
|
||||
}
|
||||
|
||||
+21
-3
@@ -41,6 +41,7 @@ type mirrorsResult struct {
|
||||
Repos []deploy.Check
|
||||
Sources []deploy.Check
|
||||
Known []deploy.MirrorResult
|
||||
IPFS []deploy.Check
|
||||
Images []deploy.ImageStatus
|
||||
Arch string
|
||||
ImgErr string
|
||||
@@ -114,9 +115,11 @@ func (s *mirrorsScreen) check() tea.Cmd {
|
||||
part(mirrorsRepos, func(r *mirrorsResult) { r.Repos = deploy.CheckRepos(&cfg) }),
|
||||
part(mirrorsSources, func(r *mirrorsResult) {
|
||||
done := make(chan []deploy.MirrorResult)
|
||||
swarm := make(chan []deploy.Check)
|
||||
go func() { done <- deploy.ProbeKnownMirrors() }()
|
||||
go func() { swarm <- deploy.ProbeIPFS() }()
|
||||
r.Sources = deploy.CheckSources(&cfg)
|
||||
r.Known = <-done
|
||||
r.Known, r.IPFS = <-done, <-swarm
|
||||
}),
|
||||
part(mirrorsImages, func(r *mirrorsResult) {
|
||||
if !cfg.Installed() {
|
||||
@@ -145,7 +148,7 @@ func (s *mirrorsScreen) update(msg tea.Msg) tea.Cmd {
|
||||
case mirrorsRepos:
|
||||
s.res.Repos = m.res.Repos
|
||||
case mirrorsSources:
|
||||
s.res.Sources, s.res.Known = m.res.Sources, m.res.Known
|
||||
s.res.Sources, s.res.Known, s.res.IPFS = m.res.Sources, m.res.Known, m.res.IPFS
|
||||
case mirrorsImages:
|
||||
s.res.ImgErr = m.res.ImgErr
|
||||
if m.res.ImgErr == "" {
|
||||
@@ -209,6 +212,12 @@ func (s *mirrorsScreen) tally(part int) (ok, n int) {
|
||||
ok++
|
||||
}
|
||||
}
|
||||
for _, c := range s.res.IPFS {
|
||||
n++
|
||||
if c.OK {
|
||||
ok++
|
||||
}
|
||||
}
|
||||
case mirrorsImages: // the ones the setup needs
|
||||
for _, c := range s.res.Images {
|
||||
if !c.Needed {
|
||||
@@ -400,7 +409,10 @@ func (s *mirrorsScreen) sourceRows(w int) []string {
|
||||
return s.waiting(mirrorsSources, "probing the mirrors…")
|
||||
}
|
||||
rows := []string{sectionHeading("Used by "+s.cfg.Domain, min(w, 80))}
|
||||
if len(src) == 0 {
|
||||
switch {
|
||||
case s.cfg.Sources.IPFS:
|
||||
rows = append(rows, sFaint.Render(" everything comes from interzone's IPFS swarm, checked below"))
|
||||
case len(src) == 0:
|
||||
rows = append(rows, sFaint.Render(" no registry or package mirror is set; the upstream ones are used"))
|
||||
}
|
||||
for _, i := range failuresFirst(len(src), func(i int) bool { return src[i].OK }) {
|
||||
@@ -416,6 +428,12 @@ func (s *mirrorsScreen) sourceRows(w int) []string {
|
||||
}
|
||||
rows = append(rows, checkRow(w, k.OK, kinds[k.Mirror.Kind]+" · "+k.Mirror.Name, k.Mirror.URL, detail)...)
|
||||
}
|
||||
if len(s.res.IPFS) > 0 {
|
||||
rows = append(rows, "", sectionHeading("interzone's IPFS swarm", min(w, 80)))
|
||||
for _, c := range s.res.IPFS {
|
||||
rows = append(rows, checkRow(w, c.OK, c.Name, c.Target, c.Detail)...)
|
||||
}
|
||||
}
|
||||
return rows
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
│ ▸ Manage example.org ││ │
|
||||
│ ││ ╭──────────────────────────╮ ╭──────────────────────────╮ ╭──────────────────────────╮ │
|
||||
│ ▾ Mirrors ││ │ 1 Repositories │ │ 2 Mirrors │ │ 3 Images │ │
|
||||
│ ▌ ✗ Repositories ││ │ 2/3 1 missing │ │ 2/2 all there │ │ – not checked │ │
|
||||
│ ▌ ✗ Repositories ││ │ 2/3 1 missing │ │ 3/3 all there │ │ – not checked │ │
|
||||
│ ✓ Mirrors ││ │ ████████████████░░░░░░░░ │ │ ████████████████████████ │ │ ░░░░░░░░░░░░░░░░░░░░░░░░ │ │
|
||||
│ · Images ││ ╰──────────────────────────╯ ╰──────────────────────────╯ ╰──────────────────────────╯ │
|
||||
│ ││ checked just now · r checks again │
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
│ ▸ Manage example.org ││ │
|
||||
│ ││ ╭──────────────────────────────────────────────╮ ╭──────────────────────────────────────────────╮ ╭──────────────────────────────────────────────╮ │
|
||||
│ ▾ Mirrors ││ │ 1 Repositories │ │ 2 Mirrors │ │ 3 Images │ │
|
||||
│ ▌ ✗ Repositories ││ │ 2/3 1 missing │ │ 2/2 all there │ │ – not checked │ │
|
||||
│ ▌ ✗ Repositories ││ │ 2/3 1 missing │ │ 3/3 all there │ │ – not checked │ │
|
||||
│ ✓ Mirrors ││ │ █████████████████████████████░░░░░░░░░░░░░░░ │ │ ████████████████████████████████████████████ │ │ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │ │
|
||||
│ · Images ││ ╰──────────────────────────────────────────────╯ ╰──────────────────────────────────────────────╯ ╰──────────────────────────────────────────────╯ │
|
||||
│ ││ checked just now · r checks again │
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
◢◤ ⇅ Mirrors
|
||||
Is everything there to download?
|
||||
|
||||
▌Repos 2/3 · Mirrors 2/2 · Images –
|
||||
▌Repos 2/3 · Mirrors 3/3 · Images –
|
||||
checked just now · r checks again
|
||||
The playbook, and the roles it pins at their
|
||||
versions from https://itsjustadream.g0th.ir/
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
◢◤ ⇅ Mirrors
|
||||
Is everything there to download?
|
||||
▌Repos 2/3 · Mirrors 2/2 · Images –
|
||||
▌Repos 2/3 · Mirrors 3/3 · Images –
|
||||
checked just now · r checks again
|
||||
The playbook, and the roles it pins at their
|
||||
versions from https://itsjustadream.g0th.ir/
|
||||
|
||||
Reference in new issue
Block a user