geosync

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 5, 2026 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Overview

Package geosync downloads geoip / geosite data files from HTTPS URLs on a schedule and reapplies GeoConfig via GeoWrapper.UpdateGeo after each successful download.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FetchViaDirectHTTP

func FetchViaDirectHTTP(ctx context.Context, rawURL string) ([]byte, error)

FetchViaDirectHTTP downloads using the process default HTTP transport (no outbound routing).

func PrefetchGeoDataFiles

func PrefetchGeoDataFiles(ctx context.Context, cfg *configs.GeoConfig) error

PrefetchGeoDataFiles downloads every configured HTTPS URL into filepath before the first UpdateGeo

Types

type GeoSync

type GeoSync struct {
	// contains filtered or unexported fields
}

GeoSync runs periodic HTTPS downloads for geo data files (cron from GeoRemoteFile).

func New

func New(gw *geo.Geo) *GeoSync

New returns a GeoSync that uses the given GeoWrapper for periodic refreshes.

func (*GeoSync) Close

func (s *GeoSync) Close() error

Close stops periodic tasks.

func (*GeoSync) Reconfigure

func (s *GeoSync) Reconfigure(cfg *configs.GeoConfig)

Reconfigure stores a clone of cfg for reloads after downloads, replaces download jobs, and restarts periodic tasks if GeoSync has already been started.

func (*GeoSync) Start

func (s *GeoSync) Start() error

Start begins periodic refresh tasks (no-op if already started or closed).

type Job

type Job struct {
	URL      string
	Filepath string
	// Standard 5-field cron; empty means prefetch only at startup / reconfigure.
	CronExpr string
	// Atomic domain set to reload after download (partial reload).
	DomainAtomicName string
	// Atomic IP set to reload after download (partial reload).
	IPAtomicName string
}

Job describes one on-disk geo data file synced from an HTTPS URL.

func CollectJobs

func CollectJobs(cfg *configs.GeoConfig) []Job

CollectJobs walks GeoConfig and returns one job per remote geosite/geoip entry.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL