func (sh *SetupHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request) { if !auth.LocalhostAuthorized(req) { fmt.Fprintf(rw, "<html><body>Setup only allowed from localhost"+ "<p><a href='/'>Back</a></p>"+ "</body></html>\n") return } if req.Method == "POST" { err := req.ParseMultipartForm(10e6) if err != nil { httputil.ServerError(rw, req, err) return } if len(req.Form) > 0 { handleSetupChange(rw, req) return } if strings.Contains(req.URL.Path, "restartCamli") { err = osutil.RestartProcess() if err != nil { log.Fatal("Failed to restart: " + err.Error()) } } } sendWizard(rw, req, false) }
func ServerError(conn http.ResponseWriter, req *http.Request, err error) { conn.WriteHeader(http.StatusInternalServerError) if auth.LocalhostAuthorized(req) { fmt.Fprintf(conn, "Server error: %s\n", err) return } fmt.Fprintf(conn, "An internal error occured, sorry.") }
func (rh *RootHandler) ServeHTTP(conn http.ResponseWriter, req *http.Request) { if rh.ui != nil && camliMode(req) == "config" && auth.IsAuthorized(req) { rh.ui.serveDiscovery(conn, req) return } if rh.Stealth { return } configLink := "" if auth.LocalhostAuthorized(req) { configLink = "<p>If you're coming from localhost, hit <a href='/setup'>/setup</a>.</p>" } fmt.Fprintf(conn, "<html><body>This is camlistored, a "+ "<a href='http://camlistore.org'>Camlistore</a> server."+ "%s</body></html>\n", configLink) }
func (rh *RootHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request) { if wantsDiscovery(req) { if auth.IsAuthorized(req) { rh.serveDiscovery(rw, req) return } if !rh.Stealth { http.Error(rw, "Unauthorized", http.StatusUnauthorized) } return } if rh.Stealth { return } configLink := "" if auth.LocalhostAuthorized(req) { configLink = "<p>If you're coming from localhost, hit <a href='/setup'>/setup</a>.</p>" } fmt.Fprintf(rw, "<html><body>This is camlistored, a "+ "<a href='http://camlistore.org'>Camlistore</a> server."+ "%s</body></html>\n", configLink) }