Skip to content

feat(plugins): allow CGNAT addresses for listed private hosts via PLUGIN_FETCH_ALLOW_CGNAT - #864

Merged
pikann merged 2 commits into
Paca-AI:masterfrom
jeeva-m-21:feat/issue-688-plugin-fetch-allow-cgnat
Dec 4, 2026
Merged

pikann merged 2 commits into
Paca-AI:masterfrom
jeeva-m-21:feat/issue-688-plugin-fetch-allow-cgnat

Conversation

@jeeva-m-21

Copy link
Copy Markdown
Contributor

Summary

Adds an explicit opt-in PLUGIN_FETCH_ALLOW_CGNAT (default false) so paca.fetch can reach services on CGNAT addresses (100.64.0.0/10, such as Tailscale) when their hostname is already listed in PLUGIN_FETCH_PRIVATE_HOSTS.

  • Why: netguard.PrivateHosts.Blocks previously only exempted net.IP.IsPrivate() (RFC 1918 and fc00::/7), keeping 100.64.0.0/10 blocked even for listed hosts because some cloud metadata endpoints live there.
  • What changed:
    • Added PrivateHostsOption / WithAllowCGNAT(bool) and isCGNAT in services/api/internal/platform/netguard/netguard.go. Only direct IPv4 / IPv4-mapped CGNAT addresses for listed hosts are exempted when opted in; unlisted hosts, loopback, link-local (169.254.0.0/16), and IPv6 transition literals remain blocked, and JEV_PRIVATE_HOSTS is unchanged.
    • Added PluginsConfig.FetchAllowCGNAT parsed from PLUGIN_FETCH_ALLOW_CGNAT (false by default) in services/api/internal/config/ and wired it in services/api/internal/bootstrap/app.go.
    • Added PLUGIN_FETCH_ALLOW_CGNAT / api.plugins.fetchAllowCGNAT to deploy/docker-compose.prod.yml, deploy/helm/paca/, deploy/README.md, and docs/plugins/backend-plugin-system.md.
    • Added unit tests in private_hosts_test.go and load_test.go.

Fixes #688

Type of Change

  • Other (feature / configuration opt-in)

Verification

Run in services/api with golang:1.26.4-alpine:

  • gofmt -s -l internal/platform/netguard internal/config internal/bootstrap (clean)
  • go test -count=1 ./internal/platform/netguard/... ./internal/config/... (passed)
  • go vet ./... (passed)
  • go build ./... (passed)
  • golangci-lint run --timeout=5m ./internal/platform/netguard/... ./internal/config/... ./internal/bootstrap/... (0 issues)

Checklist

  • The change is focused and scoped.
  • Related documentation is updated.
  • New structure or direction is explained clearly.
  • I avoided unnecessary detail or premature abstraction.

Copilot AI balanced review requested due to automatic review settings December 4, 2026 06:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No blocking issues — one non-blocking finding below.

Approach: sound — an explicit, default-off opt-in that reuses the existing listed-host mechanism and leaves every other internal range blocked.

Reviewed changes

  • CGNAT exception: PrivateHostsOption/WithAllowCGNAT and isCGNAT extend PrivateHosts.Blocks so listed hosts may reach 100.64.0.0/10 only when opted in; loopback, link-local, multicast, unspecified, and IPv6 transition literals stay blocked.
  • Config plumbing: PLUGIN_FETCH_ALLOW_CGNAT is parsed as a bool (default false, invalid values error out) into PluginsConfig.FetchAllowCGNAT and passed to NewPrivateHosts in bootstrap/app.go, reaching paca.fetch through the existing FetchPrivateHosts set.
  • Deployment and docs: Compose, Helm values/template, deploy/README.md, and the plugin backend docs describe the new opt-in.
  • Tests: New cases cover the allowed/blocked CGNAT matrix and the config default/true/invalid paths; go test ./internal/platform/netguard/... ./internal/config/... passes.

Non-blocking

Pullfrog  | Fix it ➔ | View workflow run | Using deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

@pikann pikann left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you for the contribution! 🚀

@pikann
pikann merged commit 31406c0 into Paca-AI:master Dec 4, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plugin fetch: allow CGNAT addresses (Tailscale) for listed private hosts?

3 participants