wellknownips

package
v0.18.1 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2022 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AmazonASNumber    = "16509"
	AmazonCountryCode = "US"
	AmazonASName      = "AMAZON-02"
)
View Source
const (
	// AppleASNumber is the Apple ASNumber.
	AppleASNumber    = "714"
	AppleCountryCode = "US"
	AppleASName      = "APPLE-ENGINEERING"
)
View Source
const (
	AtlassianASNumber    = "133530"
	AtlassianCountryCode = "AU"
	AtlassianASName      = "ATLASSIAN PTY LTD"
)
View Source
const (
	MicrosoftASNumber    = "8075"
	MicrosoftCountryCode = "US"
	MicrosoftASName      = "MICROSOFT-CORP-MSN-AS-BLOCK"
)
View Source
const (
	GitHubASNumber    = "36459"
	GitHubCountryCode = "US"
	GitHubASName      = "GITHUB"
)
View Source
const (
	StripeASNumber    = "5091"
	StripeCountryCode = "US"
	StripeASName      = "STRIPE"
)

Variables

View Source
var AppleDomainVerificationIPAddresses = []string{
	"17.32.139.128/27",
	"17.32.139.160/27",
	"17.140.126.0/27",
	"17.140.126.32/27",
	"17.179.144.128/27",
	"17.179.144.160/27",
	"17.179.144.192/27",
	"17.179.144.224/27",
	"17.253.0.0/16",
}

AppleDomainVerificationIPAddresses are the domain verification ip addresses for Apple. https://developer.apple.com/documentation/apple_pay_on_the_web/setting_up_your_server#3179116

View Source
var DefaultAmazonAWSIPRangesURL = "https://ip-ranges.amazonaws.com/ip-ranges.json"

DefaultAmazonAWSIPRangesURL is the default amazon aws ip ranges url.

View Source
var DefaultAtlassianIPRangesURL = "https://ip-ranges.atlassian.com/"

DefaultAtlassianIPRangesURL is the default Atlassian IP Ranges url.

View Source
var DefaultGitHubMetaURL = "https://api.github.com/meta"
View Source
var DefaultIP2ASNURL = "https://iptoasn.com/data/ip2asn-v4.tsv.gz"
View Source
var DefaultStripeIPRangesURL = "https://stripe.com/files/ips/ips_webhooks.json"

The DefaultStripeIPRangesURL is the default stripe ip ranges url.

Functions

func FetchIP2ASNDatabase

func FetchIP2ASNDatabase(
	ctx context.Context,
	client *http.Client,
	url string,
) (*ip2asnStream, error)

FetchIP2ASNDatabase fetches the IP2ASN database.

Types

type AmazonAWSIPRanges

type AmazonAWSIPRanges struct {
	Prefixes []struct {
		IPPrefix           string `json:"ip_prefix"`
		Region             string `json:"region"`
		Service            string `json:"service"`
		NetworkBorderGroup string `json:"network_border_group"`
	} `json:"prefixes"`
}

func FetchAmazonAWSIPRanges

func FetchAmazonAWSIPRanges(
	ctx context.Context,
	client *http.Client,
	url string,
) (*AmazonAWSIPRanges, error)

FetchAmazonAWSIPRanges fetches the Amazon AWS IP Ranges.

type AtlassianIPRanges

type AtlassianIPRanges struct {
	Items []struct {
		CIDR    string   `json:"cidr"`
		Product []string `json:"product"`
	} `json:"items"`
}

AtlassianIPRanges are the Atlassian IP ranges.

func FetchAtlassianIPRanges

func FetchAtlassianIPRanges(
	ctx context.Context,
	client *http.Client,
	url string,
) (*AtlassianIPRanges, error)

FetchAtlassianIPRanges fetches the Atlassian IP Ranges.

type AzureIPRanges

type AzureIPRanges struct {
	Values []struct {
		Name       string `json:"name"`
		ID         string `json:"id"`
		Properties struct {
			SystemService   string   `json:"systemService"`
			AddressPrefixes []string `json:"addressPrefixes"`
		} `json:"properties"`
	} `json:"values"`
}

AzureIPRanges are the definitions of the ip ranges for services in Azure.

func FetchAzureIPRanges

func FetchAzureIPRanges(
	ctx context.Context,
) (*AzureIPRanges, error)

FetchAzureIPRanges fetches the Azure IP Ranges for all Azure services.

type GitHubMeta

type GitHubMeta struct {
	Hooks      []string `json:"hooks"`
	Web        []string `json:"web"`
	API        []string `json:"api"`
	Git        []string `json:"git"`
	Packages   []string `json:"packages"`
	Pages      []string `json:"pages"`
	Importer   []string `json:"importer"`
	Actions    []string `json:"actions"`
	Dependabot []string `json:"dependabot"`
}

GitHubMeta is the GitHub metadata.

func FetchGitHubMeta

func FetchGitHubMeta(
	ctx context.Context,
	client *http.Client,
	url string,
) (*GitHubMeta, error)

FetchGitHubMeta fetches the GitHub metadata.

type Record

type Record struct {
	ID          string
	ASNumber    string
	CountryCode string
	ASName      string
	Service     string
}

A Record is a Well-Known IP Record.

func RecordsFromAmazonAWSIPRanges

func RecordsFromAmazonAWSIPRanges(in *AmazonAWSIPRanges) []Record

RecordsFromAmazonAWSIPRanges converts AmazonAWSIPRanges records to Well-Known IP Records.

func RecordsFromAppleDomainVerificationIPAddresses

func RecordsFromAppleDomainVerificationIPAddresses(in []string) []Record

RecordsFromAppleDomainVerificationIPAddresses converts AppleDomainVerificationIPAddresses into records.

func RecordsFromAtlassianIPRanges

func RecordsFromAtlassianIPRanges(in *AtlassianIPRanges) []Record

RecordsFromAtlassianIPRanges converts AtlassianIPRanges into records.

func RecordsFromAzureIPRanges

func RecordsFromAzureIPRanges(in *AzureIPRanges) []Record

RecordsFromAzureIPRanges converts AzureIPRanges into records.

func RecordsFromGitHubMeta

func RecordsFromGitHubMeta(in *GitHubMeta) []Record

RecordsFromGitHubMeta converts GitHubMeta into records.

func RecordsFromIP2ASNRecord

func RecordsFromIP2ASNRecord(in *ip2asnRecord) []Record

RecordsFromIP2ASNRecord converts IP2ASN records to Well-Known IP Records.

func RecordsFromStripeIPRanges

func RecordsFromStripeIPRanges(in *StripeIPRanges) []Record

RecordsFromStripeIPRanges converts StripeIPRanges into records.

func (Record) MarshalJSON

func (record Record) MarshalJSON() ([]byte, error)

MarshalJSON marshals the Well-Known IP Record as a JSON object.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server serves well-known-ip records

func NewServer

func NewServer(options ...ServerOption) *Server

NewServer creates a new Server.

func (*Server) ServeHTTP

func (srv *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements the http.Handler interface.

type ServerOption

type ServerOption func(*serverConfig)

A ServerOption customizes the server config.

func WithIP2ASNURL

func WithIP2ASNURL(url string) ServerOption

WithIP2ASNURL sets the ip2asn url in the config.

type StripeIPRanges

type StripeIPRanges struct {
	WebHooks []string `json:"WEBHOOKS"`
}

StripeIPRanges are the stripe IP ranges.

func FetchStripeIPRanges

func FetchStripeIPRanges(
	ctx context.Context,
	client *http.Client,
	url string,
) (*StripeIPRanges, error)

FetchStripeIPRanges fetches the stripe ip ranges.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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