vip

package
v1.0.189 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package vip provides deterministic virtual IP generation for Gravity.

Instead of using a per-machine atomic counter (which requires coordination), this package hashes a connection's 5-tuple plus container ID to produce a deterministic IPv6 address within a /96 subnet. Any Gravity instance given the same inputs will compute the same VIP, enabling zero-coordination failover.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateDeterministicIPV6

func GenerateDeterministicIPV6(containerID string, srcIP net.IP, srcPort uint16, dstIP net.IP, dstPort uint16, subnet net.IPNet) (net.IP, error)

GenerateDeterministicIPV6 produces a deterministic IPv6 address within the given /96 subnet by hashing the provided connection parameters.

The function hashes containerID, srcIP, srcPort, dstIP, and dstPort using SHA-256, extracts a 32-bit host identifier from the hash, and embeds it into the last 32 bits of the subnet address.

Parameters:

  • containerID: unique identifier for the container
  • srcIP: source IP address of the connection
  • srcPort: source port of the connection
  • dstIP: destination IP address of the connection
  • dstPort: destination port of the connection
  • subnet: a /96 IPv6 subnet to place the address in

Returns the generated IPv6 address, or an error if the subnet is not /96.

Types

This section is empty.

Jump to

Keyboard shortcuts

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