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 {
CacheRoot string `toml:"cache_root"`
MirrorURL string `toml:"mirror_url"`
Port string `toml:"port"`
Auth AuthConfig `toml:"auth"`
CacheRoot string `toml:"cache_root"`
MirrorURL string `toml:"mirror_url"`
MirroredRepos []string `toml:"mirrored_repos"`
Port string `toml:"port"`
Auth AuthConfig `toml:"auth"`
}
type AuthConfig struct {
+3
View File
@@ -1,5 +1,8 @@
cache_root = "/home/ewpt3ch/dev/pacman-cache-server/tmprepo"
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"
[auth]
+2 -2
View File
@@ -22,7 +22,7 @@ type Cache struct {
client http.Client
}
func NewCache(cacheRoot string, mirrorURL string) *Cache {
func NewCache(cacheRoot string, mirrorURL string, mirroredRepos []string) *Cache {
transport := &http.Transport{
DialContext: (&net.Dialer{
Timeout: 5 * time.Second,
@@ -33,7 +33,7 @@ func NewCache(cacheRoot string, mirrorURL string) *Cache {
return &Cache{
cacheRoot: cacheRoot,
mirrorURL: mirrorURL,
mirroredRepos: []string{"core", "extra", "multilib"},
mirroredRepos: mirroredRepos,
client: http.Client{
Timeout: 15 * time.Second,
Transport: transport,
+2 -1
View File
@@ -28,7 +28,7 @@ func main() {
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}
mux := http.NewServeMux()
@@ -44,6 +44,7 @@ func main() {
Handler: mux,
}
log.Printf("serving pkgstash root: %v on port: %v", cfg.CacheRoot, cfg.Port)
log.Fatal(httpServe.ListenAndServe())
}