geoip

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2025 License: MIT Imports: 7 Imported by: 0

README

Sysneting GeoIP Plugin

A middleware plugin that provides country-based access control using GeoIP databases.

Features

  • Country whitelist/blacklist filtering
  • CloudFlare, X-Real-IP, and X-Forwarded-For support
  • Automatic database updates
  • Connection termination for blocked requests
  • IPv4 and IPv6 support

Configuration

middleware:
  geoip:
    apiKey: "your-api-key"  # GeoIP database API key
    dbPath: "/etc/geo/geo.mmdb"  # Database file path
    mode: "blacklist"  # or "whitelist"
    countries: ["US", "CA"]  # ISO country codes
    updateInterval: "24h"  # Update frequency
    trustHeaders: true  # Trust proxy headers

Docker Example

services:
  web:
    labels:
      - "traefik.http.middlewares.geo-filter.plugin.geoip.apiKey=${GEOIP_LICENSE}"
      - "traefik.http.middlewares.geo-filter.plugin.geoip.mode=blacklist"
      - "traefik.http.middlewares.geo-filter.plugin.geoip.countries=US,CA"
      - "traefik.http.middlewares.geo-filter.plugin.geoip.trustHeaders=true"

License

MIT License - see LICENSE file for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(ctx context.Context, next http.Handler, config *Config, name string) (http.Handler, error)

Types

type Config

type Config struct {
	APIKey         string   `json:"apiKey,omitempty"`
	DBPath         string   `json:"dbPath,omitempty"`
	Mode           string   `json:"mode,omitempty"`
	Countries      []string `json:"countries,omitempty"`
	UpdateInterval string   `json:"updateInterval,omitempty"`
	TrustHeaders   bool     `json:"trustHeaders,omitempty"`
}

func CreateConfig

func CreateConfig() *Config

type Plugin

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

func (*Plugin) ServeHTTP

func (p *Plugin) ServeHTTP(rw http.ResponseWriter, req *http.Request)

Jump to

Keyboard shortcuts

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