🌍 MaxMindDB GeoIP database querying module for Garry's Mod

Overview

🌍 gm_maxminddb_geoip

This module reads, queries and serializes to Lua tables data from the MaxMindDB GeoIP database.

In other words, IP address goes in, GeoIP data comes out.

Installation

Downloading the module

First, run this in your server's console and it will tell you which module you need to download from the releases page

lua_run print("gmsv_maxminddb_geoip_" .. ((system.IsLinux() and "linux" .. (jit.arch == "x86" and "" or "64")) or (system.IsWindows() and "win" .. (jit.arch == "x86" and "32" or "64")) or "UNSUPPORTED") .. ".dll")

Then, put the downloaded dll file in garrysmod/lua/bin, if that folder doesn't exist, create it.

Downloading the MaxMindDB GeoIP database

Click here to download the MaxMindDB GeoIP database

You'll need to create an account unfortunately. Alternatively, you could always download a sketchy one from GitHub if you are lazy.

One you've created an account, log in and go to "Download Files" or "Download Databases" and download the database you need.

Once downloaded, copy it to garrysmod/maxminddb.mmdb on your server.

Which MaxMindDB GeoIP database do I need?

If you only need country information, download "GeoLite2 Country" (NOT the CSV one)


Developers

All data available in the maxminddb crate documentation is serialized and available.

If you want to automate the downloading of the database in some way, the module will also accept a MaxMindDB stored in garrysmod/data/maxminddb.dat which can be written to using file.Write


Rust -> Lua Type Conversions

Not all servers will have the full databases installed, and the free database contains limited data, which most servers will install. Therefore, do note that every field can be nil.

Rust Lua English
BTreeMap { [K] = V, ... } A key-value table
Vec { T, ... } A sequential table
Option T | nil Something that can be nil
&str string Text
f64 number A decimal number
u32 u16 integer A positive integer

Loading the module

(success: bool, error: [string | nil]) maxminddb.refresh()">
require("maxminddb_geoip")

-- Prints the version of the module
print(maxminddb.VERSION)

-- This will reread the database from the disk, useful if you've just written to garrysmod/data/maxminddb.dat
-- You don't need to call this function after require()ing the module, it will load automatically
-- maxminddb.refresh() -> (success: bool, error: [string | nil])
maxminddb.refresh()

Simple Querying

[(country: string, nil) | (nil, error: string)] local country, err = maxminddb.country("1.1.1.1", "en") if err then error(err) else print(country) -- "Australia" end">
-- Provided for convenience
-- maxminddb.country(ipAddress: string, lang: string = "en") -> [(country: string, nil) | (nil, error: string)]
local country, err = maxminddb.country("1.1.1.1", "en")
if err then
    error(err)
else
    print(country) -- "Australia"
end

Advanced Querying

-- Advanced querying
-- Records can be found here: https://docs.rs/maxminddb/latest/maxminddb/0.21.0
-- maxminddb.query(ipAddress: string, record) -> [(data: table, nil) | (nil, error: string)]
local data, err = maxminddb.query("1.1.1.1", maxminddb.records.Country)
if err then
    error(err)
else
    PrintTable(data) -- see below
end
-- Database used for example: GeoLite2-Country

continent:
    code        =       "OC"
    geoname_id  =       6255151
    names:
        de      =       "Ozeanien"
        en      =       "Oceania"
        es      =       "Oceanía"
        fr      =       "Océanie"
        ja      =       "オセアニア"
        pt-BR   =       "Oceania"
        ru      =       "Океания"
        zh-CN   =       "大洋洲"

country:
    geoname_id  =       2077456
    iso_code    =       "AU"
    names:
        de      =       "Australien"
        en      =       "Australia"
        es      =       "Australia"
        fr      =       "Australie"
        ja      =       "オーストラリア"
        pt-BR   =       "Austrália"
        ru      =       "Австралия"
        zh-CN   =       "澳大利亚"

registered_country:
    geoname_id  =       2077456
    iso_code    =       "AU"
    names:
        de      =       "Australien"
        en      =       "Australia"
        es      =       "Australia"
        fr      =       "Australie"
        ja      =       "オーストラリア"
        pt-BR   =       "Austrália"
        ru      =       "Австралия"
        zh-CN   =       "澳大利亚"
You might also like...
Scraper - HTML parsing and querying with CSS selectors

scraper HTML parsing and querying with CSS selectors. scraper is on Crates.io and GitHub. Scraper provides an interface to Servo's html5ever and selec

Discover GitHub token scope permission and return you an easy interface for checking token permission before querying GitHub.

github-scopes-rs Discover GitHub token scope permission and return you an easy interface for checking token permission before querying GitHub. In many

A query-building & utility crate for SurrealDB and its SQL querying language that aims to be simple

Surreal simple querybuilder A simple query-builder for the Surreal Query Language, for SurrealDB. Aims at being simple to use and not too verbose firs

An opinionated 2D sparse grid made for use with Bevy. For storing and querying entities

bevy_sparse_grid_2d An opinionated 2D sparse grid made for use with Bevy. For storing and querying entities. Personally, I'm using it for simple stupi

Efficient and fast querying and parsing of GTDB's data

xgt xgt is a Rust tool that enables efficient querying and parsing of the GTDB database. xgt consists of a collection of commands mirroring the GTDB A

Kepler is a vulnerability database and lookup store and API currently utilising National Vulnerability Database and NPM Advisories as data sources
Kepler is a vulnerability database and lookup store and API currently utilising National Vulnerability Database and NPM Advisories as data sources

Kepler — Kepler is a vulnerability database and lookup store and API currently utilising National Vulnerability Database and NPM Advisories as data so

⚙️ Workshop Publishing Utility for Garry's Mod, written in Rust & Svelte and powered by Tauri
⚙️ Workshop Publishing Utility for Garry's Mod, written in Rust & Svelte and powered by Tauri

⚙️ gmpublisher Currently in Beta development. A powerful and feature-packed Workshop publisher for Garry's Mod is finally here! Click for downloads Ar

📦 Pack hundreds of Garry's Mod Lua files into just a handful
📦 Pack hundreds of Garry's Mod Lua files into just a handful

📦 gluapack gluapack is a program that can pack hundreds of Garry's Mod Lua files into just a handful. Features Quick, easy and portable - perfect for

A swiss army knife for creating binary modules for Garry's Mod in Rust.

A swiss army knife for creating binary modules for Garry's Mod in Rust.

🐱‍👤 Cross-language static library for accessing the Lua state in Garry's Mod server plugins

gmserverplugin This is a utility library for making Server Plugins that access the Lua state in Garry's Mod. Currently, accessing the Lua state from a

A very simple Among Us mod launcher

Sussy Launcher ඞ A very simple mod launcher/loader for the game Among Us (Also referred to as Amogus ඞ). This Project is written with the Rust program

🌈 Brings back colour console to Win64 for Garry's Mod SRCDS
🌈 Brings back colour console to Win64 for Garry's Mod SRCDS

🌈 gmsv_concolormsg This module for Garry's Mod fixes x86-64 Windows 64-bit SRCDS not displaying colours. Why does it do that? Who knows! But it's eas

A Minecraft mod manager for the terminal.

Hopper A Minecraft mod manager for the terminal. Donate High-level Goals modrinth mod searching modrinth mod installation curseforge api too? per-inst

Gm microoptimisation war crime - An experimental optimisation for Garry's Mod

Wat This attractively named repository contains a Garry's Mod module that performs a micro optimisation that makes use of LuaJIT's constant folding on

Create archives of files within Garry's Mod

gm_zip Create archives of files within Garry's Mod. Note: The scope of this module only works accross the gmod installation files e.g from GarrysMod/g

A curl(libcurl) mod for rust.

curl Master Dev A lightweight Curl-wrapper for using (mostly) HTTP from Rust. While there are a couple of Rust HTTP libraries like rust-http and its s

Cross-platform CLI Rimworld Mod manager. Still under development

rwm Inspired by Spoons rmm. This is a cross-platform Mod Manager for RimWorld intended to work with macOS, linux and Windows Up to now, you must have

Mod for pxtone Collage that adds some shiny features
Mod for pxtone Collage that adds some shiny features

ptcMod Mod for pxtone Collage that adds some shiny features READ THIS FIRST The program is extremely invasive to ptCollage. This project makes extensi

A cross-platform Mod Manager for RimWorld intended to work with macOS, linux and Windows

TODOs are available here. Discussions, PRs and Issues are open for anyone who is willing to contribute. rrm Inspired by Spoons rmm. This is a cross-pl

Owner
William
aka Billy
William
GeoIP lookup server over HTTP.

geoip-http | geoip-http is a fast GeoIP lookup service in Rust, using the Axum web framework. It provides one possible server for tzupdate. Features F

Chris Down 4 Jun 3, 2023
🐱‍👤 Drop-in HTTP replacement module for Garry's Mod

??‍?? gmsv_reqwest This module is a drop-in replacement for Garry's Mod's HTTP function, inspired by gmsv_chttp created by timschumi. The module uses

William 38 Dec 12, 2022
⚡ Garry's Mod module that boosts performance by moving -condebug file I/O to a separate thread

This is a Garry's Mod server module that moves -condebug file I/O out of the main thread, which should significantly improve performance for noisy servers.

William 32 Dec 28, 2022
Base Garry's Mod binary module (Rust)

gmod-module-base-rs A base for developing Garry's Mod binary modules in Rust. Getting Started Install Rust Download or git clone this repository Open

William 7 Jul 30, 2022
A Rust-based Garry's Mod module for fetching environment variables.

gm_environ Using Environment Variables in Garry's Mod. Installation Download a copy of the module from the releases (or compile from source) Move the

Joshua Piper 2 Jan 4, 2022
Another cursed Garry's Mod module. This time, it adds the C preprocessor to Lua scripts

gm_cpreprocessor Another cursed Garry's Mod module. This time, it adds the C preprocessor to Lua scripts. It works by detouring RunStringEx and overri

William 6 Aug 14, 2022
A Garry's Mod module that lets you check which fonts are available on the system

gm_fontsx Since apparently we're never getting a proper way to check for installed fonts on Garry's Mod, this has to exist ?? Usage require("fontsx")

Earu 4 Mar 14, 2022
A Distributed SQL Database - Building the Database in the Public to Learn Database Internals

Table of Contents Overview Usage TODO MVCC in entangleDB SQL Query Execution in entangleDB entangleDB Raft Consensus Engine What I am trying to build

Sarthak Dalabehera 38 Jan 2, 2024
Valq - macros for querying and extracting value from structured data by JavaScript-like syntax

valq   valq provides a macro for querying and extracting value from structured data in very concise manner, like the JavaScript syntax. Look & Feel: u

Takumi Fujiwara 24 Dec 21, 2022
An (unofficial) Rust library for querying db-ip.com data

db_ip An (unofficial) library for querying db-ip.com CSV databases in safe Rust. This library is not affiliated with or endorsed by db-ip.com. Be advi

Finn Bear 4 Dec 2, 2022