Compare commits

...
14 Commits
Author SHA1 Message Date
Simon FreiandJakob Borg ec86db176e lib/model: Handle invalid needed items on send-only (ref #7476) (#7596) 2021-04-26 15:38:08 +02:00
Simon FreiandJakob Borg 60e8630413 gui: Handle empty path in validation (ref #7379) (#7595) 2021-04-26 15:38:08 +02:00
Simon FreiandJakob Borg 9d29dbbe5d cmd/syncthing: Don't fail early on api setup error (fixes 7558) (#7591)
* cmd/syncthing: Don't fail early on api setup error (fixes 7558)

* switch to factory pattern

* refactor config command to show help on nothing

* wip

* wip

* already abort in before
2021-04-26 15:38:08 +02:00
Simon FreiandGitHub 54e27f551d cmd/syncthing: Add debug commands to cli (#7503) 2021-04-22 11:14:25 +02:00
Jakob Borg 59bdcdabba gui, man, authors: Update docs, translations, and contributors 2021-04-21 07:45:43 +02:00
Simon FreiandGitHub f6375ecbfc gui: Unset current folder on modal close (fixes #7584) (#7586) 2021-04-20 17:29:38 +02:00
Simon FreiandGitHub 031b91c0ed gui: Fix folder path validation (fixes #7379) (#7585) 2021-04-20 17:29:06 +02:00
Jakob BorgandGitHub e4c995a321 lib/model: Don't remove non-empty .stfolder (#7578) 2021-04-15 18:13:35 +02:00
André ColombandGitHub 130d14cec9 api: Log API authorization failures. (#7575) 2021-04-15 07:33:02 +02:00
Jakob Borg e893ca1c9a gui, man, authors: Update docs, translations, and contributors 2021-04-14 07:45:37 +02:00
Simon FreiandGitHub 156d96e582 gui: Add missing file (fixes #7571, ref #7567) (#7573) 2021-04-13 20:22:55 +02:00
Simon FreiandGitHub 9ba7611537 build: Bump go-stun to v0.1.3 (fixes #7568) (#7572) 2021-04-13 17:10:52 +01:00
Simon FreiandGitHub 15d2dc3a4f lib/connections: Add SyscallConn() to quic conn (fixes #7551) (#7570) 2021-04-13 12:59:58 +01:00
André ColombandGitHub f6df1a760d lib/api: Log the remote address on login attempts (#7560)
This enables usage of the audit log to e.g. automatically block remote
addresses from connecting after repeated login failures.
2021-04-13 10:14:44 +02:00
46 changed files with 577 additions and 342 deletions
+4 -4
View File
@@ -472,7 +472,7 @@ func install(target target, tags []string) {
defer shouldCleanupSyso(sysoPath)
}
args := []string{"install", "-v", "-trimpath"}
args := []string{"install", "-v"}
args = appendParameters(args, tags, target.buildPkgs...)
runPrint(goCmd, args...)
}
@@ -504,7 +504,7 @@ func build(target target, tags []string) {
defer shouldCleanupSyso(sysoPath)
}
args := []string{"build", "-v", "-trimpath"}
args := []string{"build", "-v"}
args = appendParameters(args, tags, target.buildPkgs...)
runPrint(goCmd, args...)
}
@@ -538,13 +538,13 @@ func appendParameters(args []string, tags []string, pkgs ...string) []string {
if !debugBinary {
// Regular binaries get version tagged and skip some debug symbols
args = append(args, "-ldflags", ldflags(tags))
args = append(args, "-trimpath", "-ldflags", ldflags(tags))
} else {
// -gcflags to disable optimizations and inlining. Skip -ldflags
// because `Could not launch program: decoding dwarf section info at
// offset 0x0: too short` on 'dlv exec ...' see
// https://github.com/go-delve/delve/issues/79
args = append(args, "-gcflags", "-N -l")
args = append(args, "-gcflags", "all=-N -l")
}
return append(args, pkgs...)
-52
View File
@@ -1,52 +0,0 @@
// Copyright (C) 2014 The Syncthing Authors.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.
package main
import (
"flag"
"fmt"
"log"
"os"
"path/filepath"
"github.com/syncthing/syncthing/lib/db/backend"
)
func main() {
var mode string
log.SetFlags(0)
log.SetOutput(os.Stdout)
flag.StringVar(&mode, "mode", "dump", "Mode of operation: dump, dumpsize, idxck")
flag.Parse()
path := flag.Arg(0)
if path == "" {
path = filepath.Join(defaultConfigDir(), "index-v0.14.0.db")
}
ldb, err := backend.OpenLevelDBRO(path)
if err != nil {
log.Fatal(err)
}
switch mode {
case "dump":
dump(ldb)
case "dumpsize":
dumpsize(ldb)
case "idxck":
if !idxck(ldb) {
os.Exit(1)
}
case "account":
account(ldb)
default:
fmt.Println("Unknown mode")
}
}
-52
View File
@@ -1,52 +0,0 @@
// Copyright (C) 2015 The Syncthing Authors.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.
package main
import (
"log"
"os"
"path/filepath"
"runtime"
"github.com/syncthing/syncthing/lib/fs"
)
func nulString(bs []byte) string {
for i := range bs {
if bs[i] == 0 {
return string(bs[:i])
}
}
return string(bs)
}
func defaultConfigDir() string {
switch runtime.GOOS {
case "windows":
if p := os.Getenv("LocalAppData"); p != "" {
return filepath.Join(p, "Syncthing")
}
return filepath.Join(os.Getenv("AppData"), "Syncthing")
case "darwin":
dir, err := fs.ExpandTilde("~/Library/Application Support/Syncthing")
if err != nil {
log.Fatal(err)
}
return dir
default:
if xdgCfg := os.Getenv("XDG_CONFIG_HOME"); xdgCfg != "" {
return filepath.Join(xdgCfg, "syncthing")
}
dir, err := fs.ExpandTilde("~/.config/syncthing")
if err != nil {
log.Fatal(err)
}
return dir
}
}
+66 -11
View File
@@ -17,33 +17,88 @@ import (
"strings"
"github.com/syncthing/syncthing/lib/config"
"github.com/syncthing/syncthing/lib/events"
"github.com/syncthing/syncthing/lib/locations"
"github.com/syncthing/syncthing/lib/protocol"
)
type APIClient struct {
type APIClient interface {
Get(url string) (*http.Response, error)
Post(url, body string) (*http.Response, error)
}
type apiClient struct {
http.Client
cfg config.GUIConfiguration
apikey string
}
func getClient(cfg config.GUIConfiguration) *APIClient {
type apiClientFactory struct {
cfg config.GUIConfiguration
}
func (f *apiClientFactory) getClient() (APIClient, error) {
// Now if the API key and address is not provided (we are not connecting to a remote instance),
// try to rip it out of the config.
if f.cfg.RawAddress == "" && f.cfg.APIKey == "" {
var err error
f.cfg, err = loadGUIConfig()
if err != nil {
return nil, err
}
} else if f.cfg.Address() == "" || f.cfg.APIKey == "" {
return nil, errors.New("Both --gui-address and --gui-apikey should be specified")
}
httpClient := http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
},
DialContext: func(_ context.Context, _, _ string) (net.Conn, error) {
return net.Dial(cfg.Network(), cfg.Address())
return net.Dial(f.cfg.Network(), f.cfg.Address())
},
},
}
return &APIClient{
return &apiClient{
Client: httpClient,
cfg: cfg,
apikey: cfg.APIKey,
}
cfg: f.cfg,
apikey: f.cfg.APIKey,
}, nil
}
func (c *APIClient) Endpoint() string {
func loadGUIConfig() (config.GUIConfiguration, error) {
// Load the certs and get the ID
cert, err := tls.LoadX509KeyPair(
locations.Get(locations.CertFile),
locations.Get(locations.KeyFile),
)
if err != nil {
return config.GUIConfiguration{}, fmt.Errorf("reading device ID: %w", err)
}
myID := protocol.NewDeviceID(cert.Certificate[0])
// Load the config
cfg, _, err := config.Load(locations.Get(locations.ConfigFile), myID, events.NoopLogger)
if err != nil {
return config.GUIConfiguration{}, fmt.Errorf("loading config: %w", err)
}
guiCfg := cfg.GUI()
if guiCfg.Address() == "" {
return config.GUIConfiguration{}, errors.New("Could not find GUI Address")
}
if guiCfg.APIKey == "" {
return config.GUIConfiguration{}, errors.New("Could not find GUI API key")
}
return guiCfg, nil
}
func (c *apiClient) Endpoint() string {
if c.cfg.Network() == "unix" {
return "http://unix/"
}
@@ -54,7 +109,7 @@ func (c *APIClient) Endpoint() string {
return url
}
func (c *APIClient) Do(req *http.Request) (*http.Response, error) {
func (c *apiClient) Do(req *http.Request) (*http.Response, error) {
req.Header.Set("X-API-Key", c.apikey)
resp, err := c.Client.Do(req)
if err != nil {
@@ -63,7 +118,7 @@ func (c *APIClient) Do(req *http.Request) (*http.Response, error) {
return resp, checkResponse(resp)
}
func (c *APIClient) Get(url string) (*http.Response, error) {
func (c *apiClient) Get(url string) (*http.Response, error) {
request, err := http.NewRequest("GET", c.Endpoint()+"rest/"+url, nil)
if err != nil {
return nil, err
@@ -71,7 +126,7 @@ func (c *APIClient) Get(url string) (*http.Response, error) {
return c.Do(request)
}
func (c *APIClient) Post(url, body string) (*http.Response, error) {
func (c *apiClient) Post(url, body string) (*http.Response, error) {
request, err := http.NewRequest("POST", c.Endpoint()+"rest/"+url, bytes.NewBufferString(body))
if err != nil {
return nil, err
+87
View File
@@ -0,0 +1,87 @@
// Copyright (C) 2021 The Syncthing Authors.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.
package cli
import (
"encoding/json"
"fmt"
"reflect"
"github.com/AudriusButkevicius/recli"
"github.com/pkg/errors"
"github.com/syncthing/syncthing/lib/config"
"github.com/urfave/cli"
)
type configHandler struct {
original, cfg config.Configuration
client APIClient
err error
}
func getConfigCommand(f *apiClientFactory) (cli.Command, error) {
h := new(configHandler)
h.client, h.err = f.getClient()
if h.err == nil {
h.cfg, h.err = getConfig(h.client)
}
h.original = h.cfg.Copy()
// Copy the config and set the default flags
recliCfg := recli.DefaultConfig
recliCfg.IDTag.Name = "xml"
recliCfg.SkipTag.Name = "json"
commands, err := recli.New(recliCfg).Construct(&h.cfg)
if err != nil {
return cli.Command{}, fmt.Errorf("config reflect: %w", err)
}
return cli.Command{
Name: "config",
HideHelp: true,
Usage: "Configuration modification command group",
Subcommands: commands,
Before: h.configBefore,
After: h.configAfter,
}, nil
}
func (h *configHandler) configBefore(c *cli.Context) error {
for _, arg := range c.Args() {
if arg == "--help" || arg == "-h" {
return nil
}
}
return h.err
}
func (h *configHandler) configAfter(c *cli.Context) error {
if h.err != nil {
// Error was already returned in configBefore
return nil
}
if reflect.DeepEqual(h.cfg, h.original) {
return nil
}
body, err := json.MarshalIndent(h.cfg, "", " ")
if err != nil {
return err
}
resp, err := h.client.Post("system/config", string(body))
if err != nil {
return err
}
if resp.StatusCode != 200 {
body, err := responseToBArray(resp)
if err != nil {
return err
}
return errors.New(string(body))
}
return nil
}
+51
View File
@@ -0,0 +1,51 @@
// Copyright (C) 2021 The Syncthing Authors.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.
package cli
import (
"fmt"
"github.com/urfave/cli"
)
var debugCommand = cli.Command{
Name: "debug",
HideHelp: true,
Usage: "Debug command group",
Subcommands: []cli.Command{
{
Name: "file",
Usage: "Show information about a file (or directory/symlink)",
ArgsUsage: "FOLDER-ID PATH",
Action: expects(2, debugFile()),
},
indexCommand,
{
Name: "profile",
Usage: "Save a profile to help figuring out what Syncthing does.",
ArgsUsage: "cpu | heap",
Action: expects(1, profile()),
},
},
}
func debugFile() cli.ActionFunc {
return func(c *cli.Context) error {
return indexDumpOutput(fmt.Sprintf("debug/file?folder=%v&file=%v", c.Args()[0], normalizePath(c.Args()[1])))(c)
}
}
func profile() cli.ActionFunc {
return func(c *cli.Context) error {
switch t := c.Args()[0]; t {
case "cpu", "heap":
return saveToFile(fmt.Sprintf("debug/%vprof", c.Args()[0]))(c)
default:
return fmt.Errorf("expected cpu or heap as argument, got %v", t)
}
}
}
+2 -2
View File
@@ -22,7 +22,7 @@ var errorsCommand = cli.Command{
{
Name: "show",
Usage: "Show pending errors",
Action: expects(0, dumpOutput("system/error")),
Action: expects(0, indexDumpOutput("system/error")),
},
{
Name: "push",
@@ -39,7 +39,7 @@ var errorsCommand = cli.Command{
}
func errorsPush(c *cli.Context) error {
client := c.App.Metadata["client"].(*APIClient)
client := c.App.Metadata["client"].(APIClient)
errStr := strings.Join(c.Args(), " ")
response, err := client.Post("system/error", strings.TrimSpace(errStr))
if err != nil {
+38
View File
@@ -0,0 +1,38 @@
// Copyright (C) 2014 The Syncthing Authors.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.
package cli
import (
"github.com/urfave/cli"
)
var indexCommand = cli.Command{
Name: "index",
Usage: "Show information about the index (database)",
Subcommands: []cli.Command{
{
Name: "dump",
Usage: "Print the entire db",
Action: expects(0, indexDump),
},
{
Name: "dump-size",
Usage: "Print the db size of different categories of information",
Action: expects(0, indexDumpSize),
},
{
Name: "check",
Usage: "Check the database for inconsistencies",
Action: expects(0, indexCheck),
},
{
Name: "account",
Usage: "Print key and value size statistics per key type",
Action: expects(0, indexAccount),
},
},
}
@@ -4,22 +4,26 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.
package main
package cli
import (
"fmt"
"log"
"os"
"text/tabwriter"
"github.com/syncthing/syncthing/lib/db/backend"
"github.com/urfave/cli"
)
// account prints key and data size statistics per class
func account(ldb backend.Backend) {
// indexAccount prints key and data size statistics per class
func indexAccount(*cli.Context) error {
ldb, err := getDB()
if err != nil {
return err
}
it, err := ldb.NewPrefixIterator(nil)
if err != nil {
log.Fatal(err)
return err
}
var ksizes [256]int
@@ -55,4 +59,6 @@ func account(ldb backend.Backend) {
}
fmt.Fprintf(tw, "Total\t%d items,\t%d KB keys +\t%d KB data.\t\n", toti, totks/1000, totds/1000)
tw.Flush()
return nil
}
@@ -4,23 +4,27 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.
package main
package cli
import (
"encoding/binary"
"fmt"
"log"
"time"
"github.com/urfave/cli"
"github.com/syncthing/syncthing/lib/db"
"github.com/syncthing/syncthing/lib/db/backend"
"github.com/syncthing/syncthing/lib/protocol"
)
func dump(ldb backend.Backend) {
func indexDump(*cli.Context) error {
ldb, err := getDB()
if err != nil {
return err
}
it, err := ldb.NewPrefixIterator(nil)
if err != nil {
log.Fatal(err)
return err
}
for it.Next() {
key := it.Key()
@@ -34,7 +38,7 @@ func dump(ldb backend.Backend) {
var f protocol.FileInfo
err := f.Unmarshal(it.Value())
if err != nil {
log.Fatal(err)
return err
}
fmt.Printf(" V:%v\n", f)
@@ -61,10 +65,10 @@ func dump(ldb backend.Backend) {
folder := binary.BigEndian.Uint32(key[1:])
name := nulString(key[1+4:])
val := it.Value()
var real, virt time.Time
real.UnmarshalBinary(val[:len(val)/2])
virt.UnmarshalBinary(val[len(val)/2:])
fmt.Printf("[mtime] F:%d N:%q R:%v V:%v\n", folder, name, real, virt)
var realTime, virtualTime time.Time
realTime.UnmarshalBinary(val[:len(val)/2])
virtualTime.UnmarshalBinary(val[len(val)/2:])
fmt.Printf("[mtime] F:%d N:%q R:%v V:%v\n", folder, name, realTime, virtualTime)
case db.KeyTypeFolderIdx:
key := binary.BigEndian.Uint32(key[1:])
@@ -152,4 +156,5 @@ func dump(ldb backend.Backend) {
fmt.Printf("[??? %d]\n %x\n %x\n", key[0], key, it.Value())
}
}
return nil
}
@@ -4,16 +4,16 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.
package main
package cli
import (
"container/heap"
"encoding/binary"
"fmt"
"log"
"github.com/urfave/cli"
"github.com/syncthing/syncthing/lib/db"
"github.com/syncthing/syncthing/lib/db/backend"
)
type SizedElement struct {
@@ -39,13 +39,18 @@ func (h *ElementHeap) Pop() interface{} {
return x
}
func dumpsize(ldb backend.Backend) {
func indexDumpSize(*cli.Context) error {
ldb, err := getDB()
if err != nil {
return err
}
h := &ElementHeap{}
heap.Init(h)
it, err := ldb.NewPrefixIterator(nil)
if err != nil {
log.Fatal(err)
return err
}
var ele SizedElement
for it.Next() {
@@ -96,4 +101,6 @@ func dumpsize(ldb backend.Backend) {
ele = heap.Pop(h).(SizedElement)
fmt.Println(ele.key, ele.size)
}
return nil
}
@@ -4,17 +4,18 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.
package main
package cli
import (
"bytes"
"encoding/binary"
"errors"
"fmt"
"log"
"sort"
"github.com/urfave/cli"
"github.com/syncthing/syncthing/lib/db"
"github.com/syncthing/syncthing/lib/db/backend"
"github.com/syncthing/syncthing/lib/protocol"
)
@@ -34,7 +35,12 @@ type sequenceKey struct {
sequence uint64
}
func idxck(ldb backend.Backend) (success bool) {
func indexCheck(*cli.Context) (err error) {
ldb, err := getDB()
if err != nil {
return err
}
folders := make(map[uint32]string)
devices := make(map[uint32]string)
deviceToIDs := make(map[string]uint32)
@@ -47,11 +53,20 @@ func idxck(ldb backend.Backend) (success bool) {
usedBlocklists := make(map[string]struct{})
usedVersions := make(map[string]struct{})
var localDeviceKey uint32
success = true
success := true
defer func() {
if err == nil {
if success {
fmt.Println("Index check completed succesfully.")
} else {
err = errors.New("Inconsistencies found in the index")
}
}
}()
it, err := ldb.NewPrefixIterator(nil)
if err != nil {
log.Fatal(err)
return err
}
for it.Next() {
key := it.Key()
@@ -329,7 +344,7 @@ func idxck(ldb backend.Backend) (success bool) {
fmt.Printf("%d version entries out of %d needs GC\n", d, len(versions))
}
return
return nil
}
func needsLocally(vl db.VersionList) bool {
+16 -95
View File
@@ -8,30 +8,26 @@ package cli
import (
"bufio"
"crypto/tls"
"encoding/json"
"io/ioutil"
"os"
"reflect"
"strings"
"github.com/AudriusButkevicius/recli"
"github.com/alecthomas/kong"
"github.com/flynn-archive/go-shlex"
"github.com/mattn/go-isatty"
"github.com/pkg/errors"
"github.com/syncthing/syncthing/lib/config"
"github.com/syncthing/syncthing/lib/events"
"github.com/syncthing/syncthing/lib/locations"
"github.com/syncthing/syncthing/lib/protocol"
"github.com/urfave/cli"
"github.com/syncthing/syncthing/cmd/syncthing/cmdutil"
"github.com/syncthing/syncthing/lib/config"
)
type preCli struct {
GUIAddress string `name:"gui-address"`
GUIAPIKey string `name:"gui-apikey"`
HomeDir string `name:"home"`
ConfDir string `name:"conf"`
ConfDir string `name:"config"`
DataDir string `name:"data"`
}
func Run() error {
@@ -44,74 +40,20 @@ func Run() error {
parseFlags(&c)
// Not set as default above because the strings can be really long.
var err error
homeSet := c.HomeDir != ""
confSet := c.ConfDir != ""
switch {
case homeSet && confSet:
err = errors.New("-home must not be used together with -conf")
case homeSet:
err = locations.SetBaseDir(locations.ConfigBaseDir, c.HomeDir)
case confSet:
err = locations.SetBaseDir(locations.ConfigBaseDir, c.ConfDir)
}
err := cmdutil.SetConfigDataLocationsFromFlags(c.HomeDir, c.ConfDir, c.DataDir)
if err != nil {
return errors.Wrap(err, "Command line options:")
}
guiCfg := config.GUIConfiguration{
RawAddress: c.GUIAddress,
APIKey: c.GUIAPIKey,
clientFactory := &apiClientFactory{
cfg: config.GUIConfiguration{
RawAddress: c.GUIAddress,
APIKey: c.GUIAPIKey,
},
}
// Now if the API key and address is not provided (we are not connecting to a remote instance),
// try to rip it out of the config.
if guiCfg.RawAddress == "" && guiCfg.APIKey == "" {
// Load the certs and get the ID
cert, err := tls.LoadX509KeyPair(
locations.Get(locations.CertFile),
locations.Get(locations.KeyFile),
)
if err != nil {
return errors.Wrap(err, "reading device ID")
}
myID := protocol.NewDeviceID(cert.Certificate[0])
// Load the config
cfg, _, err := config.Load(locations.Get(locations.ConfigFile), myID, events.NoopLogger)
if err != nil {
return errors.Wrap(err, "loading config")
}
guiCfg = cfg.GUI()
} else if guiCfg.Address() == "" || guiCfg.APIKey == "" {
return errors.New("Both --gui-address and --gui-apikey should be specified")
}
if guiCfg.Address() == "" {
return errors.New("Could not find GUI Address")
}
if guiCfg.APIKey == "" {
return errors.New("Could not find GUI API key")
}
client := getClient(guiCfg)
cfg, err := getConfig(client)
original := cfg.Copy()
configCommand, err := getConfigCommand(clientFactory)
if err != nil {
return errors.Wrap(err, "getting config")
}
// Copy the config and set the default flags
recliCfg := recli.DefaultConfig
recliCfg.IDTag.Name = "xml"
recliCfg.SkipTag.Name = "json"
commands, err := recli.New(recliCfg).Construct(&cfg)
if err != nil {
return errors.Wrap(err, "config reflect")
return err
}
// Implement the same flags at the upper CLI, but do nothing with them.
@@ -143,22 +85,18 @@ func Run() error {
app := cli.NewApp()
app.Author = "The Syncthing Authors"
app.Metadata = map[string]interface{}{
"client": client,
"clientFactory": clientFactory,
}
app.Commands = []cli.Command{{
Name: "cli",
Usage: "Syncthing command line interface",
Flags: fakeFlags,
Subcommands: []cli.Command{
{
Name: "config",
HideHelp: true,
Usage: "Configuration modification command group",
Subcommands: commands,
},
configCommand,
showCommand,
operationCommand,
errorsCommand,
debugCommand,
},
}}
@@ -190,23 +128,6 @@ func Run() error {
}
}
if !reflect.DeepEqual(cfg, original) {
body, err := json.MarshalIndent(cfg, "", " ")
if err != nil {
return err
}
resp, err := client.Post("system/config", string(body))
if err != nil {
return err
}
if resp.StatusCode != 200 {
body, err := responseToBArray(resp)
if err != nil {
return err
}
return errors.New(string(body))
}
}
return nil
}
+4 -1
View File
@@ -42,7 +42,10 @@ var operationCommand = cli.Command{
}
func foldersOverride(c *cli.Context) error {
client := c.App.Metadata["client"].(*APIClient)
client, err := getClientFactory(c).getClient()
if err != nil {
return err
}
cfg, err := getConfig(client)
if err != nil {
return err
+5 -5
View File
@@ -18,27 +18,27 @@ var showCommand = cli.Command{
{
Name: "version",
Usage: "Show syncthing client version",
Action: expects(0, dumpOutput("system/version")),
Action: expects(0, indexDumpOutput("system/version")),
},
{
Name: "config-status",
Usage: "Show configuration status, whether or not a restart is required for changes to take effect",
Action: expects(0, dumpOutput("config/restart-required")),
Action: expects(0, indexDumpOutput("config/restart-required")),
},
{
Name: "system",
Usage: "Show system status",
Action: expects(0, dumpOutput("system/status")),
Action: expects(0, indexDumpOutput("system/status")),
},
{
Name: "connections",
Usage: "Report about connections to other devices",
Action: expects(0, dumpOutput("system/connections")),
Action: expects(0, indexDumpOutput("system/connections")),
},
{
Name: "usage",
Usage: "Show usage report",
Action: expects(0, dumpOutput("svc/report")),
Action: expects(0, indexDumpOutput("svc/report")),
},
},
}
+73 -5
View File
@@ -8,12 +8,17 @@ package cli
import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"mime"
"net/http"
"os"
"path/filepath"
"github.com/syncthing/syncthing/lib/config"
"github.com/syncthing/syncthing/lib/db/backend"
"github.com/syncthing/syncthing/lib/locations"
"github.com/urfave/cli"
)
@@ -27,15 +32,21 @@ func responseToBArray(response *http.Response) ([]byte, error) {
func emptyPost(url string) cli.ActionFunc {
return func(c *cli.Context) error {
client := c.App.Metadata["client"].(*APIClient)
_, err := client.Post(url, "")
client, err := getClientFactory(c).getClient()
if err != nil {
return err
}
_, err = client.Post(url, "")
return err
}
}
func dumpOutput(url string) cli.ActionFunc {
func indexDumpOutput(url string) cli.ActionFunc {
return func(c *cli.Context) error {
client := c.App.Metadata["client"].(*APIClient)
client, err := getClientFactory(c).getClient()
if err != nil {
return err
}
response, err := client.Get(url)
if err != nil {
return err
@@ -44,7 +55,43 @@ func dumpOutput(url string) cli.ActionFunc {
}
}
func getConfig(c *APIClient) (config.Configuration, error) {
func saveToFile(url string) cli.ActionFunc {
return func(c *cli.Context) error {
client, err := getClientFactory(c).getClient()
if err != nil {
return err
}
response, err := client.Get(url)
if err != nil {
return err
}
_, params, err := mime.ParseMediaType(response.Header.Get("Content-Disposition"))
if err != nil {
return err
}
filename := params["filename"]
if filename == "" {
return errors.New("Missing filename in response")
}
bs, err := responseToBArray(response)
if err != nil {
return err
}
f, err := os.Create(filename)
if err != nil {
return err
}
defer f.Close()
_, err = f.Write(bs)
if err != nil {
return err
}
fmt.Println("Wrote results to", filename)
return err
}
}
func getConfig(c APIClient) (config.Configuration, error) {
cfg := config.Configuration{}
response, err := c.Get("system/config")
if err != nil {
@@ -92,3 +139,24 @@ func prettyPrintResponse(c *cli.Context, response *http.Response) error {
// TODO: Check flag for pretty print format
return prettyPrintJSON(data)
}
func getDB() (backend.Backend, error) {
return backend.OpenLevelDBRO(locations.Get(locations.Database))
}
func nulString(bs []byte) string {
for i := range bs {
if bs[i] == 0 {
return string(bs[:i])
}
}
return string(bs)
}
func normalizePath(path string) string {
return filepath.ToSlash(filepath.Clean(path))
}
func getClientFactory(c *cli.Context) *apiClientFactory {
return c.App.Metadata["clientFactory"].(*apiClientFactory)
}
+35
View File
@@ -0,0 +1,35 @@
// Copyright (C) 2014 The Syncthing Authors.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.
package cmdutil
import (
"errors"
"github.com/syncthing/syncthing/lib/locations"
)
func SetConfigDataLocationsFromFlags(homeDir, confDir, dataDir string) error {
homeSet := homeDir != ""
confSet := confDir != ""
dataSet := dataDir != ""
switch {
case dataSet != confSet:
return errors.New("either both or none of -conf and -data must be given, use -home to set both at once")
case homeSet && dataSet:
return errors.New("-home must not be used together with -conf and -data")
case homeSet:
confDir = homeDir
dataDir = homeDir
fallthrough
case dataSet:
if err := locations.SetBaseDir(locations.ConfigBaseDir, confDir); err != nil {
return err
}
return locations.SetBaseDir(locations.DataBaseDir, dataDir)
}
return nil
}
+2 -18
View File
@@ -34,6 +34,7 @@ import (
"github.com/thejerf/suture/v4"
"github.com/syncthing/syncthing/cmd/syncthing/cli"
"github.com/syncthing/syncthing/cmd/syncthing/cmdutil"
"github.com/syncthing/syncthing/cmd/syncthing/decrypt"
"github.com/syncthing/syncthing/lib/build"
"github.com/syncthing/syncthing/lib/config"
@@ -290,24 +291,7 @@ func (options serveOptions) Run() error {
}
// Not set as default above because the strings can be really long.
var err error
homeSet := options.HomeDir != ""
confSet := options.ConfDir != ""
dataSet := options.DataDir != ""
switch {
case dataSet != confSet:
err = errors.New("either both or none of -conf and -data must be given, use -home to set both at once")
case homeSet && dataSet:
err = errors.New("-home must not be used together with -conf and -data")
case homeSet:
if err = locations.SetBaseDir(locations.ConfigBaseDir, options.HomeDir); err == nil {
err = locations.SetBaseDir(locations.DataBaseDir, options.HomeDir)
}
case dataSet:
if err = locations.SetBaseDir(locations.ConfigBaseDir, options.ConfDir); err == nil {
err = locations.SetBaseDir(locations.DataBaseDir, options.DataDir)
}
}
err := cmdutil.SetConfigDataLocationsFromFlags(options.HomeDir, options.ConfDir, options.DataDir)
if err != nil {
l.Warnln("Command line options:", err)
os.Exit(svcutil.ExitError.AsInt())
+1 -1
View File
@@ -6,7 +6,7 @@ require (
github.com/alecthomas/kong v0.2.12
github.com/bkaradzic/go-lz4 v0.0.0-20160924222819-7224d8d8f27e
github.com/calmh/xdr v1.1.0
github.com/ccding/go-stun v0.1.2
github.com/ccding/go-stun v0.1.3
github.com/certifi/gocertifi v0.0.0-20200922220541-2c3bb06c6054 // indirect
github.com/chmduquesne/rollinghash v0.0.0-20180912150627-a60f8e7142b5
github.com/d4l3k/messagediff v1.2.1
+2
View File
@@ -52,6 +52,8 @@ github.com/calmh/xdr v1.1.0/go.mod h1:E8sz2ByAdXC8MbANf1LCRYzedSnnc+/sXXJs/PVqoe
github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ=
github.com/ccding/go-stun v0.1.2 h1:1CZhjVwfyO/jGxk06a+0OSOGBWZu588kuZQQO4nihsw=
github.com/ccding/go-stun v0.1.2/go.mod h1:3FK1bMar37f7jqVY7q/63k3OMX1c47pGCufzt3X0sYE=
github.com/ccding/go-stun v0.1.3 h1:uEAFsxqPBuo4tvILfloEHUBO3b4BlEAMnx2PZdh54jE=
github.com/ccding/go-stun v0.1.3/go.mod h1:cCZjJ1J3WFSJV6Wj8Y9Di8JMTsEXh6uv2eNmLzKaUeM=
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/certifi/gocertifi v0.0.0-20200922220541-2c3bb06c6054 h1:uH66TXeswKn5PW5zdZ39xEwfS9an067BirqA+P4QaLI=
+3 -3
View File
@@ -328,8 +328,8 @@
"The entered device ID does not look valid. It should be a 52 or 56 character string consisting of letters and numbers, with spaces and dashes being optional.": "Zadaný identifikátor zařízení není platný. Měl by mít 52 nebo 56 znaků a měl by obsahovat písmena a číslice. Mezery a pomlčky jsou nepovinné.",
"The folder ID cannot be blank.": "Identifikátor složky nemůže zůstat nevyplněný.",
"The folder ID must be unique.": "Je třeba, aby se identifikátor složky neopakoval.",
"The folder content on other devices will be overwritten to become identical with this device. Files not present here will be deleted on other devices.": "The folder content on other devices will be overwritten to become identical with this device. Files not present here will be deleted on other devices.",
"The folder content on this device will be overwritten to become identical with other devices. Files newly added here will be deleted.": "The folder content on this device will be overwritten to become identical with other devices. Files newly added here will be deleted.",
"The folder content on other devices will be overwritten to become identical with this device. Files not present here will be deleted on other devices.": "Obsah složky na ostatních zařízeních bude přepsán, aby se stal identickým s tímto zařízením. Soubory, které zde chybí, budou smazány na ostatních zařízeních.",
"The folder content on this device will be overwritten to become identical with other devices. Files newly added here will be deleted.": "Obsah složky na tomto zařízení bude přepsán, aby se stal identickým s ostatními zařízeními. Lokálně přidané soubory budou smazány.",
"The folder path cannot be blank.": "Popis umístění složky nemůže zůstat nevyplněný.",
"The following intervals are used: for the first hour a version is kept every 30 seconds, for the first day a version is kept every hour, for the first 30 days a version is kept every day, until the maximum age a version is kept every week.": "Jsou použity následující intervaly: za první hodinu jsou ponechány verze pro každých 30 sekund, za první den jsou ponechány verze pro každou hodinu, za prvních 30 dní jsou ponechány verze pro každý den a do nejvyššího nastaveného stáří jsou ponechány verze pro každý týden.",
"The following items could not be synchronized.": "Následující položky nemohly být synchronizovány.",
@@ -386,7 +386,7 @@
"Waiting to Clean": "Čeká se na čistění",
"Waiting to Scan": "Čekání na skenování",
"Waiting to Sync": "Čekání na synchronizaci",
"Warning": "Warning",
"Warning": "Varování",
"Warning, this path is a parent directory of an existing folder \"{%otherFolder%}\".": "Varování, tento popis umístění je nadřazenou složkou existující „{{otherFolder}}“.",
"Warning, this path is a parent directory of an existing folder \"{%otherFolderLabel%}\" ({%otherFolder%}).": "Varování, tento popis umístění je nadřazenou složkou existující „{{otherFolderLabel}}“ ({{otherFolder}}).",
"Warning, this path is a subdirectory of an existing folder \"{%otherFolder%}\".": "Varování: toto umístění je podsložkou existující „{{otherFolder}}“.",
+1 -1
View File
@@ -329,7 +329,7 @@
"The folder ID cannot be blank.": "L'ID du partage ne peut être vide.",
"The folder ID must be unique.": "L'ID du partage doit être unique.",
"The folder content on other devices will be overwritten to become identical with this device. Files not present here will be deleted on other devices.": "Le contenu local de ce partage remplacera celui des autres appareils (les éléments absents ici seront supprimés là-bas). ",
"The folder content on this device will be overwritten to become identical with other devices. Files newly added here will be deleted.": "Le contenu distant de ce partage remplacera celui de cet appareils (les éléments présents ici seront supprimés s'ils sont absents là-bas). ",
"The folder content on this device will be overwritten to become identical with other devices. Files newly added here will be deleted.": "Le contenu distant de ce partage remplacera celui de cet appareil (les éléments présents ici seront supprimés s'ils sont absents là-bas). ",
"The folder path cannot be blank.": "Le chemin vers le répertoire ne peut pas être vide.",
"The following intervals are used: for the first hour a version is kept every 30 seconds, for the first day a version is kept every hour, for the first 30 days a version is kept every day, until the maximum age a version is kept every week.": "Les seuils de durée suivants définissent le nombre maximum de versions pour chaque fichier : pendant la première heure une version est conservée toutes les 30 secondes. Le premier jour, une version par heure - des versions de la première heure sont alors progressivement effacées pour finir par n'en garder que la dernière. Pour les 30 jours passés, une version par jour - des versions horaires du premier jour sont alors progressivement effacées pour n'en garder qu'une par jour. Au-delà et jusqu'à la limite d'âge, une version est conservée par semaine - des versions journalières du premier mois sont alors progressivement effacées pour n'en garder qu'une.",
"The following items could not be synchronized.": "Les fichiers suivants n'ont pas pu être synchronisés.",
+19 -19
View File
@@ -24,13 +24,13 @@
"Alphabetic": "По алфавиту",
"An external command handles the versioning. It has to remove the file from the shared folder. If the path to the application contains spaces, it should be quoted.": "Для версионирования используется внешняя программа. Ей нужно удалить файл из общей папки. Если путь к приложению содержит пробелы, его нужно взять в кавычки.",
"Anonymous Usage Reporting": "Анонимный отчет об использовании",
"Anonymous usage report format has changed. Would you like to move to the new format?": "Формат анонимных отчётов изменился. Вы хотите переключиться на новый формат?",
"Are you sure you want to continue?": "Are you sure you want to continue?",
"Are you sure you want to permanently delete all these files?": "Вы уверены, что хотите навсегда удалить эти файлы?",
"Are you sure you want to remove device {%name%}?": "Вы уверены, что хотите удалить устройство {{name}}?",
"Are you sure you want to remove folder {%label%}?": "Вы уверены, что хотите удалить папку {{label}}?",
"Are you sure you want to restore {%count%} files?": "Вы уверены, что хотите восстановить {{count}} файлов?",
"Are you sure you want to upgrade?": "Вы уверены, что хотите обновить?",
"Anonymous usage report format has changed. Would you like to move to the new format?": "Формат анонимных отчётов изменился. Хотите переключиться на новый формат?",
"Are you sure you want to continue?": "Уверены, что хотите продолжить?",
"Are you sure you want to permanently delete all these files?": "Уверены, что хотите навсегда удалить эти файлы?",
"Are you sure you want to remove device {%name%}?": "Уверены, что хотите удалить устройство {{name}}?",
"Are you sure you want to remove folder {%label%}?": "Уверены, что хотите удалить папку {{label}}?",
"Are you sure you want to restore {%count%} files?": "Уверены, что хотите восстановить {{count}} файлов?",
"Are you sure you want to upgrade?": "Уверены, что хотите обновить?",
"Auto Accept": "Автопринятие",
"Automatic Crash Reporting": "Автоматическая отправка отчётов о сбоях",
"Automatic upgrade now offers the choice between stable releases and release candidates.": "Автоматическое обновление теперь предлагает выбор между стабильными выпусками и кандидатами в релизы.",
@@ -43,7 +43,7 @@
"Changelog": "Журнал изменений",
"Clean out after": "Очистить после",
"Cleaning Versions": "Cleaning Versions",
"Cleanup Interval": "Cleanup Interval",
"Cleanup Interval": "Интервал очистки",
"Click to see discovery failures": "Щёлкните, чтобы посмотреть ошибки",
"Close": "Закрыть",
"Command": "Команда",
@@ -62,16 +62,16 @@
"Currently Shared With Devices": "В настоящее время используется совместно с устройствами",
"Danger!": "Опасно!",
"Debugging Facilities": "Средства отладки",
"Default Configuration": "Default Configuration",
"Default Configuration": "Настройки по умолчанию",
"Default Device": "Стандартное Устройство",
"Default Folder": "Стандартная папка",
"Default Folder Path": "Путь для папок",
"Defaults": "Стандартные параметры",
"Delete Unexpected Items": "Delete Unexpected Items",
"Delete Unexpected Items": "Удалить неожиданные элементы",
"Deleted": "Удалено",
"Deselect All": "Снять выделение",
"Deselect devices to stop sharing this folder with.": "Отмените выбор устройств, чтобы прекратить совместное использование этой папки.",
"Deselect folders to stop sharing with this device.": "Deselect folders to stop sharing with this device.",
"Deselect folders to stop sharing with this device.": "Отмените выбор папок, чтобы прекратить совместное использование с этим устройством.",
"Device": "Устройство",
"Device \"{%name%}\" ({%device%} at {%address%}) wants to connect. Add new device?": "Устройство «{{name}}» ({{device}} на {{address}}) хочет подключиться. Добавить новое устройство?",
"Device ID": "ID устройства",
@@ -151,7 +151,7 @@
"Global Discovery Servers": "Серверы глобального обнаружения",
"Global State": "Глобальное состояние",
"Help": "Помощь",
"Home page": "Домашняя страница",
"Home page": "Сайт",
"However, your current settings indicate you might not want it enabled. We have disabled automatic crash reporting for you.": "Ваши настройки указывают что вы не хотите, чтобы эта функция была включена. Мы отключили отправку отчетов о сбоях.",
"If untrusted, enter encryption password": "If untrusted, enter encryption password",
"If you want to prevent other users on this computer from accessing Syncthing and through it your files, consider setting up authentication.": "Если вы хотите запретить другим пользователям на этом компьютере доступ к Syncthing и через него к вашим файлам, подумайте о настройке аутентификации.",
@@ -361,13 +361,13 @@
"Unavailable": "Недоступно",
"Unavailable/Disabled by administrator or maintainer": "Недоступно или отключено администратором",
"Undecided (will prompt)": "Не определено (запрашивать каждый раз)",
"Unexpected Items": "Unexpected Items",
"Unexpected items have been found in this folder.": "Unexpected items have been found in this folder.",
"Unexpected Items": "Неожиданные элементы",
"Unexpected items have been found in this folder.": "В папке найдены неожиданные элементы.",
"Unignore": "Не игнорировать",
"Unknown": "Неизвестно",
"Unshared": "Необщедоступно",
"Unshared Devices": "Устройства без общего доступа",
"Unshared Folders": "Unshared Folders",
"Unshared Folders": "Необщедоступные папки",
"Untrusted": "Untrusted",
"Up to Date": "В актуальном состоянии",
"Updated": "Обновлено",
@@ -383,10 +383,10 @@
"Versions": "Версии",
"Versions Path": "Путь к версиям",
"Versions are automatically deleted if they are older than the maximum age or exceed the number of files allowed in an interval.": "Версии удаляются автоматически, если они существуют дольше максимального срока или превышают разрешённое количество файлов за интервал.",
"Waiting to Clean": "Waiting to Clean",
"Waiting to Clean": "Ожидание очистки",
"Waiting to Scan": "Ожидание сканирования",
"Waiting to Sync": "Ожидание синхронизации",
"Warning": "Warning",
"Warning": "Предупреждение",
"Warning, this path is a parent directory of an existing folder \"{%otherFolder%}\".": "Внимание! Этот путь — родительская директория уже существующей папки «{{otherFolder}}».",
"Warning, this path is a parent directory of an existing folder \"{%otherFolderLabel%}\" ({%otherFolder%}).": "Внимание! Этот путь — родительская директория уже существующей папки «{{otherFolderLabel}}» ({{otherFolder}}).",
"Warning, this path is a subdirectory of an existing folder \"{%otherFolder%}\".": "Осторожно, этот путь является подкаталогом существующей папки «{{otherFolder}}».",
@@ -405,13 +405,13 @@
"You have no ignored folders.": "У вас нет игнорируемых папок.",
"You have unsaved changes. Do you really want to discard them?": "Есть несохранённые изменения. Вы действительно хотите отменить их?",
"You must keep at least one version.": "Вы должны хранить как минимум одну версию.",
"You should never add or change anything locally in a \"{%receiveEncrypted%}\" folder.": "You should never add or change anything locally in a \"{{receiveEncrypted}}\" folder.",
"You should never add or change anything locally in a \"{%receiveEncrypted%}\" folder.": "Не добавляйте и не изменяйте ничего локально в папке «{{receiveEncrypted}}».",
"days": "дней",
"directories": "папок",
"files": "файлов",
"full documentation": "полная документация",
"items": "элементы",
"seconds": "seconds",
"seconds": "сек.",
"{%device%} wants to share folder \"{%folder%}\".": "{{device}} хочет поделиться папкой «{{folder}}».",
"{%device%} wants to share folder \"{%folderlabel%}\" ({%folder%}).": "{{device}} хочет поделиться папкой «{{folderlabel}}» ({{folder}}).",
"{%reintroducer%} might reintroduce this device.": "{{reintroducer}} might reintroduce this device."
@@ -0,0 +1,40 @@
<div class="col-md-6 checkbox">
<label for="sharedwith-{{id}}">
<input id="sharedwith-{{id}}" ng-model="selected[id]" type="checkbox" />
<span tooltip data-original-title="{{id}}">{{label}}</span>
</label>
</div>
<div class="col-md-6">
<div class="input-group">
<span class="input-group-addon" ng-switch="folderType !== 'receiveencrypted' && !encryptionPasswords[id]">
<span ng-switch-when='true' class="fas fa-fw fa-unlock" />
<span ng-switch-default class="fas fa-fw fa-lock" />
</span>
<span ng-switch="folderType === 'receiveencrypted'">
<span ng-switch-when='true'>
<input class="form-control input-sm" type="password" placeholder="{{'Received data is already encrypted' | translate}}" disabled />
</span>
<span ng-switch-default ng-switch="selected[id]">
<span ng-switch-when='true' ng-switch="untrusted">
<span ng-switch-when='true' ng-class="{'has-error': !encryptionPasswords[id]}">
<input class="form-control input-sm" type="{{plain ? 'text' : 'password'}}" ng-model="encryptionPasswords[id]" required placeholder="{{'Device is untrusted, enter encryption password' | translate}}" />
</span>
<span ng-switch-default>
<input class="form-control input-sm" type="{{plain ? 'text' : 'password'}}" ng-model="encryptionPasswords[id]" placeholder="{{'If untrusted, enter encryption password' | translate}}" />
</span>
</span>
<span ng-switch-default>
<input class="form-control input-sm" type="password" placeholder="{{'Not shared' | translate}}" disabled />
</span>
</span>
</span>
<span ng-switch="selected[id] && folderType !== 'receiveencrypted'" class="input-group-addon">
<span ng-switch-when='true'>
<span class="button fas fa-fw fa-eye" ng-click="togglePasswordVisibility()" />
</span>
<span ng-switch-default>
<span class="button fas fa-fw fa-eye" disabled />
</span>
</span>
</div>
</div>
@@ -3,7 +3,7 @@ angular.module('syncthing.core')
return {
require: 'ngModel',
link: function (scope, elm, attrs, ctrl) {
ctrl.$parsers.unshift(function (viewValue) {
ctrl.$validators.folderPathErrors = function (viewValue) {
// This function checks whether ydir is a subdirectory of xdir,
// e.g. it would return true if xdir = "/home/a", ydir = "/home/a/b".
function isSubDir(xdir, ydir) {
@@ -24,7 +24,13 @@ angular.module('syncthing.core')
scope.folderPathErrors.isParent = false;
scope.folderPathErrors.otherID = "";
scope.folderPathErrors.otherLabel = "";
if (!viewValue) {
return true;
}
for (var folderID in scope.folders) {
if (folderID === scope.currentFolder.id) {
continue;
}
if (isSubDir(scope.folders[folderID].path, viewValue)) {
scope.folderPathErrors.otherID = folderID;
scope.folderPathErrors.otherLabel = scope.folders[folderID].label;
@@ -39,8 +45,8 @@ angular.module('syncthing.core')
break;
}
}
return viewValue;
});
return true;
};
}
};
});
@@ -1893,6 +1893,7 @@ angular.module('syncthing.core')
}).one('hidden.bs.modal', function () {
$('.nav-tabs a[href="#folder-general"]').tab('show');
window.location.hash = "";
$scope.currentFolder = {};
});
};
+9 -5
View File
@@ -29,11 +29,15 @@ var (
sessionsMut = sync.NewMutex()
)
func emitLoginAttempt(success bool, username string, evLogger events.Logger) {
func emitLoginAttempt(success bool, username, address string, evLogger events.Logger) {
evLogger.Log(events.LoginAttempt, map[string]interface{}{
"success": success,
"username": username,
"success": success,
"username": username,
"remoteAddress": address,
})
if !success {
l.Infof("Wrong credentials supplied during API authorization from %s", address)
}
}
func basicAuthAndSessionMiddleware(cookieName string, guiCfg config.GUIConfiguration, ldapCfg config.LDAPConfiguration, next http.Handler, evLogger events.Logger) http.Handler {
@@ -95,7 +99,7 @@ func basicAuthAndSessionMiddleware(cookieName string, guiCfg config.GUIConfigura
}
if !authOk {
emitLoginAttempt(false, username, evLogger)
emitLoginAttempt(false, username, r.RemoteAddr, evLogger)
error()
return
}
@@ -110,7 +114,7 @@ func basicAuthAndSessionMiddleware(cookieName string, guiCfg config.GUIConfigura
MaxAge: 0,
})
emitLoginAttempt(true, username, evLogger)
emitLoginAttempt(true, username, r.RemoteAddr, evLogger)
next.ServeHTTP(w, r)
})
}
+7 -1
View File
@@ -16,6 +16,7 @@ import (
"strings"
"sync"
"sync/atomic"
"syscall"
"time"
"github.com/lucas-clemente/quic-go"
@@ -223,7 +224,12 @@ type stunConnQUICWrapper struct {
underlying *net.UDPConn
}
// SetReadBuffer is required by QUIC.
// SetReadBuffer is required by QUIC < v0.20.0
func (s *stunConnQUICWrapper) SetReadBuffer(size int) error {
return s.underlying.SetReadBuffer(size)
}
// SyscallConn is required by QUIC
func (s *stunConnQUICWrapper) SyscallConn() (syscall.RawConn, error) {
return s.underlying.SyscallConn()
}
+14 -17
View File
@@ -37,8 +37,10 @@ func (f *sendOnlyFolder) PullErrors() []FileError {
// pull checks need for files that only differ by metadata (no changes on disk)
func (f *sendOnlyFolder) pull() (bool, error) {
batch := make([]protocol.FileInfo, 0, maxBatchSizeFiles)
batchSizeBytes := 0
batch := newFileInfoBatch(func(files []protocol.FileInfo) error {
f.updateLocalsFromPulling(files)
return nil
})
snap, err := f.dbSnapshot()
if err != nil {
@@ -46,45 +48,40 @@ func (f *sendOnlyFolder) pull() (bool, error) {
}
defer snap.Release()
snap.WithNeed(protocol.LocalDeviceID, func(intf protocol.FileIntf) bool {
if len(batch) == maxBatchSizeFiles || batchSizeBytes > maxBatchSizeBytes {
f.updateLocalsFromPulling(batch)
batch = batch[:0]
batchSizeBytes = 0
}
batch.flushIfFull()
file := intf.(protocol.FileInfo)
if f.ignores.ShouldIgnore(intf.FileName()) {
file := intf.(protocol.FileInfo)
file.SetIgnored()
batch = append(batch, file)
batchSizeBytes += file.ProtoSize()
batch.append(file)
l.Debugln(f, "Handling ignored file", file)
return true
}
curFile, ok := snap.Get(protocol.LocalDeviceID, intf.FileName())
if !ok {
if intf.IsDeleted() {
if intf.IsInvalid() {
// Global invalid file just exists for need accounting
batch.append(file)
} else if intf.IsDeleted() {
l.Debugln("Should never get a deleted file as needed when we don't have it")
f.evLogger.Log(events.Failure, "got deleted file that doesn't exist locally as needed when pulling on send-only")
}
return true
}
file := intf.(protocol.FileInfo)
if !file.IsEquivalentOptional(curFile, f.modTimeWindow, f.IgnorePerms, false, 0) {
return true
}
batch = append(batch, file)
batchSizeBytes += file.ProtoSize()
batch.append(file)
l.Debugln(f, "Merging versions of identical file", file)
return true
})
if len(batch) > 0 {
f.updateLocalsFromPulling(batch)
}
batch.flush()
return true, nil
}
+7 -2
View File
@@ -475,8 +475,13 @@ func (m *model) removeFolder(cfg config.FolderConfiguration) {
}
}
if isPathUnique {
// Delete syncthing specific files
cfg.Filesystem().RemoveAll(config.DefaultMarkerName)
// Remove (if empty and removable) or move away (if non-empty or
// otherwise not removable) Syncthing-specific marker files.
fs := cfg.Filesystem()
if err := fs.Remove(config.DefaultMarkerName); err != nil {
moved := config.DefaultMarkerName + time.Now().Format(".removed-20060102-150405")
_ = fs.Rename(config.DefaultMarkerName, moved)
}
}
m.cleanupFolderLocked(cfg)
+1 -1
View File
@@ -1,6 +1,6 @@
.\" Man page generated from reStructuredText.
.
.TH "STDISCOSRV" "1" "Apr 04, 2021" "v1" "Syncthing"
.TH "STDISCOSRV" "1" "Apr 15, 2021" "v1" "Syncthing"
.SH NAME
stdiscosrv \- Syncthing Discovery Server
.
+1 -1
View File
@@ -1,6 +1,6 @@
.\" Man page generated from reStructuredText.
.
.TH "STRELAYSRV" "1" "Apr 04, 2021" "v1" "Syncthing"
.TH "STRELAYSRV" "1" "Apr 15, 2021" "v1" "Syncthing"
.SH NAME
strelaysrv \- Syncthing Relay Server
.
+1 -1
View File
@@ -1,6 +1,6 @@
.\" Man page generated from reStructuredText.
.
.TH "SYNCTHING-BEP" "7" "Apr 04, 2021" "v1" "Syncthing"
.TH "SYNCTHING-BEP" "7" "Apr 15, 2021" "v1" "Syncthing"
.SH NAME
syncthing-bep \- Block Exchange Protocol v1
.
+1 -1
View File
@@ -1,6 +1,6 @@
.\" Man page generated from reStructuredText.
.
.TH "SYNCTHING-CONFIG" "5" "Apr 04, 2021" "v1" "Syncthing"
.TH "SYNCTHING-CONFIG" "5" "Apr 15, 2021" "v1" "Syncthing"
.SH NAME
syncthing-config \- Syncthing Configuration
.
+1 -1
View File
@@ -1,6 +1,6 @@
.\" Man page generated from reStructuredText.
.
.TH "SYNCTHING-DEVICE-IDS" "7" "Apr 04, 2021" "v1" "Syncthing"
.TH "SYNCTHING-DEVICE-IDS" "7" "Apr 15, 2021" "v1" "Syncthing"
.SH NAME
syncthing-device-ids \- Understanding Device IDs
.
+5 -2
View File
@@ -1,6 +1,6 @@
.\" Man page generated from reStructuredText.
.
.TH "SYNCTHING-EVENT-API" "7" "Apr 04, 2021" "v1" "Syncthing"
.TH "SYNCTHING-EVENT-API" "7" "Apr 15, 2021" "v1" "Syncthing"
.SH NAME
syncthing-event-api \- Event API
.
@@ -713,7 +713,9 @@ changes during a scan.
.sp
When authentication is enabled for the GUI, this event is emitted on every
login attempt. If either the username or password are incorrect, \fBsuccess\fP
is false and in any case the given username is returned.
is false and in any case the given username is returned. The included
remote address concerns the immediate connecting host, which may not be the
origin of the request, but e.g. a reverse proxy.
.INDENT 0.0
.INDENT 3.5
.sp
@@ -723,6 +725,7 @@ is false and in any case the given username is returned.
"id" : 187,
"time" : "2017\-03\-07T00:19:24.420386143+01:00",
"data" : {
"remoteAddress" : "127.0.0.1:55530",
"username" : "somename",
"success" : false
},
+1 -1
View File
@@ -1,6 +1,6 @@
.\" Man page generated from reStructuredText.
.
.TH "SYNCTHING-FAQ" "7" "Apr 04, 2021" "v1" "Syncthing"
.TH "SYNCTHING-FAQ" "7" "Apr 15, 2021" "v1" "Syncthing"
.SH NAME
syncthing-faq \- Frequently Asked Questions
.
+1 -1
View File
@@ -1,6 +1,6 @@
.\" Man page generated from reStructuredText.
.
.TH "SYNCTHING-GLOBALDISCO" "7" "Apr 04, 2021" "v1" "Syncthing"
.TH "SYNCTHING-GLOBALDISCO" "7" "Apr 15, 2021" "v1" "Syncthing"
.SH NAME
syncthing-globaldisco \- Global Discovery Protocol v3
.
+1 -1
View File
@@ -1,6 +1,6 @@
.\" Man page generated from reStructuredText.
.
.TH "SYNCTHING-LOCALDISCO" "7" "Apr 04, 2021" "v1" "Syncthing"
.TH "SYNCTHING-LOCALDISCO" "7" "Apr 15, 2021" "v1" "Syncthing"
.SH NAME
syncthing-localdisco \- Local Discovery Protocol v4
.
+1 -1
View File
@@ -1,6 +1,6 @@
.\" Man page generated from reStructuredText.
.
.TH "SYNCTHING-NETWORKING" "7" "Apr 04, 2021" "v1" "Syncthing"
.TH "SYNCTHING-NETWORKING" "7" "Apr 15, 2021" "v1" "Syncthing"
.SH NAME
syncthing-networking \- Firewall Setup
.
+1 -1
View File
@@ -1,6 +1,6 @@
.\" Man page generated from reStructuredText.
.
.TH "SYNCTHING-RELAY" "7" "Apr 04, 2021" "v1" "Syncthing"
.TH "SYNCTHING-RELAY" "7" "Apr 15, 2021" "v1" "Syncthing"
.SH NAME
syncthing-relay \- Relay Protocol v1
.
+1 -1
View File
@@ -1,6 +1,6 @@
.\" Man page generated from reStructuredText.
.
.TH "SYNCTHING-REST-API" "7" "Apr 04, 2021" "v1" "Syncthing"
.TH "SYNCTHING-REST-API" "7" "Apr 15, 2021" "v1" "Syncthing"
.SH NAME
syncthing-rest-api \- REST API
.
+1 -1
View File
@@ -1,6 +1,6 @@
.\" Man page generated from reStructuredText.
.
.TH "SYNCTHING-SECURITY" "7" "Apr 04, 2021" "v1" "Syncthing"
.TH "SYNCTHING-SECURITY" "7" "Apr 15, 2021" "v1" "Syncthing"
.SH NAME
syncthing-security \- Security Principles
.
+1 -1
View File
@@ -1,6 +1,6 @@
.\" Man page generated from reStructuredText.
.
.TH "SYNCTHING-STIGNORE" "5" "Apr 04, 2021" "v1" "Syncthing"
.TH "SYNCTHING-STIGNORE" "5" "Apr 15, 2021" "v1" "Syncthing"
.SH NAME
syncthing-stignore \- Prevent files from being synchronized to other nodes
.
+1 -1
View File
@@ -1,6 +1,6 @@
.\" Man page generated from reStructuredText.
.
.TH "SYNCTHING-VERSIONING" "7" "Apr 04, 2021" "v1" "Syncthing"
.TH "SYNCTHING-VERSIONING" "7" "Apr 15, 2021" "v1" "Syncthing"
.SH NAME
syncthing-versioning \- Keep automatic backups of deleted files by other nodes
.
+1 -1
View File
@@ -1,6 +1,6 @@
.\" Man page generated from reStructuredText.
.
.TH "SYNCTHING" "1" "Apr 04, 2021" "v1" "Syncthing"
.TH "SYNCTHING" "1" "Apr 15, 2021" "v1" "Syncthing"
.SH NAME
syncthing \- Syncthing
.