Initial

Jakob Borg committed 2015-01-03 16:40:19 +01:00
1 parent 530433e80e
commit aeef469ed5
25 files changed
+1120 -360

No files matched your search

-28
@@ -1,28 +0,0 @@
# Prerequisites
* Go 1.2 and a correctly configured $GOPATH.
* godep (`go get github.com/tools/godep`)
* Git, Mercurial and Bazaar (for fetching dependencies, only Git necessary if `godep` is available)
* bash (for the build script)
If you're not a Go developer since before, the easiest way to get going is to download Go 1.2 as instructed in http://golang.org/doc/install and `export GOPATH=~`.
# Building
Syncthing it "go-gettable" on the path github.com/calmh/syncthing/cmd/syncthing so the easiest way to get a working binary is: `go get github.com/calmh/syncthing/cmd/syncthing`. This also gets you the source code and build scripts to do "proper" builds.
The source code should have materialized in `$GOPATH/src/github.com/calmh/syncthing`, which is likely `~/src/github.com/calmh/syncthing`. If you haven't used `go get` or want to check out the code manually, this is the place you want the code checked out. (If you aren't a Go developer, you might think you want the source somewhere else, like `~/Projects/By Others/syncthing` or something, but you really don't...)
The included `build.sh` will run tests and build the syncthing binary for the local OS/architecture and others, plus tag it with a build version. There are three ways to run the build script;
* `./build.sh` -- create a syncthing binary in the current directory
* `./build.sh tar` -- create a syncthing tar.gz dist file in the current directory
* `./build.sh all` -- create distribution files for all supported OS/architecture combinations. This requires Go set up for cross compilation.
* `./build.sh test` -- run the tests
* `./build.sh assets` -- rebuild the compiled-in GUI assets
* `./build.sh deps` -- update the in-repo dependencies
There is a special build mode for GUI development. `./build.sh "" -tags guidev` builds a binary without compiled in assets, instead loading them from the "gui" directory. Use this to be able to edit and reload the GUI stuff without recompiling all the time.
If the tests fail and you are building the `master` branch you should be very, very suspicious.
-131
@@ -1,131 +0,0 @@
This is a walkthrough of my syncthing setup. It shows one way to utilize the capabilities of syncthing and illustrates how it's tested in day to day development. I have two clusters running for two separate use cases.
The first case is backup and syncing of the Lightroom catalog and Documents folder from my laptop to both the "Home Server" and the "Offsite Server". This is about 5 GB of data in 22.000 files. In this setup the "Laptop" node is set to read only, since it will be the master source of data. Remember, "read only" in this case means from the cluster point of view i.e. it will never overwrite local files with data from the cluster, however it will introduce new data *into* the cluster as it is changed locally.
[[case2.png]]
The second is a simple backup mirroring of my photo collection, with one side being read only for safety reasons. This is about 375 GB of data in 78.000 files originating on my "Home Server". Since these change fairly rarely I've decreased the scan interval from once every minute to once every hour. The listening port has been changed from `:22000` to `:22001` to avoid conflicts with the first cluster.
[[case1.png]]
## Configuration
For the first cluster setup, this is the `config.xml` from the laptop:
```xml
<configuration version="1">
<repository directory="~/Sync">
<node id="XNYUM3SCMTDEJQ5ASGAI74ZKJAWGTRA7F3FP6262OS4XAXMKGUYQ" name="laptop">
<address>dynamic</address>
</node>
<node id="AWTTGVQIJJTBUI5XEES4NHYELTCJ5Q6QSVDAVZPVKCY2PPTSQTVQ" name="offsite-server">
<address>dynamic</address>
</node>
<node id="HYRGTFWXKDLRPD7CNBYVCE3DRCP4XGNYLKHEZ43SZM5TKZJ7ZHUA" name="home-server">
<address>dynamic</address>
</node>
</repository>
<options>
<listenAddress>:22000</listenAddress>
<readOnly>true</readOnly>
<allowDelete>false</allowDelete>
<followSymlinks>true</followSymlinks>
<guiEnabled>true</guiEnabled>
<guiAddress>127.0.0.1:8080</guiAddress>
<globalAnnounceServer>announce.syncthing.net:22025</globalAnnounceServer>
<globalAnnounceEnabled>true</globalAnnounceEnabled>
<localAnnounceEnabled>true</localAnnounceEnabled>
<parallelRequests>32</parallelRequests>
<maxSendKbps>0</maxSendKbps>
<rescanIntervalS>60</rescanIntervalS>
<reconnectionIntervalS>60</reconnectionIntervalS>
<maxChangeKbps>1000</maxChangeKbps>
<startBrowser>false</startBrowser>
</options>
</configuration>
```
You can see the ID:s for all three nodes, with descriptive names, and the `readOnly` attribute having been changed to `true`. All addresses are set to `dynamic` so the nodes will find each other by discovery. This works well regardless of where the laptop happens to be, network wise. If it's out roaming it won't be able to connect to the home server behind NAT (I haven't bothered to set up a port forward), however it will sync with the offsite server which will pass on the changes.
Another interesting aspect of this config is that the repository directory is set to it's default of `~/Sync` even though that's not actually where I keep the files in question. Instead, that folder just contains two symlinks:
```
$ ls -l Sync/
total 16
lrwxr-xr-x 1 jb staff 12 Mar 13 21:55 Documents@ -> ../Documents
lrwxr-xr-x 1 jb staff 12 Jan 31 19:54 Lightroom@ -> ../Lightroom
```
Since `followSymlinks` is `true` (the default), these will be followed and the cluster will see the files as if they were actually in those two directories. Other nodes can do similar things if the two directories should be on different partitions or something similar.
On the laptop I keep syncthing running by using a LaunchAgent, a Mac OS X specific concept of a user specific service. This is the contents of `~/Library/LaunchAgents/se.nym.syncthing.plist` which will make sure syncthing starts on login:
```xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>se.nym.syncthing</string>
<key>ProgramArguments</key>
<array>
<string>/Users/jb/bin/syncthing</string>
</array>
<key>EnvironmentVariables</key>
<dict>
<key>HOME</key>
<string>/Users/jb</string>
<key>STNORESTART</key>
<string>1</string>
</dict>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
```
On the offsite server, the `config.xml` is almost the same as on the laptop, but not read only and with the `Sync` directory on a separate partition with more space than `/home`:
```xml
<configuration version="1">
<repository directory="/data/Sync">
<node id="AWTTGVQIJJTBUI5XEES4NHYELTCJ5Q6QSVDAVZPVKCY2PPTSQTVQ" name="offsite-server">
<address>dynamic</address>
</node>
<node id="HYRGTFWXKDLRPD7CNBYVCE3DRCP4XGNYLKHEZ43SZM5TKZJ7ZHUA" name="home-server">
<address>dynamic</address>
</node>
<node id="XNYUM3SCMTDEJQ5ASGAI74ZKJAWGTRA7F3FP6262OS4XAXMKGUYQ" name="laptop">
<address>dynamic</address>
</node>
</repository>
<options>
<listenAddress>:22000</listenAddress>
<readOnly>false</readOnly>
<allowDelete>true</allowDelete>
<followSymlinks>true</followSymlinks>
<guiEnabled>true</guiEnabled>
<guiAddress>:8080</guiAddress>
<globalAnnounceServer>announce.syncthing.net:22025</globalAnnounceServer>
<globalAnnounceEnabled>true</globalAnnounceEnabled>
<localAnnounceEnabled>true</localAnnounceEnabled>
<parallelRequests>16</parallelRequests>
<maxSendKbps>0</maxSendKbps>
<rescanIntervalS>60</rescanIntervalS>
<reconnectionIntervalS>60</reconnectionIntervalS>
<maxChangeKbps>1000</maxChangeKbps>
<startBrowser>true</startBrowser>
</options>
</configuration>
```
Here, I keep syncthing running with the help of a `runit` service:
```
$ cat /etc/service/syncthing/run
#!/bin/bash
exec su - jb -c ~jb/bin/syncthing
```
The home server setup is almost identical, apart from using SMF to keep syncthing running. If you run that kind of thing you already know how to set that up...
+82
@@ -0,0 +1,82 @@
This page lists integrations, addons and packagings of syncthing created by the community. Like all documentation pages, it's wiki editable so feel free to edit and add your own.
# GUI Wrappers
## Cross-platform
https://github.com/syncthing/syncthing-gtk
https://github.com/alex2108/syncthing-tray (Tray icon only)
## Android
https://github.com/syncthing/syncthing-android
## Ubuntu
https://github.com/icaruseffect/syncthing-ubuntu-indicator
## Windows
https://github.com/iss0/SyncthingTray
https://github.com/bloones/SyncThingWin (Windows service helper and tray icon)
## OS-X
https://github.com/m0ppers/syncthing-bar
# Packages and Bundlings
## ArchLinux
https://www.archlinux.org/packages/?q=syncthing
## arkOS
Syncthing is included in arkOS, https://arkos.io/.
## Debian / Ubuntu
PPA: https://launchpad.net/~ytvwld/+archive/ubuntu/syncthing
Syncthing GTK PPA: https://launchpad.net/~nilarimogard/+archive/ubuntu/webupd8/
## Docker
https://github.com/firecat53/dockerfiles/tree/master/syncthing (runs Syncthing and/or builds the binary from source)
https://github.com/firecat53/dockerfiles/tree/master/syncthing_discovery (Global announce server in a container)
## Fedora
https://github.com/thunderbirdtr/syncthing_rpm (SRPM, binary packages coming)
## FreeBSD
http://www.freshports.org/net/syncthing/
## OpenSUSE
http://software.opensuse.org/package/syncthing
## Synology NAS
http://cytec.us/spk/ Add url to Package Center in DSM. **(Syno boxes with limited CPU & memory resources may struggle syncing large repos.)
# Integrations
## REST API Bindings
* Ruby: https://github.com/retgoat/syncthing-ruby
## Ports
* Swift: https://github.com/dapperstout/pulse-swift
* Java: https://github.com/dapperstout/pulse-java
* PHP: https://github.com/cebe/pulse-php-discover (Only Discovery so far)
## Configuration management
* Saltstack: https://bitbucket.org/StartledPhoenix/saltstack-syncthing
* Command line interface: https://github.com/syncthing/syncthing-cli
# Other
[Pulse](http://ind.ie/pulse/) is a rebranding / fork of syncthing.
+133
@@ -0,0 +1,133 @@
Syncthing uses a single directory to store configuration, crypto keys and index caches. The location defaults to `~/.config/syncthing` (Unixes), `%AppData%/Syncthing` (Windows) or `~/Library/Application Support/Syncthing` (Mac) but is also settable at runtime using the `-home` flag. In this directory you'll generally see something like the following files:
* `cert.pem`: The node's RSA public key, named "cert" for legacy reasons.
* `key.pem`: The node's RSA private key. This needs to be protected.
* `config.xml`: The configuration file, in XML format.
* `https-cert.pem` and `https-key.pem`: The certificate and key for HTTPS GUI connections.
* `index/`: A directory holding the database with metadata and hashes of the files currently on disk and available from peers.
* `csrftokens.txt`: A list of recently issued CSRF tokens (for protection against browser cross site request forgery).
# Config File Format
The following is an example default configuration file:
```xml
<configuration version="2">
<repository id="default" directory="/Users/jb/Sync" ro="false" ignorePerms="false">
<node id="GXN5ECCWTA2B7EB5FXYL5OWGOADX5EF5VNJAQSIBAY6XHJ24BNOA"></node>
</repository>
<node id="GXN5ECCWTA2B7EB5FXYL5OWGOADX5EF5VNJAQSIBAY6XHJ24BNOA" name="jborg-mbp">
<address>dynamic</address>
</node>
<gui enabled="true" tls="true">
<address>127.0.0.1:54096</address>
<user>jb</user>
<password>$2a$10$EKaTIcpz2...</password>
<apikey>O80CDOJ9LVUVCMHFK2OJDO4T882735</apikey>
</gui>
<options>
<listenAddress>:54097</listenAddress>
<globalAnnounceServer>announce.syncthing.net:22025</globalAnnounceServer>
<globalAnnounceEnabled>true</globalAnnounceEnabled>
<localAnnounceEnabled>true</localAnnounceEnabled>
<parallelRequests>16</parallelRequests>
<maxSendKbps>0</maxSendKbps>
<rescanIntervalS>60</rescanIntervalS>
<reconnectionIntervalS>60</reconnectionIntervalS>
<maxChangeKbps>10000</maxChangeKbps>
<startBrowser>true</startBrowser>
<upnpEnabled>true</upnpEnabled>
<urAccepted>0</urAccepted>
</options>
</configuration>
```
The following sections should be present in a well formed config file.
## configuration
The root element.
### Attributes
* `version`: The config version. `2` is current.
## repository
One or more `repository` elements must be present in the file. Each element describes one repository.
Within the `repository` element one or more `node` element should be present. These must contain the `id` attribute and nothing else. Mentioned nodes are those that will be sharing the repository in question. Each mentioned node must have a separate `node` element later in the file. It is customary that the local node ID is included in all repositories. Syncthing will currently add this automatically if it is not present in the configuration file.
### Attributes
* `id`: The repository ID, must be unique. (mandatory)
* `directory`: The directory where the repository is stored on this node; not sent to other nodes. (mandatory)
* `ro`: True if the repository is read only (will not be modified by syncthing) on this node. (optional, defaults to `false`)
* `ignorePerms`: True if the repository should [ignore permissions](http://discourse.syncthing.net/t/v0-8-10-ignore-permissions/263).
### Children
* One or mode `node` elements.
## node
One or more `node` elements must be present in the file. Each element describes a node participating in the cluster. It is customary to include a `node` element for the local node; syncthing will currently add one if it is not present.
### Attributes
* `id`: The node ID. This must be written in canonical form, that is without any spaces or dashes. (mandatory)
* `name`: A friendly name for the node. (optional)
### Children
* One or mode `address` elements.
## address
The address section is only valid inside of `node` elements. It contains a single address, on one of the following forms:
* IPv4 addresses, IPv6 addresses within brackets, or DNS names, all optionally followed by a port number.
* `dynamic`: The address will be resolved using discovery.
## gui
There must be exactly one `gui` element.
### Attributes
* `enabled`: `true`/`false`
* `tls`: `true`/`false` - if true then the GUI will use HTTPS
### Children
* `address`: One or more address elements must be present, containing an `ip:port` listen address.
* `username` and `password`: Set to require authentication. `password` contains the bcrypt hash of the real password.
* `apikey`: If set, this is the API key that enables usage of the [REST interface]().
## options
There must be exactly one `options` element. It contains the following configuration settings as children;
* `listenAddress`&nbsp;: `host:port` or `:port` string denoting an address to listen for BEP (sync protocol) connections. More than one `listenAddress` may be given. (default `0.0.0.0:22000`)
* `globalAnnounceServer`&nbsp;: `host:port` where a global announce server may be reached. (default `announce.syncthing.net:22025´)
* `globalAnnounceEnabled`: `true`/`false` (default `true`)
* `localAnnounceEnabled`: `true`/`false` (default `true`)
* `parallelRequests`: The maximum number of outstanding block requests to have against any given peer. (default `16`)
* `maxSendKbps`: Rate limit
* `rescanIntervalS`: The number of seconds to wait between each scan for modification of the local repositories. (default `60`)
* `reconnectionIntervalS`: The number of seconds to wait between each attempt to connect to currently unconnected nodes. (default `60`)
* `maxChangeKbps`: The maximum rate of change allowed for a single file. When this rate is exceeded, further changes to the file are not announced, until the rate is reduced below the limit. (default `10000`)
* `startBrowser`: `true`/`false` (default `true`)
* `upnpEnabled`: `true`/`false` (default `true`)
* `urAccepted`: Whether the user as accepted to submit anonymous usage data. The default, `0`, mean the user has not made a choice, and syncthing will ask at some point in the future. `-1` means no, `1` means yes.
-7
@@ -1,7 +0,0 @@
Any and all contributions are welcome. These are just some notes on areas where I know work is necessary and I haven't gotten there myself. Some are probably larger chunks of work than others. Some have open issues describing the need or bug, others don't. For those that don't, it might be a good idea to open an issue to announce that you're working on it and to collect any relevant discussion.
* Vet the [protocol spec](https://github.com/calmh/syncthing/blob/master/protocol/PROTOCOL.md). This is the single most important artefact in the project and it's *essential* that it makes sense and is unambiguous. More eyes are always welcome.
* Take a look at the [open issues that I don't plan on fixing myself](https://github.com/calmh/syncthing/issues?labels=wontfix&page=1&state=open). These are all valid points, but something I feel I won't get around to - you maybe could! :)
* Make the [web site](http://syncthing.net) nicer.
-91
@@ -1,91 +0,0 @@
Syncthing provides a simple long polling interface for exposing events from the core utility towards a GUI.
To receive events, perform a HTTP GET of /rest/events/<lastSeenID>, where <lastSeenID> is the ID of the last event you've already seen or zero. Syncthing returns a JSON encoded array of event objects, starting at the event just after the one with the last seen ID. There is a limit to the number of events buffered, so if the rate of events is high or the time between polling calls is long some events might be missed. This can be detected by noting a discontinuity in the event IDs.
# Event Structure
Each event is represented by an object similar to the following:
```json
{
"id": 1,
"timestamp": "2014-04-22T09:03:11.274499963+02:00",
"type": "NODE_CONNECTED",
"params": {
"node": "LGFPDIT7SKNNJVJZA4FC7QNCRKCE753K72BW5QD2FOZ7FRFEP57Q"
}
}
```
The top level keys `id`, `timestamp`, `type` and `params` are always present, though `params` may be `null`.
* `id` is a monotonically increasing integer. The first event generated has id `1`, the next has id `2` etc.
* `timestamp` is the time the event was generated.
* `type` indicates the type of (i.e. reason for) the event and is one of the event types below.
* `params` is an object containing optional extra information; the exact structure is determined by the event type.
# Event Types
## TIMEOUT
The timeout event is generated to terminate a long polling request after 300 seconds, if no other event has occurred during the time period. It is special in that it always has an `id` of `-1`. It has no optional parameters. The event ID is not incremented, so a new call with the same `lastSeenID` should be made to subscribe to further events.
## NODE_CONNECT
Generated each time a connection to a node has been established.
Parameters:
* `node`: The node ID of the connected node.
## NODE_DISCONNECT
Generated each time a connection to a node has been terminated.
Parameters:
* `node`: The node ID of the connected node.
## NODE_INDEX
Generated each time new index information is received from a node.
Parameters:
* `node`: The node ID of the connected node.
* `repo`: The repository ID the new index updates.
* `hasBytes`: The number of bytes in all files announced by the node that are of the latest version.
* `totalBytes`: The number of bytes in all files announced by *any* node (including ourselves) that are of the latest version.
`hasBytes` is the sum of up-to-date files on the node in question, while `totalBytes` is the sum of up-to-date files in the entire cluster. The two are equal if the node is entirely up to date ("in sync"). If `hasBytes` is a lower number than `totalBytes` the node lacks the latest version of some files and is presumably in the process of synchronizing those (or it is read-only). The opposite can't happen.
## PULL_START
Generated when syncthing begins synchronizing a file to a newer version.
Parameters:
* `repo`: The repository ID
* `file`: The file name
* `size`: The new file size, in bytes
* `modified`: The file modification timestamp, in Unix epoch seconds
* `flags`: The file mode and permission flags, as defined in the BEP protocol spec.
## PULL_COMPLETE
Generated when syncthing finishes synchronizing a file to a newer version.
Parameters:
* `repo`: The repository ID
* `file`: The file name
## PULL_ERROR
Generated when syncthing failed to synchronize a file to a newer version.
Parameters:
* `repo`: The repository ID
* `file`: The file name
* `error`: An error message describing the error
+14
@@ -0,0 +1,14 @@
# Port Forwards
If you have a NAT router, the easiest way to get a working port forward is to make sure UPnP is enabled – syncthing will handle the rest. If this is not possible or desirable you should set up a port forward for port **22000/TCP**, or the port set in the *Sync Protocol Listen Address* setting.
# Local Firewall
If your PC has a local firewall, you will need to open the following ports for incoming traffic:
* Port **22000/TCP** (or the actual listening port if you have changed the *Sync Protocol Listen Address* setting.)
* Port **21025/UDP** (for discovery broadcasts)
# Remote Web GUI
To be able to access the web GUI from other computers, you need to change the *GUI Listen Address* setting from the default `127.0.0.1:8080` to `0.0.0.0:8080`. You also need to open the port in your local firewall if you have one.
+52 -28
@@ -1,43 +1,67 @@
# Installing and Starting Up
# Introduction
syncthing will synchronize a single directory between a cluster of nodes that you configure. Each node will have its own unique ID. Only nodes with an ID listed in the config file are allowed to connect. The ID corresponds to the TLS certificate fingerprint of that node.
For this guide lets assume you have two machines that you want to sync files between. In keeping with syncthing terminology they are going to be called "devices" in the rest of the documentation. The "local device" is the one you are configuring, viewing status for, etc while the "remote device" is the other machine.
Download syncthing for your OS/architecture from https://github.com/calmh/syncthing/releases and unpack it:
The best way to follow this guide is to do the install on both machines and configure them in parallel. If both machines aren't accessible simultaneously that's fine, the results will just be a little less immediately obvious.
$ tar zxvf syncthing-linux-amd64-tar.gz
# Installing
Run syncthing on the first node to let it create its config and certificate:
Grab the latest release of Syncthing for your operating system at https://github.com/syncthing/syncthing/releases/latest and unpack it. There will be a binary called `syncthing` (or `syncthing.exe` on Windows). Start this in whatever way you are most comfortable with; double clicking should work in any graphical environment, but I'll use the terminal to better illustrate what happens. At first start, syncthing will generate a configuration and some keys and then start the admin GUI in your browser. Something like the following will be printed on the terminal:
$ syncthing
2014/02/09 22:03:29 INFO: Generating RSA certificate and key...
2014/02/09 22:03:32 OK: Created RSA certificate file
2014/02/09 22:03:32 OK: Created RSA key file
[C6JEY] 2014/02/09 22:03:32 INFO: Version v0.5.4
[C6JEY] 2014/02/09 22:03:32 INFO: My ID: C6JEY4C6HY2RG4C5256YTP3SMNYTL5GMSE6CQCOAMDBWBEVGXBKA
[C6JEY] 2014/02/09 22:03:32 INFO: No config file; starting with empty defaults
[C6JEY] 2014/02/09 22:03:32 INFO: Edit /Users/jb/.syncthing/config.xml to taste or use the GUI
[C6JEY] 2014/02/09 22:03:32 INFO: Starting web GUI on http://127.0.0.1:8080
```
$ syncthing
[monitor] 15:56:58 INFO: Starting syncthing
15:56:58 INFO: Generating RSA key and certificate for syncthing...
[ANSMX] 15:57:05 INFO: syncthing v0.10.14 (go1.4 darwin-amd64 default) jb@syno 2014-12-31 12:08:37 UTC
[ANSMX] 15:57:05 INFO: My ID: ANSMXYD-E6CF3JC-TCVPYGF-GXJPHSJ-MKUXBUQ-ZSPOKXH-RG4SOAL-5447KQW
[ANSMX] 15:57:05 INFO: No config file; starting with empty defaults
[ANSMX] 15:57:05 INFO: Edit gs1/config.xml to taste or use the GUI
[ANSMX] 15:57:05 INFO: Starting web GUI on http://127.0.0.1:8080/
[ANSMX] 15:57:05 INFO: Loading HTTPS certificate: open gs1/https-cert.pem: no such file or directory
[ANSMX] 15:57:05 INFO: Creating new HTTPS certificate
[ANSMX] 15:57:05 INFO: Generating RSA key and certificate for syno...
[ANSMX] 15:57:07 INFO: Starting UPnP discovery...
[ANSMX] 15:57:13 INFO: UPnP discovery complete (found 0 devices).
[ANSMX] 15:57:13 INFO: Starting local discovery announcements
[ANSMX] 15:57:13 INFO: Local discovery over IPv4 unavailable
[ANSMX] 15:57:13 INFO: Starting global discovery announcements
[ANSMX] 15:57:13 OK: Ready to synchronize default (read-write)
[ANSMX] 15:57:13 INFO: Device ANSMXYD-E6CF3JC-TCVPYGF-GXJPHSJ-MKUXBUQ-ZSPOKXH-RG4SOAL-5447KQW is "syno" at [dynamic]
[ANSMX] 15:57:13 INFO: Completed initial scan (rw) of folder default
```
Do the same on the second node. At this point you have two nodes, each with their own certificate and ID. You will now need to configure both nodes to talk to the other and synchronize a common directory.
At this point syncthing will also have set up a folder called `default` for you, in a directory called `Sync` in your home directory. You can use this as a starting point, then remove it or add more folders later.
Syncthing will have created a template configuration file at `~/.syncthing/config.xml`. This contains the path to the repository directory, the list of cluster members and various configurations settings. You might want to look this file over and possibly change the repository directory.
# Configuring
The list of cluster members in the configuration should be the same on all nodes and list all nodes that make up the cluster. You can add the cluster nodes in this configuration file. Changes to the configuration file only take effect on restarting syncthing.
The admin GUI starts automatically and remains available on http://localhost:8080/. It should look something like this:
You can also use the GUI, by default available on http://127.0.0.1:8080/ to add each node to the other.
[[img/gs1.png]]
If the nodes are running on the same network, or are reachable on port 22000 from the outside world, you can set all addresses to "dynamic" and they will find each other using automatic discovery.
On the left is the list of "folders", or directories to synchronize. You can see the `default` folder was created for you, and it's currently marked "Unshared" since it's not yet shared with any other device. On the right is the list of devices. Currently there is only one device, the computer you are running this on.
# Accessing the GUI
For Syncthing to be able to synchronize files with another device, it must be told about that device. This is accomplished by exchanging "device IDs". A device ID is a unique, cryptographically secure identifier that is generated as part of the key generation the first time you start Syncthing. It is printed in the log above, and you can see it in the web GUI by selecting the "gear menu" (top right) and "Show ID".
The web based GUI is enabled per default on localhost only. Surf to http://127.0.0.1:8080/ to access it.
Two devices will *only* connect and talk to each other if they both know about the others' device ID. Since the configuration must be mutual for a connection to happen, device IDs don't need to be kept secret.
# Excluding Files
To get your two devices to talk to each other, click "Add Device" at the bottom right on both, and enter the device ID of the other side. You should also select the folder(s) that you want to share with this device. The device name is optional, but you can set it to something that makes sense for your you to remember what device this is.
syncthing looks for files named `.stignore` while walking the
repository. The file is expected to contain glob patterns of file names
to ignore. Patterns are matched on file name only and apply to files in
the same directory as the `.stignore` file and in directories lower down
in the hierarchy.
[[img/gs2.png]]
The `.stignore` files are local to each node and will not be synchronized between nodes in a cluster.
On you click "Save" the new device will appear on right side of the GUI (although disconnected) and a prompt will be shown to indicate the need for a restart.
[[img/gs3.png]]
Syncthing needs to be restarted for some configuration changes, like sharing folders with new devices, to take effect. When you click restart syncthing will first restart:
[[img/gs4.png]]
... then come back up and after a while (up to a minute) connect to the other device. Remember though that you need to do the above process on both devices, and only once you've done this on both witll they be able to connect.
[[img/gs5.png]]
At this point the two devices share an empty directory. Adding files to the Sync directory on either device will synchronize those files to the other side. Each device scans for changes every sixty seconds, so changes can take a bit over a minute to propagate to the other side.
---
Good luck and have fun! There is more [documentation](https://github.com/syncthing/syncthing/wiki) and if you run into trouble feel free to post a question in the [support forum](http://discourse.syncthing.net/category/support). If you have problems getting this to connect, first take a look at [[Firewalls and Port Forwards]], then look at any error messages in the GUI or on the console and if necessary move on to [[Debugging]].
+10 -63
@@ -1,70 +1,17 @@
Welcome to the syncthing wiki!
[[img/logo-text-256.png|height=64px]]
Your first stop should probably be the [[Getting Started]] guide. See the [[Release Schedule]] about when to expect new versions. Look at the [[Case Study]] for an overview of how syncthing can be used.
## Documentation
If you want to start hacking, you should probably read about [[Building]] syncthing. Take a look at the [[Contributions Needed]] page to get ideas for areas to work on.
If you're a new user, [[Getting Started]] is a good place to start. If
you run into trouble getting devices to connect to each other,
[[Firewalls and Port Forwards]] explain the networking necessary to get
it to work.
# Features
## Contact
> To request features and file bugs, see [the issue tracker][issues].
* To report bugs or request features, please use the [issue tracker](https://github.com/syncthing/syncthing/issues). Before you do so, make sure you are running the [latest version](https://github.com/syncthing/syncthing/releases/latest), and please do a quick search to see if the issue has already been reported.
The following features are _currently implemented and working_:
* To get help and support, to discuss scenarios, or just connect with other users and developers you can head over to the [friendly forum](https://discourse.syncthing.net/).
* The formation of a cluster of nodes, certificate authenticated and
communicating over TLS over TCP.
* For a more real time experience, there's also an IRC channel `#syncthing` on Freenode.
* Synchronization of a single directory among the cluster nodes.
* Change detection by periodic scanning of the local repository.
* Static configuration of cluster nodes.
* Automatic discovery of cluster nodes. See [discover.go][discover.go]
for the protocol specification. Discovery on the LAN is performed by
broadcasts, Internet wide discovery is performed with the assistance
of a global server.
* Handling of deleted files. Deletes can be propagated or ignored per
client.
* Synchronizing multiple unrelated directory trees by following
symlinks directly below the repository level.
* HTTP GUI.
* Syncing multiple directories from the same syncthing instance.
* Automatic NAT port mapping via UPnP.
The following features are _not implemented but may be implemented_ in
the future:
* Change detection by listening to file system notifications instead of
periodic scanning.
* Conflict resolution. Currently whichever file has the newest
version stamp. The correct behavior in the face of conflicts is
open for discussion.
[discover.go]: https://github.com/calmh/syncthing/blob/master/discover/discover.go
[issues]: https://github.com/calmh/syncthing/issues
# Supported OS/architectures
```
| Mac OS X Linux FreeBSD Solaris Windows
|----------------------------------------------------
i386 | Untested Untested Untested - Untested
AMD64 | Yes Yes Untested Broken[1] Yes
ARMv5 | - Untested - - -
ARMv6 | - Untested - - -
ARMv7 | - Untested - - -
```
("Yes" - I build and test on this; "Untested" - It compiles, I guess it ought to work.)
[1] - There are issues with the Go runtime on Solaris, causing segfaults.
# Further Reading
See the [[Security]] page for the thinking behind the security mechanisms in syncthing.
+69
@@ -0,0 +1,69 @@
If some files should not be synchronized to other nodes, a file called `.stignore` can be created containing file patterns to ignore. The `.stignore` file must be placed in the root of the repository. The `.stignore` file itself will never be synced to other nodes, although it can `#include` files that *are* synchronized between nodes. All patterns are relative to the repository root.
## Patterns
The `.stignore` file contains a list of file or path patterns. The *first* pattern that matches will decide the fate of a given file.
* Regular file names match themselves, i.e. the pattern `foo` matches the files `foo`, `subdir/foo` as well as any directory named `foo`.
* Asterisk matches zero or more characters in a filename, but does not match the directory separator. `te*st` matches `test`, `subdir/telerest` but not `tele/rest`.
* Double asterisk matches as above, but also directory separators. `te**st` matches `test`, `subdir/telerest` and `tele/sub/dir/rest`.
* Question mark matches a single character that is not the directory separator. `te??st` matches `tebest` but not `teb/st` or `test`.
* A pattern beginning with `/` matches in the current directory only. `/foo` matches `foo` but not `subdir/foo`.
* A pattern beginning with `#include` results in loading patterns from the named file. It is an error for a file to not exist or be included more than once. Note that while this can be used to include patterns from a file in a subdirectory, the patterns themselves are still relative to the repository *root*. Example: `#include more-patterns.txt`.
* A pattern beginning with `!` negates the pattern, that is matching files are *not* ignored. This can be used to override more general patterns. Note that files in ignored directories can not be excluded this way. This is due to the fact that syncthing stops scanning when it reaches an ignored directory, so doesn't know what files it might contain.
* A line beginning with `//` is a comment and has no effect.
## Example
Given a directory layout:
```
foo
foofoo
bar/
baz
quux
quuz
bar2/
baz
frobble
```
and an `.stignore` file with the contents:
```xml
!frobble
!quuz
foo
*2
qu*
```
all files and directories called "foo", ending in a "2" or starting with "qu" will be ignored. The end result becomes
```xml
foo # ignored, matches "foo"
foofoo # synced, does not match "foo" but would match "foo*" or "*foo"
bar/ # synced
baz # synced
quux # ignored, matches "qu*"
quuz # synced, matches "qu*" but is excluded by the preceding "!quuz"
bar2/ # ignored, matched "*2"
baz # ignored, due to parent being ignored
frobble # ignored, due to parent being ignored; "!frobble" doesn't help
```
## Effects on "In Sync" Status
Currently the effects on who is in sync with what can be a bit confusing when using ignore patterns. This should be cleared up in a future version...
Assume two nodes, Alice and Bob, where Alice has 100 files to share, but Bob ignores 25 of these. From Alice's point of view Bob will become about 75% in sync (the actual number depends on the sizes of the individual files) and remain in "Syncing" state even though it is in fact not syncing anything (issue [#623](https://github.com/syncthing/syncthing/issues/623)). From Bob's point of view it's 100% up to date but will show fewer files in both the local and global view.
If Bob adds files that have already been synced to the ignore list, they will remain in the "global" view but disappear from the "local" view. The end result is more files in the global repository than in the local, but still 100% in sync (issue [#624](https://github.com/syncthing/syncthing/issues/624)). From Alice's point of view, Bob will remain 100% in sync until the next reconnect, because Bob has already announce that he has the files that are now suddenly ignored.
+254
@@ -0,0 +1,254 @@
Syncthing exposes a REST interface over HTTP on the GUI port. This is used by the GUI code (Javascript) and can be used by other processes wishing to control syncthing. In most cases both the input and output data is in JSON format. The interface is subject to change.
## API Key
To use the POST methods, or any method when authentication is enabled, an API key must be set and used. The API key can be generated in the GUI, or set in the `configuration/gui/apikey` element in the configuration file. To use an API key, set the request header `X-API-Key` to the API key value.
## GET /rest/ping
Returns a `{"ping": "pong"}` object.
## GET /rest/version
Restuns the current syncthing version information.
```bash
$ curl -s http://localhost:8080/rest/version | json
{
"arch": "amd64",
"longVersion": "syncthing v0.9.17+2-gd7956dd-dirty (go1.3.1 darwin-amd64 default) [email protected] 2014-09-18 10:52:45 UTC",
"os": "darwin",
"version": "v0.9.17+2-gd7956dd-dirty"
}
```
## GET /rest/model
Returns information about the current status of a folder.
Parameters: `folder`, the ID of a folder.
```bash
$ curl -s http://localhost:8080/rest/model?folder=lightroom | jsonpp
{
# latest version according to cluster:
"globalBytes": 5429128994,
"globalDeleted": 452,
"globalFiles": 23547,
# what we have locally:
"localBytes": 5428313970,
"localDeleted": 452,
"localFiles": 23536,
# which part of what we have locally is the latest cluster verision:
"inSyncBytes": 5428313970,
"inSyncFiles": 13280,
# which part of what we have locally should be fetched from the cluster:
"needBytes": 815024,
"needFiles": 10267,
"state": "idle" # idle, scanning, cleaning or syncing
"invalid": "", # non-empty if the folder is stopped due to being invalid
}
```
## GET /rest/connections
Returns the list of current connections and some metadata associated with the connection/peer.
```
$ curl -s http://localhost:8080/rest/connections | jsonpp
{
"LGFPDIT7SKNNJVJZA4FC7QNCRKCE753K72BW5QD2FOZ7FRFEP57Q": {
"At": "2014-05-12T22:15:29.554958764-03:00",
"InBytesTotal": 3064376,
"OutBytesTotal": 2661387,
"Address": "192.162.129.11:22000",
"ClientVersion": "v0.8.5"
}
}
```
## GET /rest/completion
Returns the completion percentage (0 to 100) for a given device and folder. Takes `device` and `folder` parameters.
```
$ curl -s 'http://localhost:8080/rest/completion?device=ZJCXQL7-M3NP4IC-4KQ7WFU-3NANYUX-AD74QRL-Q5LJ7BH-72KYZHK-GHTAOAK&folder=lightroom' | json
{
"completion": 0
}
```
## GET /rest/config
Returns the current configuration.
```bash
$ curl -s http://localhost:8080/rest/config | jsonpp
{
# etc
}
```
## GET /rest/config/sync
Returns whether the config is in sync, i.e. whether the running configuration is the same as that on disk.
```bash
$ curl -s http://localhost:8080/rest/config/sync
{"configInSync":true}
```
## GET /rest/system
Returns information about current system status and resource usage.
```bash
$ curl -s http://localhost:8080/rest/system | jsonpp
{
"alloc": 32147752, # allocated memory, in use
"cpuPercent": 0.669829340548344,
"extAnnounceOK": true, # true if we are registered with the global announce server, false on failure, absent if disabled
"goroutines": 34,
"myID": "P56IOI7MZJNU2IQGDREYDM2MGTMGL3BXNPQ6W5BTBBZ4TJXZWICQ",
"sys": 66463976 # allocated memory, total
}
```
## GET /rest/errors
Returns the list of recent errors.
```bash
$ curl -s http://localhost:8080/rest/errors | json
{
"errors": [
{
"Time": "2014-09-18T12:59:26.549953186+02:00",
"Error": "This is an error string"
}
]
}
```
## GET /rest/discovery
Returns the contents of the local discovery cache.
```bash
$ curl -s http://localhost:8080/rest/discovery | jsonpp
{
"LGFPDIT7SKNNJVJZA4FC7QNCRKCE753K72BW5QD2FOZ7FRFEP57Q": [
"192.162.129.11:22000"
]
}
```
## GET /rest/deviceid
Verifies and formats a device ID. Accepts all currently valid formats (52 or 56 characters with or without separators, upper or lower case, with trivial substitutions). Takes one parameter, `id`, and returns either a valid device ID in modern format, or an error.
```bash
$ curl -s http://localhost:8080/rest/deviceid?id=1234 | json
{
"error": "device ID invalid: incorrect length"
}
$ curl -s http://localhost:8080/rest/deviceid?id=p56ioi7m--zjnu2iq-gdr-eydm-2mgtmgl3bxnpq6w5btbbz4tjxzwicq | json
{
"id": "P56IOI7-MZJNU2Y-IQGDREY-DM2MGTI-MGL3BXN-PQ6W5BM-TBBZ4TJ-XZWICQ2"
}
```
## GET /rest/upgrade
Checks for a possible upgrade and returns an object describing the newest version and upgrade possibility.
```json
$ curl -s http://localhost:8080/rest/upgrade | json
{
"latest": "v0.9.17",
"newer": false, # whether the latest released version is newer than the currently running
"running": "v0.9.17+5-gb1a31d3"
}
```
## GET /rest/ignores
Takes one parameter, `folder`, and returns the content of the `.stignore` as the `ignore` field. A second field, `patterns`, provides a compiled version of all included ignore patterns in the form of regular expressions. Excluded items in the `patterns` field have a nonstandard `(?exclude)` marker in front of the regular expression.
```json
$ curl -s http://localhost:8080/rest/ignores?folder=default | json_pp
{
"ignore" : [
"Thumbs.db",
"#include anotherfile",
"",
"// Comment",
"somefile"
],
"patterns": [
"(?i)^\\.DS_Store$",
"(?i)^.*/\\.DS_Store$",
"(?i)^Thumbs\\.db$",
"(?i)^.*/Thumbs\\.db$",
"(?exclude)(?i)^importantFile$",
"(?exclude)(?i)^.*/importantFile$"
]
}
```
## POST /rest/ping
Returns a `{"ping": "pong"}` object.
## POST /rest/config
Post the full contents of the configuration, in the same format as returned by the corresponding GET request. The configuration will be saved to disk and the configInSync flag set to false. Restart syncthing to activate.
## POST /rest/restart
Post with empty body to immediately restart syncthing.
## POST /rest/reset
Post with empty body to immediately *reset* syncthing. This means renaming all folder directories to temporary, unique names, wiping all indexes and restarting. This should probably not be used during normal operations...
## POST /rest/shutdown
Post with empty body to cause syncthing to exit and not restart.
## POST /rest/error
Post with an error message in the body (plain text) to register a new error. The new error will be displayed on any active GUI clients.
## POST /rest/error/clear
Post with empty to body to remove all recent errors.
## POST /rest/discovery/hint
Post with the query parameters `device` and `addr` to add entries to the discovery cache.
```bash
curl -X POST http://127.0.0.1:8080/rest/discovery/hint?device=LGFPDIT7SKNNJVJZA4FC7QNCRKCE753K72BW5QD2FOZ7FRFEP57Q\&addr=192.162.129.11:22000
```
## POST /rest/scan
Request immediate rescan of a folder, or a specific path within a folder. Takes the mandatory parameter `folder` (folder ID) and the optional parameter `sub` (path relative to the folder root). If `sub` is omitted or empty, the entire folder is scanned for changes, otherwise only the given path (and children, in case it's a directory) is scanned.
Requesting scan of a path that no longer exists, but previously did, is valid and will result in syncthing noticing the deletion of the path in question.
Returns status 200 and no content upon success, or status 500 and a plain text error if an error occurred during scanning.
```bash
curl -X POST http://127.0.0.1:8080/rest/scan?folder=default&sub=foo/bar
```
## POST /rest/upgrade
Perform an upgrade to the newest released version and restart. Does nothing if there is no newer version than currently running.
## POST /rest/ignores
Expects a format similar to the output of `GET` call, but only containing the `ignore` field (`patterns` field should be omitted). It takes one parameter, `folder`, and either updates the content of the `.stignore` echoing it back as a response, or returns an error.
+3 -11
@@ -1,13 +1,5 @@
Security is one of the primary project goals. This means that it should
not be possible for an attacker to join a cluster uninvited, and it
should not be possible to extract private information from intercepted
traffic. Currently this is implemented as follows.
Security is one of the primary project goals. This means that it should not be possible for an attacker to join a cluster uninvited, and it should not be possible to extract private information from intercepted traffic. Currently this is implemented as follows.
All traffic is protected by TLS. To prevent uninvited nodes from joining
a cluster, the certificate fingerprint of each node is compared to a
preset list of acceptable nodes at connection establishment. The
fingerprint is computed as the SHA-256 hash of the certificate and
displayed in BASE32 encoding to form a reasonably compact and convenient string.
All traffic is protected by TLS. To prevent uninvited nodes from joining a cluster, the certificate fingerprint of each node is compared to a preset list of acceptable nodes at connection establishment. The fingerprint is computed as the SHA-256 hash of the certificate and displayed in BASE32 encoding to form a reasonably compact and convenient string.
Incoming requests for file data are verified to the extent that the
requested file name must exist in the local index and the global model.
Incoming requests for file data are verified to the extent that the requested file name must exist in the local index and the global model.
+1
@@ -0,0 +1 @@
[[Getting Started]] | [Discussion Forum](https://discourse.syncthing.net/)
BIN
Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

BIN
Binary file not shown.

Before

Width:  |  Height:  |  Size: 63 KiB

+47
@@ -0,0 +1,47 @@
There's a lot that happens behind the covers, and syncthing is generally quite silent about it. A number of environment variables can be used to set the logging to verbose for various parts of the program, and to enable profiling.
## STTRACE
The environment variable `STTRACE` can be set to a comma separated list of "facilities", to enable extra debugging information for said facility. A facility generally maps to a Go package, although there are a few extra that map to parts of the `main` package. Currently, the following facilities are supported (an up to date list is always printed by `syncthing --help`):
```
- "beacon" (the beacon package)
- "discover" (the discover package)
- "files" (the files package)
- "net" (the main package; connections & network messages)
- "model" (the model package)
- "scanner" (the scanner package)
- "upnp" (the upnp package)
- "xdr" (the xdr package)
- "all" (all of the above)
```
The debug output is often of the kind that it doesn't make much sense without looking at the code. The purpose of the different packages / facilities are something like this:
* beacon sends and receives UDP broadcasts used by the local discovery system. Debugging here will show which interfaces and addresses are selected for broadcasts, etc.
* discover sends and received local discovery packets. Debugging here will output the parsed packets, nodes that get registered etc.
* files keeps track of lists of files with metadata and figures out which is the newest version of each.
* net shows connection attempts, incoming connections, and the low level error when connection attempts fail.
* model is the largest chunk of the system; this is where pulling of out of date files happen, indexes sent and received, and incoming requests for file chunks are logged.
* scanner is the local filesystem scanner. Debugging here will output information about changed and unchanged files.
* upnp is the upnp talker.
* xdr is the low level protocol encoder. Debugging here will output all bytes sent/received over the sync connection. Very verbose.
* all simply enabled debugging of all facilities.
Enabling any of the facilities will also change the log format to include microsecond timestamps and file names plus line numbers. This can be used to enable this extra information on the normal logging level, without enabling any debugging: `STTRACE=somethingnonexistent` for example.
Under Unix (including Mac) the easiest way to run syncthing with an environment variable set is to prepend the variable to the command line. I.e:
`$ STTRACE=model syncthing`
On windows, it needs to be set prior to running syncthing.
```
C:\> set STTRACE=model
C:\> syncthing
```
## STPROFILER
The `STPROFILER` environment variable sets the listen address for the HTTP profiler. If set to for example `:9090` the profiler will start and listen on port 9090. http://localhost:9090/debug/pprof is then the address to the profiler. Se `go tool pprof` for more information.
+130
@@ -0,0 +1,130 @@
Every node is identified by a node ID. The node ID is used for address resolution, authentication and authorization. The term "node ID" could interchangably have been "key ID" since the node ID is a direct properties of the public key in use.
# Keys
To understand node IDs we need to look at the underlying mechanisms. At first startup, syncthing will create an public/private key pair.
Currently this is a 3072 bit RSA key. The keys are saved in the form of the private key (`key.pem`) and a self signed certificate (`cert.pem`). The self signing part doesn't actually add any security or functionality as far as syncthing is concerned but it enables the use of the keys in a standard TLS exchange.
The typical certificate will look something like this, inspected with `openssl x509`:
```
Certificate:
Data:
Version: 3 (0x2)
Serial Number: 0 (0x0)
Signature Algorithm: sha1WithRSAEncryption
Issuer: CN=syncthing
Validity
Not Before: Mar 30 21:10:52 2014 GMT
Not After : Dec 31 23:59:59 2049 GMT
Subject: CN=syncthing
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
RSA Public Key: (3072 bit)
Modulus (3072 bit):
00:da:83:8a:c0:95:af:0a:42:af:43:74:65:29:f2:
30:e3:b9:12:d2:6b:70:93:da:0b:7b:8a:1e:e5:79:
...
99:09:4c:a9:7b:ba:4a:6a:8b:3b:e6:e7:c7:2c:00:
90:aa:bc:ad:94:e7:80:95:d2:1b
Exponent: 65537 (0x10001)
X509v3 extensions:
X509v3 Key Usage: critical
Digital Signature, Key Encipherment
X509v3 Extended Key Usage:
TLS Web Server Authentication, TLS Web Client Authentication
X509v3 Basic Constraints: critical
CA:FALSE
Signature Algorithm: sha1WithRSAEncryption
68:72:43:8b:83:61:09:68:f0:ef:f0:43:b7:30:a6:73:1e:a8:
d9:24:6c:2d:b4:bc:c9:e8:3e:0b:1e:3c:cc:7a:b2:c8:f1:1d:
...
88:7e:e2:61:aa:4c:02:e3:64:b0:da:70:3a:cd:1c:3d:86:db:
df:54:b9:4e:be:1b
```
We can see here that the certificate is little more than a container for the public key; the serial number is zero and the Issuer and Subject are both "syncthing" where a qualified name might otherwise be expected.
An advanced user could replace the `key.pem` and `cert.pem` files with a keypair generated directly by the `openssl` utility or other mechanism.
# Node IDs
To form a node ID the SHA-256 hash of the certificate data in DER form is calculated. This means the hash covers all information under the `Certificate:` section above.
The hashing results in a 256 bit hash, which we encode using base32. Base32 encodes five bits per character, so we need 256 / 5 = 51.2 characters to encode the node ID. This becomes 52 characters in practice, but 52 characters of base32 would decode to 260 bits which is not an whole number of bytes. The base32 encoding adds padding to 280 bits (the next multiple of both 5 and 8 bits) so the resulting ID looks something like
`MFZWI3DBONSGYYLTMRWGC43ENRQXGZDMMFZWI3DBONSGYYLTMRWA====`.
The padding (`====`) is stripped away, the node ID split in four groups, and [check digits](https://discourse.syncthing.net/t/v0-9-0-new-node-id-format/478) are added for each group. For presentation purposes the node ID is grouped with dashes, resulting in the final value: `MFZWI3D-BONSGYC-YLTMRWG-C43ENR5-QXGZDMM-FZWI3DP-BONSGYY-LTMRWAD`.
# Connection Establishment
So now we know what node IDs are, here's how they are used in syncthing. When you add a node ID to the syncthing configuration, syncthing will attempt to connect to that node. The first thing we need to do is figure out the IP and port to connect to. There's three possibilities here;
* The IP and port can be set statically in the configuration. The IP can equally well be a hostname, so if you have a static IP or a dynamic DNS setup this might be a good option.
* Using local discovery, if enabled. Every syncthing instance on a LAN periodically broadcasts information about itself (node ID, address, port number). If we've seen one of these broadcasts for a given node ID that's where we try to connect.
* Using global discovery, if enabled. Every syncthing instance announces itself to the global discovery service (node ID and external port number - the internal address is not announced to the global server). If we don't have a static address and haven't seen any local announcements the global discovery server will be queried for an address.
Once we have and address and port a TCP connection is established and a TLS handshake performed. As part of the handshake both nodes present their certificates. Once the handshake has completed and the peer certificiate is known, the following steps are performed.
1. Calculate the remote node ID by using the process above on the received certificate.
2. Weed out a few possible misconfigurations - i.e. if the node ID is that of the local node or of a node we already have an active connection to. Drop the connection in these cases.
3. Verify the remote node ID against the configuration. If it is not a node ID we are expecting to talk to, drop the connection.
4. Verify the certificate `CommonName` against the configuration. By default, we expect it to be `syncthing`, but when using custom certificates this can be changed.
5. If everything checks out so far, accept the connection.
## An Aside About Collisions
The SHA-256 hash is cryptographically collision resistant. This means that there is no way that we know of to create two different messages with the same hash.
You can argue that of course there are collisions - there's an infinite amount of inputs and a finite amount of outputs, so per definition there are infinitely many messages that result in the same hash.
I'm going to quote [stack overflow](http://stackoverflow.com/questions/4014090/is-it-safe-to-ignore-the-possibility-of-sha-collisions-in-practice) here:
> The usual answer goes thus: what is the probability that a rogue asteroid crashes on Earth within the next second, obliterating civilization-as-we-know-it, and killing off a few billion people ? It can be argued that any unlucky event with a probability lower than that is not actually very important.
> If we have a "perfect" hash function with output size n, and we have p messages to hash (individual message length is not important), then probability of collision is about p2/2n+1 (this is an approximation which is valid for "small" p, i.e. substantially smaller than 2n/2). For instance, with SHA-256 (n=256) and one billion messages (p=10^9) then the probability is about 4.3*10^-60.
> A mass-murderer space rock happens about once every 30 million years on average. This leads to a probability of such an event occurring in the next second to about 10^-15. That's 45 orders of magnitude more probable than the SHA-256 collision. Briefly stated, if you find SHA-256 collisions scary then your priorities are wrong.
It's also worth noting that the property of SHA-256 that we are using is not simply collision resistance but resistance to a preimage attack. I.e. even if you can find two messages that result in a hash collision that doesn't help you attack syncthing (or TLS in general). You need to create a message that hashes to exactly the hash that my certificate already has or you won't get in.
Note also that it's not good enough to find a random blob of bits that happen to have the same hash as my certificate. You need to create a valid DER-encoded, signed certificate that has the same hash as mine. The difficulty of this is staggeringly far beyond the already staggering difficulty of finding a SHA-256 collision.
# Problems and Vulnerabilities
As far as I know, these are the issues or potential issues with the above mechanism.
## Discovery Spoofing
Currently, neither the local nor global discovery mechanism is protected by crypto. This means that any node can in theory announce itself for any node ID and potentially receive connections for that node.
This could be a denial of service attack (we can't find the real node for a given node ID, so can't connect to it and sync). It could also be an intelligence gathering attack; if I spoof a given ID, I can see which nodes try to connect to it.
It could be mitigated in several ways;
* Announcements could be signed by the node private key. This requires already having the public key to verify.
* Announcements to the global announce server could be done using TLS, so the server calculates the node ID based on the certificate instead of trusting to the node to tell the truth.
* The user could statically configure IP or hostname for the nodes.
* The user could run a trusted global server.
It's something we might want to look at at some point, but not a huge problem as I see it.
## Long Node IDs are Painful
It's a mouthful to read over the phone, annoying to type into an SMS or even into a computer. And it needs to be done twice, once for each side.
This isn't a vulnerability as such, but a user experience problem. There are various possible solutions;
* Use shorter node IDs with verification based on the full ID ("You entered MFZWI3; I found and connected to a node with the ID MFZWI3-DBONSG-YYLTMR-WGC43E-NRQXGZ-DMMFZW-I3DBON-SGYYLT-MRWA, please confirm that this is correct.").
* Use shorter node IDs with an out of band authentication, a la Bluetooth pairing. You enter a one time PIN into syncthing and give that PIN plus a short node ID to another user. On initial connect, both sides verify that the other knows the correct PIN before accepting the connection.
+324
@@ -0,0 +1,324 @@
Syncthing, in v0.9 and higher, provides a simple long polling interface for exposing events from the core utility towards a GUI.
To receive events, perform a HTTP GET of `/rest/events?since=<lastSeenID>`, where `<lastSeenID>` is the ID of the last event you've already seen or zero. Syncthing returns a JSON encoded array of event objects, starting at the event just after the one with the last seen ID. There is a limit to the number of events buffered, so if the rate of events is high or the time between polling calls is long some events might be missed. This can be detected by noting a discontinuity in the event IDs.
To receive only a limited number of events, add the `limit=n` parameter with a suitable value for `n` and only the *last* `n` events will be returned. This can be used to catch up with the latest event ID after a disconnection for example: `/rest/events?since=0&limit=1`.
# Event Structure
Each event is represented by an object similar to the following:
```json
{
"id": 2,
"type": "DeviceConnected",
"time": "2014-07-13T21:04:33.687836696+02:00",
"data": {
"addr": "172.16.32.25:22000",
"id": "NFGKEKE-7Z6RTH7-I3PRZXS-DEJF3UJ-FRWJBFO-VBBTDND-4SGNGVZ-QUQHJAG"
}
}
```
The top level keys `id`, `time`, `type` and `data` are always present, though `data` may be `null`.
* `id` is a monotonically increasing integer. The first event generated has id `1`, the next has id `2` etc.
* `time` is the time the event was generated.
* `type` indicates the type of (i.e. reason for) the event and is one of the event types below.
* `data` is an object containing optional extra information; the exact structure is determined by the event type.
# Event Types
## Starting
Emitted exactly once, when syncthing starts, before parsing configuration etc.
```json
{
"id": 1,
"type": "Starting",
"time": "2014-07-17T13:13:32.044470055+02:00",
"data": {
"home": "/home/jb/.config/syncthing"
}
}
```
## StartupComplete
Emitted exactly once, when initialization is complete and syncthing is ready to start exchanging data with other devices.
```json
{
"id": 1,
"type": "StartupComplete",
"time": "2014-07-13T21:03:18.383239179+02:00",
"data": null
}
```
## Ping
The Ping event is generated automatically every five minutes. This means that even in the absence of any other activity, the event polling HTTP request will return within five minutes.
```json
{
"id": 46,
"type": "Ping",
"time": "2014-07-13T21:13:18.502171586+02:00",
"data": null
}
```
## DeviceDiscovered
Emitted when a new device is discovered using local discovery.
```json
{
"id": 13,
"type": "DeviceDiscovered",
"time": "2014-07-17T13:28:05.043465207+02:00",
"data": {
"addrs": [
"172.16.32.25:22000"
],
"device": "NFGKEKE-7Z6RTH7-I3PRZXS-DEJF3UJ-FRWJBFO-VBBTDND-4SGNGVZ-QUQHJAG"
}
}
```
## DeviceConnected
Generated each time a connection to a device has been established.
```json
{
"id": 2,
"type": "DeviceConnected",
"time": "2014-07-13T21:04:33.687836696+02:00",
"data": {
"addr": "172.16.32.25:22000",
"id": "NFGKEKE-7Z6RTH7-I3PRZXS-DEJF3UJ-FRWJBFO-VBBTDND-4SGNGVZ-QUQHJAG"
}
}
```
## DeviceDisconnected
Generated each time a connection to a device has been terminated.
```json
{
"id": 48,
"type": "DeviceDisconnected",
"time": "2014-07-13T21:18:52.859929215+02:00",
"data": {
"error": "unexpected EOF",
"id": "NFGKEKE-7Z6RTH7-I3PRZXS-DEJF3UJ-FRWJBFO-VBBTDND-4SGNGVZ-QUQHJAG"
}
}
```
> :exclamation: The `error` key contains the cause for disconnection, which might not necessarily be an *error* as such. Specifically, "EOF" and "unexpected EOF" both signify TCP connection termination, either due to the other device restarting or going offline or due to a network change.
## RemoteIndexUpdated
Generated each time new index information is received from a device.
```json
{
"id": 44,
"type": "RemoteIndexUpdated",
"time": "2014-07-13T21:04:35.394184435+02:00",
"data": {
"device": "NFGKEKE-7Z6RTH7-I3PRZXS-DEJF3UJ-FRWJBFO-VBBTDND-4SGNGVZ-QUQHJAG",
"folder": "lightroom",
"items": 1000
}
}
```
> :exclamation: This event is intentionally light on the details about what changed in the index update, i.e. does not include the new global size or device completion percentage. These statistics are currently somewhat expensive to compute so it's better if an interested client asks for them when seeing this event, after proper debouncing.
## LocalIndexUpdated
Generated when the local index information has changed, due to synchronizing an item from the cluster.
```json
{
"id": 59,
"type": "LocalIndexUpdated",
"time": "2014-07-17T13:27:28.051369434+02:00",
"data": {
"flags": "0644",
"modified": "2014-07-17T13:26:55+02:00",
"name": "test.txt",
"folder": "lightroom",
"size": 4
}
}
```
> :exclamation: This event is intentionally light on the details about what changed in the index update, i.e. does not include the new global size or device completion percentage. These statistics are currently somewhat expensive to compute so it's better if an interested client asks for them when seeing this event, after proper debouncing.
## ItemStarted
Generated when syncthing begins synchronizing a file to a newer version.
```json
{
"id": 93,
"type": "ItemStarted",
"time": "2014-07-13T21:22:03.414609034+02:00",
"data": {
"item": "test.txt",
"folder": "default"
}
}
```
> :exclamation: There is currently no event for completion of an item. LocalIndexUpdated will be emitted on success, however.
## StateChanged
Emitted when a folder changes state. Possible states are `idle`, `scanning`, `cleaning` and `syncing`. The field `duration` is the number of seconds the folder spent in state `from`. In the example below, the folder `default` was in state `scanning` for 0.198 seconds and is now in state `idle`.
```json
{
"id": 8,
"type": "StateChanged",
"time": "2014-07-17T13:14:28.697493016+02:00",
"data": {
"folder": "default",
"from": "scanning",
"duration": 0.19782869900000002,
"to": "idle"
}
}
```
## FolderRejected
Emitted when a device sends index information for a folder we do not have, or have but do not share with the device in question.
```json
{
"id": 27,
"type": "FolderRejected",
"time": "2014-08-19T10:41:06.761751399+02:00",
"data": {
"device": "EJHMPAQ-OGCVORE-ISB4IS3-SYYVJXF-TKJGLTU-66DIQPF-GJ5D2GX-GQ3OWQK",
"folder": "unique"
}
}
```
## DeviceRejected
Emitted when there is a connection from a device we are not configured to talk to.
```json
{
"id": 24,
"type": "DeviceRejected",
"time": "2014-08-19T10:43:00.562821045+02:00",
"data": {
"address": "127.0.0.1:51807",
"device": "EJHMPAQ-OGCVORE-ISB4IS3-SYYVJXF-TKJGLTU-66DIQPF-GJ5D2GX-GQ3OWQK"
}
}
```
## ConfigSaved
Emitted after the config has been saved by the user or by Syncthing itself.
```json
{
"id": 50,
"type": "ConfigSaved",
"time": "2014-12-13T00:09:13.5166486Z",
"data":{
"Version": 7,
"Options": { ... },
"GUI": { ... },
"Devices": [ ... ],
"Folders": [ ... ]
}
}
```
## DownloadProgress
Emitted during file downloads for each folder for each file.
By default only a single file in a folder is handled at the same time, but custom configuration can cause multiple files to be shown.
```json
{
"id": 221
"type": "DownloadProgress",
"time": "2014-12-13T00:26:12.9876937Z",
"data": {
"folder1": {
"file1": {
"Total": 800,
"Pulling": 2,
"CopiedFromOrigin": 0,
"Reused": 633,
"CopiedFromElsewhere": 0,
"Pulled": 38,
"BytesTotal": 104792064,
"BytesDone": 87883776
},
"dir\\file2": {
"Total": 80,
"Pulling": 2,
"CopiedFromOrigin": 0,
"Reused": 0,
"CopiedFromElsewhere": 0,
"Pulled": 32,
"BytesTotal": 10420224,
"BytesDone": 4128768
}
},
"folder2": {
"file3": {
"Total": 800,
"Pulling": 2,
"CopiedFromOrigin": 0,
"Reused": 633,
"CopiedFromElsewhere": 0,
"Pulled": 38,
"BytesTotal": 104792064,
"BytesDone": 87883776
},
"dir\\file4": {
"Total": 80,
"Pulling": 2,
"CopiedFromOrigin": 0,
"Reused": 0,
"CopiedFromElsewhere": 0,
"Pulled": 32,
"BytesTotal": 10420224,
"BytesDone": 4128768
}
}
}
}
```
* `Total` - total number of blocks in the file
* `Pulling` - number of blocks currently being downloaded
* `CopiedFromOrigin` - number of blocks copied from the file we are about to replace
* `Reused` - number of blocks reused from a previous temporary file
* `CopiedFromElsewhere` - number of blocks copied from other files or potentially other folders
* `Pulled` - number of blocks actually downloaded so far
* `BytesTotal` - approximate total file size
* `BytesDone` - approximate number of bytes already handled (already reused, copied or pulled)
Where block size is 128KB.
Files/folders appearing in the event data imply that the download has been started for that file/folder,
where disappearing implies that the downloads has been finished or failed for that file/folder.
There is always a last event emitted with no data, which implies all downloads being finished/failed.
+1 -1
@@ -4,7 +4,7 @@ Syncthing follows the [Semantic Versioning](http://semver.org/) scheme of versio
A new *major* version is released when there are incompatible API or protocol changes, a new *minor* version is released when there are new features but compatibility with older releases is retained, and a new *patch* version is released when there are bug fixes (compatibility with older releases always retained).
While still in pre-release mode, i.e. versions 0.*x*, breaking changes are made in minor releases rather than major. Version 0.7.3 should be able to talk to version 0.7.52, but will probably not understand version 0.8.0. This also means that if you don't like 0.7.52, you can safely downgrade to 0.7.3 again and keep your configuration, index caches, etc. However 0.8.0 might have a different format for those things so a downgrade to 0.7.x might be trickier.
While still in pre-release mode, i.e. versions 0.*x*, breaking changes are made in minor releases rather than major. Version 0.7.3 should be able to talk to version 0.7.52, but will probably not understand version 0.8.0. This also means that if you don't like 0.7.52, you can safely downgrade to 0.7.3 again and keep your configuration, index caches, etc. However 0.8.0 might have a different format for those things so a downgrade to 0.7.x might be trickier.
# Patch Releases
BIN
Binary file not shown.

After

Width:  |  Height:  |  Size: 273 KiB

BIN
Binary file not shown.

After

Width:  |  Height:  |  Size: 352 KiB

BIN
Binary file not shown.

After

Width:  |  Height:  |  Size: 329 KiB

BIN
Binary file not shown.

After

Width:  |  Height:  |  Size: 297 KiB

BIN
Binary file not shown.

After

Width:  |  Height:  |  Size: 350 KiB

BIN
Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB