geo

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Overview

Package geo manages the geoip.dat / geosite.dat databases Xray needs to resolve geosite:/geoip: routing rules. They live in an asset dir pointed at by XRAY_LOCATION_ASSET.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Categories

func Categories(dir string) (geosite, geoip []string, err error)

Categories parses the category names out of geosite.dat and geoip.dat in dir. Both files are v2ray's GeoSiteList/GeoIPList protobuf: a flat sequence of length-delimited entries (field 1), each whose first field (1) is the uppercase category code (string). We only need that code, so a tiny reader avoids pulling in the full xray proto. Codes are returned lowercased + sorted.

func Ensure

func Ensure(dir string) error

Ensure downloads any missing database into dir (best-effort). Existing files are left as-is; refresh is handled separately.

func Refresh

func Refresh(dir string) error

Refresh re-downloads every database into dir regardless of whether it already exists, pulling the latest published version. It attempts all files and returns the first error encountered.

Types

type FileInfo

type FileInfo struct {
	Name       string `json:"name"`
	Present    bool   `json:"present"`
	Size       int64  `json:"size"`
	ModifiedAt int64  `json:"modified_at"` // unix seconds ≈ last successful download
}

FileInfo is the on-disk state of one geo database (for the settings UI).

func Status

func Status(dir string) []FileInfo

Status returns metadata for the geo databases in dir. The file mtime doubles as the "last downloaded" timestamp (download writes atomically via rename).

Jump to

Keyboard shortcuts

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