Skip to content

Commit

Permalink
Implement private IP ranges fetcher
Browse files Browse the repository at this point in the history
  • Loading branch information
aleho committed Jan 28, 2025
1 parent d8e6519 commit 951f0f6
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 10 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ The plugin includes predefined IP ranges for popular AI services. These ranges a
| GitHub Copilot | [github.go](ranges/fetchers/github.go) |
| Microsoft Azure | [azure.go](ranges/fetchers/azure.go) |
| Localhost (testing) | [localhost.go](ranges/fetchers/localhost.go) |
| Private (testing) | [private.go](ranges/fetchers/private.go) |
| AWS | [aws.go](ranges/fetchers/aws/aws.go) |
| AWS Region | [aws_region.go](ranges/fetchers/aws/aws_region.go) |

Expand Down
22 changes: 12 additions & 10 deletions ranges/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ The **Fetchers Module** is a Go package designed to fetch IP ranges for various
| `OpenAIFetcher` | Fetches IP ranges for OpenAI services (e.g., ChatGPT, GPTBot). |
| `GithubCopilotFetcher` | Fetches IP ranges for GitHub Copilot services. |
| `LocalhostFetcher` | Fetches IP ranges for localhost (used for development and testing). |
| `PrivateFetcher` | Fetches IP ranges for private network ranges (used for testing). |

---

Expand Down Expand Up @@ -63,16 +64,17 @@ func main() {

The `IPRanges` map in the `data` package contains the following keys:

| Key | Description |
|-------------------|-----------------------------------------------------------------------------|
| `aws` | Global IP ranges for AWS services. |
| `aws-us-east-1` | IP ranges for the AWS `us-east-1` region. |
| `aws-us-west-1` | IP ranges for the AWS `us-west-1` region. |
| `aws-eu-west-1` | IP ranges for the AWS `eu-west-1` region. |
| `gcloud` | IP ranges for Google Cloud Platform (GCP) services. |
| `openai` | IP ranges for OpenAI services (e.g., ChatGPT, GPTBot). |
| `githubcopilot` | IP ranges for GitHub Copilot services. |
| `localhost` | IP ranges for localhost (used for development and testing). |
| Key | Description |
|-----------------|-------------------------------------------------------------|
| `aws` | Global IP ranges for AWS services. |
| `aws-us-east-1` | IP ranges for the AWS `us-east-1` region. |
| `aws-us-west-1` | IP ranges for the AWS `us-west-1` region. |
| `aws-eu-west-1` | IP ranges for the AWS `eu-west-1` region. |
| `gcloud` | IP ranges for Google Cloud Platform (GCP) services. |
| `openai` | IP ranges for OpenAI services (e.g., ChatGPT, GPTBot). |
| `githubcopilot` | IP ranges for GitHub Copilot services. |
| `localhost` | IP ranges for localhost (used for development and testing). |
| `private` | IP ranges for private (used for testing). |

### Regenerating Pregenerated Results

Expand Down
20 changes: 20 additions & 0 deletions ranges/fetchers/private.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package fetchers

// PrivateFetcher implements the IPRangeFetcher interface for private network ranges.
type PrivateFetcher struct{}

func (f PrivateFetcher) Name() string {
return "Private"
}
func (f PrivateFetcher) Description() string {
return "Hardcoded IP ranges for private network ranges. Used in testing."
}
func (f PrivateFetcher) FetchIPRanges() ([]string, error) {

return []string{
"10.0.0.0/8",
"172.16.0.0/12",
"192.168.0.0/16",
"fd00::/8",
}, nil
}
1 change: 1 addition & 0 deletions ranges/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func main() {
aws.AWSRegionFetcher{Region: "us-west-1"}, // us-west-1 region
aws.AWSRegionFetcher{Region: "eu-west-1"}, // eu-west-1 region
fetchers.LocalhostFetcher{},
fetchers.PrivateFetcher{},
}

// Load the existing IP ranges from the data package
Expand Down

0 comments on commit 951f0f6

Please sign in to comment.