-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdoc.go
More file actions
49 lines (49 loc) · 1.3 KB
/
Copy pathdoc.go
File metadata and controls
49 lines (49 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Package cloudip provides fast cloud provider IP detection.
//
// It determines whether an IP address belongs to AWS, GCP, Azure,
// Cloudflare, DigitalOcean, or Oracle Cloud with sub-microsecond
// lookup times using a Patricia trie data structure.
//
// # Quick Start
//
// Use package-level functions for simple lookups:
//
// if cloudip.IsAWS("52.94.76.1") {
// fmt.Println("This is an AWS IP")
// }
//
// provider := cloudip.GetProvider("34.64.0.1")
// fmt.Println("Provider:", provider) // "gcp"
//
// result := cloudip.Lookup("52.94.76.1")
// if result.Found {
// fmt.Printf("Provider: %s, Region: %s\n", result.Provider, result.Region)
// }
//
// # Custom Detector
//
// For more control, create a custom Detector:
//
// detector, err := cloudip.NewDetector(
// cloudip.WithDataDir("./cache"),
// cloudip.WithAutoUpdate(24 * time.Hour),
// )
// if err != nil {
// log.Fatal(err)
// }
// defer detector.Close()
//
// result := detector.Lookup("52.94.76.1")
//
// # High Performance
//
// For best performance, use netip.Addr directly:
//
// addr, _ := netip.ParseAddr("52.94.76.1")
// result := cloudip.LookupAddr(addr)
//
// # Data Source
//
// IP ranges are sourced from official cloud provider publications
// and compiled into an embedded database that can be updated at runtime.
package cloudip