Geo based redirect module

Hi everyone, just here to share my small module I use and hope someone likes it.

Geo based redirect module provides a latency-aware alternative to traditional latency-based DNS routing. It works by calculating the geographical distance between the client’s IP address and a list of target domain IPs. It then redirects the client to the closest server, minimizing network latency and improving user experience.

Features:

  • From a pool of domains, redirect users to the one with the closest geographical location to minimize latency

  • For each domain it periodically check’s if DNS A record changed

  • For each domain it periodically check’s health, slower service is better then dead service

  • Ability to periodically sync geo ip database

  • Designed with performance in mind, it caches everything it can

I personally use it for my blog website.

4 Likes

Looking at the source code of your module, there seems to be a bug on line 312 of geoip.go:

	// We do not support IPv6 so we just skip it
	if clientIp.Is6() && clientIp.IsPrivate() {
		return "", fmt.Errorf("ipv6 and private subnets are not supported: %s", clientIp.String())
	}

Surely that should be || instead of &&?

2 Likes

Many thanks, I really appreciate that you took the time to view it!
Currently I don’t have integration I should definitely add them
You are right, pushed the fix.