add whitelist flag

This commit is contained in:
Jimmy Zelinskie
2014-07-25 01:48:30 -04:00
parent 941de3d12e
commit 64d08ca16b
4 changed files with 78 additions and 9 deletions

View File

@@ -23,15 +23,17 @@ import (
)
var (
maxProcs int
profile string
configPath string
maxProcs int
profile string
configPath string
whitelistPath string
)
func init() {
flag.IntVar(&maxProcs, "maxprocs", runtime.NumCPU(), "maximum parallel threads")
flag.StringVar(&profile, "profile", "", "if non-empty, path to write profiling data")
flag.StringVar(&configPath, "config", "", "path to the configuration file")
flag.StringVar(&whitelistPath, "whitelist", "", "path to a client whitelist")
}
// Boot starts Chihaya. By exporting this function, anyone can import their own
@@ -78,6 +80,13 @@ func Boot() {
glog.Fatal("New: ", err)
}
if whitelistPath != "" {
err = tkr.LoadApprovedClients(whitelistPath)
if err != nil {
glog.Fatal("Failed to load whitelist: ", err.Error())
}
}
http.Serve(cfg, tkr)
glog.Info("Gracefully shut down")
}