added mirrored repos to config

This commit is contained in:
2026-04-20 19:08:44 -06:00
parent 727e9f40af
commit 6fdf5a4a52
4 changed files with 12 additions and 7 deletions
+5 -4
View File
@@ -7,10 +7,11 @@ import (
) )
type Config struct { type Config struct {
CacheRoot string `toml:"cache_root"` CacheRoot string `toml:"cache_root"`
MirrorURL string `toml:"mirror_url"` MirrorURL string `toml:"mirror_url"`
Port string `toml:"port"` MirroredRepos []string `toml:"mirrored_repos"`
Auth AuthConfig `toml:"auth"` Port string `toml:"port"`
Auth AuthConfig `toml:"auth"`
} }
type AuthConfig struct { type AuthConfig struct {
+3
View File
@@ -1,5 +1,8 @@
cache_root = "/home/ewpt3ch/dev/pacman-cache-server/tmprepo" cache_root = "/home/ewpt3ch/dev/pacman-cache-server/tmprepo"
mirror_url = "https://us.mirrors.cicku.me/archlinux/" mirror_url = "https://us.mirrors.cicku.me/archlinux/"
# array of upstream repos this server caches see pacman.conf
# or pacman docs for more info <core, extra, multilib>
mirrored_repos = ["core", "extra"]
port = "8090" port = "8090"
[auth] [auth]
+2 -2
View File
@@ -22,7 +22,7 @@ type Cache struct {
client http.Client client http.Client
} }
func NewCache(cacheRoot string, mirrorURL string) *Cache { func NewCache(cacheRoot string, mirrorURL string, mirroredRepos []string) *Cache {
transport := &http.Transport{ transport := &http.Transport{
DialContext: (&net.Dialer{ DialContext: (&net.Dialer{
Timeout: 5 * time.Second, Timeout: 5 * time.Second,
@@ -33,7 +33,7 @@ func NewCache(cacheRoot string, mirrorURL string) *Cache {
return &Cache{ return &Cache{
cacheRoot: cacheRoot, cacheRoot: cacheRoot,
mirrorURL: mirrorURL, mirrorURL: mirrorURL,
mirroredRepos: []string{"core", "extra", "multilib"}, mirroredRepos: mirroredRepos,
client: http.Client{ client: http.Client{
Timeout: 15 * time.Second, Timeout: 15 * time.Second,
Transport: transport, Transport: transport,
+2 -1
View File
@@ -28,7 +28,7 @@ func main() {
log.Fatal(err) log.Fatal(err)
} }
c := cache.NewCache(cfg.CacheRoot, cfg.MirrorURL) c := cache.NewCache(cfg.CacheRoot, cfg.MirrorURL, cfg.MirroredRepos)
srv := &Server{cfg: cfg, c: c} srv := &Server{cfg: cfg, c: c}
mux := http.NewServeMux() mux := http.NewServeMux()
@@ -44,6 +44,7 @@ func main() {
Handler: mux, Handler: mux,
} }
log.Printf("serving pkgstash root: %v on port: %v", cfg.CacheRoot, cfg.Port)
log.Fatal(httpServe.ListenAndServe()) log.Fatal(httpServe.ListenAndServe())
} }