From 63de838f2757194f69a6682cd5472499e0da8c8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Colomb?= Date: Wed, 10 Aug 2022 08:25:13 +0200 Subject: [PATCH] gui, api: Show internal config and state paths (fixes #8323) (#8324) * lib/locations: Fix enum values camelCase. * lib/locations: Remove unused FailuresFile. * cmd/syncthing: Turn around role of locations storage. Previously the locations package was used to provide default paths, possibly with an overridden home directory. Extra paths supplied on the command line were handled and passed around in the options object. To make the changed paths available to any other interested package, override the location setting from the option if supplied, instead of vice versa when not supplied. Adapt code using this to read from the locations package instead of passing through the options object. * lib/locations: Refactor showPaths to locations package. Generate a reusable string in locations.PrettyPrintPaths(). Enumerating all possible locations in different packages is error prone, so add a new public function to generate the listing as a string in the locations package. Adapt cmd/syncthing --paths to use that instead of its own console output. * lib/locations: Include CSRF token in pretty printed paths. * lib/api: New endpoint /rest/system/paths. The paths should be available for troubleshooting from a running instance. Using the --paths CLI option is not easy in some environments, so expose the locations mapping to a JSON endpoint. Add utility function ListExpandedPaths() that also filters out any entries which still contain variable placeholders. * gui: List runtime paths in separate log viewer tab. * Wrap paths. * lib/syncthing: Utilize locations.Get() instead of passing an arg. * Include base directories, move label to table caption. * gui: Switch to hard-coded paths instead of iterating over all. * gui: Break aboutModalView into tabs. Use tabs to separate authors from included third-party software. * gui: Move paths from log viewer to about modal. * lib/locations: Adjust pretty print output order to match GUI. * gui, authors: Remove additional bot names and fix indent. The indentation changed because of the tabbed about dialog, fix the authors script to respect that. Skip Syncthing*Automation in authors list as well. * Update AUTHORS list to remove bot names. * Revert AUTHORS email order change. * Do not emphasize DB and log file locations. * Review line wrapping. * review part 1: strings.Builder, naming * Rename and extend locations.Set() with error handling. Remodel the Override() function along the existing SetBaseDir() and rename it to simply Set(). Make sure to use absolute paths when given log file or GUI assets override options. Add proper error reporting if that goes wrong. * Remove obsolete comment about empty logfile option. * Don't filter out unexpanded baseDir placeholders, only ${timestamp}. * Restore behavior regarding special "-" logfile argument. If the option is given, but with empty value, assume the no log file (same as "-"). Don't try to convert the special value to an absolute path though and document this fact in a comment for the Set() function. * Use template to check for location key validity. * Don't filter out timestamp placeholders. * lib/api: Remove paths from /rest/system/status. * lib/ur: Properly initialize map in failure data (fixes #8479) Co-authored-by: Jakob Borg --- cmd/syncthing/main.go | 32 ++-- cmd/syncthing/monitor.go | 2 +- gui/default/assets/css/overrides.css | 2 + gui/default/index.html | 2 +- .../syncthing/core/aboutModalView.html | 161 ++++++++++++------ .../syncthing/core/syncthingController.js | 13 ++ lib/api/api.go | 5 + lib/locations/locations.go | 48 +++++- lib/syncthing/syncthing.go | 3 +- script/authors.go | 2 +- 10 files changed, 191 insertions(+), 79 deletions(-) diff --git a/cmd/syncthing/main.go b/cmd/syncthing/main.go index 1c1f38793..3471c7b1d 100644 --- a/cmd/syncthing/main.go +++ b/cmd/syncthing/main.go @@ -292,16 +292,25 @@ func (options serveOptions) Run() error { os.Exit(svcutil.ExitError.AsInt()) } - if options.LogFile == "default" || options.LogFile == "" { + // Treat an explicitly empty log file name as no log file + if options.LogFile == "" { + options.LogFile = "-" + } + if options.LogFile != "default" { // We must set this *after* expandLocations above. - // Handling an empty value is for backwards compatibility (<1.4.1). - options.LogFile = locations.Get(locations.LogFile) + if err := locations.Set(locations.LogFile, options.LogFile); err != nil { + l.Warnln("Setting log file path:", err) + os.Exit(svcutil.ExitError.AsInt()) + } } - if options.DebugGUIAssetsDir == "" { + if options.DebugGUIAssetsDir != "" { // The asset dir is blank if STGUIASSETS wasn't set, in which case we // should look for extra assets in the default place. - options.DebugGUIAssetsDir = locations.Get(locations.GUIAssets) + if err := locations.Set(locations.GUIAssets, options.DebugGUIAssetsDir); err != nil { + l.Warnln("Setting GUI assets path:", err) + os.Exit(svcutil.ExitError.AsInt()) + } } if options.Version { @@ -310,7 +319,7 @@ func (options serveOptions) Run() error { } if options.Paths { - showPaths(options) + fmt.Print(locations.PrettyPaths()) return nil } @@ -612,7 +621,6 @@ func syncthingMain(options serveOptions) { } appOpts := syncthing.Options{ - AssetDir: options.DebugGUIAssetsDir, DeadlockTimeoutS: options.DebugDeadlockTimeout, NoUpgrade: options.NoUpgrade, ProfilerAddr: options.DebugProfilerListen, @@ -890,16 +898,6 @@ func cleanConfigDirectory() { } } -func showPaths(options serveOptions) { - fmt.Printf("Configuration file:\n\t%s\n\n", locations.Get(locations.ConfigFile)) - fmt.Printf("Database directory:\n\t%s\n\n", locations.Get(locations.Database)) - fmt.Printf("Device private key & certificate files:\n\t%s\n\t%s\n\n", locations.Get(locations.KeyFile), locations.Get(locations.CertFile)) - fmt.Printf("HTTPS private key & certificate files:\n\t%s\n\t%s\n\n", locations.Get(locations.HTTPSKeyFile), locations.Get(locations.HTTPSCertFile)) - fmt.Printf("Log file:\n\t%s\n\n", options.LogFile) - fmt.Printf("GUI override directory:\n\t%s\n\n", options.DebugGUIAssetsDir) - fmt.Printf("Default sync folder directory:\n\t%s\n\n", locations.Get(locations.DefFolder)) -} - func setPauseState(cfgWrapper config.Wrapper, paused bool) { _, err := cfgWrapper.Modify(func(cfg *config.Configuration) { for i := range cfg.Devices { diff --git a/cmd/syncthing/monitor.go b/cmd/syncthing/monitor.go index a118a24ae..d15a449ef 100644 --- a/cmd/syncthing/monitor.go +++ b/cmd/syncthing/monitor.go @@ -48,7 +48,7 @@ func monitorMain(options serveOptions) { var dst io.Writer = os.Stdout - logFile := options.LogFile + logFile := locations.Get(locations.LogFile) if logFile != "-" { if expanded, err := fs.ExpandTilde(logFile); err == nil { logFile = expanded diff --git a/gui/default/assets/css/overrides.css b/gui/default/assets/css/overrides.css index fcd8caa50..527c5cc59 100644 --- a/gui/default/assets/css/overrides.css +++ b/gui/default/assets/css/overrides.css @@ -420,6 +420,8 @@ ul.three-columns li, ul.two-columns li { height: 276px; } + table.table-auto td, + table.table-auto th, table.table-condensed td, table.table-condensed th { /* for mobile phones to allow linebreaks in long repro folder/shared with diff --git a/gui/default/index.html b/gui/default/index.html index 447472b2a..3a463ac6a 100644 --- a/gui/default/index.html +++ b/gui/default/index.html @@ -110,7 +110,7 @@  Help -
  •  About
  • +
  •  About
  •  Advanced
  •  Logs
  • diff --git a/gui/default/syncthing/core/aboutModalView.html b/gui/default/syncthing/core/aboutModalView.html index ef0106a3a..06c65c234 100644 --- a/gui/default/syncthing/core/aboutModalView.html +++ b/gui/default/syncthing/core/aboutModalView.html @@ -15,61 +15,114 @@

    Syncthing is Free and Open Source Software licensed as MPL v2.0.

    -
    -

    The Syncthing Authors

    -
    -
    -Jakob Borg, Audrius Butkevicius, Jesse Lucas, Simon Frei, Alexander Graf, Alexandre Viau, Anderson Mesquita, André Colomb, Antony Male, Ben Schulz, Caleb Callaway, Daniel Harte, Evgeny Kuznetsov, Lars K.W. Gohlke, Lode Hoste, Michael Ploujnikov, Nate Morrison, Philippe Schommers, Ryan Sullivan, Sergey Mishin, Stefan Tatschner, Tomasz Wilczyński, Wulf Weich, greatroar, Aaron Bieber, Adam Piggott, Adel Qalieh, Alan Pope, Alberto Donato, Alessandro G., Alex Lindeman, Alex Xu, Aman Gupta, Andrew Dunham, Andrew Meyer, Andrew Rabert, Andrey D, Anjan Momi, Antoine Lamielle, Anur, Aranjedeath, Arkadiusz Tymiński, Aroun, Arthur Axel fREW Schmidt, Artur Zubilewicz, Aurélien Rainone, BAHADIR YILMAZ, Bart De Vries, Ben Curthoys, Ben Shepherd, Ben Sidhom, Benedikt Heine, Benedikt Morbach, Benjamin Nater, Benno Fünfstück, Benny Ng, Boqin Qin, Boris Rybalkin, Brandon Philips, Brendan Long, Brian R. Becker, Carsten Hagemann, Cathryne Linenweaver, Cedric Staniewski, Chih-Hsuan Yen, Choongkyu, Chris Howie, Chris Joel, Chris Tonkinson, Christian Prescott, Colin Kennedy, Cromefire_, Cyprien Devillez, Dale Visser, Dan, Daniel Barczyk, Daniel Bergmann, Daniel Martí, Darshil Chanpura, David Rimmer, Denis A., Dennis Wilson, Devon G. Redekopp, Dmitry Saveliev, Domenic Horner, Dominik Heidler, Elias Jarlebring, Elliot Huffman, Emil Hessman, Eng Zer Jun, Eric Lesiuta, Erik Meitner, Evan Spensley, Federico Castagnini, Felix Ableitner, Felix Lampe, Felix Unterpaintner, Francois-Xavier Gsell, Frank Isemann, Gahl Saraf, Gilli Sigurdsson, Gleb Sinyavskiy, Graham Miln, Greg, Han Boetes, HansK-p, Harrison Jones, Heiko Zuerker, Hugo Locurcio, Iain Barnett, Ian Johnson, Ikko Ashimine, Ilya Brin, Iskander Sharipov, Jaakko Hannikainen, Jacek Szafarkiewicz, Jack Croft, Jacob, Jake Peterson, James Patterson, Jaroslav Lichtblau, Jaroslav Malec, Jaya Chithra, Jeffery To, Jens Diemer, Jerry Jacobs, Jochen Voss, Johan Andersson, Johan Vromans, John Rinehart, Jonas Thelemann, Jonathan, Jonathan Cross, Jonta, Jose Manuel Delicado, Jörg Thalheim, Jędrzej Kula, Kalle Laine, Karol Różycki, Kebin Liu, Keith Turner, Kelong Cong, Ken'ichi Kamada, Kevin Allen, Kevin Bushiri, Kevin White, Jr., Kurt Fitzner, LSmithx2, Lars Lehtonen, Laurent Arnoud, Laurent Etiemble, Leo Arias, Liu Siyuan, Lord Landon Agahnim, Lukas Lihotzki, Majed Abdulaziz, Marc Laporte, Marc Pujol, Marcin Dziadus, Marcus Legendre, Mario Majila, Mark Pulford, Martchus, Mateusz Naściszewski, Mateusz Ż, Matic Potočnik, Matt Burke, Matt Robenolt, Matteo Ruina, Maurizio Tomasi, Max, Max Schulze, MaximAL, Maxime Thirouin, MichaIng, Michael Jephcote, Michael Rienstra, Michael Tilli, Mike Boone, MikeLund, MikolajTwarog, Mingxuan Lin, Naveen, Nicholas Rishel, Nico Stapelbroek, Nicolas Braud-Santoni, Nicolas Perraut, Niels Peter Roest, Nils Jakobi, NinoM4ster, Nitroretro, NoLooseEnds, Oliver Freyermuth, Otiel, Oyebanji Jacob Mayowa, Pablo, Pascal Jungblut, Paul Brit, Pawel Palenica, Paweł Rozlach, Peter Badida, Peter Dave Hello, Peter Hoeg, Peter Marquardt, Phani Rithvij, Phil Davis, Phill Luby, Pier Paolo Ramon, Piotr Bejda, Pramodh KP, Quentin Hibon, Rahmi Pruitt, Richard Hartmann, Robert Carosi, Roberto Santalla, Robin Schoonover, Roman Zaynetdinov, Ross Smith II, Ruslan Yevdokymov, Ryan Qian, Sacheendra Talluri, Scott Klupfel, Shaarad Dalvi, Simon Mwepu, Sly_tom_cat, Stefan Kuntz, Steven Eckhoff, Suhas Gundimeda, Taylor Khan, Thomas Hipp, Tim Abell, Tim Howes, Tobias Klauser, Tobias Nygren, Tobias Tom, Tom Jakubowski, Tommy Thorn, Tully Robinson, Tyler Brazier, Tyler Kropp, Unrud, Veeti Paananen, Victor Buinsky, Vil Brekin, Vladimir Rusinov, William A. Kennington III, Xavier O., Yannic A., andresvia, andyleap, boomsquared, bt90, chenrui, chucic, derekriemer, desbma, georgespatton, ghjklw, ignacy123, janost, jaseg, jelle van der Waa, jtagcat, klemens, marco-m, mclang, mv1005, otbutz, overkill, perewa, red_led, rubenbe, sec65, villekalliomaki, wangguoliang, wouter bolsterlee, xarx00, xjtdy888, 佛跳墙, 落心 -
    -
    -
    - -

    Syncthing includes the following software or portions thereof:

    -