added mirrored repos to config
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
type Config struct {
|
||||
CacheRoot string `toml:"cache_root"`
|
||||
MirrorURL string `toml:"mirror_url"`
|
||||
MirroredRepos []string `toml:"mirrored_repos"`
|
||||
Port string `toml:"port"`
|
||||
Auth AuthConfig `toml:"auth"`
|
||||
}
|
||||
|
||||
@@ -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]
|
||||
|
||||
Vendored
+2
-2
@@ -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,
|
||||
|
||||
@@ -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())
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user