Skip to content

docs: correct ALLOW_LOCALNETWORKS description in app.example.ini - #39240

Open
rawsun007 wants to merge 1 commit into
go-gitea:mainfrom
rawsun007:docs-allow-localnetworks
Open

docs: correct ALLOW_LOCALNETWORKS description in app.example.ini#39240
rawsun007 wants to merge 1 commit into
go-gitea:mainfrom
rawsun007:docs-allow-localnetworks

Conversation

@rawsun007

Copy link
Copy Markdown
Contributor

Fixes the app.example.ini half of #39224.

The comment says:

If a domain is allowed by ALLOWED_DOMAINS, this option will be ignored.

That is no longer true. checkByAllowBlockList in services/migrations/migrate.go consults the block list first and returns immediately:

if blockList.MatchHostName(hostName) || ipBlocked {
    return &git.ErrInvalidCloneAddr{Host: hostName, IsPermissionDenied: true}
}
// if we have an allow-list, check the allow-list before return to get the more accurate error
if !allowList.IsEmpty() { ... }

IsMigrateURLAllowed resolves the host with net.LookupIP and passes the addresses in, so with ALLOW_LOCALNETWORKS = false a host that appears in ALLOWED_DOMAINS is still rejected once any resolved address is private or loopback — the allow list never gets a look. The reporter traced this to the validation hardening in #38324 / #38400, and the code matches their description.

The new wording states the precedence rather than the old override claim.

Scope: this only covers custom/conf/app.example.ini, which lives here. The same stale sentence is on the config cheat sheet in gitea/docs (both the English and zh-cn pages) per the issue; that is a separate repository, and the PR template says documentation changes go there, so I have not touched it. Happy to send that one too.

I did not change behaviour — I have no opinion on whether block-before-allow is the right precedence, only that the comment describes the opposite of what the code does.

Disclosure: prepared with AI assistance (Claude, via Claude Code); the commit carries an Assisted-by: trailer. I read the validation path rather than inferring it, and every quote above is from current main. Per your contributing guide, review replies here will be mine rather than an AI's.

The comment claimed ALLOWED_DOMAINS overrides this option. Since the
migration URL validation hardening, checkByAllowBlockList returns on the
block list before it consults the allow list, so a host listed in
ALLOWED_DOMAINS is still rejected when it resolves to a private or loopback
address and ALLOW_LOCALNETWORKS is false.

Assisted-by: Claude (Claude Code)
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Sep 4, 2026
@github-actions github-actions Bot added type/docs This PR mainly updates/creates documentation docs-update-needed The document needs to be updated synchronously labels Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs-update-needed The document needs to be updated synchronously lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. type/docs This PR mainly updates/creates documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants