forked from goproxy/goproxy.cn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
43 lines (37 loc) · 955 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"github.com/davecgh/go-spew/spew"
"github.com/spf13/pflag"
"log"
"net/http"
"os"
"strings"
"github.com/goproxy/goproxy"
"github.com/goproxy/goproxy/cacher"
_ "github.com/joho/godotenv/autoload"
"github.com/spf13/viper"
)
var cfgFile = pflag.StringP("config", "c", "config.yaml", "config file")
func init() {
viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_", ".", "_"))
viper.SetEnvPrefix("GU")
viper.AutomaticEnv()
viper.SetConfigType("yaml")
viper.SetConfigFile(*cfgFile)
if err := viper.ReadInConfig(); err != nil {
panic(err)
}
spew.Dump(viper.AllSettings())
}
func main() {
g := goproxy.New()
g.GoBinEnv = append(
os.Environ(),
)
g.Cacher = &cacher.Disk{
Root: viper.GetString("cache.disk.root"),
}
g.ProxiedSUMDBs = viper.GetStringSlice("goproxy.proxied_sumdbs")
log.Println("Server Listen on: ", viper.GetString("http.listen"))
http.ListenAndServe(viper.GetString("http.listen"), g)
}