mirror of
https://github.com/NoCLin/LightMirrors
synced 2025-07-23 18:16:39 +08:00
feat: go proxy
This commit is contained in:
parent
c9ebbac425
commit
098b06a58b
@ -29,6 +29,7 @@ from mirrorsrun.sites.pypi import pypi
|
|||||||
from mirrorsrun.sites.torch import torch
|
from mirrorsrun.sites.torch import torch
|
||||||
from mirrorsrun.sites.docker import dockerhub, k8s, quay, ghcr, nvcr
|
from mirrorsrun.sites.docker import dockerhub, k8s, quay, ghcr, nvcr
|
||||||
from mirrorsrun.sites.common import common
|
from mirrorsrun.sites.common import common
|
||||||
|
from mirrorsrun.sites.goproxy import goproxy
|
||||||
|
|
||||||
subdomain_mapping = {
|
subdomain_mapping = {
|
||||||
"mirrors": common,
|
"mirrors": common,
|
||||||
@ -40,6 +41,7 @@ subdomain_mapping = {
|
|||||||
"ghcr": ghcr,
|
"ghcr": ghcr,
|
||||||
"quay": quay,
|
"quay": quay,
|
||||||
"nvcr": nvcr,
|
"nvcr": nvcr,
|
||||||
|
"goproxy": goproxy,
|
||||||
}
|
}
|
||||||
|
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
|
29
src/mirrorsrun/sites/goproxy.py
Normal file
29
src/mirrorsrun/sites/goproxy.py
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
from starlette.requests import Request
|
||||||
|
|
||||||
|
from mirrorsrun.proxy.direct import direct_proxy
|
||||||
|
from starlette.responses import Response
|
||||||
|
|
||||||
|
|
||||||
|
async def goproxy(request: Request):
|
||||||
|
path = request.url.path
|
||||||
|
|
||||||
|
sumdb_prefix = "/sumdb/sum.golang.org"
|
||||||
|
if path.startswith(sumdb_prefix):
|
||||||
|
sumdb_path = path.removeprefix(sumdb_prefix)
|
||||||
|
if sumdb_path.startswith("/supported"):
|
||||||
|
return Response(
|
||||||
|
content=b"",
|
||||||
|
)
|
||||||
|
target_url = "https://sum.golang.org" + sumdb_path
|
||||||
|
return await direct_proxy(
|
||||||
|
request,
|
||||||
|
target_url,
|
||||||
|
)
|
||||||
|
|
||||||
|
target_url = "https://proxy.golang.org" + path
|
||||||
|
|
||||||
|
return await direct_proxy(
|
||||||
|
request,
|
||||||
|
target_url,
|
||||||
|
)
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user