- Add v4_ip_start and v4_ip_end columns to live_routes table - Calculate IPv4 CIDR ranges as 32-bit integers for fast lookups - Update PrefixHandler to populate IPv4 range fields - Add GetASInfoForIP method with optimized IPv4 queries - Add comprehensive tests for IP conversion functions
21 lines
329 B
Go
21 lines
329 B
Go
package database
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
func generateUUID() uuid.UUID {
|
|
return uuid.New()
|
|
}
|
|
|
|
// detectIPVersion determines if a prefix is IPv4 (returns 4) or IPv6 (returns 6)
|
|
func detectIPVersion(prefix string) int {
|
|
if strings.Contains(prefix, ":") {
|
|
return ipVersionV6
|
|
}
|
|
|
|
return ipVersionV4
|
|
}
|