package conntrack

import "net"

var privateRanges = []string{
	"10.0.0.0/8",
	"172.16.0.0/12",
	"192.168.0.0/16",
}

var privateCIDRs []*net.IPNet

func init() {
	for _, cidr := range privateRanges {
		_, ipnet, _ := net.ParseCIDR(cidr)
		privateCIDRs = append(privateCIDRs, ipnet)
	}
}

func IsWGPeer(ip net.IP, wgSubnet *net.IPNet) bool {
	return wgSubnet.Contains(ip)
}

func IsExternal(ip net.IP) bool {
	for _, cidr := range privateCIDRs {
		if cidr.Contains(ip) {
			return false
		}
	}
	return true
}

func ProtoName(proto uint8) string {
	switch proto {
	case 6:
		return "tcp"
	case 17:
		return "udp"
	case 1:
		return "icmp"
	default:
		return "unknown"
	}
}