8 "github.com/kuroneko/configureit"
11 var configFile *configureit.Config = configureit.New()
14 configFile.Add("x509 certificate", configureit.NewStringOption("/etc/orchestra/conductor_crt.pem"))
15 configFile.Add("x509 private key", configureit.NewStringOption("/etc/orchestra/conductor_key.pem"))
16 configFile.Add("ca certificates", configureit.NewPathListOption(nil))
17 configFile.Add("bind address", configureit.NewStringOption(""))
18 configFile.Add("server name", configureit.NewStringOption(""))
19 configFile.Add("audience socket path", configureit.NewStringOption("/var/spool/orchestra/conductor.sock"))
20 configFile.Add("conductor state path", configureit.NewStringOption("/var/spool/orchestra"))
21 configFile.Add("player file path", configureit.NewStringOption("/etc/orchestra/players"))
24 func GetStringOpt(key string) string {
25 cnode := configFile.Get(key)
27 o.Assert("tried to get a configuration option that doesn't exist.")
29 sopt, ok := cnode.(*configureit.StringOption)
31 o.Assert("tried to get a non-string configuration option with GetStringOpt")
33 return strings.TrimSpace(sopt.Value)
37 func GetCACertList() []string {
38 cnode := configFile.Get("ca certificates")
40 o.Assert("tried to get a configuration option that doesn't exist.")
42 plopt, _ := cnode.(*configureit.PathListOption)
47 // attempt to open the configuration file.
48 fh, err := os.Open(*ConfigFile)
51 // reset the config File data, then reload it.
53 ierr := configFile.Read(fh, 1)
54 o.MightFail(ierr, "Couldn't parse configuration")
56 o.Warn("Couldn't open configuration file: %s. Proceeding anyway.", err)
59 playerpath := strings.TrimSpace(GetStringOpt("player file path"))
60 pfh, err := os.Open(playerpath)
61 o.MightFail(err, "Couldn't open \"%s\"", playerpath)
63 pbr := bufio.NewReader(pfh)
65 ahmap := make(map[string]bool)
66 for err = nil; err == nil; {
70 lb, prefix, err = pbr.ReadLine()
76 o.Fail("ConfigLoad: Short Read (prefix only)!")
79 line := strings.TrimSpace(string(lb))
88 // convert newAuthorisedHosts to a slice
89 authorisedHosts := make([]string, len(ahmap))
91 for k,_ := range ahmap {
92 authorisedHosts[idx] = k
95 ClientUpdateKnown(authorisedHosts)
97 // set the spool directory
98 SetSpoolDirectory(GetStringOpt("conductor state path"))
102 func HostAuthorised(hostname string) (r bool) {
103 /* if we haven't loaded the configuration, nobody is authorised */
104 ci := ClientGet(hostname)