Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GOPROXY protocol support #7608

Closed
lunny opened this issue Jul 25, 2019 · 10 comments · Fixed by #24687
Closed

GOPROXY protocol support #7608

lunny opened this issue Jul 25, 2019 · 10 comments · Fixed by #24687
Labels
type/feature Completely new functionality. Can only be merged if feature freeze is not active. type/proposal The new feature has not been accepted yet but needs to be discussed first.
Milestone

Comments

@lunny
Copy link
Member

lunny commented Jul 25, 2019

If gitea could be as a goproxy server and all requested repositories could be stored on a special orgnization. That maybe a good idea.

ref: https://go.dev/ref/mod#goproxy-protocol

@lunny lunny added the type/proposal The new feature has not been accepted yet but needs to be discussed first. label Jul 25, 2019
@lunny
Copy link
Member Author

lunny commented Aug 8, 2019

The benefit when gitea support goproxy protocol but not a third-party:

  • all the information saved already in gitea(almost tags list, go mod file, source zip)
  • private repositories support. No proxy will save your token or private repositories copy.
  • if you have mirrored many packages from github, it could be goproxy resouces since we know which repositories you mirrored from.

A goproxy protocol request likes below, there are 5 http requests need to be implemented.

GET $HOST:$PORT/gitea.com/gitea/gitea/@v/list
GET $HOST:$PORT/gitea.com/gitea/gitea/@v/v1.0.0.info
GET $HOST:$PORT/gitea.com/gitea/gitea/@v/v1.0.0.mod
GET $HOST:$PORT/gitea.com/gitea/gitea/@v/v1.0.0.zip
GET $HOST:$PORT/gitea.com/gitea/gitea/@latest

If gitea supports that, the domain gitea.com will be a reserved username.

refs:
https://research.swtch.com/vgo-module
https://docs.gomods.io/intro/protocol/

btw:
Since go1.13 will support multiple goproxies, this will be possible.

@lafriks
Copy link
Member

lafriks commented Aug 8, 2019

but problem is that pretty much any domain will have to be reserved username then...

@sapk
Copy link
Member

sapk commented Aug 8, 2019

And what it would do with external package (not a local repo) ? cache them also ?
From an architecture point, I feel that it would be better to use one of the many goproxy implementation since it would be better to setup it under another domain like goproxy.domain.com. Furtermore, one of the goal of the goproxy is to act as a cache in case of downtime of repo, implentating goproxy in gitea would lost this advantage.

@lunny
Copy link
Member Author

lunny commented Aug 8, 2019

@lafriks No. Only the domain gitea itself. Mirrors could be any place because we know they mirrored from.

@lunny
Copy link
Member Author

lunny commented Aug 8, 2019

@sapk there are two functionality of goproxy protocol. One is for cache, another is for repositories.
Before go module come, go will get packages via go get that we only needs to provide a meta and a VCS(git) protocol.

On go module time, above is also available but provide a direct protocol is better. It will accelerate directly visit because git is too slow for a go module protocol.

You can consider this is a go module protocol v2 rather than go get protocol v1.

This will not against goproxy, it will only provide repositories via goproxy protocol.

@lunny
Copy link
Member Author

lunny commented Aug 8, 2019

When I and unknwon begin gopm repository on 2014 or 2015. We download github's zip or tar.gz source packages but not via git protocol. It's faster than go get that time. The goproxy is similiar.

@sapk
Copy link
Member

sapk commented Aug 8, 2019

@lunny I understand the speed-up but the trade-off are "big" (blocking some name, adding complexity, ...) compare to someone just setup a goproxy aside.
And for blocking name, technically module are not necessary FQDN at the base so it can interfere with a lot of other url. I think we better try to offer api endpoint (if needed) and work with goproxy implementation to help them speed there inital search on gitea.

On a side note, I haven't tested but GOPROXY should support a subfolder like GOPROXY=https://myproxy.com/sub-folder. (at least, it support it for file:// url) confirmed and confirmed
If we implement goproxy, I think it would be better to offer a sub-folder as an endpoint.

@lafriks
Copy link
Member

lafriks commented Aug 8, 2019

we could set to reserved username registry to use for goproxy, maybe later also for npm, docker registries etc, so that it could be used with GOPROXY=https://gitea.com/registry/go/ and for others we could use https://gitea.com/registry/npm/ etc

@lunny
Copy link
Member Author

lunny commented Aug 9, 2019

@sapk @lafriks Yeah. Gitea could implement these package protocols for this instance's repositories (NOT for a cache proxy). The target is different from goproxy or athens . And as what @lafriks said, this should be a first step to support golang, furthermore we can support other language packages protocols.

For enterprises' public or private repositories, that will reduce an extra server(goproxies or other languages).

Once gitea implemented this and with go 1.13, we can just set GOPROXY=https://myenterprise.com/registry/go,https://goproxy.io

@s3rj1k
Copy link

s3rj1k commented Apr 6, 2023

Highly needed feature

@lunny lunny added the type/feature Completely new functionality. Can only be merged if feature freeze is not active. label May 13, 2023
@lunny lunny added this to the 1.20.0 milestone May 13, 2023
lunny pushed a commit that referenced this issue May 14, 2023
Fixes #7608

This PR adds a Go package registry usable with the Go proxy protocol.

![grafik](https://github.com/go-gitea/gitea/assets/1666336/328feb5c-3df2-4f9d-8eae-fe3126d14c37)
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type/feature Completely new functionality. Can only be merged if feature freeze is not active. type/proposal The new feature has not been accepted yet but needs to be discussed first.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants