package geckorelay import ( "crypto/sha256" "encoding/hex" "fmt" "io" "os" "path/filepath" ) const AssetsPrefix = "/assets/v0.0.1/" // Hashes of the two unmodified files in upstream v0.0.1. The release archive // itself is pinned in docs/operations/gecko-relay.md. Refuse mixed engine/glue. func VerifyAssets(dir string) error { for name, want := range map[string]string{ "gecko.js": "e5aeebffd21106eccf23b1219316221add5e95085bc5a1bfb941117cfcd75ef7", "gecko.wasm.zst": "ebd6c75179152624d9644865e11792ed25cadc714d9e0985f412baf9c637a086", } { f, err := os.Open(filepath.Join(dir, name)) if err != nil { return fmt.Errorf("required Gecko asset unavailable: %s", name) } h := sha256.New() _, err = io.Copy(h, io.LimitReader(f, 64<<20)) f.Close() if err != nil || hex.EncodeToString(h.Sum(nil)) != want { return fmt.Errorf("Gecko asset checksum mismatch: %s", name) } } return nil }