Improper parsing of IPv6 literals from config file #10138
Labels
issue/confirmed
Issue has been reviewed and confirmed to be present or accepted to be implemented
type/bug
Milestone
Gitea version 1.10.3 built with GNU Make 4.2.1, go1.13.6 : bindata, sqlite, pam
git version 2.25.0
Arch Linux
[x]
):Description
When I try to interact with git over SSH Gitea is unable to access its internal UpdatePublicKey endpoint because of the way that it builds the URL with an IPv6 literal. The URL used is "http://::1:3000/" when it should be "http://[::1]:3000" and it looks like there is a string split happening that interprets the ":1:3000" as a port number.
Error from the log file:
The HTTP_ADDR in the config is set to [::1], which works for the web interface (proxied via nginx):
Netstat shows Gitea listening correctly on localhost:
I've found the relevant parts of the codebase. This line builds the internal API URL by concatentating the LocalURL setting with the API path:
gitea/modules/private/serv.go
Line 76 in 7dcd305
Since the local URL has not been specified int he config file, this section sets the LocalURL parameter to HTTP_ADDR:HTTP_PORT/:
gitea/modules/setting/setting.go
Lines 632 to 639 in 7dcd305
And this line sets the HTTP_ADDR to the value in the config file:
gitea/modules/setting/setting.go
Line 592 in 7dcd305
The issue seems to be that when "[::1]" is parsed the brackets are dropped, which breaks the API URL building.
If I put the address in double quotes
HTTP_ADDR = "[::1]"
the git pull succeeds but Gitea still tries to access the broken http://::1:3000/api/internal/ssh/8/update URL.The text was updated successfully, but these errors were encountered: