diff --git a/config.go b/config.go index 6adc258..2a2f985 100644 --- a/config.go +++ b/config.go @@ -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 { diff --git a/deploy/pkgstash.toml.example b/deploy/pkgstash.toml.example index a5447bb..dd1d326 100644 --- a/deploy/pkgstash.toml.example +++ b/deploy/pkgstash.toml.example @@ -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 +mirrored_repos = ["core", "extra"] port = "8090" [auth] diff --git a/internal/cache/cache.go b/internal/cache/cache.go index 41d3ec4..032d210 100644 --- a/internal/cache/cache.go +++ b/internal/cache/cache.go @@ -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, diff --git a/main.go b/main.go index 6f4f634..b833d8c 100644 --- a/main.go +++ b/main.go @@ -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()) }