mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-09-28 05:46:36 +08:00
3328d3d121
Agent ships without City/Country MMDB in the binary; Docker images COPY databases into data_dir, bare installs seed via download on first start. Server keeps Country-only embed for optional MaxMind control-plane use. Also harden fetch script nonempty check and reject non-file MMDB paths.
26 lines
554 B
Go
26 lines
554 B
Go
package data
|
|
|
|
import (
|
|
"io/fs"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/oschwald/maxminddb-golang"
|
|
)
|
|
|
|
func TestEmbeddedCountryDatabaseIsValid(t *testing.T) {
|
|
raw, err := fs.ReadFile(FS, DefaultMMDBName)
|
|
if err != nil {
|
|
t.Fatalf("read embedded Country database: %v", err)
|
|
}
|
|
reader, err := maxminddb.FromBytes(raw)
|
|
if err != nil {
|
|
t.Fatalf("open embedded Country database: %v", err)
|
|
}
|
|
defer reader.Close()
|
|
|
|
if !strings.Contains(reader.Metadata.DatabaseType, "Country") {
|
|
t.Fatalf("unexpected database type %q", reader.Metadata.DatabaseType)
|
|
}
|
|
}
|