func main() { options.Parse() if *options.String["config"] != "" && !*options.Bool["init"] { err := options.Load(*options.String["config"]) options.FailIf(err, "Can't load configuration") } fmt.Println("Cloudproxy HTTPS Server") if tao.Parent() == nil { options.Fail(nil, "can't continue: no host Tao available") } self, err := tao.Parent().GetTaoName() options.FailIf(err, "Can't get Tao name") // TODO(kwalsh) extend tao name with operating mode and policy addr := net.JoinHostPort(*options.String["host"], *options.String["port"]) cpath := *options.String["config"] kdir := *options.String["keys"] if kdir == "" && cpath != "" { kdir = path.Dir(cpath) } else if kdir == "" { options.Fail(nil, "Option -keys or -config is required") } docs := *options.String["docs"] if docs == "" && cpath != "" { docs = path.Join(path.Dir(cpath), "docs") } else if docs == "" { options.Fail(nil, "Option -keys or -config is required") } var keys *tao.Keys if *options.Bool["init"] { keys = taoca.GenerateKeys(name, addr, kdir) } else { keys = taoca.LoadKeys(kdir) } fmt.Printf("Configuration file: %s\n", cpath) if *options.Bool["init"] && cpath != "" { err := options.Save(cpath, "HTTPS server configuration", "persistent") options.FailIf(err, "Can't save configuration") } http.Handle("/cert/", https.CertificateHandler{keys.CertificatePool}) http.Handle("/prin/", https.ManifestHandler{"/prin/", self.String()}) http.Handle("/", http.FileServer(https.LoggingFilesystem{http.Dir(docs)})) fmt.Printf("Listening at %s using HTTPS\n", addr) err = tao.ListenAndServeTLS(addr, keys) options.FailIf(err, "can't listen and serve") fmt.Println("Server Done") }
func main() { options.Parse() if *options.String["config"] != "" && !*options.Bool["init"] { err := options.Load(*options.String["config"]) options.FailIf(err, "Can't load configuration") } fmt.Println("Cloudproxy HTTPS Netlog Viewer") if tao.Parent() == nil { options.Fail(nil, "can't continue: no host Tao available") } // TODO(kwalsh) extend tao name with operating mode and policy addr := net.JoinHostPort(*options.String["host"], *options.String["port"]) cpath := *options.String["config"] kdir := *options.String["keys"] if kdir == "" && cpath != "" { kdir = path.Dir(cpath) } else if kdir == "" { options.Fail(nil, "Option -keys or -config is required") } var keys *tao.Keys if *options.Bool["init"] { keys = taoca.GenerateKeys(name, addr, kdir) } else { keys = taoca.LoadKeys(kdir) } fmt.Printf("Configuration file: %s\n", cpath) if *options.Bool["init"] && cpath != "" { err := options.Save(cpath, "Cloudproxy HTTPS netlog viewer configuration", "persistent") options.FailIf(err, "Can't save configuration") } http.Handle("/cert/", https.CertificateHandler{keys.CertificatePool}) http.Handle("/index.html", http.RedirectHandler("/", 301)) http.HandleFunc("/", netlog_show) fmt.Printf("Listening at %s using HTTPS\n", addr) err := tao.ListenAndServeTLS(addr, keys) options.FailIf(err, "can't listen and serve") fmt.Println("Server Done") }