From 0ce21aea083b4367ed0ec88c2a1fc92aa27177d9 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Tue, 9 Feb 2016 16:50:57 +0100 Subject: [PATCH 1/5] Add .arcconfig to project root --- .arcconfig | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .arcconfig diff --git a/.arcconfig b/.arcconfig new file mode 100644 index 000000000..3f25df55c --- /dev/null +++ b/.arcconfig @@ -0,0 +1,5 @@ +{ + "phabricator.uri": "https://source.syncthing.net/", + "project_id": "syncthing", + "project.name": "syncthing" +} From 4fa4668ed65a2de2c7a8eb9a68b9489309afee41 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Thu, 11 Feb 2016 21:17:01 +0100 Subject: [PATCH 2/5] Revert "Add .arcconfig to project root" This reverts commit 0ce21aea083b4367ed0ec88c2a1fc92aa27177d9. --- .arcconfig | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 .arcconfig diff --git a/.arcconfig b/.arcconfig deleted file mode 100644 index 3f25df55c..000000000 --- a/.arcconfig +++ /dev/null @@ -1,5 +0,0 @@ -{ - "phabricator.uri": "https://source.syncthing.net/", - "project_id": "syncthing", - "project.name": "syncthing" -} From 3c7164846d05d703076c7e32cba2a163cd675111 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Fri, 12 Feb 2016 14:53:09 +0100 Subject: [PATCH 3/5] Return "No such object in the index" when /rest/db/file gets called on something that doesn't exist Better than the confusing result of getting a blank fileinfo that looks valid apart from being all crap. --- cmd/syncthing/gui.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cmd/syncthing/gui.go b/cmd/syncthing/gui.go index 79f6585dc..66fb97582 100644 --- a/cmd/syncthing/gui.go +++ b/cmd/syncthing/gui.go @@ -615,8 +615,14 @@ func (s *apiService) getDBFile(w http.ResponseWriter, r *http.Request) { qs := r.URL.Query() folder := qs.Get("folder") file := qs.Get("file") - gf, _ := s.model.CurrentGlobalFile(folder, file) - lf, _ := s.model.CurrentFolderFile(folder, file) + gf, gfOk := s.model.CurrentGlobalFile(folder, file) + lf, lfOk := s.model.CurrentFolderFile(folder, file) + + if !(gfOk || lfOk) { + // This file for sure does not exist. + http.Error(w, "No such object in the index", http.StatusNotFound) + return + } av := s.model.Availability(folder, file) sendJSON(w, map[string]interface{}{ From d8e19b776ebd5c3ab7b4fdf19f66443935dd8fdf Mon Sep 17 00:00:00 2001 From: Laurent Etiemble Date: Fri, 12 Feb 2016 22:10:08 +0100 Subject: [PATCH 4/5] Swap the corsMiddleware and the csrfMiddleware to the unauthenticated OPTIONS requests are first processed. --- cmd/syncthing/gui.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cmd/syncthing/gui.go b/cmd/syncthing/gui.go index 79f6585dc..9b0b93d46 100644 --- a/cmd/syncthing/gui.go +++ b/cmd/syncthing/gui.go @@ -236,12 +236,12 @@ func (s *apiService) Serve() { guiCfg := s.cfg.GUI() + // Add the CORS handling + handler := corsMiddleware(mux) + // Wrap everything in CSRF protection. The /rest prefix should be // protected, other requests will grant cookies. - handler := csrfMiddleware(s.id.String()[:5], "/rest", guiCfg, mux) - - // Add the CORS handling - handler = corsMiddleware(handler) + handler = csrfMiddleware(s.id.String()[:5], "/rest", guiCfg, handler) // Add our version and ID as a header to responses handler = withDetailsMiddleware(s.id, handler) @@ -382,6 +382,10 @@ func corsMiddleware(next http.Handler) http.Handler { // Handle CORS headers and CORS OPTIONS request. // CORS OPTIONS request are typically sent by browser during AJAX preflight // when the browser initiate a POST request. + // + // As the OPTIONS request is unauthorized, this handler must be the first + // of the chain. + // // See https://www.w3.org/TR/cors/ for details. return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { // Add a generous access-control-allow-origin header since we may be From e11302172e21fe5c3919c8dfb5c108ea391cdaf0 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Sat, 13 Feb 2016 08:18:40 +0100 Subject: [PATCH 5/5] Report versioning usage in usage report I consider it a bug that we didn't already and that this is covered already under the agreement that we report which features are in use. --- cmd/syncthing/usage_report.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/cmd/syncthing/usage_report.go b/cmd/syncthing/usage_report.go index be26edcc6..0618e7518 100644 --- a/cmd/syncthing/usage_report.go +++ b/cmd/syncthing/usage_report.go @@ -121,10 +121,14 @@ func reportData(cfg *config.Wrapper, m *model.Model) map[string]interface{} { var rescanIntvs []int folderUses := map[string]int{ - "readonly": 0, - "ignorePerms": 0, - "ignoreDelete": 0, - "autoNormalize": 0, + "readonly": 0, + "ignorePerms": 0, + "ignoreDelete": 0, + "autoNormalize": 0, + "simpleVersioning": 0, + "externalVersioning": 0, + "staggeredVersioning": 0, + "trashcanVersioning": 0, } for _, cfg := range cfg.Folders() { rescanIntvs = append(rescanIntvs, cfg.RescanIntervalS) @@ -141,6 +145,9 @@ func reportData(cfg *config.Wrapper, m *model.Model) map[string]interface{} { if cfg.AutoNormalize { folderUses["autoNormalize"]++ } + if cfg.Versioning.Type != "" { + folderUses[cfg.Versioning.Type+"Versioning"]++ + } } sort.Ints(rescanIntvs) res["rescanIntvs"] = rescanIntvs