mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-13 10:26:38 +08:00
refactor(agent): stop embedding GeoIP MMDB in agent binary
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.
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,15 @@
|
||||
// Package data embeds the MaxMind GeoLite2 Country database for the control plane.
|
||||
//
|
||||
// Server keeps a Country-only embed so MaxMind provider can seed without network.
|
||||
// Agent does NOT use this package — Agent MMDB files are image COPY / download only.
|
||||
package data
|
||||
|
||||
import "embed"
|
||||
|
||||
// FS holds the embedded GeoLite2-Country.mmdb database.
|
||||
//
|
||||
//go:embed GeoLite2-Country.mmdb
|
||||
var FS embed.FS
|
||||
|
||||
// DefaultMMDBName is the filename of the embedded MaxMind Country database.
|
||||
const DefaultMMDBName = "GeoLite2-Country.mmdb"
|
||||
@@ -0,0 +1,25 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user