geodata

package
v0.0.0-...-27db090 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2023 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package geodata includes utilities to decode and parse the geoip & geosite dat files.

It relies on the proto structure of GeoIP, GeoIPList, GeoSite and GeoSiteList in github.com/v2fly/v2ray-core/v4/app/router/config.proto to comply with following rules:

  1. GeoIPList and GeoSiteList cannot be changed
  2. The country_code in GeoIP and GeoSite must be a length-delimited `string`(wired type) and has field_number set to 1

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFailedToReadBytes            = errors.New("failed to read bytes")
	ErrFailedToReadExpectedLenBytes = errors.New("failed to read expected length of bytes")
	ErrInvalidGeodataFile           = errors.New("invalid geodata file")
	ErrInvalidGeodataVarintLength   = errors.New("invalid geodata varint length")
	ErrCodeNotFound                 = errors.New("code not found")
)

Functions

func Decode

func Decode(filename, code string) ([]byte, error)

func EmitBytes

func EmitBytes(f io.ReadSeeker, code string) ([]byte, error)

Types

type GeodataLoader

type GeodataLoader interface {
	LoadIP(filename, country string) ([]*v2router.CIDR, error)
	LoadSite(filename, list string) ([]*v2router.Domain, error)
	LoadGeoIP(country string) ([]*v2router.CIDR, error)
	LoadGeoSite(list string) ([]*v2router.Domain, error)
}

func NewGeodataLoader

func NewGeodataLoader() GeodataLoader

Jump to

Keyboard shortcuts

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