Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsGithubIP ¶
IsGithubIP returns true if the ip address falls within one of the known GitHub ip ranges.
Example ¶
ips := []netip.Addr{
netip.MustParseAddr("192.30.252.1"),
netip.MustParseAddr("127.0.0.1"),
}
for _, ip := range ips {
if IsGithubIP(ip) {
fmt.Printf("%s is GitHub\n", ip)
} else {
fmt.Printf("%s is NOT GitHub\n", ip)
}
}
Output: 192.30.252.1 is GitHub 127.0.0.1 is NOT GitHub
Types ¶
type IPRange ¶
func Range ¶
Range returns the ip range and metadata an address falls within. If the IP is not a GitHub IP address it returns nil
Example ¶
ip := netip.MustParseAddr("192.30.252.1")
r := Range(ip)
fmt.Println(r.Prefix)
fmt.Println(r.Services)
Output: 192.30.252.0/22 [api copilot git github_enterprise_importer hooks web]
Click to show internal directories.
Click to hide internal directories.