Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ForgeMMDB

Lightweight GeoIP classifier using MaxMind MMDB.

Provides fast country lookup for IPv4 and cheap domain CN prediction.

Features

  • Zero-copy MMDB lookup (libmaxminddb mmap)
  • Packed ISO-3166 alpha-2 (UInt16) country code
  • Fast .cn / punycode domain prediction
  • iOS & macOS Swift Package

Installation

.package(url: "https://github.com/CoderQuinn/ForgeMMDB.git", from: "0.1.0")
.product(name: "ForgeMMDB", package: "ForgeMMDB")

Usage

Default classifier

import ForgeMMDB

let classifier = try ForgeMMDB.makeDefaultClassifier()

if classifier.isCN(ip: ip) {
	// direct
}

Custom database

let reader = try MMDBReader(location: .absolute("/path/Country.mmdb"))

Supported locations:

  • bundle
  • app support
  • app group
  • absolute path

Notes

  • Domain prediction is hint only
  • Routing decisions should rely on IP lookup
  • Private IP handling belongs to upper layers

License

ForgeMMDB and bundled libmaxminddb follow their respective LICENSE files.

About

Provides fast country lookup for IPv4 and cheap domain CN prediction.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages