├── .codecov.yml ├── .gitattributes ├── .github ├── CODEOWNERS ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── 01-feature.md │ ├── 02-bug.md │ └── config.yml ├── PULL_REQUEST_TEMPLATE.md └── SECURITY.md ├── .gitignore ├── .golangci.yml ├── AUTHORS ├── CONDUCT.md ├── CONTRIBUTING.md ├── Dockerfile ├── Dockerfile.builder ├── Dockerfile.buildx ├── Dockerfile.stdiscosrv ├── Dockerfile.strelaysrv ├── GOALS.md ├── LICENSE ├── README-Docker.md ├── README.md ├── assets ├── logo-128.png ├── logo-256.png ├── logo-32.png ├── logo-512.png ├── logo-64.png ├── logo-horizontal.svg ├── logo-only.svg ├── logo-text-128.png ├── logo-text-256.png ├── logo-text-64.png ├── logo-vertical.svg ├── logo-wtext.png ├── logo.ai ├── logo.ico ├── logo.pdf ├── statusicons │ ├── default.svg │ ├── notify.svg │ ├── pause.svg │ └── sync.svg └── syncthing_folder_icon.icns ├── build.go ├── build.ps1 ├── build.sh ├── cmd ├── .gitignore ├── stcli │ ├── client.go │ ├── errors.go │ ├── main.go │ ├── operations.go │ ├── show.go │ └── utils.go ├── stcompdirs │ └── main.go ├── stcrashreceiver │ ├── _testdata │ │ └── panic.log │ ├── main.go │ ├── sentry.go │ ├── sentry_test.go │ ├── sourcecodeloader.go │ └── stcrashreceiver.go ├── stdisco │ └── main.go ├── stdiscosrv │ ├── README.md │ ├── apisrv.go │ ├── apisrv_test.go │ ├── database.go │ ├── database.pb.go │ ├── database.proto │ ├── database_test.go │ ├── etc │ │ ├── firewall-ufw │ │ │ └── stdiscosrv │ │ └── linux-systemd │ │ │ ├── default │ │ │ └── stdiscosrv.service │ ├── main.go │ ├── replication.go │ ├── scripts │ │ └── preinst │ └── stats.go ├── stevents │ └── main.go ├── stfileinfo │ └── main.go ├── stfinddevice │ └── main.go ├── stfindignored │ └── main.go ├── stgenfiles │ └── main.go ├── stindex │ ├── accounting.go │ ├── dump.go │ ├── dumpsize.go │ ├── idxck.go │ ├── main.go │ └── util.go ├── strelaypoolsrv │ ├── LICENSE │ ├── README.md │ ├── auto │ │ ├── .gitignore │ │ └── doc.go │ ├── gui │ │ └── index.html │ ├── main.go │ ├── main_test.go │ ├── stats.go │ └── stats_test.go ├── strelaysrv │ ├── LICENSE │ ├── README.md │ ├── etc │ │ ├── firewall-ufw │ │ │ └── strelaysrv │ │ └── linux-systemd │ │ │ ├── default │ │ │ └── strelaysrv.service │ ├── listener.go │ ├── main.go │ ├── pool.go │ ├── scripts │ │ └── preinst │ ├── session.go │ ├── status.go │ ├── testutil │ │ └── main.go │ └── utils.go ├── stsigtool │ └── main.go ├── stupgrades │ └── main.go ├── stvanity │ └── main.go ├── stwatchfile │ └── main.go ├── syncthing │ ├── .gitignore │ ├── .stfolder │ ├── blockprof.go │ ├── crash_reporting.go │ ├── crash_reporting_test.go │ ├── debug.go │ ├── heapprof.go │ ├── main.go │ ├── monitor.go │ ├── monitor_test.go │ ├── openurl_unix.go │ ├── openurl_windows.go │ ├── perfstats_unix.go │ ├── traceback.go │ └── usage.go ├── uraggregate │ └── main.go └── ursrv │ ├── analytics.go │ ├── compiler_test.go │ ├── formatting.go │ ├── main.go │ ├── migration.go │ └── static │ ├── assets │ └── img │ │ └── favicon.png │ ├── bootstrap │ ├── css │ │ ├── bootstrap-theme.min.css │ │ └── bootstrap.min.css │ └── js │ │ └── bootstrap.min.js │ ├── fonts │ ├── glyphicons-halflings-regular.eot │ ├── glyphicons-halflings-regular.svg │ ├── glyphicons-halflings-regular.ttf │ └── glyphicons-halflings-regular.woff │ └── index.html ├── etc ├── README.md ├── firewall-ufw │ ├── README.md │ └── syncthing ├── freebsd-rc │ ├── README.md │ └── syncthing ├── linux-desktop │ ├── README.md │ ├── syncthing-start.desktop │ └── syncthing-ui.desktop ├── linux-runit │ ├── README.md │ ├── log │ │ └── run │ └── run ├── linux-systemd │ ├── README.md │ ├── system │ │ ├── syncthing-resume.service │ │ └── syncthing@.service │ └── user │ │ └── syncthing.service ├── linux-upstart │ ├── README.md │ ├── system │ │ └── syncthing.conf │ └── user │ │ └── syncthing.conf ├── macos-launchd │ ├── README.md │ └── syncthing.plist └── solaris-smf │ ├── README.md │ └── syncthing.xml ├── go.mod ├── go.sum ├── gui ├── black │ └── assets │ │ └── css │ │ └── theme.css ├── dark │ └── assets │ │ └── css │ │ └── theme.css ├── default │ ├── assets │ │ ├── css │ │ │ ├── dev.css │ │ │ ├── overrides.css │ │ │ └── theme.css │ │ ├── font │ │ │ ├── raleway-500.woff │ │ │ └── raleway.css │ │ ├── img │ │ │ ├── favicon-default.png │ │ │ ├── favicon-notify.png │ │ │ ├── favicon-pause.png │ │ │ ├── favicon-sync.png │ │ │ ├── logo-horizontal.svg │ │ │ └── safari-pinned-tab.svg │ │ └── lang │ │ │ ├── README.txt │ │ │ ├── lang-bg.json │ │ │ ├── lang-ca@valencia.json │ │ │ ├── lang-cs.json │ │ │ ├── lang-da.json │ │ │ ├── lang-de.json │ │ │ ├── lang-el.json │ │ │ ├── lang-en-AU.json │ │ │ ├── lang-en-GB.json │ │ │ ├── lang-en.json │ │ │ ├── lang-eo.json │ │ │ ├── lang-es-ES.json │ │ │ ├── lang-es.json │ │ │ ├── lang-eu.json │ │ │ ├── lang-fi.json │ │ │ ├── lang-fr.json │ │ │ ├── lang-fy.json │ │ │ ├── lang-hu.json │ │ │ ├── lang-it.json │ │ │ ├── lang-ja.json │ │ │ ├── lang-ko-KR.json │ │ │ ├── lang-lt.json │ │ │ ├── lang-nb.json │ │ │ ├── lang-nl-BE.json │ │ │ ├── lang-nl.json │ │ │ ├── lang-pl.json │ │ │ ├── lang-pt-BR.json │ │ │ ├── lang-pt-PT.json │ │ │ ├── lang-ru.json │ │ │ ├── lang-sk.json │ │ │ ├── lang-sv.json │ │ │ ├── lang-tr.json │ │ │ ├── lang-uk.json │ │ │ ├── lang-zh-CN.json │ │ │ ├── lang-zh-TW.json │ │ │ ├── prettyprint.js │ │ │ └── valid-langs.js │ ├── index.html │ ├── modal.html │ ├── syncthing │ │ ├── app.js │ │ ├── core │ │ │ ├── aboutModalView.html │ │ │ ├── alwaysNumberFilter.js │ │ │ ├── basenameFilter.js │ │ │ ├── binaryFilter.js │ │ │ ├── discoveryFailuresModalView.html │ │ │ ├── durationFilter.js │ │ │ ├── eventService.js │ │ │ ├── httpErrorDialogView.html │ │ │ ├── identiconDirective.js │ │ │ ├── languageSelectDirective.js │ │ │ ├── lastErrorComponentFilter.js │ │ │ ├── localeNumberFilter.js │ │ │ ├── localeService.js │ │ │ ├── logViewerModalView.html │ │ │ ├── majorUpgradeModalView.html │ │ │ ├── metricFilter.js │ │ │ ├── modalDirective.js │ │ │ ├── module.js │ │ │ ├── networkErrorDialogView.html │ │ │ ├── notificationDirective.js │ │ │ ├── notifications.html │ │ │ ├── pathIsSubDirDirective.js │ │ │ ├── percentFilter.js │ │ │ ├── popoverDirective.js │ │ │ ├── restartingDialogView.html │ │ │ ├── selectOnClickDirective.js │ │ │ ├── shutdownDialogView.html │ │ │ ├── syncthingController.js │ │ │ ├── tooltipDirective.js │ │ │ ├── uncamelFilter.js │ │ │ ├── uniqueFolderDirective.js │ │ │ ├── upgradeModalView.html │ │ │ ├── upgradingDialogView.html │ │ │ └── validDeviceidDirective.js │ │ ├── development │ │ │ ├── logbar.html │ │ │ └── logbar.js │ │ ├── device │ │ │ ├── editDeviceModalView.html │ │ │ ├── globalChangesModalView.html │ │ │ ├── idqrModalView.html │ │ │ └── removeDeviceDialogView.html │ │ ├── folder │ │ │ ├── editFolderModalView.html │ │ │ ├── removeFolderDialogView.html │ │ │ ├── restoreVersionsConfirmation.html │ │ │ ├── restoreVersionsMassActions.html │ │ │ ├── restoreVersionsModalView.html │ │ │ └── restoreVersionsVersionSelector.html │ │ ├── settings │ │ │ ├── advancedSettingsModalView.html │ │ │ ├── discardChangesConfirmation.html │ │ │ └── settingsModalView.html │ │ ├── transfer │ │ │ ├── failedFilesModalView.html │ │ │ ├── localChangedFilesModalView.html │ │ │ ├── neededFilesModalView.html │ │ │ └── remoteNeededFilesModalView.html │ │ └── usagereport │ │ │ ├── usageReportModalView.html │ │ │ └── usageReportPreviewModalView.html │ └── vendor │ │ ├── angular │ │ ├── README.md │ │ ├── angular-dirPagination.js │ │ ├── angular-dirPagination.js.LICENSE │ │ ├── angular-sanitize.js │ │ ├── angular-sanitize.js.LICENSE │ │ ├── angular-translate-loader-static-files.js │ │ ├── angular-translate-loader-static-files.js.LICENSE │ │ ├── angular-translate.js │ │ ├── angular-translate.js.LICENSE │ │ ├── angular.js │ │ └── angular.js.LICENSE │ │ ├── bootstrap │ │ ├── LICENSE │ │ ├── config.json │ │ ├── css │ │ │ ├── bootstrap-theme.css │ │ │ └── bootstrap.css │ │ └── js │ │ │ └── bootstrap.js │ │ ├── daterangepicker │ │ ├── LICENSE │ │ ├── daterangepicker.css │ │ └── daterangepicker.js │ │ ├── fancytree │ │ ├── LICENSE.txt │ │ ├── css │ │ │ └── ui.fancytree.css │ │ ├── jquery.fancytree-all-deps.js │ │ └── skin-lion │ │ │ ├── icons.gif │ │ │ ├── loading.gif │ │ │ └── vline.gif │ │ ├── fork-awesome │ │ ├── css │ │ │ ├── fork-awesome.css │ │ │ └── v5-compat.css │ │ └── fonts │ │ │ ├── forkawesome-webfont.eot │ │ │ ├── forkawesome-webfont.svg │ │ │ ├── forkawesome-webfont.ttf │ │ │ ├── forkawesome-webfont.woff │ │ │ └── forkawesome-webfont.woff2 │ │ ├── jquery │ │ ├── LICENSE │ │ └── jquery-2.2.2.js │ │ └── moment │ │ ├── LICENSE │ │ └── moment.js └── light │ └── assets │ └── css │ └── theme.css ├── lib ├── api │ ├── .gitignore │ ├── api.go │ ├── api_auth.go │ ├── api_auth_test.go │ ├── api_csrf.go │ ├── api_statics.go │ ├── api_test.go │ ├── auto │ │ ├── .gitignore │ │ ├── auto_test.go │ │ └── doc.go │ ├── confighandler.go │ ├── debug.go │ ├── mocked_config_test.go │ ├── mocked_connections_test.go │ ├── mocked_discovery_test.go │ ├── mocked_events_test.go │ ├── mocked_logger_test.go │ ├── mocked_model_test.go │ ├── support_bundle.go │ └── testdata │ │ ├── .stfolder │ │ ├── config │ │ ├── cert.pem │ │ ├── config.xml │ │ ├── https-cert.pem │ │ ├── https-key.pem │ │ └── key.pem │ │ ├── default │ │ ├── a │ │ ├── b │ │ └── d │ │ ├── foo │ │ └── a │ │ └── testfolder │ │ └── .stfolder ├── assets │ ├── assets.go │ └── assets_test.go ├── beacon │ ├── beacon.go │ ├── broadcast.go │ ├── broadcast_test.go │ ├── debug.go │ ├── doc.go │ └── multicast.go ├── build │ ├── build.go │ ├── build_test.go │ └── tags_race.go ├── config │ ├── authmode.go │ ├── authmode.pb.go │ ├── blockpullorder.go │ ├── blockpullorder.pb.go │ ├── commit_test.go │ ├── config.go │ ├── config.pb.go │ ├── config_test.go │ ├── debug.go │ ├── deviceconfiguration.go │ ├── deviceconfiguration.pb.go │ ├── folderconfiguration.go │ ├── folderconfiguration.pb.go │ ├── foldertype.go │ ├── foldertype.pb.go │ ├── guiconfiguration.go │ ├── guiconfiguration.pb.go │ ├── ldapconfiguration.go │ ├── ldapconfiguration.pb.go │ ├── ldaptransport.go │ ├── ldaptransport.pb.go │ ├── migrations.go │ ├── migrations_test.go │ ├── observed.pb.go │ ├── optionsconfiguration.go │ ├── optionsconfiguration.pb.go │ ├── pullorder.go │ ├── pullorder.pb.go │ ├── size.go │ ├── size.pb.go │ ├── size_test.go │ ├── testdata │ │ ├── deviceaddressesdynamic.xml │ │ ├── deviceaddressesstatic.xml │ │ ├── devicecompression.xml │ │ ├── dupdevices.xml │ │ ├── dupfolders.xml │ │ ├── example.xml │ │ ├── ignoreddevices.xml │ │ ├── ignoredfolders.xml │ │ ├── issue-1262.xml │ │ ├── issue-1750.xml │ │ ├── largeinterval.xml │ │ ├── nolistenaddress.xml │ │ ├── nopath.xml │ │ ├── overridenvalues.xml │ │ ├── pullorder.xml │ │ ├── v22.xml │ │ ├── v5.xml │ │ └── versioningconfig.xml │ ├── tuning.go │ ├── tuning.pb.go │ ├── tuning_test.go │ ├── versioningconfiguration.go │ ├── versioningconfiguration.pb.go │ └── wrapper.go ├── connections │ ├── connections_test.go │ ├── debug.go │ ├── deprecated.go │ ├── lan_test.go │ ├── limiter.go │ ├── limiter_test.go │ ├── quic_dial.go │ ├── quic_listen.go │ ├── quic_misc.go │ ├── registry │ │ ├── registry.go │ │ └── registry_test.go │ ├── relay_dial.go │ ├── relay_listen.go │ ├── service.go │ ├── structs.go │ ├── tcp_dial.go │ ├── tcp_listen.go │ └── util.go ├── db │ ├── .gitignore │ ├── backend │ │ ├── backend.go │ │ ├── backend_test.go │ │ ├── badger_backend.go │ │ ├── badger_test.go │ │ ├── debug.go │ │ ├── leveldb_backend.go │ │ ├── leveldb_open.go │ │ └── leveldb_test.go │ ├── benchmark_test.go │ ├── blockmap.go │ ├── blockmap_test.go │ ├── db_test.go │ ├── debug.go │ ├── keyer.go │ ├── keyer_test.go │ ├── lowlevel.go │ ├── meta.go │ ├── meta_test.go │ ├── namespaced.go │ ├── namespaced_test.go │ ├── schemaupdater.go │ ├── set.go │ ├── set_test.go │ ├── smallindex.go │ ├── smallindex_test.go │ ├── structs.go │ ├── structs.pb.go │ ├── testdata │ │ ├── .gitignore │ │ ├── v0.14.45-update0to3.db.jsons │ │ ├── v0.14.48-ignoredfiles.db.jsons │ │ └── v1.4.0-updateTo10.json │ ├── transactions.go │ └── util_test.go ├── dialer │ ├── control_unix.go │ ├── control_unsupported.go │ ├── control_windows.go │ ├── debug.go │ ├── empty_test.go │ ├── internal.go │ └── public.go ├── discover │ ├── cache.go │ ├── cache_test.go │ ├── debug.go │ ├── discover.go │ ├── doc.go │ ├── global.go │ ├── global_test.go │ ├── local.go │ ├── local.pb.go │ ├── local.proto │ ├── local_test.go │ └── manager.go ├── events │ ├── debug.go │ ├── events.go │ └── events_test.go ├── fs │ ├── basicfs.go │ ├── basicfs_copy_range.go │ ├── basicfs_copy_range_copyfilerange.go │ ├── basicfs_copy_range_duplicateextents.go │ ├── basicfs_copy_range_ioctl.go │ ├── basicfs_copy_range_sendfile.go │ ├── basicfs_fileinfo_unix.go │ ├── basicfs_fileinfo_windows.go │ ├── basicfs_lstat_broken.go │ ├── basicfs_lstat_regular.go │ ├── basicfs_lstat_windows.go │ ├── basicfs_test.go │ ├── basicfs_unix.go │ ├── basicfs_watch.go │ ├── basicfs_watch_errors_linux.go │ ├── basicfs_watch_errors_others.go │ ├── basicfs_watch_eventtypes_fen.go │ ├── basicfs_watch_eventtypes_inotify.go │ ├── basicfs_watch_eventtypes_kqueue.go │ ├── basicfs_watch_eventtypes_other.go │ ├── basicfs_watch_eventtypes_readdcw.go │ ├── basicfs_watch_test.go │ ├── basicfs_watch_unsupported.go │ ├── basicfs_windows.go │ ├── basicfs_windows_test.go │ ├── casefs.go │ ├── casefs_test.go │ ├── copyrangemethod.go │ ├── copyrangemethod.pb.go │ ├── debug.go │ ├── debug_symlink_unix.go │ ├── debug_symlink_windows.go │ ├── errorfs.go │ ├── fakefs.go │ ├── fakefs_test.go │ ├── filesystem.go │ ├── filesystem_copy_range.go │ ├── filesystem_copy_range_allwithfallback.go │ ├── filesystem_copy_range_standard.go │ ├── filesystem_copy_range_test.go │ ├── filesystem_test.go │ ├── folding.go │ ├── folding_test.go │ ├── logfs.go │ ├── mtimefs.go │ ├── mtimefs_test.go │ ├── tempname.go │ ├── tempname_test.go │ ├── types.go │ ├── types.pb.go │ ├── util.go │ ├── util_test.go │ ├── walkfs.go │ └── walkfs_test.go ├── ignore │ ├── cache.go │ ├── cache_test.go │ ├── ignore.go │ ├── ignore_test.go │ └── testdata │ │ ├── .stignore │ │ ├── dir3 │ │ ├── cfile │ │ └── dfile │ │ ├── excludes │ │ └── further-excludes ├── locations │ └── locations.go ├── logger │ ├── LICENSE │ ├── logger.go │ └── logger_test.go ├── model │ ├── blockpullreorderer.go │ ├── blockpullreorderer_test.go │ ├── bytesemaphore.go │ ├── bytesemaphore_test.go │ ├── debug.go │ ├── deviceactivity.go │ ├── deviceactivity_test.go │ ├── devicedownloadstate.go │ ├── devicedownloadstate_test.go │ ├── doc.go │ ├── fakeconns_test.go │ ├── folder.go │ ├── folder_recvonly.go │ ├── folder_recvonly_test.go │ ├── folder_sendonly.go │ ├── folder_sendrecv.go │ ├── folder_sendrecv_test.go │ ├── folder_summary.go │ ├── folder_test.go │ ├── folderstate.go │ ├── indexsender.go │ ├── model.go │ ├── model_test.go │ ├── progressemitter.go │ ├── progressemitter_test.go │ ├── queue.go │ ├── queue_test.go │ ├── requests_test.go │ ├── sentdownloadstate.go │ ├── sharedpullerstate.go │ ├── sharedpullerstate_test.go │ ├── testdata │ │ ├── bar │ │ ├── baz │ │ │ └── quux │ │ ├── empty │ │ ├── foo │ │ └── tmpfile │ ├── testos_test.go │ ├── testutils_test.go │ ├── util.go │ └── utils_test.go ├── nat │ ├── debug.go │ ├── interface.go │ ├── registry.go │ ├── service.go │ ├── structs.go │ └── structs_test.go ├── osutil │ ├── atomic.go │ ├── atomic_test.go │ ├── atomic_unix_test.go │ ├── filenames_darwin.go │ ├── filenames_unix.go │ ├── filenames_windows.go │ ├── hidden_unix.go │ ├── hidden_windows.go │ ├── lan.go │ ├── lowprio_linux.go │ ├── lowprio_unix.go │ ├── lowprio_windows.go │ ├── net.go │ ├── osutil.go │ ├── osutil_test.go │ ├── ping.go │ ├── replacingwriter.go │ ├── replacingwriter_test.go │ ├── rlimit_unix.go │ ├── rlimit_windows.go │ ├── tempfile.go │ ├── traversessymlink.go │ └── traversessymlink_test.go ├── pmp │ ├── debug.go │ ├── empty_test.go │ └── pmp.go ├── protocol │ ├── LICENSE │ ├── benchmark_test.go │ ├── bep.pb.go │ ├── bep_extensions.go │ ├── bufferpool.go │ ├── bufferpool_test.go │ ├── common_test.go │ ├── compression.go │ ├── compression_test.go │ ├── conflict_test.go │ ├── counting.go │ ├── debug.go │ ├── deviceid.go │ ├── deviceid_test.go │ ├── deviceid_test.pb.go │ ├── deviceid_test.proto │ ├── doc.go │ ├── errors.go │ ├── hello.go │ ├── hello_test.go │ ├── luhn.go │ ├── luhn_test.go │ ├── nativemodel_darwin.go │ ├── nativemodel_unix.go │ ├── nativemodel_windows.go │ ├── nativemodel_windows_test.go │ ├── protocol.go │ ├── protocol_test.go │ ├── vector.go │ ├── vector_test.go │ └── wireformat.go ├── rand │ ├── random.go │ ├── random_test.go │ ├── securesource.go │ └── securesource_test.go ├── rc │ ├── debug.go │ └── rc.go ├── relay │ ├── client │ │ ├── client.go │ │ ├── debug.go │ │ ├── dynamic.go │ │ ├── empty_test.go │ │ ├── methods.go │ │ └── static.go │ └── protocol │ │ ├── empty_test.go │ │ ├── packets.go │ │ ├── packets_xdr.go │ │ └── protocol.go ├── scanner │ ├── .gitignore │ ├── blockqueue.go │ ├── blocks.go │ ├── blocks_test.go │ ├── debug.go │ ├── doc.go │ ├── testdata │ │ ├── .stignore │ │ ├── afile │ │ ├── bfile │ │ ├── dir1 │ │ │ ├── cfile │ │ │ └── dfile │ │ ├── dir2 │ │ │ ├── cfile │ │ │ ├── dfile │ │ │ └── dir21 │ │ │ │ ├── dir22 │ │ │ │ ├── dir23 │ │ │ │ │ └── efile │ │ │ │ └── efile │ │ │ │ │ └── efile │ │ │ │ ├── dira │ │ │ │ ├── efile │ │ │ │ └── ffile │ │ │ │ └── efile │ │ │ │ └── ign │ │ │ │ └── efile │ │ ├── dir3 │ │ │ ├── cfile │ │ │ └── dfile │ │ ├── excludes │ │ └── further-excludes │ ├── virtualfs_test.go │ ├── walk.go │ └── walk_test.go ├── sha256 │ └── sha256.go ├── signature │ ├── signature.go │ └── signature_test.go ├── stats │ ├── debug.go │ ├── device.go │ ├── empty_test.go │ └── folder.go ├── stun │ ├── debug.go │ ├── filter.go │ └── stun.go ├── sync │ ├── debug.go │ ├── sync.go │ └── sync_test.go ├── syncthing │ ├── auditservice.go │ ├── auditservice_test.go │ ├── debug.go │ ├── superuser_unix.go │ ├── superuser_windows.go │ ├── syncthing.go │ ├── syncthing_test.go │ ├── utils.go │ └── verboseservice.go ├── testutils │ └── testutils.go ├── tlsutil │ ├── tlsutil.go │ └── tlsutil_test.go ├── upgrade │ ├── debug.go │ ├── signingkey.go │ ├── upgrade_common.go │ ├── upgrade_supported.go │ ├── upgrade_test.go │ └── upgrade_unsupp.go ├── upnp │ ├── debug.go │ ├── igd_service.go │ ├── upnp.go │ └── upnp_test.go ├── ur │ ├── contract │ │ ├── contract.go │ │ └── contract_test.go │ ├── debug.go │ ├── failurereporting.go │ ├── memsize_darwin.go │ ├── memsize_linux.go │ ├── memsize_netbsd.go │ ├── memsize_solaris.go │ ├── memsize_unimpl.go │ ├── memsize_windows.go │ └── usage_report.go ├── util │ ├── utils.go │ └── utils_test.go ├── versioner │ ├── .gitignore │ ├── _external_test │ │ ├── external.bat │ │ └── external.sh │ ├── debug.go │ ├── empty_dir_tracker.go │ ├── empty_dir_tracker_test.go │ ├── external.go │ ├── external_test.go │ ├── simple.go │ ├── simple_test.go │ ├── staggered.go │ ├── staggered_test.go │ ├── trashcan.go │ ├── trashcan_test.go │ ├── util.go │ ├── versioner.go │ └── versioner_test.go ├── watchaggregator │ ├── aggregator.go │ ├── aggregator_test.go │ └── debug.go └── weakhash │ ├── benchmark_test.go │ ├── weakhash.go │ └── weakhash_test.go ├── man ├── README.md ├── refresh.sh ├── stdiscosrv.1 ├── strelaysrv.1 ├── syncthing-bep.7 ├── syncthing-config.5 ├── syncthing-device-ids.7 ├── syncthing-event-api.7 ├── syncthing-faq.7 ├── syncthing-globaldisco.7 ├── syncthing-localdisco.7 ├── syncthing-networking.7 ├── syncthing-relay.7 ├── syncthing-rest-api.7 ├── syncthing-security.7 ├── syncthing-stignore.5 ├── syncthing-versioning.7 └── syncthing.1 ├── meta ├── README.txt ├── copyright_test.go ├── gofmt_test.go └── metalint_test.go ├── proto ├── ext.proto ├── ext │ └── ext.pb.go ├── generate.go ├── lib │ ├── config │ │ ├── authmode.proto │ │ ├── blockpullorder.proto │ │ ├── config.proto │ │ ├── deviceconfiguration.proto │ │ ├── folderconfiguration.proto │ │ ├── foldertype.proto │ │ ├── guiconfiguration.proto │ │ ├── ldapconfiguration.proto │ │ ├── ldaptransport.proto │ │ ├── observed.proto │ │ ├── optionsconfiguration.proto │ │ ├── pullorder.proto │ │ ├── size.proto │ │ ├── tuning.proto │ │ └── versioningconfiguration.proto │ ├── db │ │ └── structs.proto │ ├── fs │ │ ├── copyrangemethod.proto │ │ └── types.proto │ └── protocol │ │ └── bep.proto └── scripts │ ├── dump_tags.go │ ├── protoc_plugin.go │ └── protofmt.go ├── script ├── authors.go ├── commit-msg.go ├── docker-entrypoint.sh ├── genassets.go ├── post-upgrade ├── transifexdl.go └── translate.go └── test ├── .gitignore ├── cli_test.go ├── conflict_test.go ├── delay_scan_test.go ├── filetype_test.go ├── folders.sh ├── h1 ├── cert.pem ├── config.xml ├── https-cert.pem ├── https-key.pem └── key.pem ├── h2 ├── cert.pem ├── config.xml ├── https-cert.pem ├── https-key.pem └── key.pem ├── h3 ├── cert.pem ├── config.xml ├── https-cert.pem ├── https-key.pem └── key.pem ├── h4 ├── cert.pem ├── config.xml ├── https-cert.pem ├── https-key.pem └── key.pem ├── http_test.go ├── ignore_test.go ├── logs └── .gitignore ├── manypeers_test.go ├── override_test.go ├── parallell_scan_test.go ├── reconnect_test.go ├── reset_test.go ├── scan_test.go ├── symlink_test.go ├── sync_test.go ├── transfer-bench_test.go ├── usage_unix.go ├── usage_windows.go └── util.go /.codecov.yml: -------------------------------------------------------------------------------- 1 | coverage: 2 | range: "40...100" 3 | 4 | ignore: 5 | - "**.pb.go" 6 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Text files use LF line endings in this repository 2 | * text=auto 3 | 4 | # Except the dependencies, which we leave alone 5 | vendor/** -text=auto 6 | 7 | # Diffs on these files are meaningless 8 | *.svg -diff 9 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | /AUTHORS @calmh 2 | /*.md @calmh 3 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: syncthing 2 | custom: "https://syncthing.net/donations/" 3 | 4 | # patreon: # Replace with a single Patreon username 5 | # open_collective: # Replace with a single Open Collective username 6 | # ko_fi: # Replace with a single Ko-fi username 7 | # tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | # community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | # liberapay: # Replace with a single Liberapay username 10 | # issuehunt: # Replace with a single IssueHunt username 11 | # otechie: # Replace with a single Otechie username 12 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/01-feature.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: If you're just not sure how to do something, see "ask a question". 4 | labels: enhancement, needs-triage 5 | --- 6 | 7 | ### Include required information 8 | 9 | Please be sure to include at least: 10 | 11 | - what problem your new feature would solve 12 | - how or why you think it is generally useful (i.e., not just for you) 13 | - what alternatives or workarounds you considered 14 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/02-bug.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: If you're actually looking for support, see "ask a question". 4 | labels: bug, needs-triage 5 | --- 6 | 7 | ### Does your log mention database corruption? 8 | 9 | If your Syncthing log reports panics because of database corruption it is 10 | most likely a fault with your system's storage or memory. Affected log 11 | entries will contain lines starting with `panic: leveldb`. You will need to 12 | delete the index database to clear this, by running `syncthing 13 | -reset-database`. 14 | 15 | ### Include required information 16 | 17 | Please be sure to include at least: 18 | 19 | - which version of Syncthing and what operating system you are using 20 | - browser and version, if applicable 21 | - what happened, 22 | - what you expected to happen instead, and 23 | - any steps to reproduce the problem. 24 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: I need help / I have a question 4 | url: https://forum.syncthing.net/ 5 | about: Ask questions, get support, and discuss with other community members. 6 | - name: Android issues 7 | url: https://github.com/syncthing/syncthing-android/issues/ 8 | about: The Android app has its own issue tracker. 9 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### Purpose 2 | 3 | Describe the purpose of this change. If there is an existing issue that is 4 | resolved by this pull request, ensure that the commit subject is on the form 5 | `Some short description (fixes #1234)` where 1234 is the issue number. 6 | 7 | ### Testing 8 | 9 | Describe what testing has been done, and how the reviewer can test the change 10 | if new tests are not included. 11 | 12 | ### Screenshots 13 | 14 | If this is a GUI change, include screenshots of the change. If not, please 15 | feel free to just delete this section. 16 | 17 | ### Documentation 18 | 19 | If this is a user visible change (including API and protocol changes), add a link here 20 | to the corresponding pull request on https://github.com/syncthing/docs or describe 21 | the documentation changes necessary. 22 | 23 | ## Authorship 24 | 25 | Your name and email will be added automatically to the AUTHORS file 26 | based on the commit metadata. 27 | 28 | -------------------------------------------------------------------------------- /.github/SECURITY.md: -------------------------------------------------------------------------------- 1 | ## Reporting a Vulnerability 2 | 3 | If you believe that you've found a Syncthing-related security vulnerability, 4 | please report it by sending email to the address security@syncthing.net. The 5 | [PGP key for security@syncthing.net 6 | (B683AD7B76CAB013)](https://syncthing.net/security-key.txt) can be used to 7 | send encrypted mail or to verify responses received from that address. 8 | 9 | You can read more about Syncthing security at 10 | https://syncthing.net/security/. 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /syncthing 2 | /stdiscosrv 3 | syncthing.exe 4 | stdiscosrv.exe 5 | *.tar.gz 6 | *.zip 7 | *.asc 8 | *.deb 9 | .jshintrc 10 | coverage.out 11 | files/pidx 12 | bin 13 | perfstats*.csv 14 | coverage.xml 15 | syncthing.sig 16 | RELEASE 17 | deb 18 | *.bz2 19 | /repos 20 | /proto/scripts/protoc-gen-gosyncthing 21 | -------------------------------------------------------------------------------- /.golangci.yml: -------------------------------------------------------------------------------- 1 | linters-settings: 2 | maligned: 3 | suggest-new: true 4 | 5 | linters: 6 | enable-all: true 7 | disable: 8 | - goimports 9 | - depguard 10 | - lll 11 | - gochecknoinits 12 | - gochecknoglobals 13 | - gofmt 14 | - scopelint 15 | - gocyclo 16 | - funlen 17 | - wsl 18 | - gocognit 19 | - godox 20 | 21 | service: 22 | golangci-lint-version: 1.21.x 23 | prepare: 24 | - rm -f go.sum # 1.12 -> 1.13 issues with QUIC-go 25 | - GO111MODULE=on go mod vendor 26 | - go run build.go assets 27 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | ARG GOVERSION=latest 2 | FROM golang:$GOVERSION AS builder 3 | 4 | WORKDIR /src 5 | COPY . . 6 | 7 | ENV CGO_ENABLED=0 8 | ENV BUILD_HOST=syncthing.net 9 | ENV BUILD_USER=docker 10 | RUN rm -f syncthing && go run build.go -no-upgrade build syncthing 11 | 12 | FROM alpine 13 | 14 | EXPOSE 8384 22000 21027/udp 15 | 16 | VOLUME ["/var/syncthing"] 17 | 18 | RUN apk add --no-cache ca-certificates su-exec tzdata 19 | 20 | COPY --from=builder /src/syncthing /bin/syncthing 21 | COPY --from=builder /src/script/docker-entrypoint.sh /bin/entrypoint.sh 22 | 23 | ENV PUID=1000 PGID=1000 HOME=/var/syncthing 24 | 25 | HEALTHCHECK --interval=1m --timeout=10s \ 26 | CMD nc -z 127.0.0.1 8384 || exit 1 27 | 28 | ENV STGUIADDRESS=0.0.0.0:8384 29 | ENTRYPOINT ["/bin/entrypoint.sh", "/bin/syncthing", "-home", "/var/syncthing/config"] 30 | -------------------------------------------------------------------------------- /Dockerfile.builder: -------------------------------------------------------------------------------- 1 | ARG GOVERSION=latest 2 | FROM golang:$GOVERSION 3 | 4 | # FPM to build Debian packages 5 | RUN apt-get update && apt-get install -y --no-install-recommends \ 6 | locales rubygems ruby-dev build-essential git \ 7 | && apt-get clean \ 8 | && rm -rf /var/lib/apt/lists/* \ 9 | && gem install --no-ri --no-rdoc fpm 10 | -------------------------------------------------------------------------------- /Dockerfile.buildx: -------------------------------------------------------------------------------- 1 | FROM alpine 2 | ARG TARGETARCH 3 | 4 | EXPOSE 8384 22000 21027/udp 5 | 6 | VOLUME ["/var/syncthing"] 7 | 8 | RUN apk add --no-cache ca-certificates su-exec tzdata 9 | 10 | COPY ./syncthing-linux-$TARGETARCH /bin/syncthing 11 | COPY ./script/docker-entrypoint.sh /bin/entrypoint.sh 12 | 13 | ENV PUID=1000 PGID=1000 HOME=/var/syncthing 14 | 15 | HEALTHCHECK --interval=1m --timeout=10s \ 16 | CMD nc -z 127.0.0.1 8384 || exit 1 17 | 18 | ENV STGUIADDRESS=0.0.0.0:8384 19 | ENTRYPOINT ["/bin/entrypoint.sh", "/bin/syncthing", "-home", "/var/syncthing/config"] 20 | -------------------------------------------------------------------------------- /Dockerfile.stdiscosrv: -------------------------------------------------------------------------------- 1 | ARG GOVERSION=latest 2 | FROM golang:$GOVERSION AS builder 3 | 4 | WORKDIR /src 5 | COPY . . 6 | 7 | ENV CGO_ENABLED=0 8 | ENV BUILD_HOST=syncthing.net 9 | ENV BUILD_USER=docker 10 | RUN rm -f stdiscosrv && go run build.go -no-upgrade build stdiscosrv 11 | 12 | FROM alpine 13 | 14 | EXPOSE 19200 8443 15 | 16 | VOLUME ["/var/stdiscosrv"] 17 | 18 | RUN apk add --no-cache ca-certificates su-exec 19 | 20 | COPY --from=builder /src/stdiscosrv /bin/stdiscosrv 21 | COPY --from=builder /src/script/docker-entrypoint.sh /bin/entrypoint.sh 22 | 23 | ENV PUID=1000 PGID=1000 HOME=/var/stdiscosrv 24 | 25 | HEALTHCHECK --interval=1m --timeout=10s \ 26 | CMD nc -z localhost 8443 || exit 1 27 | 28 | WORKDIR /var/stdiscosrv 29 | ENTRYPOINT ["/bin/entrypoint.sh", "/bin/stdiscosrv"] 30 | -------------------------------------------------------------------------------- /Dockerfile.strelaysrv: -------------------------------------------------------------------------------- 1 | ARG GOVERSION=latest 2 | FROM golang:$GOVERSION AS builder 3 | 4 | WORKDIR /src 5 | COPY . . 6 | 7 | ENV CGO_ENABLED=0 8 | ENV BUILD_HOST=syncthing.net 9 | ENV BUILD_USER=docker 10 | RUN rm -f strelaysrv && go run build.go -no-upgrade build strelaysrv 11 | 12 | FROM alpine 13 | 14 | EXPOSE 22067 22070 15 | 16 | VOLUME ["/var/strelaysrv"] 17 | 18 | RUN apk add --no-cache ca-certificates su-exec 19 | 20 | COPY --from=builder /src/strelaysrv /bin/strelaysrv 21 | COPY --from=builder /src/script/docker-entrypoint.sh /bin/entrypoint.sh 22 | 23 | ENV PUID=1000 PGID=1000 HOME=/var/strelaysrv 24 | 25 | HEALTHCHECK --interval=1m --timeout=10s \ 26 | CMD nc -z localhost 22067 || exit 1 27 | 28 | WORKDIR /var/strelaysrv 29 | ENTRYPOINT ["/bin/entrypoint.sh", "/bin/strelaysrv"] 30 | -------------------------------------------------------------------------------- /assets/logo-128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isyncthing/syncthing/d0ccea04045e9b154970a92f8eafa0c76cb0f2e2/assets/logo-128.png -------------------------------------------------------------------------------- /assets/logo-256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isyncthing/syncthing/d0ccea04045e9b154970a92f8eafa0c76cb0f2e2/assets/logo-256.png -------------------------------------------------------------------------------- /assets/logo-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isyncthing/syncthing/d0ccea04045e9b154970a92f8eafa0c76cb0f2e2/assets/logo-32.png -------------------------------------------------------------------------------- /assets/logo-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isyncthing/syncthing/d0ccea04045e9b154970a92f8eafa0c76cb0f2e2/assets/logo-512.png -------------------------------------------------------------------------------- /assets/logo-64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isyncthing/syncthing/d0ccea04045e9b154970a92f8eafa0c76cb0f2e2/assets/logo-64.png -------------------------------------------------------------------------------- /assets/logo-text-128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isyncthing/syncthing/d0ccea04045e9b154970a92f8eafa0c76cb0f2e2/assets/logo-text-128.png -------------------------------------------------------------------------------- /assets/logo-text-256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isyncthing/syncthing/d0ccea04045e9b154970a92f8eafa0c76cb0f2e2/assets/logo-text-256.png -------------------------------------------------------------------------------- /assets/logo-text-64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isyncthing/syncthing/d0ccea04045e9b154970a92f8eafa0c76cb0f2e2/assets/logo-text-64.png -------------------------------------------------------------------------------- /assets/logo-wtext.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isyncthing/syncthing/d0ccea04045e9b154970a92f8eafa0c76cb0f2e2/assets/logo-wtext.png -------------------------------------------------------------------------------- /assets/logo.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isyncthing/syncthing/d0ccea04045e9b154970a92f8eafa0c76cb0f2e2/assets/logo.ai -------------------------------------------------------------------------------- /assets/logo.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isyncthing/syncthing/d0ccea04045e9b154970a92f8eafa0c76cb0f2e2/assets/logo.ico -------------------------------------------------------------------------------- /assets/logo.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isyncthing/syncthing/d0ccea04045e9b154970a92f8eafa0c76cb0f2e2/assets/logo.pdf -------------------------------------------------------------------------------- /assets/syncthing_folder_icon.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isyncthing/syncthing/d0ccea04045e9b154970a92f8eafa0c76cb0f2e2/assets/syncthing_folder_icon.icns -------------------------------------------------------------------------------- /build.ps1: -------------------------------------------------------------------------------- 1 | function build { 2 | go run build.go @args 3 | } 4 | 5 | $cmd, $rest = $args 6 | switch ($cmd) { 7 | "test" { 8 | $env:LOGGER_DISCARD=1 9 | build test 10 | } 11 | 12 | "bench" { 13 | $env:LOGGER_DISCARD=1 14 | build bench 15 | } 16 | 17 | default { 18 | build @rest 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -euo pipefail 3 | IFS=$'\n\t' 4 | 5 | script() { 6 | name="$1" 7 | shift 8 | go run "script/$name.go" "$@" 9 | } 10 | 11 | build() { 12 | go run build.go "$@" 13 | } 14 | 15 | case "${1:-default}" in 16 | test) 17 | LOGGER_DISCARD=1 build test 18 | ;; 19 | 20 | bench) 21 | LOGGER_DISCARD=1 build bench 22 | ;; 23 | 24 | prerelease) 25 | script authors 26 | build transifex 27 | pushd man ; ./refresh.sh ; popd 28 | git add -A gui man AUTHORS 29 | git commit -m 'gui, man, authors: Update docs, translations, and contributors' 30 | ;; 31 | 32 | *) 33 | build "$@" 34 | ;; 35 | esac 36 | -------------------------------------------------------------------------------- /cmd/.gitignore: -------------------------------------------------------------------------------- 1 | !syncthing 2 | -------------------------------------------------------------------------------- /cmd/stdiscosrv/README.md: -------------------------------------------------------------------------------- 1 | stdiscosrv 2 | ========== 3 | 4 | This is the global discovery server for the `syncthing` project. 5 | 6 | Usage 7 | ----- 8 | 9 | https://docs.syncthing.net/users/stdiscosrv.html 10 | 11 | -------------------------------------------------------------------------------- /cmd/stdiscosrv/etc/firewall-ufw/stdiscosrv: -------------------------------------------------------------------------------- 1 | [stdiscosrv] 2 | title=Syncthing discovery server 3 | description=Lets syncthing clients discover each other 4 | ports=8443/tcp 5 | -------------------------------------------------------------------------------- /cmd/stdiscosrv/etc/linux-systemd/default: -------------------------------------------------------------------------------- 1 | # Default settings for syncthing-discosrv (stdiscosrv). 2 | ## Add Options here: 3 | DISCOSRV_OPTS= 4 | -------------------------------------------------------------------------------- /cmd/stdiscosrv/etc/linux-systemd/stdiscosrv.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Syncthing Discovery Server 3 | After=network.target 4 | Documentation=man:stdiscosrv(1) 5 | 6 | [Service] 7 | WorkingDirectory=/var/lib/syncthing-discosrv 8 | EnvironmentFile=/etc/default/syncthing-discosrv 9 | ExecStart=/usr/bin/stdiscosrv $DISCOSRV_OPTS 10 | 11 | # Hardening 12 | User=syncthing-discosrv 13 | Group=syncthing 14 | ProtectSystem=strict 15 | ReadWritePaths=/var/lib/syncthing-discosrv 16 | NoNewPrivileges=true 17 | PrivateTmp=true 18 | PrivateDevices=true 19 | ProtectHome=true 20 | SystemCallArchitectures=native 21 | MemoryDenyWriteExecute=true 22 | 23 | [Install] 24 | WantedBy=multi-user.target 25 | Alias=syncthing-discosrv.service 26 | -------------------------------------------------------------------------------- /cmd/stdiscosrv/scripts/preinst: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | addgroup --system syncthing 4 | adduser --system --home /var/lib/syncthing-discosrv --ingroup syncthing syncthing-discosrv 5 | -------------------------------------------------------------------------------- /cmd/stfindignored/main.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | // Commmand stfindignored lists ignored files under a given folder root. 8 | package main 9 | 10 | import ( 11 | "flag" 12 | "fmt" 13 | "os" 14 | 15 | "github.com/syncthing/syncthing/lib/fs" 16 | "github.com/syncthing/syncthing/lib/ignore" 17 | ) 18 | 19 | func main() { 20 | flag.Parse() 21 | root := flag.Arg(0) 22 | if root == "" { 23 | root = "." 24 | } 25 | 26 | vfs := fs.NewWalkFilesystem(fs.NewFilesystem(fs.FilesystemTypeBasic, root)) 27 | 28 | ign := ignore.New(vfs) 29 | if err := ign.Load(".stignore"); err != nil { 30 | fmt.Fprintf(os.Stderr, "Fatal: loading ignores: %v\n", err) 31 | os.Exit(1) 32 | } 33 | 34 | vfs.Walk(".", func(path string, info fs.FileInfo, err error) error { 35 | if err != nil { 36 | fmt.Fprintf(os.Stderr, "Warning: %s: %v\n", path, err) 37 | return fs.SkipDir 38 | } 39 | if ign.Match(path).IsIgnored() { 40 | fmt.Println(path) 41 | } 42 | return nil 43 | }) 44 | } 45 | -------------------------------------------------------------------------------- /cmd/strelaypoolsrv/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 The Syncthing Project 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /cmd/strelaypoolsrv/README.md: -------------------------------------------------------------------------------- 1 | # relaypoolsrv 2 | 3 | This is the relay pool server for the `syncthing` project, which allows 4 | community hosted [relaysrv](https://github.com/syncthing/relaysrv)'s to join 5 | the public pool. 6 | 7 | Servers that join the pool are then advertised to users of `syncthing` as 8 | potential connection points for those who are unable to connect directly due 9 | to NAT or firewall issues. 10 | 11 | There is very little reason why you'd want to run this yourself, as 12 | `relaypoolsrv` is just used for announcement and lookup of public relay 13 | servers. If you are looking to setup a private or a public relay, please 14 | check the documentation for 15 | [relaysrv](https://github.com/syncthing/relaysrv), which also explains how 16 | to join the default public pool. 17 | 18 | See `relaypoolsrv -help` for configuration options. 19 | 20 | ##### Third-party attributions 21 | 22 | [oschwald/geoip2-golang](https://github.com/oschwald/geoip2-golang), [oschwald/maxminddb-golang](https://github.com/oschwald/maxminddb-golang), Copyright (C) 2015 [Gregory J. Oschwald](mailto:oschwald@gmail.com). 23 | 24 | [lib/pq](https://github.com/lib/pq), Copyright (C) 2011-2013 'pq' Contributors Portions Copyright (C) 2011 Blake Mizerany. 25 | -------------------------------------------------------------------------------- /cmd/strelaypoolsrv/auto/.gitignore: -------------------------------------------------------------------------------- 1 | gui.files.go 2 | -------------------------------------------------------------------------------- /cmd/strelaypoolsrv/auto/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | //go:generate go run ../../../script/genassets.go -o gui.files.go ../gui 8 | 9 | // Package auto contains auto generated files for web assets. 10 | package auto 11 | -------------------------------------------------------------------------------- /cmd/strelaypoolsrv/stats_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 Audrius Butkevicius and Contributors (see the CONTRIBUTORS file). 2 | 3 | package main 4 | 5 | import ( 6 | "testing" 7 | ) 8 | 9 | func TestMerge(t *testing.T) { 10 | if mergeValue(1001, 1000) != 1001 { 11 | t.Error("the computer says no") 12 | } 13 | 14 | if mergeValue(999, 1000) != 1000 { 15 | t.Error("the computer says no") 16 | } 17 | 18 | if mergeValue(1, 1000) != 1 { 19 | t.Error("the computer says no") 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /cmd/strelaysrv/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 The Syncthing Project 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /cmd/strelaysrv/etc/firewall-ufw/strelaysrv: -------------------------------------------------------------------------------- 1 | [strelaysrv] 2 | title=Syncthing relay server 3 | description=Proxies traffic of syncthing client behind firewalls 4 | ports=22067/tcp 5 | 6 | [strelaysrv-metrics] 7 | title=Syncthing relay metrics 8 | description=Provides metrics about the syncthing relay server 9 | ports=22070/tcp 10 | -------------------------------------------------------------------------------- /cmd/strelaysrv/etc/linux-systemd/default: -------------------------------------------------------------------------------- 1 | # Default settings for syncthing-relaysrv (strelaysrv). 2 | NAT=true 3 | 4 | ## Add Options here: 5 | RELAYSRV_OPTS= 6 | -------------------------------------------------------------------------------- /cmd/strelaysrv/etc/linux-systemd/strelaysrv.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Syncthing Relay Server 3 | After=network.target 4 | Documentation=man:strelaysrv(1) 5 | 6 | [Service] 7 | WorkingDirectory=/var/lib/syncthing-relaysrv 8 | EnvironmentFile=/etc/default/syncthing-relaysrv 9 | ExecStart=/usr/bin/strelaysrv -nat=${NAT} $RELAYSRV_OPTS 10 | 11 | # Hardening 12 | User=syncthing-relaysrv 13 | Group=syncthing 14 | ProtectSystem=strict 15 | ReadWritePaths=/var/lib/syncthing-relaysrv 16 | NoNewPrivileges=true 17 | PrivateTmp=true 18 | PrivateDevices=true 19 | ProtectHome=true 20 | SystemCallArchitectures=native 21 | MemoryDenyWriteExecute=true 22 | 23 | [Install] 24 | WantedBy=multi-user.target 25 | Alias=syncthing-relaysrv.service 26 | -------------------------------------------------------------------------------- /cmd/strelaysrv/scripts/preinst: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | addgroup --system syncthing 4 | adduser --system --home /var/lib/syncthing-relaysrv --ingroup syncthing syncthing-relaysrv 5 | -------------------------------------------------------------------------------- /cmd/strelaysrv/utils.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 Audrius Butkevicius and Contributors. 2 | 3 | package main 4 | 5 | import ( 6 | "errors" 7 | "net" 8 | ) 9 | 10 | func setTCPOptions(conn net.Conn) error { 11 | tcpConn, ok := conn.(*net.TCPConn) 12 | if !ok { 13 | return errors.New("Not a TCP connection") 14 | } 15 | if err := tcpConn.SetLinger(0); err != nil { 16 | return err 17 | } 18 | if err := tcpConn.SetNoDelay(true); err != nil { 19 | return err 20 | } 21 | if err := tcpConn.SetKeepAlivePeriod(networkTimeout); err != nil { 22 | return err 23 | } 24 | if err := tcpConn.SetKeepAlive(true); err != nil { 25 | return err 26 | } 27 | return nil 28 | } 29 | -------------------------------------------------------------------------------- /cmd/syncthing/.gitignore: -------------------------------------------------------------------------------- 1 | *.idx.gz 2 | -------------------------------------------------------------------------------- /cmd/syncthing/.stfolder: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isyncthing/syncthing/d0ccea04045e9b154970a92f8eafa0c76cb0f2e2/cmd/syncthing/.stfolder -------------------------------------------------------------------------------- /cmd/syncthing/crash_reporting_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package main 8 | 9 | import ( 10 | "bytes" 11 | "testing" 12 | ) 13 | 14 | func TestFilterLogLines(t *testing.T) { 15 | in := []byte(`[ABCD123] syncthing version whatever 16 | here is more log data 17 | and more 18 | ... 19 | and some more 20 | yet more 21 | Panic detected at like right now 22 | here is panic data 23 | and yet more panic stuff 24 | `) 25 | 26 | filtered := []byte(`syncthing version whatever 27 | Panic detected at like right now 28 | here is panic data 29 | and yet more panic stuff 30 | `) 31 | 32 | result := filterLogLines(in) 33 | if !bytes.Equal(result, filtered) { 34 | t.Logf("%q\n", result) 35 | t.Error("it should have been filtered") 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /cmd/syncthing/debug.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package main 8 | 9 | import ( 10 | "github.com/syncthing/syncthing/lib/logger" 11 | ) 12 | 13 | var ( 14 | l = logger.DefaultLogger.NewFacility("main", "Main package") 15 | ) 16 | -------------------------------------------------------------------------------- /cmd/syncthing/openurl_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | // +build !windows 8 | 9 | package main 10 | 11 | import ( 12 | "os/exec" 13 | "runtime" 14 | "syscall" 15 | ) 16 | 17 | func openURL(url string) error { 18 | switch runtime.GOOS { 19 | case "darwin": 20 | return exec.Command("open", url).Run() 21 | 22 | default: 23 | cmd := exec.Command("xdg-open", url) 24 | cmd.SysProcAttr = &syscall.SysProcAttr{ 25 | Setpgid: true, 26 | } 27 | return cmd.Run() 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /cmd/syncthing/openurl_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | // +build windows 8 | 9 | package main 10 | 11 | import "os/exec" 12 | 13 | func openURL(url string) error { 14 | return exec.Command("cmd.exe", "/C", "start "+url).Run() 15 | } 16 | -------------------------------------------------------------------------------- /cmd/syncthing/traceback.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | //+build go1.7 8 | 9 | package main 10 | 11 | import "runtime/debug" 12 | 13 | func init() { 14 | // We want all (our) goroutines in panic traces. 15 | debug.SetTraceback("all") 16 | } 17 | -------------------------------------------------------------------------------- /cmd/ursrv/static/assets/img/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isyncthing/syncthing/d0ccea04045e9b154970a92f8eafa0c76cb0f2e2/cmd/ursrv/static/assets/img/favicon.png -------------------------------------------------------------------------------- /cmd/ursrv/static/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isyncthing/syncthing/d0ccea04045e9b154970a92f8eafa0c76cb0f2e2/cmd/ursrv/static/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /cmd/ursrv/static/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isyncthing/syncthing/d0ccea04045e9b154970a92f8eafa0c76cb0f2e2/cmd/ursrv/static/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /cmd/ursrv/static/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isyncthing/syncthing/d0ccea04045e9b154970a92f8eafa0c76cb0f2e2/cmd/ursrv/static/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /etc/README.md: -------------------------------------------------------------------------------- 1 | This directory contains contributed setup examples. 2 | -------------------------------------------------------------------------------- /etc/firewall-ufw/README.md: -------------------------------------------------------------------------------- 1 | Uncomplicated FireWall application preset 2 | =================== 3 | Installation 4 | ----------- 5 | **Please note:** When you installed syncthing using the official deb package, you can skip the copying. 6 | 7 | Copy the file `syncthing` to your ufw applications directory usually located at `/etc/ufw/applications.d/` (root permissions required). 8 | 9 | In a terminal run 10 | ``` 11 | sudo ufw app update syncthing 12 | sudo ufw app update syncthing-gui 13 | ``` 14 | to load the presets. 15 | To allow the syncthing ports, run 16 | ``` 17 | sudo ufw allow syncthing 18 | ``` 19 | If you want to access the web gui from anywhere (not only from localhost), you can also allow the gui port. 20 | This is step is **not** necessary for a "normal" installation! 21 | ``` 22 | sudo ufw allow syncthing-gui 23 | ``` 24 | 25 | 26 | Verification 27 | ---------- 28 | You can verify the opened ports by running 29 | ``` 30 | sudo ufw status verbose 31 | ``` 32 | -------------------------------------------------------------------------------- /etc/firewall-ufw/syncthing: -------------------------------------------------------------------------------- 1 | [syncthing] 2 | title=Syncthing 3 | description=Syncthing file synchronisation 4 | ports=22000/tcp|21027/udp 5 | 6 | [syncthing-gui] 7 | title=Syncthing-GUI 8 | description=Syncthing web gui 9 | ports=8384/tcp 10 | -------------------------------------------------------------------------------- /etc/freebsd-rc/README.md: -------------------------------------------------------------------------------- 1 | This directory contains an example for running Syncthing with a `rc.d` script in FreeBSD. 2 | 3 | * Install `syncthing` in `/usr/local/bin/syncthing`. 4 | * Copy the `syncthing` rc.d script in `/usr/local/etc/rc.d/syncthing`. 5 | * To automatically start `syncthing` at boot time, add the following line to `/etc/rc.conf`: 6 | ``` 7 | syncthing_enable=YES 8 | ``` 9 | * Optional configuration options are: 10 | ``` 11 | syncthing_home= 12 | syncthing_log_file= 13 | syncthing_user= 14 | syncthing_group= 15 | ``` 16 | See the rc.d script for more informations. -------------------------------------------------------------------------------- /etc/linux-desktop/README.md: -------------------------------------------------------------------------------- 1 | # Desktop Entries 2 | 3 | This directory contains files to integrate Syncthing in your desktop environment (DE). 4 | Specifically this works for DEs that implement the [XDG Desktop Menu Specification][1], which 5 | is virtually every DE. 6 | To add Syncthing to desktop menus for all users, copy the `.desktop` files to 7 | `/usr/local/share/applications` (root required). To add it for just your user, copy them to `~/.local/share/applications`. 8 | To start Syncthing automatically, you have two options: Either you go to the autostart settings of your DE and choose Syncthing or you copy the `syncthing-start.desktop` file to `~/.config/autostart`. 9 | For more information refer to the [ArchWiki page on Desktop entries][2] 10 | 11 | [1]: https://specifications.freedesktop.org/menu-spec/menu-spec-latest.html 12 | [2]: https://wiki.archlinux.org/index.php/Desktop_entries 13 | -------------------------------------------------------------------------------- /etc/linux-desktop/syncthing-start.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name=Start Syncthing 3 | GenericName=File synchronization 4 | Comment=Starts the main syncthing process in the background. 5 | Exec=/usr/bin/syncthing -no-browser -logfile=default 6 | Icon=syncthing 7 | Terminal=false 8 | Type=Application 9 | Keywords=synchronization;daemon; 10 | Categories=Network;FileTransfer;P2P 11 | -------------------------------------------------------------------------------- /etc/linux-desktop/syncthing-ui.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name=Syncthing Web UI 3 | GenericName=File synchronization UI 4 | Comment=Opens Syncthing's Web UI in the default browser (Syncthing must already be started). 5 | Exec=/usr/bin/syncthing -browser-only 6 | Icon=syncthing 7 | Terminal=false 8 | Type=Application 9 | Keywords=synchronization;interface; 10 | Categories=Network;FileTransfer;P2P 11 | -------------------------------------------------------------------------------- /etc/linux-runit/README.md: -------------------------------------------------------------------------------- 1 | This directory contains a configuration for running syncthing under the 2 | "runit" service manager on Linux. It probably works perfectly fine on 3 | other platforms also using runit. 4 | 5 | 1. Install runit. 6 | 7 | 2. Edit the `run` file to set the username to run as, the user's home 8 | directory and the place where the syncthing binary lives. It is 9 | recommended to place it in a directory writeable by the running user 10 | so that automatic upgrades work. 11 | 12 | 3. Copy this directory (containing the edited `run` file and `log` folder) to 13 | `/etc/service/syncthing`. 14 | 15 | Log output is sent to syslogd. 16 | 17 | -------------------------------------------------------------------------------- /etc/linux-runit/log/run: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | exec logger -t syncthing 4 | 5 | -------------------------------------------------------------------------------- /etc/linux-runit/run: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export USERNAME=jb 4 | export HOME="/home/$USERNAME" 5 | export SYNCTHING="$HOME/bin/syncthing" 6 | 7 | exec 2>&1 8 | exec chpst -u "$USERNAME" "$SYNCTHING" -logflags 0 9 | 10 | -------------------------------------------------------------------------------- /etc/linux-systemd/README.md: -------------------------------------------------------------------------------- 1 | # Systemd Configuration 2 | 3 | This directory contains configuration files for running Syncthing under the 4 | "systemd" service manager on Linux both under either a systemd system service or 5 | systemd user service. For further documentation take a look at the [systemd 6 | section][1] on https://docs.syncthing.net. 7 | 8 | [1]: https://docs.syncthing.net/users/autostart.html#using-systemd 9 | -------------------------------------------------------------------------------- /etc/linux-systemd/system/syncthing-resume.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Restart Syncthing after resume 3 | Documentation=man:syncthing(1) 4 | After=sleep.target 5 | 6 | [Service] 7 | Type=oneshot 8 | ExecStart=-/usr/bin/pkill -HUP -x syncthing 9 | 10 | [Install] 11 | WantedBy=sleep.target 12 | -------------------------------------------------------------------------------- /etc/linux-systemd/system/syncthing@.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Syncthing - Open Source Continuous File Synchronization for %I 3 | Documentation=man:syncthing(1) 4 | After=network.target 5 | 6 | [Service] 7 | User=%i 8 | ExecStart=/usr/bin/syncthing -no-browser -no-restart -logflags=0 9 | Restart=on-failure 10 | RestartSec=5 11 | SuccessExitStatus=3 4 12 | RestartForceExitStatus=3 4 13 | 14 | # Hardening 15 | ProtectSystem=full 16 | PrivateTmp=true 17 | SystemCallArchitectures=native 18 | MemoryDenyWriteExecute=true 19 | NoNewPrivileges=true 20 | 21 | [Install] 22 | WantedBy=multi-user.target 23 | -------------------------------------------------------------------------------- /etc/linux-systemd/user/syncthing.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Syncthing - Open Source Continuous File Synchronization 3 | Documentation=man:syncthing(1) 4 | 5 | [Service] 6 | ExecStart=/usr/bin/syncthing -no-browser -no-restart -logflags=0 7 | Restart=on-failure 8 | RestartSec=5 9 | SuccessExitStatus=3 4 10 | RestartForceExitStatus=3 4 11 | 12 | # Hardening 13 | SystemCallArchitectures=native 14 | MemoryDenyWriteExecute=true 15 | NoNewPrivileges=true 16 | 17 | [Install] 18 | WantedBy=default.target 19 | -------------------------------------------------------------------------------- /etc/linux-upstart/README.md: -------------------------------------------------------------------------------- 1 | # Upstart Configuration 2 | 3 | This directory contains example configuration files for running Syncthing under 4 | the "Upstart" service manager on Linux. To have syncthing start when you login 5 | place "user/syncthing.conf" in the "/home/[username]/.config/upstart/" folder. 6 | To have syncthing start when the system boots place "system/syncthing.conf" 7 | in the "/etc/init/" folder. 8 | To manually start syncthing via Upstart when using the system configuration use: 9 | 10 | ``` 11 | sudo initctl start syncthing 12 | ``` 13 | 14 | For further documentation see [https://docs.syncthing.net/users/autostart.html][1]. 15 | 16 | [1]: https://docs.syncthing.net/users/autostart.html#Upstart 17 | -------------------------------------------------------------------------------- /etc/linux-upstart/system/syncthing.conf: -------------------------------------------------------------------------------- 1 | description "Syncthing" 2 | 3 | start on (local-filesystems and net-device-up IFACE!=lo) 4 | stop on runlevel [!2345] 5 | 6 | env STNORESTART=yes 7 | env HOME=/home/$USER 8 | setuid "$USER" 9 | setgid "$USER" 10 | 11 | exec /usr/local/bin/syncthing 12 | 13 | respawn 14 | -------------------------------------------------------------------------------- /etc/linux-upstart/user/syncthing.conf: -------------------------------------------------------------------------------- 1 | # Location of the syncthing executable 2 | env SYNCTHING_EXE="/usr/local/bin" 3 | 4 | # Set the name of the application 5 | description "Syncthing" 6 | 7 | # Start syncthing you login to your desktop 8 | start on desktop-start 9 | 10 | # Stop syncthing you logout of your desktop 11 | stop on desktop-end 12 | 13 | # Set STNORESTART to yes to have Upstart monitor the process instead 14 | # of having a separate syncthing process do the monitoring 15 | env STNORESTART=yes 16 | 17 | # If Upstart detects syncthing has failed - it should restart it 18 | respawn 19 | 20 | # the syncthing command Upstart is to execute when it is started up 21 | exec $SYNCTHING_EXE -no-browser 22 | -------------------------------------------------------------------------------- /etc/macos-launchd/README.md: -------------------------------------------------------------------------------- 1 | This directory contains an example for running Syncthing in the 2 | background under macOS. 3 | 4 | 1. Install the `syncthing` binary in a directory called `bin` in your 5 | home directory. 6 | 7 | 2. Edit the `syncthing.plist` by replacing `USERNAME` with your actual 8 | username such as `jb`. 9 | 10 | 3. Copy the `syncthing.plist` file to `~/Library/LaunchAgents`. 11 | 12 | 4. Log out and in again, or run `launchctl load 13 | ~/Library/LaunchAgents/syncthing.plist`. 14 | 15 | You probably want to turn off "Start Browser" among the settings to 16 | avoid it opening a browser window on each login. 17 | 18 | Logs are in `~/Library/Logs/Syncthing.log` and, for crashes and exceptions, 19 | `~/Library/Logs/Syncthing-Error.log`. 20 | -------------------------------------------------------------------------------- /etc/solaris-smf/README.md: -------------------------------------------------------------------------------- 1 | This directory contains an example for running Syncthing under SMF on 2 | Solaris. 3 | 4 | 1. Install the `syncthing` binary in a directory called `bin` in your 5 | home directory. 6 | 7 | 2. Edit the `syncthing.xml` file in the two places that refer to your 8 | username and home directory; that is, replace `jb` with your actual 9 | username and `/home/jb` with your actual home directory location. 10 | 11 | 3. Load the service manifest, as a user with the appropriate rights. 12 | `svccfg import syncthing.xml`. 13 | 14 | -------------------------------------------------------------------------------- /gui/default/assets/css/dev.css: -------------------------------------------------------------------------------- 1 | .dev-top-bar{ 2 | background-color: yellow; 3 | } 4 | 5 | .dev-error .hasCount{ 6 | background-color: red; 7 | } 8 | 9 | .dev-warn .hasCount{ 10 | background-color: yellow; 11 | } -------------------------------------------------------------------------------- /gui/default/assets/css/theme.css: -------------------------------------------------------------------------------- 1 | /* 2 | // Copyright (C) 2016 The Syncthing Authors. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 6 | // You can obtain one at https://mozilla.org/MPL/2.0/. 7 | 8 | */ 9 | 10 | @import "../../theme-assets/dark/assets/css/theme.css" screen and (prefers-color-scheme: dark); 11 | @import "../../theme-assets/light/assets/css/theme.css" (prefers-color-scheme: light), (prefers-color-scheme: no-preference); 12 | -------------------------------------------------------------------------------- /gui/default/assets/font/raleway-500.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isyncthing/syncthing/d0ccea04045e9b154970a92f8eafa0c76cb0f2e2/gui/default/assets/font/raleway-500.woff -------------------------------------------------------------------------------- /gui/default/assets/font/raleway.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'Raleway'; 3 | font-style: normal; 4 | font-weight: 500; 5 | src: local('Raleway Medium'), local('Raleway-Medium'), url(raleway-500.woff) format('woff'); 6 | } 7 | -------------------------------------------------------------------------------- /gui/default/assets/img/favicon-default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isyncthing/syncthing/d0ccea04045e9b154970a92f8eafa0c76cb0f2e2/gui/default/assets/img/favicon-default.png -------------------------------------------------------------------------------- /gui/default/assets/img/favicon-notify.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isyncthing/syncthing/d0ccea04045e9b154970a92f8eafa0c76cb0f2e2/gui/default/assets/img/favicon-notify.png -------------------------------------------------------------------------------- /gui/default/assets/img/favicon-pause.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isyncthing/syncthing/d0ccea04045e9b154970a92f8eafa0c76cb0f2e2/gui/default/assets/img/favicon-pause.png -------------------------------------------------------------------------------- /gui/default/assets/img/favicon-sync.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isyncthing/syncthing/d0ccea04045e9b154970a92f8eafa0c76cb0f2e2/gui/default/assets/img/favicon-sync.png -------------------------------------------------------------------------------- /gui/default/assets/lang/README.txt: -------------------------------------------------------------------------------- 1 | All files in this directory are auto generated. Do not change any of 2 | them. To contribute translations, please head over to 3 | 4 | https://www.transifex.com/projects/p/syncthing/ 5 | 6 | Any updates made on Transifex will be automatically pulled into these 7 | files. 8 | -------------------------------------------------------------------------------- /gui/default/assets/lang/prettyprint.js: -------------------------------------------------------------------------------- 1 | var langPrettyprint = {"bg":"Bulgarian","ca@valencia":"Catalan (Valencian)","cs":"Czech","da":"Danish","de":"German","el":"Greek","en":"English","en-AU":"English (Australia)","en-GB":"English (United Kingdom)","eo":"Esperanto","es":"Spanish","es-ES":"Spanish (Spain)","eu":"Basque","fi":"Finnish","fr":"French","fy":"Western Frisian","hu":"Hungarian","it":"Italian","ja":"Japanese","ko-KR":"Korean (Korea)","lt":"Lithuanian","nb":"Norwegian Bokmål","nl":"Dutch","pl":"Polish","pt-BR":"Portuguese (Brazil)","pt-PT":"Portuguese (Portugal)","ru":"Russian","sk":"Slovak","sv":"Swedish","tr":"Turkish","uk":"Ukrainian","zh-CN":"Chinese (China)","zh-TW":"Chinese (Taiwan)"} 2 | -------------------------------------------------------------------------------- /gui/default/assets/lang/valid-langs.js: -------------------------------------------------------------------------------- 1 | var validLangs = ["bg","ca@valencia","cs","da","de","el","en","en-AU","en-GB","eo","es","es-ES","eu","fi","fr","fy","hu","it","ja","ko-KR","lt","nb","nl","pl","pt-BR","pt-PT","ru","sk","sv","tr","uk","zh-CN","zh-TW"] 2 | -------------------------------------------------------------------------------- /gui/default/modal.html: -------------------------------------------------------------------------------- 1 | 23 | -------------------------------------------------------------------------------- /gui/default/syncthing/core/alwaysNumberFilter.js: -------------------------------------------------------------------------------- 1 | angular.module('syncthing.core') 2 | .filter('alwaysNumber', function () { 3 | return function (input) { 4 | if (input === undefined) { 5 | return 0; 6 | } 7 | return input; 8 | }; 9 | }); 10 | -------------------------------------------------------------------------------- /gui/default/syncthing/core/basenameFilter.js: -------------------------------------------------------------------------------- 1 | angular.module('syncthing.core') 2 | .filter('basename', function () { 3 | return function (input) { 4 | if (input === undefined) 5 | return ""; 6 | var parts = input.split(/[\/\\]/); 7 | if (!parts || parts.length < 1) { 8 | return input; 9 | } 10 | return parts[parts.length - 1]; 11 | }; 12 | }); 13 | -------------------------------------------------------------------------------- /gui/default/syncthing/core/binaryFilter.js: -------------------------------------------------------------------------------- 1 | angular.module('syncthing.core') 2 | .filter('binary', function () { 3 | return function (input) { 4 | return unitPrefixed(input, true); 5 | }; 6 | }); 7 | -------------------------------------------------------------------------------- /gui/default/syncthing/core/discoveryFailuresModalView.html: -------------------------------------------------------------------------------- 1 | 2 | 7 |
8 |
9 |
10 |
11 | Failure to connect to IPv6 servers is expected if there is no IPv6 connectivity. 12 |
13 |
14 |
15 |
16 | 21 |
22 | -------------------------------------------------------------------------------- /gui/default/syncthing/core/httpErrorDialogView.html: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | -------------------------------------------------------------------------------- /gui/default/syncthing/core/lastErrorComponentFilter.js: -------------------------------------------------------------------------------- 1 | angular.module('syncthing.core') 2 | .filter('lastErrorComponent', function () { 3 | return function (input) { 4 | if (input === undefined) 5 | return ""; 6 | var parts = input.split(/:\s*/); 7 | if (!parts || parts.length < 1) { 8 | return input; 9 | } 10 | return parts[parts.length - 1]; 11 | }; 12 | }); 13 | -------------------------------------------------------------------------------- /gui/default/syncthing/core/localeNumberFilter.js: -------------------------------------------------------------------------------- 1 | angular.module('syncthing.core') 2 | .filter('localeNumber', function () { 3 | return function (input) { 4 | return input.toLocaleString(); 5 | }; 6 | }); 7 | -------------------------------------------------------------------------------- /gui/default/syncthing/core/majorUpgradeModalView.html: -------------------------------------------------------------------------------- 1 | 2 | 12 | 20 | 21 | -------------------------------------------------------------------------------- /gui/default/syncthing/core/metricFilter.js: -------------------------------------------------------------------------------- 1 | angular.module('syncthing.core') 2 | .filter('metric', function () { 3 | return function (input) { 4 | return unitPrefixed(input, false); 5 | }; 6 | }); 7 | -------------------------------------------------------------------------------- /gui/default/syncthing/core/module.js: -------------------------------------------------------------------------------- 1 | angular.module('syncthing.core', []); 2 | -------------------------------------------------------------------------------- /gui/default/syncthing/core/networkErrorDialogView.html: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | -------------------------------------------------------------------------------- /gui/default/syncthing/core/notificationDirective.js: -------------------------------------------------------------------------------- 1 | angular.module('syncthing.core') 2 | .directive('notification', function () { 3 | return { 4 | restrict: 'E', 5 | scope: {}, 6 | transclude: true, 7 | template: '
', 8 | link: function (scope, elm, attrs) { 9 | scope.visible = function () { 10 | return scope.$parent.config.options.unackedNotificationIDs.indexOf(attrs.id) > -1; 11 | }; 12 | } 13 | }; 14 | }); 15 | -------------------------------------------------------------------------------- /gui/default/syncthing/core/percentFilter.js: -------------------------------------------------------------------------------- 1 | angular.module('syncthing.core') 2 | .filter('percent', function () { 3 | return function (input) { 4 | // Prevent 0.00% 5 | if (input === undefined || input < 0.01) { 6 | return 0 + '%'; 7 | } 8 | // Hard limit at two decimals 9 | if (input < 0.1) { 10 | return input.toLocaleString(undefined, { maximumFractionDigits: 2 }) + '%'; 11 | } 12 | // "Soft" limit at two significant digits (e.g. 1.2%, not 1.27%) 13 | return input.toLocaleString(undefined, { maximumSignificantDigits: 2 }) + '%'; 14 | }; 15 | }); 16 | -------------------------------------------------------------------------------- /gui/default/syncthing/core/popoverDirective.js: -------------------------------------------------------------------------------- 1 | angular.module('syncthing.core') 2 | .directive('popover', function () { 3 | return { 4 | restrict: 'A', 5 | link: function (scope, element, attributes) { 6 | $(element).popover(); 7 | } 8 | }; 9 | }); 10 | -------------------------------------------------------------------------------- /gui/default/syncthing/core/restartingDialogView.html: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | -------------------------------------------------------------------------------- /gui/default/syncthing/core/selectOnClickDirective.js: -------------------------------------------------------------------------------- 1 | angular.module('syncthing.core') 2 | .directive('selectOnClick', function ($window) { 3 | return { 4 | link: function (scope, element, attrs) { 5 | element.on('click', function () { 6 | var selection = $window.getSelection(); 7 | var range = document.createRange(); 8 | range.selectNodeContents(element[0]); 9 | selection.removeAllRanges(); 10 | selection.addRange(range); 11 | }); 12 | } 13 | }; 14 | }); 15 | -------------------------------------------------------------------------------- /gui/default/syncthing/core/shutdownDialogView.html: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | -------------------------------------------------------------------------------- /gui/default/syncthing/core/tooltipDirective.js: -------------------------------------------------------------------------------- 1 | angular.module('syncthing.core') 2 | .directive('tooltip', function () { 3 | return { 4 | restrict: 'A', 5 | link: function (scope, element, attributes) { 6 | $(element).tooltip({ 7 | html: 'true' 8 | }); 9 | } 10 | }; 11 | }); 12 | -------------------------------------------------------------------------------- /gui/default/syncthing/core/uncamelFilter.js: -------------------------------------------------------------------------------- 1 | angular.module('syncthing.core') 2 | .filter('uncamel', function () { 3 | return function (input) { 4 | input = input.replace(/(.)([A-Z][a-z]+)/g, '$1 $2').replace(/([a-z0-9])([A-Z])/g, '$1 $2'); 5 | var parts = input.split(' '); 6 | var lastPart = parts.splice(-1)[0]; 7 | switch (lastPart) { 8 | case "S": 9 | parts.push('(seconds)'); 10 | break; 11 | case "M": 12 | parts.push('(minutes)'); 13 | break; 14 | case "H": 15 | parts.push('(hours)'); 16 | break; 17 | case "Ms": 18 | parts.push('(milliseconds)'); 19 | break; 20 | default: 21 | parts.push(lastPart); 22 | break; 23 | } 24 | input = parts.join(' '); 25 | return input.charAt(0).toUpperCase() + input.slice(1); 26 | }; 27 | }); 28 | -------------------------------------------------------------------------------- /gui/default/syncthing/core/uniqueFolderDirective.js: -------------------------------------------------------------------------------- 1 | angular.module('syncthing.core') 2 | .directive('uniqueFolder', function () { 3 | return { 4 | require: 'ngModel', 5 | link: function (scope, elm, attrs, ctrl) { 6 | ctrl.$parsers.unshift(function (viewValue) { 7 | if (scope.editingExisting) { 8 | // we shouldn't validate 9 | ctrl.$setValidity('uniqueFolder', true); 10 | } else if (scope.folders.hasOwnProperty(viewValue)) { 11 | // the folder exists already 12 | ctrl.$setValidity('uniqueFolder', false); 13 | } else { 14 | // the folder is unique 15 | ctrl.$setValidity('uniqueFolder', true); 16 | } 17 | return viewValue; 18 | }); 19 | } 20 | }; 21 | }); 22 | -------------------------------------------------------------------------------- /gui/default/syncthing/core/upgradeModalView.html: -------------------------------------------------------------------------------- 1 | 2 | 10 | 18 | 19 | -------------------------------------------------------------------------------- /gui/default/syncthing/core/upgradingDialogView.html: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | -------------------------------------------------------------------------------- /gui/default/syncthing/development/logbar.html: -------------------------------------------------------------------------------- 1 | 14 | -------------------------------------------------------------------------------- /gui/default/syncthing/development/logbar.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | function intercept(method, handler) { 4 | var console = window.console; 5 | var original = console[method]; 6 | console[method] = function () { 7 | handler(method); 8 | // do sneaky stuff 9 | if (original.apply) { 10 | // Do this for normal browsers 11 | original.apply(console, arguments); 12 | } else { 13 | // Do this for IE 14 | var message = Array.prototype.slice.apply(arguments).join(' '); 15 | original(message); 16 | } 17 | }; 18 | } 19 | 20 | function handleConsoleCall(type) { 21 | var element = document.querySelector('#log_' + type); 22 | if (element) { 23 | if (!element.classList.contains("hasCount")) { 24 | element.classList.add("hasCount"); 25 | } 26 | 27 | var devTopBar = document.querySelector('#dev-top-bar'); 28 | devTopBar.style.display = 'block'; 29 | 30 | element.innerHTML = parseInt(element.innerHTML) + 1; 31 | } 32 | } 33 | 34 | if (window.console) { 35 | var methods = ['error', 'warn']; 36 | for (var i = 0; i < methods.length; i++) { 37 | intercept(methods[i], handleConsoleCall); 38 | } 39 | } -------------------------------------------------------------------------------- /gui/default/syncthing/device/idqrModalView.html: -------------------------------------------------------------------------------- 1 | 2 | 6 | 11 | 12 | -------------------------------------------------------------------------------- /gui/default/syncthing/device/removeDeviceDialogView.html: -------------------------------------------------------------------------------- 1 | 2 | 7 | 15 | 16 | -------------------------------------------------------------------------------- /gui/default/syncthing/folder/removeFolderDialogView.html: -------------------------------------------------------------------------------- 1 | 2 | 10 | 18 | 19 | -------------------------------------------------------------------------------- /gui/default/syncthing/folder/restoreVersionsConfirmation.html: -------------------------------------------------------------------------------- 1 | 2 | 7 | 15 | 16 | -------------------------------------------------------------------------------- /gui/default/syncthing/folder/restoreVersionsMassActions.html: -------------------------------------------------------------------------------- 1 | 12 | -------------------------------------------------------------------------------- /gui/default/syncthing/folder/restoreVersionsVersionSelector.html: -------------------------------------------------------------------------------- 1 | 18 | -------------------------------------------------------------------------------- /gui/default/syncthing/settings/discardChangesConfirmation.html: -------------------------------------------------------------------------------- 1 | 2 | 7 | 16 | 17 | -------------------------------------------------------------------------------- /gui/default/vendor/angular/README.md: -------------------------------------------------------------------------------- 1 | The files contained herein are: 2 | 3 | - angular 1.3.20 4 | - angular-translate 2.9.0.1 5 | - angular-translate-loader-static-files 2.11.0 6 | - angular-dirPagination 759009c -------------------------------------------------------------------------------- /gui/default/vendor/angular/angular-dirPagination.js.LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2014 Michael Bromley 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /gui/default/vendor/angular/angular-sanitize.js.LICENSE: -------------------------------------------------------------------------------- 1 | (c) 2010-2014 Google, Inc. http://angularjs.org 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /gui/default/vendor/angular/angular-translate-loader-static-files.js.LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 The angular-translate team, Pascal Precht; Licensed MIT 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /gui/default/vendor/angular/angular-translate.js.LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 The angular-translate team, Pascal Precht; Licensed MIT 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /gui/default/vendor/angular/angular.js.LICENSE: -------------------------------------------------------------------------------- 1 | (c) 2010-2014 Google, Inc. http://angularjs.org 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /gui/default/vendor/bootstrap/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2011-2016 Twitter, Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /gui/default/vendor/daterangepicker/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012-2018 Dan Grossman 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /gui/default/vendor/fancytree/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright 2008-2018 Martin Wendt, 2 | http://wwWendt.de/ 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining 5 | a copy of this software and associated documentation files (the 6 | "Software"), to deal in the Software without restriction, including 7 | without limitation the rights to use, copy, modify, merge, publish, 8 | distribute, sublicense, and/or sell copies of the Software, and to 9 | permit persons to whom the Software is furnished to do so, subject to 10 | the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /gui/default/vendor/fancytree/skin-lion/icons.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isyncthing/syncthing/d0ccea04045e9b154970a92f8eafa0c76cb0f2e2/gui/default/vendor/fancytree/skin-lion/icons.gif -------------------------------------------------------------------------------- /gui/default/vendor/fancytree/skin-lion/loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isyncthing/syncthing/d0ccea04045e9b154970a92f8eafa0c76cb0f2e2/gui/default/vendor/fancytree/skin-lion/loading.gif -------------------------------------------------------------------------------- /gui/default/vendor/fancytree/skin-lion/vline.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isyncthing/syncthing/d0ccea04045e9b154970a92f8eafa0c76cb0f2e2/gui/default/vendor/fancytree/skin-lion/vline.gif -------------------------------------------------------------------------------- /gui/default/vendor/fork-awesome/fonts/forkawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isyncthing/syncthing/d0ccea04045e9b154970a92f8eafa0c76cb0f2e2/gui/default/vendor/fork-awesome/fonts/forkawesome-webfont.eot -------------------------------------------------------------------------------- /gui/default/vendor/fork-awesome/fonts/forkawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isyncthing/syncthing/d0ccea04045e9b154970a92f8eafa0c76cb0f2e2/gui/default/vendor/fork-awesome/fonts/forkawesome-webfont.ttf -------------------------------------------------------------------------------- /gui/default/vendor/fork-awesome/fonts/forkawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isyncthing/syncthing/d0ccea04045e9b154970a92f8eafa0c76cb0f2e2/gui/default/vendor/fork-awesome/fonts/forkawesome-webfont.woff -------------------------------------------------------------------------------- /gui/default/vendor/fork-awesome/fonts/forkawesome-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isyncthing/syncthing/d0ccea04045e9b154970a92f8eafa0c76cb0f2e2/gui/default/vendor/fork-awesome/fonts/forkawesome-webfont.woff2 -------------------------------------------------------------------------------- /gui/default/vendor/jquery/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright jQuery Foundation and other contributors 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /gui/default/vendor/moment/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) JS Foundation and other contributors 2 | 3 | Permission is hereby granted, free of charge, to any person 4 | obtaining a copy of this software and associated documentation 5 | files (the "Software"), to deal in the Software without 6 | restriction, including without limitation the rights to use, 7 | copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the 9 | Software is furnished to do so, subject to the following 10 | conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 17 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /gui/light/assets/css/theme.css: -------------------------------------------------------------------------------- 1 | /* 2 | // Copyright (C) 2016 The Syncthing Authors. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla Public 5 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 6 | // You can obtain one at https://mozilla.org/MPL/2.0/. 7 | 8 | */ 9 | 10 | .panel-progress { 11 | background: #3498db; 12 | } 13 | 14 | .identicon rect { 15 | fill: #333; 16 | } 17 | 18 | .panel-warning .identicon rect { 19 | fill: #fff; 20 | } 21 | 22 | .li-column { 23 | background-color: rgb(236, 240, 241); 24 | border-radius: 3px; 25 | } 26 | 27 | .panel-heading:hover, .panel-heading:focus { 28 | text-decoration: none; 29 | } 30 | 31 | .fancytree-ext-filter-hide tr.fancytree-submatch span.fancytree-title, 32 | .fancytree-ext-filter-hide span.fancytree-node.fancytree-submatch span.fancytree-title { 33 | color: black !important; 34 | font-weight: lighter !important; 35 | } 36 | -------------------------------------------------------------------------------- /lib/api/.gitignore: -------------------------------------------------------------------------------- 1 | /testdata/config/csrftokens.txt 2 | -------------------------------------------------------------------------------- /lib/api/api_auth_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package api 8 | 9 | import ( 10 | "testing" 11 | 12 | "golang.org/x/crypto/bcrypt" 13 | ) 14 | 15 | var passwordHashBytes []byte 16 | 17 | func init() { 18 | passwordHashBytes, _ = bcrypt.GenerateFromPassword([]byte("pass"), 0) 19 | } 20 | 21 | func TestStaticAuthOK(t *testing.T) { 22 | t.Parallel() 23 | 24 | ok := authStatic("user", "pass", "user", string(passwordHashBytes)) 25 | if !ok { 26 | t.Fatalf("should pass auth") 27 | } 28 | } 29 | 30 | func TestSimpleAuthUsernameFail(t *testing.T) { 31 | t.Parallel() 32 | 33 | ok := authStatic("userWRONG", "pass", "user", string(passwordHashBytes)) 34 | if ok { 35 | t.Fatalf("should fail auth") 36 | } 37 | } 38 | 39 | func TestStaticAuthPasswordFail(t *testing.T) { 40 | t.Parallel() 41 | 42 | ok := authStatic("user", "passWRONG", "user", string(passwordHashBytes)) 43 | if ok { 44 | t.Fatalf("should fail auth") 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /lib/api/auto/.gitignore: -------------------------------------------------------------------------------- 1 | gui.files.go 2 | -------------------------------------------------------------------------------- /lib/api/auto/auto_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package auto_test 8 | 9 | import ( 10 | "bytes" 11 | "compress/gzip" 12 | "io/ioutil" 13 | "strings" 14 | "testing" 15 | 16 | "github.com/syncthing/syncthing/lib/api/auto" 17 | ) 18 | 19 | func TestAssets(t *testing.T) { 20 | assets := auto.Assets() 21 | idx, ok := assets["default/index.html"] 22 | if !ok { 23 | t.Fatal("No index.html in compiled in assets") 24 | } 25 | if !idx.Gzipped { 26 | t.Fatal("default/index.html should be compressed") 27 | } 28 | 29 | var gr *gzip.Reader 30 | gr, _ = gzip.NewReader(strings.NewReader(idx.Content)) 31 | html, _ := ioutil.ReadAll(gr) 32 | 33 | if !bytes.Contains(html, []byte(" 2 | 3 |
4 |
5 | 6 | 7 | 8 |
dynamic
9 |
10 | 11 | -------------------------------------------------------------------------------- /lib/config/testdata/deviceaddressesstatic.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 |
192.0.2.1
4 |
192.0.2.2
5 |
6 | 7 |
192.0.2.3:6070
8 |
[2001:db8::42]:4242
9 |
10 | 11 |
[2001:db8::44]:4444
12 |
192.0.2.4:6090
13 |
14 |
15 | -------------------------------------------------------------------------------- /lib/config/testdata/devicecompression.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /lib/config/testdata/dupdevices.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 |
192.0.2.1
4 |
192.0.2.2
5 |
6 | 7 |
192.0.2.3:6070
8 |
[2001:db8::42]:4242
9 |
10 | 11 |
[2001:db8::44]:4444
12 |
192.0.2.4:6090
13 |
14 | 15 | 16 |
192.0.2.5
17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | -------------------------------------------------------------------------------- /lib/config/testdata/dupfolders.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /lib/config/testdata/ignoreddevices.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 |
dynamic
4 |
5 | 6 |
dynamic
7 |
8 | 9 | 10 |
11 | -------------------------------------------------------------------------------- /lib/config/testdata/ignoredfolders.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /lib/config/testdata/issue-1262.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /lib/config/testdata/issue-1750.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | :23000 4 | :23001 5 | udp4://syncthing.nym.se:22026 6 | udp4://syncthing.nym.se:22027 7 | 8 | 9 | -------------------------------------------------------------------------------- /lib/config/testdata/largeinterval.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /lib/config/testdata/nolistenaddress.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /lib/config/testdata/nopath.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /lib/config/testdata/pullorder.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | random 6 | 7 | 8 | alphabetic 9 | 10 | 11 | whatever 12 | 13 | 14 | smallestFirst 15 | 16 | 17 | largestFirst 18 | 19 | 20 | oldestFirst 21 | 22 | 23 | newestFirst 24 | 25 | 26 | -------------------------------------------------------------------------------- /lib/config/testdata/v22.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | basic 4 | 5 | 6 | 1 7 | -1 8 | true 9 | 10 | 11 |
tcp://a
12 |
13 | 14 |
tcp://b
15 |
16 |
17 | -------------------------------------------------------------------------------- /lib/config/testdata/v5.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |
a
8 |
9 | 10 |
b
11 |
12 |
13 | -------------------------------------------------------------------------------- /lib/config/testdata/versioningconfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /lib/config/tuning.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package config 8 | 9 | func (t Tuning) String() string { 10 | switch t { 11 | case TuningAuto: 12 | return "auto" 13 | case TuningSmall: 14 | return "small" 15 | case TuningLarge: 16 | return "large" 17 | default: 18 | return "unknown" 19 | } 20 | } 21 | 22 | func (t Tuning) MarshalText() ([]byte, error) { 23 | return []byte(t.String()), nil 24 | } 25 | 26 | func (t *Tuning) UnmarshalText(bs []byte) error { 27 | switch string(bs) { 28 | case "auto": 29 | *t = TuningAuto 30 | case "small": 31 | *t = TuningSmall 32 | case "large": 33 | *t = TuningLarge 34 | default: 35 | *t = TuningAuto 36 | } 37 | return nil 38 | } 39 | -------------------------------------------------------------------------------- /lib/config/tuning_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package config_test 8 | 9 | import ( 10 | "testing" 11 | 12 | "github.com/syncthing/syncthing/lib/config" 13 | "github.com/syncthing/syncthing/lib/db/backend" 14 | ) 15 | 16 | func TestTuningMatches(t *testing.T) { 17 | if int(config.TuningAuto) != int(backend.TuningAuto) { 18 | t.Error("mismatch for TuningAuto") 19 | } 20 | if int(config.TuningSmall) != int(backend.TuningSmall) { 21 | t.Error("mismatch for TuningSmall") 22 | } 23 | if int(config.TuningLarge) != int(backend.TuningLarge) { 24 | t.Error("mismatch for TuningLarge") 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /lib/connections/debug.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package connections 8 | 9 | import ( 10 | "github.com/syncthing/syncthing/lib/logger" 11 | ) 12 | 13 | var ( 14 | l = logger.DefaultLogger.NewFacility("connections", "Connection handling") 15 | ) 16 | -------------------------------------------------------------------------------- /lib/connections/deprecated.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package connections 8 | 9 | import "github.com/syncthing/syncthing/lib/config" 10 | 11 | // deprecatedListener is never valid 12 | type deprecatedListener struct { 13 | listenerFactory 14 | } 15 | 16 | func (deprecatedListener) Valid(_ config.Configuration) error { 17 | return errDeprecated 18 | } 19 | 20 | // deprecatedDialer is never valid 21 | type deprecatedDialer struct { 22 | dialerFactory 23 | } 24 | 25 | func (deprecatedDialer) Valid(_ config.Configuration) error { 26 | return errDeprecated 27 | } 28 | 29 | func init() { 30 | listeners["kcp"] = deprecatedListener{} 31 | listeners["kcp4"] = deprecatedListener{} 32 | listeners["kcp6"] = deprecatedListener{} 33 | dialers["kcp"] = deprecatedDialer{} 34 | dialers["kcp4"] = deprecatedDialer{} 35 | dialers["kcp6"] = deprecatedDialer{} 36 | } 37 | -------------------------------------------------------------------------------- /lib/db/.gitignore: -------------------------------------------------------------------------------- 1 | !*.zip 2 | testdata/*.db 3 | -------------------------------------------------------------------------------- /lib/db/backend/badger_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package backend 8 | 9 | import "testing" 10 | 11 | func TestCommonPrefix(t *testing.T) { 12 | cases := []struct { 13 | a string 14 | b string 15 | common string 16 | }{ 17 | {"", "", ""}, 18 | {"a", "b", ""}, 19 | {"aa", "ab", "a"}, 20 | {"aa", "a", "a"}, 21 | {"a", "aa", "a"}, 22 | {"aabab", "ab", "a"}, 23 | {"ab", "aabab", "a"}, 24 | {"abac", "ababab", "aba"}, 25 | {"ababab", "abac", "aba"}, 26 | } 27 | 28 | for _, tc := range cases { 29 | pref := string(commonPrefix([]byte(tc.a), []byte(tc.b))) 30 | if pref != tc.common { 31 | t.Errorf("commonPrefix(%q, %q) => %q, expected %q", tc.a, tc.b, pref, tc.common) 32 | } 33 | } 34 | } 35 | 36 | func TestBadgerBackendBehavior(t *testing.T) { 37 | testBackendBehavior(t, OpenBadgerMemory) 38 | } 39 | -------------------------------------------------------------------------------- /lib/db/backend/debug.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package backend 8 | 9 | import ( 10 | "github.com/syncthing/syncthing/lib/logger" 11 | ) 12 | 13 | var ( 14 | l = logger.DefaultLogger.NewFacility("backend", "The database backend") 15 | ) 16 | -------------------------------------------------------------------------------- /lib/db/backend/leveldb_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package backend 8 | 9 | import "testing" 10 | 11 | func TestLevelDBBackendBehavior(t *testing.T) { 12 | testBackendBehavior(t, OpenLevelDBMemory) 13 | } 14 | -------------------------------------------------------------------------------- /lib/db/debug.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package db 8 | 9 | import ( 10 | "github.com/syncthing/syncthing/lib/logger" 11 | ) 12 | 13 | var ( 14 | l = logger.DefaultLogger.NewFacility("db", "The database layer") 15 | ) 16 | 17 | func shouldDebug() bool { 18 | return l.ShouldDebug("db") 19 | } 20 | -------------------------------------------------------------------------------- /lib/db/testdata/.gitignore: -------------------------------------------------------------------------------- 1 | index.db 2 | -------------------------------------------------------------------------------- /lib/db/testdata/v0.14.48-ignoredfiles.db.jsons: -------------------------------------------------------------------------------- 1 | {"k":"AAAAAAAAAAABYmFy","v":"CgNiYXJKBwoFCAEQ6QdQAg=="} 2 | {"k":"AAAAAAAAAAABZm9v","v":"CgNmb284AUoHCgUIARDoB1AB"} 3 | {"k":"AAAAAAAAAAACYmF6","v":"CgNiYXo4AUoHCgUIKhDoBw=="} 4 | {"k":"AAAAAAAAAAACcXV1eA==","v":"CgRxdXV4SgcKBQgqEOoH"} 5 | {"k":"AQAAAABiYXI=","v":"CisKBwoFCAEQ6QcSIP//////////////////////////////////////////"} 6 | {"k":"AQAAAABiYXo=","v":"Ci0KBwoFCCoQ6AcSICoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGAE="} 7 | {"k":"AQAAAABmb28=","v":"Ci0KBwoFCAEQ6AcSIP//////////////////////////////////////////GAE="} 8 | {"k":"AQAAAABxdXV4","v":"CisKBwoFCCoQ6gcSICoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"} 9 | {"k":"BgAAAAAAAAAA","v":"dGVzdA=="} 10 | {"k":"BwAAAAAAAAAA","v":""} 11 | {"k":"BwAAAAEAAAAA","v":"//////////////////////////////////////////8="} 12 | {"k":"BwAAAAIAAAAA","v":"KgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="} 13 | {"k":"CQAAAAA=","v":"CicIATACigEg//////////////////////////////////////////8KJwgCMAKKASD4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+Pj4+AolCAGKASAqAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABCoudnCuM+vlxU="} 14 | {"k":"CwAAAAAAAAAAAAAAAQ==","v":"AAAAAAAAAAABZm9v"} 15 | {"k":"CwAAAAAAAAAAAAAAAg==","v":"AAAAAAAAAAABYmFy"} 16 | -------------------------------------------------------------------------------- /lib/dialer/control_unsupported.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | // +build solaris 8 | 9 | package dialer 10 | 11 | import "syscall" 12 | 13 | var SupportsReusePort = false 14 | 15 | func ReusePortControl(_, _ string, _ syscall.RawConn) error { 16 | return nil 17 | } 18 | -------------------------------------------------------------------------------- /lib/dialer/control_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | // +build windows 8 | 9 | package dialer 10 | 11 | import ( 12 | "syscall" 13 | ) 14 | 15 | var SupportsReusePort = true 16 | 17 | func ReusePortControl(_, _ string, c syscall.RawConn) error { 18 | var opErr error 19 | err := c.Control(func(fd uintptr) { 20 | // On Windows, SO_REUSEADDR is equivalent to SO_REUSEPORT on Linux. 21 | opErr = syscall.SetsockoptInt(syscall.Handle(fd), syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1) 22 | }) 23 | if err != nil { 24 | l.Debugln("ReusePortControl", err) 25 | return err 26 | } 27 | if opErr != nil { 28 | l.Debugln("ReusePortControl", opErr) 29 | } 30 | return opErr 31 | } 32 | -------------------------------------------------------------------------------- /lib/dialer/debug.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package dialer 8 | 9 | import ( 10 | "os" 11 | "strings" 12 | 13 | "github.com/syncthing/syncthing/lib/logger" 14 | ) 15 | 16 | var ( 17 | l = logger.DefaultLogger.NewFacility("dialer", "Dialing connections") 18 | // To run before init() of other files that log on init. 19 | _ = func() error { 20 | l.SetDebug("dialer", strings.Contains(os.Getenv("STTRACE"), "dialer") || os.Getenv("STTRACE") == "all") 21 | return nil 22 | }() 23 | ) 24 | -------------------------------------------------------------------------------- /lib/dialer/empty_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | // The existence of this file means we get 0% test coverage rather than no 8 | // test coverage at all. Remove when implementing an actual test. 9 | 10 | package dialer 11 | -------------------------------------------------------------------------------- /lib/discover/debug.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package discover 8 | 9 | import ( 10 | "github.com/syncthing/syncthing/lib/logger" 11 | ) 12 | 13 | var ( 14 | l = logger.DefaultLogger.NewFacility("discover", "Remote device discovery") 15 | ) 16 | -------------------------------------------------------------------------------- /lib/discover/local.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package discover; 4 | 5 | import "repos/protobuf/gogoproto/gogo.proto"; 6 | 7 | option (gogoproto.goproto_getters_all) = false; 8 | option (gogoproto.sizer_all) = false; 9 | option (gogoproto.protosizer_all) = true; 10 | option (gogoproto.goproto_unkeyed_all) = false; 11 | option (gogoproto.goproto_unrecognized_all) = false; 12 | option (gogoproto.goproto_sizecache_all) = false; 13 | 14 | message Announce { 15 | bytes id = 1 [(gogoproto.customname) = "ID", (gogoproto.customtype) = "github.com/syncthing/syncthing/lib/protocol.DeviceID", (gogoproto.nullable) = false]; 16 | repeated string addresses = 2; 17 | int64 instance_id = 3 [(gogoproto.customname) = "InstanceID"]; 18 | } 19 | -------------------------------------------------------------------------------- /lib/events/debug.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package events 8 | 9 | import ( 10 | liblogger "github.com/syncthing/syncthing/lib/logger" 11 | ) 12 | 13 | var ( 14 | dl = liblogger.DefaultLogger.NewFacility("events", "Event generation and logging") 15 | ) 16 | -------------------------------------------------------------------------------- /lib/fs/basicfs_fileinfo_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2017 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | // +build !windows 8 | 9 | package fs 10 | 11 | import ( 12 | "os" 13 | "syscall" 14 | ) 15 | 16 | func (e basicFileInfo) Mode() FileMode { 17 | return FileMode(e.FileInfo.Mode()) 18 | } 19 | 20 | func (e basicFileInfo) Owner() int { 21 | if st, ok := e.Sys().(*syscall.Stat_t); ok { 22 | return int(st.Uid) 23 | } 24 | return -1 25 | } 26 | 27 | func (e basicFileInfo) Group() int { 28 | if st, ok := e.Sys().(*syscall.Stat_t); ok { 29 | return int(st.Gid) 30 | } 31 | return -1 32 | } 33 | 34 | // fileStat converts e to os.FileInfo that is suitable 35 | // to be passed to os.SameFile. Non-trivial on Windows. 36 | func (e *basicFileInfo) osFileInfo() os.FileInfo { 37 | return e.FileInfo 38 | } 39 | -------------------------------------------------------------------------------- /lib/fs/basicfs_lstat_broken.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | // +build linux android 8 | 9 | package fs 10 | 11 | import ( 12 | "os" 13 | "syscall" 14 | "time" 15 | ) 16 | 17 | // Lstat is like os.Lstat, except lobotomized for Android. See 18 | // https://forum.syncthing.net/t/2395 19 | func (*BasicFilesystem) underlyingLstat(name string) (fi os.FileInfo, err error) { 20 | for i := 0; i < 10; i++ { // We have to draw the line somewhere 21 | fi, err = os.Lstat(name) 22 | if err, ok := err.(*os.PathError); ok && err.Err == syscall.EINTR { 23 | time.Sleep(time.Duration(i+1) * time.Millisecond) 24 | continue 25 | } 26 | return 27 | } 28 | return 29 | } 30 | -------------------------------------------------------------------------------- /lib/fs/basicfs_lstat_regular.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | // +build !linux,!android,!windows 8 | 9 | package fs 10 | 11 | import "os" 12 | 13 | func (*BasicFilesystem) underlyingLstat(name string) (fi os.FileInfo, err error) { 14 | return os.Lstat(name) 15 | } 16 | -------------------------------------------------------------------------------- /lib/fs/basicfs_watch_errors_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at http://mozilla.org/MPL/2.0/. 6 | 7 | // +build linux 8 | 9 | package fs 10 | 11 | import ( 12 | "os" 13 | "syscall" 14 | ) 15 | 16 | func reachedMaxUserWatches(err error) bool { 17 | if pathErr, ok := err.(*os.PathError); ok { 18 | if errno, ok := pathErr.Err.(syscall.Errno); ok { 19 | return errno == 24 || errno == 28 20 | } 21 | } 22 | return false 23 | } 24 | -------------------------------------------------------------------------------- /lib/fs/basicfs_watch_errors_others.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at http://mozilla.org/MPL/2.0/. 6 | 7 | // +build !linux 8 | 9 | package fs 10 | 11 | func reachedMaxUserWatches(err error) bool { 12 | return false 13 | } 14 | -------------------------------------------------------------------------------- /lib/fs/basicfs_watch_eventtypes_fen.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2017 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at http://mozilla.org/MPL/2.0/. 6 | 7 | // +build solaris,cgo 8 | 9 | package fs 10 | 11 | import "github.com/syncthing/notify" 12 | 13 | const ( 14 | subEventMask = notify.Create | notify.FileModified | notify.FileRenameFrom | notify.FileDelete | notify.FileRenameTo 15 | permEventMask = notify.FileAttrib 16 | rmEventMask = notify.FileDelete | notify.FileRenameFrom 17 | ) 18 | -------------------------------------------------------------------------------- /lib/fs/basicfs_watch_eventtypes_inotify.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2017 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at http://mozilla.org/MPL/2.0/. 6 | 7 | // +build linux 8 | 9 | package fs 10 | 11 | import "github.com/syncthing/notify" 12 | 13 | const ( 14 | subEventMask = notify.InCreate | notify.InMovedTo | notify.InDelete | notify.InDeleteSelf | notify.InModify | notify.InMovedFrom | notify.InMoveSelf 15 | permEventMask = notify.InAttrib 16 | rmEventMask = notify.InDelete | notify.InDeleteSelf | notify.InMovedFrom | notify.InMoveSelf 17 | ) 18 | -------------------------------------------------------------------------------- /lib/fs/basicfs_watch_eventtypes_kqueue.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2017 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at http://mozilla.org/MPL/2.0/. 6 | 7 | // +build dragonfly freebsd netbsd openbsd 8 | 9 | package fs 10 | 11 | import "github.com/syncthing/notify" 12 | 13 | const ( 14 | // Platform independent notify.Create is required, as kqueue does not have 15 | // any event signalling file creation, but notify does generate those internally. 16 | subEventMask = notify.NoteDelete | notify.NoteWrite | notify.NoteRename | notify.Create 17 | permEventMask = notify.NoteAttrib | notify.NoteExtend 18 | rmEventMask = notify.NoteDelete | notify.NoteRename 19 | ) 20 | -------------------------------------------------------------------------------- /lib/fs/basicfs_watch_eventtypes_other.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2017 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at http://mozilla.org/MPL/2.0/. 6 | 7 | // +build !linux,!windows,!dragonfly,!freebsd,!netbsd,!openbsd,!solaris 8 | // +build !darwin darwin,cgo 9 | 10 | // Catch all platforms that are not specifically handled to use the generic 11 | // event types. 12 | 13 | package fs 14 | 15 | import "github.com/syncthing/notify" 16 | 17 | const ( 18 | subEventMask = notify.All 19 | permEventMask = 0 20 | rmEventMask = notify.Remove | notify.Rename 21 | ) 22 | -------------------------------------------------------------------------------- /lib/fs/basicfs_watch_eventtypes_readdcw.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2017 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at http://mozilla.org/MPL/2.0/. 6 | 7 | // +build windows 8 | 9 | package fs 10 | 11 | import "github.com/syncthing/notify" 12 | 13 | const ( 14 | subEventMask = notify.FileNotifyChangeFileName | notify.FileNotifyChangeDirName | notify.FileNotifyChangeSize | notify.FileNotifyChangeCreation | notify.FileNotifyChangeLastWrite 15 | permEventMask = notify.FileNotifyChangeAttributes 16 | rmEventMask = notify.FileActionRemoved | notify.FileActionRenamedOldName 17 | ) 18 | -------------------------------------------------------------------------------- /lib/fs/basicfs_watch_unsupported.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at http://mozilla.org/MPL/2.0/. 6 | 7 | // +build solaris,!cgo darwin,!cgo 8 | 9 | package fs 10 | 11 | import "context" 12 | 13 | func (f *BasicFilesystem) Watch(name string, ignore Matcher, ctx context.Context, ignorePerms bool) (<-chan Event, <-chan error, error) { 14 | return nil, nil, ErrWatchNotSupported 15 | } 16 | -------------------------------------------------------------------------------- /lib/fs/debug.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package fs 8 | 9 | import ( 10 | "github.com/syncthing/syncthing/lib/logger" 11 | ) 12 | 13 | var ( 14 | l = logger.DefaultLogger.NewFacility("fs", "Filesystem access") 15 | ) 16 | 17 | func init() { 18 | logger.DefaultLogger.NewFacility("walkfs", "Filesystem access while walking") 19 | if logger.DefaultLogger.ShouldDebug("walkfs") { 20 | l.SetDebug("fs", true) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /lib/fs/debug_symlink_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2017 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | // +build !windows 8 | 9 | package fs 10 | 11 | import ( 12 | "os" 13 | "path/filepath" 14 | ) 15 | 16 | // DebugSymlinkForTestsOnly is not and should not be used in Syncthing code, 17 | // hence the cumbersome name to make it obvious if this ever leaks. Its 18 | // reason for existence is the Windows version, which allows creating 19 | // symlinks when non-elevated. 20 | func DebugSymlinkForTestsOnly(oldFs, newFs Filesystem, oldname, newname string) error { 21 | if caseFs, ok := unwrapFilesystem(newFs).(*caseFilesystem); ok { 22 | if err := caseFs.checkCase(newname); err != nil { 23 | return err 24 | } 25 | caseFs.dropCache() 26 | } 27 | if err := os.Symlink(filepath.Join(oldFs.URI(), oldname), filepath.Join(newFs.URI(), newname)); err != nil { 28 | return err 29 | } 30 | return nil 31 | } 32 | -------------------------------------------------------------------------------- /lib/fs/filesystem_copy_range_allwithfallback.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package fs 8 | 9 | func init() { 10 | registerCopyRangeImplementation(CopyRangeMethodAllWithFallback, copyRangeAllWithFallback) 11 | } 12 | 13 | func copyRangeAllWithFallback(src, dst File, srcOffset, dstOffset, size int64) error { 14 | var err error 15 | for _, method := range []CopyRangeMethod{CopyRangeMethodIoctl, CopyRangeMethodCopyFileRange, CopyRangeMethodSendFile, CopyRangeMethodDuplicateExtents, CopyRangeMethodStandard} { 16 | if err = CopyRange(method, src, dst, srcOffset, dstOffset, size); err == nil { 17 | return nil 18 | } 19 | } 20 | return err 21 | } 22 | -------------------------------------------------------------------------------- /lib/fs/filesystem_copy_range_standard.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package fs 8 | 9 | import ( 10 | "io" 11 | ) 12 | 13 | func init() { 14 | registerCopyRangeImplementation(CopyRangeMethodStandard, copyRangeStandard) 15 | } 16 | 17 | func copyRangeStandard(src, dst File, srcOffset, dstOffset, size int64) error { 18 | const bufSize = 4 << 20 19 | 20 | buf := make([]byte, bufSize) 21 | 22 | // TODO: In go 1.15, we should use file.ReadFrom that uses copy_file_range underneath. 23 | 24 | // ReadAt and WriteAt does not modify the position of the file. 25 | for size > 0 { 26 | if size < bufSize { 27 | buf = buf[:size] 28 | } 29 | n, err := src.ReadAt(buf, srcOffset) 30 | if err != nil { 31 | if err == io.EOF { 32 | return io.ErrUnexpectedEOF 33 | } 34 | return err 35 | } 36 | if _, err = dst.WriteAt(buf[:n], dstOffset); err != nil { 37 | return err 38 | } 39 | srcOffset += int64(n) 40 | dstOffset += int64(n) 41 | size -= int64(n) 42 | } 43 | 44 | return nil 45 | } 46 | -------------------------------------------------------------------------------- /lib/fs/folding.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2017 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package fs 8 | 9 | import ( 10 | "strings" 11 | "unicode" 12 | "unicode/utf8" 13 | ) 14 | 15 | func UnicodeLowercase(s string) string { 16 | i := firstCaseChange(s) 17 | if i == -1 { 18 | return s 19 | } 20 | 21 | var rs strings.Builder 22 | // WriteRune always reserves utf8.UTFMax bytes for non-ASCII runes, 23 | // even if it doesn't need all that space. Overallocate now to prevent 24 | // it from ever triggering a reallocation. 25 | rs.Grow(utf8.UTFMax - 1 + len(s)) 26 | rs.WriteString(s[:i]) 27 | 28 | for _, r := range s[i:] { 29 | rs.WriteRune(unicode.ToLower(unicode.ToUpper(r))) 30 | } 31 | return rs.String() 32 | } 33 | 34 | // Byte index of the first rune r s.t. lower(upper(r)) != r. 35 | func firstCaseChange(s string) int { 36 | for i, r := range s { 37 | if r <= unicode.MaxASCII && (r < 'A' || r > 'Z') { 38 | continue 39 | } 40 | if unicode.ToLower(unicode.ToUpper(r)) != r { 41 | return i 42 | } 43 | } 44 | return -1 45 | } 46 | -------------------------------------------------------------------------------- /lib/fs/tempname_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package fs 8 | 9 | import ( 10 | "strings" 11 | "testing" 12 | ) 13 | 14 | func TestLongTempFilename(t *testing.T) { 15 | filename := "" 16 | for i := 0; i < 300; i++ { 17 | filename += "l" 18 | } 19 | tFile := TempName(filename) 20 | if len(tFile) < 10 || len(tFile) > 200 { 21 | t.Fatal("Invalid long filename") 22 | } 23 | if !strings.HasSuffix(TempName("short"), "short.tmp") { 24 | t.Fatal("Invalid short filename", TempName("short")) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /lib/fs/types.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package fs 8 | 9 | func (t FilesystemType) String() string { 10 | switch t { 11 | case FilesystemTypeBasic: 12 | return "basic" 13 | case FilesystemTypeFake: 14 | return "fake" 15 | default: 16 | return "unknown" 17 | } 18 | } 19 | 20 | func (t FilesystemType) MarshalText() ([]byte, error) { 21 | return []byte(t.String()), nil 22 | } 23 | 24 | func (t *FilesystemType) UnmarshalText(bs []byte) error { 25 | switch string(bs) { 26 | case "basic": 27 | *t = FilesystemTypeBasic 28 | case "fake": 29 | *t = FilesystemTypeFake 30 | default: 31 | *t = FilesystemTypeBasic 32 | } 33 | return nil 34 | } 35 | -------------------------------------------------------------------------------- /lib/ignore/testdata/.stignore: -------------------------------------------------------------------------------- 1 | #include excludes 2 | 3 | bfile 4 | dir1/cfile 5 | **/efile 6 | /ffile 7 | lost+found 8 | -------------------------------------------------------------------------------- /lib/ignore/testdata/dir3/cfile: -------------------------------------------------------------------------------- 1 | baz 2 | -------------------------------------------------------------------------------- /lib/ignore/testdata/dir3/dfile: -------------------------------------------------------------------------------- 1 | quux 2 | -------------------------------------------------------------------------------- /lib/ignore/testdata/excludes: -------------------------------------------------------------------------------- 1 | dir2/dfile 2 | #include further-excludes 3 | -------------------------------------------------------------------------------- /lib/ignore/testdata/further-excludes: -------------------------------------------------------------------------------- 1 | dir3 2 | -------------------------------------------------------------------------------- /lib/logger/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2013 Jakob Borg 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 7 | of the Software, and to permit persons to whom the Software is furnished to do 8 | so, subject to the following conditions: 9 | 10 | - The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /lib/model/debug.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package model 8 | 9 | import ( 10 | "github.com/syncthing/syncthing/lib/logger" 11 | ) 12 | 13 | var ( 14 | l = logger.DefaultLogger.NewFacility("model", "The root hub") 15 | ) 16 | 17 | func shouldDebug() bool { 18 | return l.ShouldDebug("model") 19 | } 20 | -------------------------------------------------------------------------------- /lib/model/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | // Package model implements folder abstraction and file pulling mechanisms 8 | package model 9 | -------------------------------------------------------------------------------- /lib/model/sharedpullerstate_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package model 8 | 9 | import ( 10 | "os" 11 | "testing" 12 | 13 | "github.com/syncthing/syncthing/lib/fs" 14 | "github.com/syncthing/syncthing/lib/sync" 15 | ) 16 | 17 | // Test creating temporary file inside read-only directory 18 | func TestReadOnlyDir(t *testing.T) { 19 | // Create a read only directory, clean it up afterwards. 20 | tmpDir := createTmpDir() 21 | defer os.RemoveAll(tmpDir) 22 | if err := os.Chmod(tmpDir, 0555); err != nil { 23 | t.Fatal(err) 24 | } 25 | defer os.Chmod(tmpDir, 0755) 26 | 27 | s := sharedPullerState{ 28 | fs: fs.NewFilesystem(fs.FilesystemTypeBasic, tmpDir), 29 | tempName: ".temp_name", 30 | mut: sync.NewRWMutex(), 31 | } 32 | 33 | fd, err := s.tempFile() 34 | if err != nil { 35 | t.Fatal(err) 36 | } 37 | if fd == nil { 38 | t.Fatal("Unexpected nil fd") 39 | } 40 | 41 | s.fail(nil) 42 | s.finalClose() 43 | } 44 | -------------------------------------------------------------------------------- /lib/model/testdata/bar: -------------------------------------------------------------------------------- 1 | foobarbaz 2 | -------------------------------------------------------------------------------- /lib/model/testdata/baz/quux: -------------------------------------------------------------------------------- 1 | baazquux 2 | -------------------------------------------------------------------------------- /lib/model/testdata/empty: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isyncthing/syncthing/d0ccea04045e9b154970a92f8eafa0c76cb0f2e2/lib/model/testdata/empty -------------------------------------------------------------------------------- /lib/model/testdata/foo: -------------------------------------------------------------------------------- 1 | foobar 2 | -------------------------------------------------------------------------------- /lib/model/testdata/tmpfile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isyncthing/syncthing/d0ccea04045e9b154970a92f8eafa0c76cb0f2e2/lib/model/testdata/tmpfile -------------------------------------------------------------------------------- /lib/nat/debug.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package nat 8 | 9 | import ( 10 | "github.com/syncthing/syncthing/lib/logger" 11 | ) 12 | 13 | var ( 14 | l = logger.DefaultLogger.NewFacility("nat", "NAT discovery and port mapping") 15 | ) 16 | -------------------------------------------------------------------------------- /lib/nat/interface.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package nat 8 | 9 | import ( 10 | "context" 11 | "net" 12 | "time" 13 | ) 14 | 15 | type Protocol string 16 | 17 | const ( 18 | TCP Protocol = "TCP" 19 | UDP Protocol = "UDP" 20 | ) 21 | 22 | type Device interface { 23 | ID() string 24 | GetLocalIPAddress() net.IP 25 | AddPortMapping(ctx context.Context, protocol Protocol, internalPort, externalPort int, description string, duration time.Duration) (int, error) 26 | GetExternalIPAddress(ctx context.Context) (net.IP, error) 27 | } 28 | -------------------------------------------------------------------------------- /lib/osutil/atomic_unix_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | //+build !windows 8 | 9 | // (No syscall.Umask or the equivalent on Windows) 10 | 11 | package osutil 12 | 13 | import ( 14 | "io/ioutil" 15 | "os" 16 | "syscall" 17 | "testing" 18 | ) 19 | 20 | func TestTempFilePermissions(t *testing.T) { 21 | // Set a zero umask, so any files created will have the permission bits 22 | // asked for in the create call and nothing less. 23 | oldMask := syscall.Umask(0) 24 | defer syscall.Umask(oldMask) 25 | 26 | fd, err := ioutil.TempFile("", "test") 27 | if err != nil { 28 | t.Fatal(err) 29 | } 30 | 31 | info, err := fd.Stat() 32 | if err != nil { 33 | t.Fatal(err) 34 | } 35 | defer os.Remove(fd.Name()) 36 | defer fd.Close() 37 | 38 | // The temp file should have 0600 permissions at the most, or we have a 39 | // security problem in CreateAtomic. 40 | t.Logf("Got 0%03o", info.Mode()) 41 | if info.Mode()&^0600 != 0 { 42 | t.Errorf("Permission 0%03o is too generous", info.Mode()) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /lib/osutil/filenames_darwin.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package osutil 8 | 9 | import "golang.org/x/text/unicode/norm" 10 | 11 | func NormalizedFilename(s string) string { 12 | return norm.NFC.String(s) 13 | } 14 | 15 | func NativeFilename(s string) string { 16 | return norm.NFD.String(s) 17 | } 18 | -------------------------------------------------------------------------------- /lib/osutil/filenames_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | // +build !windows,!darwin 8 | 9 | package osutil 10 | 11 | import "golang.org/x/text/unicode/norm" 12 | 13 | func NormalizedFilename(s string) string { 14 | return norm.NFC.String(s) 15 | } 16 | 17 | func NativeFilename(s string) string { 18 | return s 19 | } 20 | -------------------------------------------------------------------------------- /lib/osutil/filenames_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package osutil 8 | 9 | import ( 10 | "path/filepath" 11 | 12 | "golang.org/x/text/unicode/norm" 13 | ) 14 | 15 | func NormalizedFilename(s string) string { 16 | return norm.NFC.String(filepath.ToSlash(s)) 17 | } 18 | 19 | func NativeFilename(s string) string { 20 | return filepath.FromSlash(s) 21 | } 22 | -------------------------------------------------------------------------------- /lib/osutil/hidden_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | // +build !windows 8 | 9 | package osutil 10 | 11 | func HideConsole() {} 12 | -------------------------------------------------------------------------------- /lib/osutil/hidden_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | // +build windows 8 | 9 | package osutil 10 | 11 | import "syscall" 12 | 13 | func HideConsole() { 14 | getConsoleWindow := syscall.NewLazyDLL("kernel32.dll").NewProc("GetConsoleWindow") 15 | showWindow := syscall.NewLazyDLL("user32.dll").NewProc("ShowWindow") 16 | if getConsoleWindow.Find() == nil && showWindow.Find() == nil { 17 | hwnd, _, _ := getConsoleWindow.Call() 18 | if hwnd != 0 { 19 | showWindow.Call(hwnd, 0) 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /lib/osutil/lan.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package osutil 8 | 9 | import ( 10 | "net" 11 | ) 12 | 13 | func GetLans() ([]*net.IPNet, error) { 14 | addrs, err := net.InterfaceAddrs() 15 | if err != nil { 16 | return nil, err 17 | } 18 | 19 | nets := make([]*net.IPNet, 0, len(addrs)) 20 | 21 | for _, addr := range addrs { 22 | net, ok := addr.(*net.IPNet) 23 | if ok { 24 | nets = append(nets, net) 25 | } 26 | } 27 | return nets, nil 28 | } 29 | -------------------------------------------------------------------------------- /lib/osutil/lowprio_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | // +build !windows,!linux android 8 | 9 | package osutil 10 | 11 | import ( 12 | "syscall" 13 | 14 | "github.com/pkg/errors" 15 | ) 16 | 17 | // SetLowPriority lowers the process CPU scheduling priority, and possibly 18 | // I/O priority depending on the platform and OS. 19 | func SetLowPriority() error { 20 | // Process zero is "self", niceness value 9 is something between 0 21 | // (default) and 19 (worst priority). 22 | const ( 23 | pidSelf = 0 24 | wantNiceLevel = 9 25 | ) 26 | 27 | if cur, err := syscall.Getpriority(syscall.PRIO_PROCESS, pidSelf); err == nil && cur >= wantNiceLevel { 28 | // We're done here. 29 | return nil 30 | } 31 | 32 | err := syscall.Setpriority(syscall.PRIO_PROCESS, pidSelf, wantNiceLevel) 33 | return errors.Wrap(err, "set niceness") // wraps nil as nil 34 | } 35 | -------------------------------------------------------------------------------- /lib/osutil/net.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at http://mozilla.org/MPL/2.0/. 6 | 7 | package osutil 8 | 9 | import ( 10 | "net" 11 | ) 12 | 13 | func interfaceAddresses(network string, intf *net.Interface) []string { 14 | var out []string 15 | addrs, err := intf.Addrs() 16 | if err != nil { 17 | return out 18 | } 19 | 20 | for _, addr := range addrs { 21 | ipnet, ok := addr.(*net.IPNet) 22 | if ok && (network == "tcp" || (network == "tcp4" && len(ipnet.IP) == net.IPv4len) || (network == "tcp6" && len(ipnet.IP) == net.IPv6len)) { 23 | out = append(out, ipnet.IP.String()) 24 | } 25 | } 26 | 27 | return out 28 | } 29 | -------------------------------------------------------------------------------- /lib/osutil/replacingwriter.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package osutil 8 | 9 | import ( 10 | "bytes" 11 | "io" 12 | ) 13 | 14 | type ReplacingWriter struct { 15 | Writer io.Writer 16 | From byte 17 | To []byte 18 | } 19 | 20 | func (w ReplacingWriter) Write(bs []byte) (int, error) { 21 | var n, written int 22 | var err error 23 | 24 | newlineIdx := bytes.IndexByte(bs, w.From) 25 | for newlineIdx >= 0 { 26 | n, err = w.Writer.Write(bs[:newlineIdx]) 27 | written += n 28 | if err != nil { 29 | break 30 | } 31 | if len(w.To) > 0 { 32 | n, err := w.Writer.Write(w.To) 33 | if n == len(w.To) { 34 | written++ 35 | } 36 | if err != nil { 37 | break 38 | } 39 | } 40 | bs = bs[newlineIdx+1:] 41 | newlineIdx = bytes.IndexByte(bs, w.From) 42 | } 43 | 44 | n, err = w.Writer.Write(bs) 45 | written += n 46 | 47 | return written, err 48 | } 49 | -------------------------------------------------------------------------------- /lib/osutil/replacingwriter_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package osutil 8 | 9 | import ( 10 | "bytes" 11 | "fmt" 12 | "testing" 13 | ) 14 | 15 | var testcases = []struct { 16 | from byte 17 | to []byte 18 | a, b string 19 | }{ 20 | {'\n', []byte{'\r', '\n'}, "", ""}, 21 | {'\n', []byte{'\r', '\n'}, "foo", "foo"}, 22 | {'\n', []byte{'\r', '\n'}, "foo\n", "foo\r\n"}, 23 | {'\n', []byte{'\r', '\n'}, "foo\nbar", "foo\r\nbar"}, 24 | {'\n', []byte{'\r', '\n'}, "foo\nbar\nbaz", "foo\r\nbar\r\nbaz"}, 25 | {'\n', []byte{'\r', '\n'}, "\nbar", "\r\nbar"}, 26 | {'o', []byte{'x', 'l', 'r'}, "\nfoo", "\nfxlrxlr"}, 27 | {'o', nil, "\nfoo", "\nf"}, 28 | {'f', []byte{}, "\nfoo", "\noo"}, 29 | } 30 | 31 | func TestReplacingWriter(t *testing.T) { 32 | for _, tc := range testcases { 33 | var buf bytes.Buffer 34 | w := ReplacingWriter{ 35 | Writer: &buf, 36 | From: tc.from, 37 | To: tc.to, 38 | } 39 | fmt.Fprint(w, tc.a) 40 | if buf.String() != tc.b { 41 | t.Errorf("%q != %q", buf.String(), tc.b) 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /lib/osutil/rlimit_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | // +build windows 8 | 9 | package osutil 10 | 11 | import ( 12 | "errors" 13 | ) 14 | 15 | func MaximizeOpenFileLimit() (int, error) { 16 | return 0, errors.New("not relevant on Windows") 17 | } 18 | -------------------------------------------------------------------------------- /lib/pmp/debug.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package pmp 8 | 9 | import ( 10 | "github.com/syncthing/syncthing/lib/logger" 11 | ) 12 | 13 | var ( 14 | l = logger.DefaultLogger.NewFacility("pmp", "NAT-PMP discovery and port mapping") 15 | ) 16 | -------------------------------------------------------------------------------- /lib/pmp/empty_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | // The existence of this file means we get 0% test coverage rather than no 8 | // test coverage at all. Remove when implementing an actual test. 9 | 10 | package pmp 11 | -------------------------------------------------------------------------------- /lib/protocol/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2014-2015 The Protocol Authors 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 7 | of the Software, and to permit persons to whom the Software is furnished to do 8 | so, subject to the following conditions: 9 | 10 | - The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /lib/protocol/compression.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Protocol Authors. 2 | 3 | package protocol 4 | 5 | import "fmt" 6 | 7 | const ( 8 | compressionThreshold = 128 // don't bother compressing messages smaller than this many bytes 9 | ) 10 | 11 | var compressionMarshal = map[Compression]string{ 12 | CompressionNever: "never", 13 | CompressionMetadata: "metadata", 14 | CompressionAlways: "always", 15 | } 16 | 17 | var compressionUnmarshal = map[string]Compression{ 18 | // Legacy 19 | "false": CompressionNever, 20 | "true": CompressionMetadata, 21 | 22 | // Current 23 | "never": CompressionNever, 24 | "metadata": CompressionMetadata, 25 | "always": CompressionAlways, 26 | } 27 | 28 | func (c Compression) GoString() string { 29 | return fmt.Sprintf("%q", c.String()) 30 | } 31 | 32 | func (c Compression) MarshalText() ([]byte, error) { 33 | return []byte(compressionMarshal[c]), nil 34 | } 35 | 36 | func (c *Compression) UnmarshalText(bs []byte) error { 37 | *c = compressionUnmarshal[string(bs)] 38 | return nil 39 | } 40 | -------------------------------------------------------------------------------- /lib/protocol/compression_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Protocol Authors. 2 | 3 | package protocol 4 | 5 | import "testing" 6 | 7 | func TestCompressionMarshal(t *testing.T) { 8 | uTestcases := []struct { 9 | s string 10 | c Compression 11 | }{ 12 | {"true", CompressionMetadata}, 13 | {"false", CompressionNever}, 14 | {"never", CompressionNever}, 15 | {"metadata", CompressionMetadata}, 16 | {"always", CompressionAlways}, 17 | {"whatever", CompressionMetadata}, 18 | } 19 | 20 | mTestcases := []struct { 21 | s string 22 | c Compression 23 | }{ 24 | {"never", CompressionNever}, 25 | {"metadata", CompressionMetadata}, 26 | {"always", CompressionAlways}, 27 | } 28 | 29 | var c Compression 30 | for _, tc := range uTestcases { 31 | err := c.UnmarshalText([]byte(tc.s)) 32 | if err != nil { 33 | t.Error(err) 34 | } 35 | if c != tc.c { 36 | t.Errorf("%s unmarshalled to %d, not %d", tc.s, c, tc.c) 37 | } 38 | } 39 | 40 | for _, tc := range mTestcases { 41 | bs, err := tc.c.MarshalText() 42 | if err != nil { 43 | t.Error(err) 44 | } 45 | if s := string(bs); s != tc.s { 46 | t.Errorf("%d marshalled to %q, not %q", tc.c, s, tc.s) 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /lib/protocol/conflict_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Protocol Authors. 2 | 3 | package protocol 4 | 5 | import "testing" 6 | 7 | func TestWinsConflict(t *testing.T) { 8 | testcases := [][2]FileInfo{ 9 | // The first should always win over the second 10 | {{ModifiedS: 42}, {ModifiedS: 41}}, 11 | {{ModifiedS: 41}, {ModifiedS: 42, Deleted: true}}, 12 | {{Deleted: true}, {ModifiedS: 10, RawInvalid: true}}, 13 | {{ModifiedS: 41, Version: Vector{Counters: []Counter{{ID: 42, Value: 2}, {ID: 43, Value: 1}}}}, {ModifiedS: 41, Version: Vector{Counters: []Counter{{ID: 42, Value: 1}, {ID: 43, Value: 2}}}}}, 14 | } 15 | 16 | for _, tc := range testcases { 17 | if !WinsConflict(tc[0], tc[1]) { 18 | t.Errorf("%v should win over %v", tc[0], tc[1]) 19 | } 20 | if WinsConflict(tc[1], tc[0]) { 21 | t.Errorf("%v should not win over %v", tc[1], tc[0]) 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /lib/protocol/debug.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Protocol Authors. 2 | 3 | package protocol 4 | 5 | import ( 6 | "github.com/syncthing/syncthing/lib/logger" 7 | ) 8 | 9 | var ( 10 | l = logger.DefaultLogger.NewFacility("protocol", "The BEP protocol") 11 | ) 12 | -------------------------------------------------------------------------------- /lib/protocol/deviceid_test.proto: -------------------------------------------------------------------------------- 1 | 2 | syntax = "proto3"; 3 | 4 | package protocol; 5 | 6 | import "repos/protobuf/gogoproto/gogo.proto"; 7 | 8 | option (gogoproto.goproto_getters_all) = false; 9 | option (gogoproto.sizer_all) = false; 10 | option (gogoproto.protosizer_all) = true; 11 | option (gogoproto.goproto_enum_stringer_all) = false; 12 | option (gogoproto.goproto_enum_prefix_all) = false; 13 | option (gogoproto.goproto_unkeyed_all) = false; 14 | option (gogoproto.goproto_unrecognized_all) = false; 15 | option (gogoproto.goproto_sizecache_all) = false; 16 | 17 | message TestOldDeviceID { 18 | bytes test = 1; 19 | } 20 | 21 | message TestNewDeviceID { 22 | bytes test = 1 [(gogoproto.customtype) = "DeviceID", (gogoproto.nullable) = false]; 23 | } 24 | -------------------------------------------------------------------------------- /lib/protocol/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Protocol Authors. 2 | 3 | // Package protocol implements the Block Exchange Protocol. 4 | package protocol 5 | -------------------------------------------------------------------------------- /lib/protocol/errors.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Protocol Authors. 2 | 3 | package protocol 4 | 5 | import ( 6 | "errors" 7 | ) 8 | 9 | var ( 10 | ErrNoError error 11 | ErrGeneric = errors.New("generic error") 12 | ErrNoSuchFile = errors.New("no such file") 13 | ErrInvalid = errors.New("file is invalid") 14 | ) 15 | 16 | var lookupError = map[ErrorCode]error{ 17 | ErrorCodeNoError: ErrNoError, 18 | ErrorCodeGeneric: ErrGeneric, 19 | ErrorCodeNoSuchFile: ErrNoSuchFile, 20 | ErrorCodeInvalidFile: ErrInvalid, 21 | } 22 | 23 | var lookupCode = map[error]ErrorCode{ 24 | ErrNoError: ErrorCodeNoError, 25 | ErrGeneric: ErrorCodeGeneric, 26 | ErrNoSuchFile: ErrorCodeNoSuchFile, 27 | ErrInvalid: ErrorCodeInvalidFile, 28 | } 29 | 30 | func codeToError(code ErrorCode) error { 31 | err, ok := lookupError[code] 32 | if !ok { 33 | return ErrGeneric 34 | } 35 | return err 36 | } 37 | 38 | func errorToCode(err error) ErrorCode { 39 | code, ok := lookupCode[err] 40 | if !ok { 41 | return ErrorCodeGeneric 42 | } 43 | return code 44 | } 45 | -------------------------------------------------------------------------------- /lib/protocol/luhn.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Protocol Authors. 2 | 3 | package protocol 4 | 5 | import "fmt" 6 | 7 | var luhnBase32 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567" 8 | 9 | func codepoint32(b byte) int { 10 | switch { 11 | case 'A' <= b && b <= 'Z': 12 | return int(b - 'A') 13 | case '2' <= b && b <= '7': 14 | return int(b + 26 - '2') 15 | default: 16 | return -1 17 | } 18 | } 19 | 20 | // luhn32 returns a check digit for the string s, which should be composed 21 | // of characters from the alphabet luhnBase32. 22 | // Doesn't follow the actual Luhn algorithm 23 | // see https://forum.syncthing.net/t/v0-9-0-new-node-id-format/478/6 for more. 24 | func luhn32(s string) (rune, error) { 25 | factor := 1 26 | sum := 0 27 | const n = 32 28 | 29 | for i := range s { 30 | codepoint := codepoint32(s[i]) 31 | if codepoint == -1 { 32 | return 0, fmt.Errorf("digit %q not valid in alphabet %q", s[i], luhnBase32) 33 | } 34 | addend := factor * codepoint 35 | if factor == 2 { 36 | factor = 1 37 | } else { 38 | factor = 2 39 | } 40 | addend = (addend / n) + (addend % n) 41 | sum += addend 42 | } 43 | remainder := sum % n 44 | checkCodepoint := (n - remainder) % n 45 | return rune(luhnBase32[checkCodepoint]), nil 46 | } 47 | -------------------------------------------------------------------------------- /lib/protocol/luhn_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Protocol Authors. 2 | 3 | package protocol 4 | 5 | import ( 6 | "strings" 7 | "testing" 8 | ) 9 | 10 | func TestLuhn32(t *testing.T) { 11 | c, err := luhn32("AB725E4GHIQPL3ZFGT") 12 | if err != nil { 13 | t.Fatal(err) 14 | } 15 | if c != 'G' { 16 | t.Errorf("Incorrect check digit %c != G", c) 17 | } 18 | 19 | _, err = luhn32("3734EJEKMRHWPZQTWYQ1") 20 | if err == nil { 21 | t.Error("Unexpected nil error") 22 | } 23 | if !strings.Contains(err.Error(), "'1'") { 24 | t.Errorf("luhn32 should have errored on digit '1', got %v", err) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /lib/protocol/nativemodel_darwin.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Protocol Authors. 2 | 3 | // +build darwin 4 | 5 | package protocol 6 | 7 | // Darwin uses NFD normalization 8 | 9 | import "golang.org/x/text/unicode/norm" 10 | 11 | type nativeModel struct { 12 | Model 13 | } 14 | 15 | func (m nativeModel) Index(deviceID DeviceID, folder string, files []FileInfo) error { 16 | for i := range files { 17 | files[i].Name = norm.NFD.String(files[i].Name) 18 | } 19 | return m.Model.Index(deviceID, folder, files) 20 | } 21 | 22 | func (m nativeModel) IndexUpdate(deviceID DeviceID, folder string, files []FileInfo) error { 23 | for i := range files { 24 | files[i].Name = norm.NFD.String(files[i].Name) 25 | } 26 | return m.Model.IndexUpdate(deviceID, folder, files) 27 | } 28 | 29 | func (m nativeModel) Request(deviceID DeviceID, folder, name string, size int32, offset int64, hash []byte, weakHash uint32, fromTemporary bool) (RequestResponse, error) { 30 | name = norm.NFD.String(name) 31 | return m.Model.Request(deviceID, folder, name, size, offset, hash, weakHash, fromTemporary) 32 | } 33 | -------------------------------------------------------------------------------- /lib/protocol/nativemodel_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Protocol Authors. 2 | 3 | // +build !windows,!darwin 4 | 5 | package protocol 6 | 7 | // Normal Unixes uses NFC and slashes, which is the wire format. 8 | 9 | type nativeModel struct { 10 | Model 11 | } 12 | -------------------------------------------------------------------------------- /lib/protocol/nativemodel_windows_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 The Protocol Authors. 2 | 3 | package protocol 4 | 5 | import ( 6 | "reflect" 7 | "testing" 8 | ) 9 | 10 | func TestFixupFiles(t *testing.T) { 11 | files := []FileInfo{ 12 | {Name: "foo/bar"}, 13 | {Name: `foo\bar`}, 14 | {Name: "foo/baz"}, 15 | {Name: "foo/quux"}, 16 | {Name: `foo\fail`}, 17 | } 18 | 19 | // Filenames should be slash converted, except files which already have 20 | // backslashes in them which are instead filtered out. 21 | expected := []FileInfo{ 22 | {Name: `foo\bar`}, 23 | {Name: `foo\baz`}, 24 | {Name: `foo\quux`}, 25 | } 26 | 27 | fixed := fixupFiles(files) 28 | if !reflect.DeepEqual(fixed, expected) { 29 | t.Errorf("Got %v, expected %v", fixed, expected) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /lib/rand/random_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package rand 8 | 9 | import "testing" 10 | 11 | func TestRandomString(t *testing.T) { 12 | for _, l := range []int{0, 1, 2, 3, 4, 8, 42} { 13 | s := String(l) 14 | if len(s) != l { 15 | t.Errorf("Incorrect length %d != %d", len(s), l) 16 | } 17 | } 18 | 19 | strings := make([]string, 1000) 20 | for i := range strings { 21 | strings[i] = String(8) 22 | for j := range strings { 23 | if i == j { 24 | continue 25 | } 26 | if strings[i] == strings[j] { 27 | t.Errorf("Repeated random string %q", strings[i]) 28 | } 29 | } 30 | } 31 | } 32 | 33 | func TestRandomUint64(t *testing.T) { 34 | ints := make([]uint64, 1000) 35 | for i := range ints { 36 | ints[i] = Uint64() 37 | for j := range ints { 38 | if i == j { 39 | continue 40 | } 41 | if ints[i] == ints[j] { 42 | t.Errorf("Repeated random int64 %d", ints[i]) 43 | } 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /lib/rc/debug.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package rc 8 | 9 | import ( 10 | "github.com/syncthing/syncthing/lib/logger" 11 | ) 12 | 13 | var ( 14 | l = logger.DefaultLogger.NewFacility("rc", "Remote control package") 15 | ) 16 | -------------------------------------------------------------------------------- /lib/relay/client/debug.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 Audrius Butkevicius and Contributors (see the CONTRIBUTORS file). 2 | 3 | package client 4 | 5 | import ( 6 | "github.com/syncthing/syncthing/lib/logger" 7 | ) 8 | 9 | var ( 10 | l = logger.DefaultLogger.NewFacility("relay", "") 11 | ) 12 | -------------------------------------------------------------------------------- /lib/relay/client/empty_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | // The existence of this file means we get 0% test coverage rather than no 8 | // test coverage at all. Remove when implementing an actual test. 9 | 10 | package client 11 | -------------------------------------------------------------------------------- /lib/relay/protocol/empty_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | // The existence of this file means we get 0% test coverage rather than no 8 | // test coverage at all. Remove when implementing an actual test. 9 | 10 | package protocol 11 | -------------------------------------------------------------------------------- /lib/scanner/.gitignore: -------------------------------------------------------------------------------- 1 | _random.data 2 | -------------------------------------------------------------------------------- /lib/scanner/debug.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package scanner 8 | 9 | import ( 10 | "github.com/syncthing/syncthing/lib/logger" 11 | ) 12 | 13 | var ( 14 | l = logger.DefaultLogger.NewFacility("scanner", "File change detection and hashing") 15 | ) 16 | -------------------------------------------------------------------------------- /lib/scanner/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | // Package scanner implements a file system scanner and hasher. 8 | package scanner 9 | -------------------------------------------------------------------------------- /lib/scanner/testdata/.stignore: -------------------------------------------------------------------------------- 1 | #include excludes 2 | 3 | bfile 4 | dir1/cfile 5 | /dir2/dir21 6 | -------------------------------------------------------------------------------- /lib/scanner/testdata/afile: -------------------------------------------------------------------------------- 1 | foo 2 | -------------------------------------------------------------------------------- /lib/scanner/testdata/bfile: -------------------------------------------------------------------------------- 1 | bar 2 | -------------------------------------------------------------------------------- /lib/scanner/testdata/dir1/cfile: -------------------------------------------------------------------------------- 1 | baz 2 | -------------------------------------------------------------------------------- /lib/scanner/testdata/dir1/dfile: -------------------------------------------------------------------------------- 1 | quux 2 | -------------------------------------------------------------------------------- /lib/scanner/testdata/dir2/cfile: -------------------------------------------------------------------------------- 1 | baz 2 | -------------------------------------------------------------------------------- /lib/scanner/testdata/dir2/dfile: -------------------------------------------------------------------------------- 1 | quux 2 | -------------------------------------------------------------------------------- /lib/scanner/testdata/dir2/dir21/dir22/dir23/efile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isyncthing/syncthing/d0ccea04045e9b154970a92f8eafa0c76cb0f2e2/lib/scanner/testdata/dir2/dir21/dir22/dir23/efile -------------------------------------------------------------------------------- /lib/scanner/testdata/dir2/dir21/dir22/efile/efile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isyncthing/syncthing/d0ccea04045e9b154970a92f8eafa0c76cb0f2e2/lib/scanner/testdata/dir2/dir21/dir22/efile/efile -------------------------------------------------------------------------------- /lib/scanner/testdata/dir2/dir21/dira/efile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isyncthing/syncthing/d0ccea04045e9b154970a92f8eafa0c76cb0f2e2/lib/scanner/testdata/dir2/dir21/dira/efile -------------------------------------------------------------------------------- /lib/scanner/testdata/dir2/dir21/dira/ffile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isyncthing/syncthing/d0ccea04045e9b154970a92f8eafa0c76cb0f2e2/lib/scanner/testdata/dir2/dir21/dira/ffile -------------------------------------------------------------------------------- /lib/scanner/testdata/dir2/dir21/efile/ign/efile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isyncthing/syncthing/d0ccea04045e9b154970a92f8eafa0c76cb0f2e2/lib/scanner/testdata/dir2/dir21/efile/ign/efile -------------------------------------------------------------------------------- /lib/scanner/testdata/dir3/cfile: -------------------------------------------------------------------------------- 1 | baz 2 | -------------------------------------------------------------------------------- /lib/scanner/testdata/dir3/dfile: -------------------------------------------------------------------------------- 1 | quux 2 | -------------------------------------------------------------------------------- /lib/scanner/testdata/excludes: -------------------------------------------------------------------------------- 1 | dir2/dfile 2 | #include further-excludes 3 | -------------------------------------------------------------------------------- /lib/scanner/testdata/further-excludes: -------------------------------------------------------------------------------- 1 | dir3 2 | -------------------------------------------------------------------------------- /lib/stats/debug.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package stats 8 | 9 | import ( 10 | "github.com/syncthing/syncthing/lib/logger" 11 | ) 12 | 13 | var ( 14 | l = logger.DefaultLogger.NewFacility("stats", "Persistent device and folder statistics") 15 | ) 16 | -------------------------------------------------------------------------------- /lib/stats/empty_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | // The existence of this file means we get 0% test coverage rather than no 8 | // test coverage at all. Remove when implementing an actual test. 9 | 10 | package stats 11 | -------------------------------------------------------------------------------- /lib/stun/debug.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package stun 8 | 9 | import ( 10 | "github.com/syncthing/syncthing/lib/logger" 11 | ) 12 | 13 | var ( 14 | l = logger.DefaultLogger.NewFacility("stun", "STUN functionality") 15 | ) 16 | -------------------------------------------------------------------------------- /lib/syncthing/debug.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package syncthing 8 | 9 | import ( 10 | "github.com/syncthing/syncthing/lib/logger" 11 | ) 12 | 13 | var ( 14 | l = logger.DefaultLogger.NewFacility("app", "Main run facility") 15 | ) 16 | 17 | func shouldDebug() bool { 18 | return l.ShouldDebug("app") 19 | } 20 | -------------------------------------------------------------------------------- /lib/syncthing/superuser_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2017 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | // +build !windows 8 | 9 | package syncthing 10 | 11 | import ( 12 | "os" 13 | ) 14 | 15 | func isSuperUser() bool { 16 | return os.Geteuid() == 0 17 | } 18 | -------------------------------------------------------------------------------- /lib/syncthing/superuser_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2017 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package syncthing 8 | 9 | import "syscall" 10 | 11 | // https://msdn.microsoft.com/en-us/library/windows/desktop/aa379649(v=vs.85).aspx 12 | const securityLocalSystemRID = "S-1-5-18" 13 | 14 | func isSuperUser() bool { 15 | tok, err := syscall.OpenCurrentProcessToken() 16 | if err != nil { 17 | l.Debugln("OpenCurrentProcessToken:", err) 18 | return false 19 | } 20 | defer tok.Close() 21 | 22 | user, err := tok.GetTokenUser() 23 | if err != nil { 24 | l.Debugln("GetTokenUser:", err) 25 | return false 26 | } 27 | 28 | if user.User.Sid == nil { 29 | l.Debugln("sid is nil") 30 | return false 31 | } 32 | 33 | sid, err := user.User.Sid.String() 34 | if err != nil { 35 | l.Debugln("Sid.String():", err) 36 | return false 37 | } 38 | 39 | l.Debugf("SID: %q", sid) 40 | return sid == securityLocalSystemRID 41 | } 42 | -------------------------------------------------------------------------------- /lib/testutils/testutils.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package testutils 8 | 9 | // BlockingRW implements io.Reader and Writer but never returns when called 10 | type BlockingRW struct{ nilChan chan struct{} } 11 | 12 | func (rw *BlockingRW) Read(p []byte) (n int, err error) { 13 | <-rw.nilChan 14 | return 15 | } 16 | 17 | func (rw *BlockingRW) Write(p []byte) (n int, err error) { 18 | <-rw.nilChan 19 | return 20 | } 21 | 22 | // NoopRW implements io.Reader and Writer but never returns when called 23 | type NoopRW struct{} 24 | 25 | func (rw *NoopRW) Read(p []byte) (n int, err error) { 26 | return len(p), nil 27 | } 28 | 29 | func (rw *NoopRW) Write(p []byte) (n int, err error) { 30 | return len(p), nil 31 | } 32 | -------------------------------------------------------------------------------- /lib/upgrade/debug.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package upgrade 8 | 9 | import ( 10 | "github.com/syncthing/syncthing/lib/logger" 11 | ) 12 | 13 | var ( 14 | l = logger.DefaultLogger.NewFacility("upgrade", "Binary upgrades") 15 | ) 16 | -------------------------------------------------------------------------------- /lib/upgrade/signingkey.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package upgrade 8 | 9 | // SigningKey is the public key used to verify signed upgrades. It must match 10 | // the private key used to sign binaries for the built in upgrade mechanism to 11 | // accept an upgrade. Keys and signatures can be created and verified with the 12 | // stsigtool utility. The build script creates signed binaries when given the 13 | // -sign option. 14 | var SigningKey = []byte(`-----BEGIN EC PUBLIC KEY----- 15 | MIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQA1iRk+p+DsmolixxVKcpEVlMDPOeQ 16 | 1dWthURMqsjxoJuDAe5I98P/A0kXSdBI7avm5hXhX2opJ5TAyBZLHPpDTRoBg4WN 17 | 7jUpeAjtPoVVxvOh37qDeDVcjCgJbbDTPKbjxq/Ae3SHlQMRcoes7lVY1+YJ8dPk 18 | 2oPfjA6jtmo9aVbf/uo= 19 | -----END EC PUBLIC KEY-----`) 20 | -------------------------------------------------------------------------------- /lib/upgrade/upgrade_unsupp.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | // +build noupgrade 8 | 9 | package upgrade 10 | 11 | const DisabledByCompilation = true 12 | 13 | func upgradeTo(binary string, rel Release) error { 14 | return ErrUpgradeUnsupported 15 | } 16 | 17 | func upgradeToURL(archiveName, binary, url string) error { 18 | return ErrUpgradeUnsupported 19 | } 20 | 21 | func LatestRelease(releasesURL, current string, upgradeToPreRelease bool) (Release, error) { 22 | return Release{}, ErrUpgradeUnsupported 23 | } 24 | -------------------------------------------------------------------------------- /lib/upnp/debug.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package upnp 8 | 9 | import ( 10 | "github.com/syncthing/syncthing/lib/logger" 11 | ) 12 | 13 | var ( 14 | l = logger.DefaultLogger.NewFacility("upnp", "UPnP discovery and port mapping") 15 | ) 16 | -------------------------------------------------------------------------------- /lib/ur/debug.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package ur 8 | 9 | import ( 10 | "github.com/syncthing/syncthing/lib/logger" 11 | ) 12 | 13 | var ( 14 | l = logger.DefaultLogger.NewFacility("ur", "Usage reporting") 15 | ) 16 | -------------------------------------------------------------------------------- /lib/ur/memsize_darwin.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package ur 8 | 9 | import "golang.org/x/sys/unix" 10 | 11 | func memorySize() int64 { 12 | mem, err := unix.SysctlUint64("hw.memsize") 13 | if err != nil { 14 | return 0 15 | } 16 | return int64(mem) 17 | } 18 | -------------------------------------------------------------------------------- /lib/ur/memsize_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package ur 8 | 9 | import ( 10 | "bufio" 11 | "os" 12 | "strconv" 13 | "strings" 14 | ) 15 | 16 | func memorySize() int64 { 17 | f, err := os.Open("/proc/meminfo") 18 | if err != nil { 19 | return 0 20 | } 21 | 22 | s := bufio.NewScanner(f) 23 | if !s.Scan() { 24 | return 0 25 | } 26 | 27 | l := s.Text() 28 | fs := strings.Fields(l) 29 | if len(fs) != 3 || fs[2] != "kB" { 30 | return 0 31 | } 32 | 33 | kb, err := strconv.ParseInt(fs[1], 10, 64) 34 | if err != nil { 35 | return 0 36 | } 37 | return kb * 1024 38 | } 39 | -------------------------------------------------------------------------------- /lib/ur/memsize_netbsd.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package ur 8 | 9 | import ( 10 | "os/exec" 11 | "strconv" 12 | "strings" 13 | ) 14 | 15 | func memorySize() int64 { 16 | cmd := exec.Command("/sbin/sysctl", "hw.physmem64") 17 | out, err := cmd.Output() 18 | if err != nil { 19 | return 0 20 | } 21 | fs := strings.Fields(string(out)) 22 | if len(fs) != 3 { 23 | return 0 24 | } 25 | bytes, err := strconv.ParseInt(fs[2], 10, 64) 26 | if err != nil { 27 | return 0 28 | } 29 | return bytes 30 | } 31 | -------------------------------------------------------------------------------- /lib/ur/memsize_solaris.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | // +build solaris 8 | 9 | package ur 10 | 11 | import ( 12 | "os/exec" 13 | "strconv" 14 | ) 15 | 16 | func memorySize() int64 { 17 | cmd := exec.Command("prtconf", "-m") 18 | out, err := cmd.CombinedOutput() 19 | if err != nil { 20 | return 0 21 | } 22 | 23 | mb, err := strconv.ParseInt(string(out), 10, 64) 24 | if err != nil { 25 | return 0 26 | } 27 | return mb * 1024 * 1024 28 | } 29 | -------------------------------------------------------------------------------- /lib/ur/memsize_unimpl.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | // +build freebsd openbsd dragonfly 8 | 9 | package ur 10 | 11 | func memorySize() int64 { 12 | return 0 13 | } 14 | -------------------------------------------------------------------------------- /lib/ur/memsize_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package ur 8 | 9 | import ( 10 | "encoding/binary" 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | var ( 16 | kernel32, _ = syscall.LoadLibrary("kernel32.dll") 17 | globalMemoryStatusEx, _ = syscall.GetProcAddress(kernel32, "GlobalMemoryStatusEx") 18 | ) 19 | 20 | func memorySize() int64 { 21 | var memoryStatusEx [64]byte 22 | binary.LittleEndian.PutUint32(memoryStatusEx[:], 64) 23 | 24 | ret, _, _ := syscall.Syscall(uintptr(globalMemoryStatusEx), 1, uintptr(unsafe.Pointer(&memoryStatusEx[0])), 0, 0) 25 | if ret == 0 { 26 | return 0 27 | } 28 | 29 | return int64(binary.LittleEndian.Uint64(memoryStatusEx[8:])) 30 | } 31 | -------------------------------------------------------------------------------- /lib/versioner/.gitignore: -------------------------------------------------------------------------------- 1 | testdata 2 | -------------------------------------------------------------------------------- /lib/versioner/_external_test/external.bat: -------------------------------------------------------------------------------- 1 | set "FOLDER_PATH=%~1" 2 | set "FILE_PATH=%~2" 3 | echo "1--%FOLDER_PATH%--" 4 | echo "2--%FILE_PATH%--" 5 | del "%FOLDER_PATH%\%FILE_PATH%" 6 | -------------------------------------------------------------------------------- /lib/versioner/_external_test/external.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "1--$1--" 4 | echo "2--$2--" 5 | rm -f "$1/$2" 6 | -------------------------------------------------------------------------------- /lib/versioner/debug.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | package versioner 8 | 9 | import ( 10 | "github.com/syncthing/syncthing/lib/logger" 11 | ) 12 | 13 | var ( 14 | l = logger.DefaultLogger.NewFacility("versioner", "File versioning") 15 | ) 16 | -------------------------------------------------------------------------------- /lib/watchaggregator/debug.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at http://mozilla.org/MPL/2.0/. 6 | 7 | package watchaggregator 8 | 9 | import ( 10 | "github.com/syncthing/syncthing/lib/logger" 11 | ) 12 | 13 | var ( 14 | l = logger.DefaultLogger.NewFacility("watchaggregator", "Filesystem event watcher") 15 | ) 16 | -------------------------------------------------------------------------------- /man/README.md: -------------------------------------------------------------------------------- 1 | These manual pages are generates on https://docs.syncthing.net/, based on 2 | the https://github.com/syncthing/docs repo. Do not edit them in this 3 | repo. 4 | -------------------------------------------------------------------------------- /man/refresh.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | base=https://docs.syncthing.net/man/ 4 | pages=( 5 | syncthing.1 6 | stdiscosrv.1 7 | strelaysrv.1 8 | syncthing-config.5 9 | syncthing-stignore.5 10 | syncthing-device-ids.7 11 | syncthing-event-api.7 12 | syncthing-faq.7 13 | syncthing-networking.7 14 | syncthing-rest-api.7 15 | syncthing-security.7 16 | syncthing-versioning.7 17 | syncthing-bep.7 18 | syncthing-localdisco.7 19 | syncthing-globaldisco.7 20 | syncthing-relay.7 21 | ) 22 | 23 | for page in "${pages[@]}" ; do 24 | curl -sLO "$base$page" 25 | done 26 | -------------------------------------------------------------------------------- /meta/README.txt: -------------------------------------------------------------------------------- 1 | The files in this directory contain metadata tests - that is, tests on the 2 | shape and colour of the code in the rest of the repository. This code is not 3 | compiled into the final product. -------------------------------------------------------------------------------- /proto/ext.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package ext; 4 | 5 | import "google/protobuf/descriptor.proto"; 6 | 7 | option go_package = "github.com/syncthing/syncthing/proto/ext"; 8 | 9 | extend google.protobuf.MessageOptions { 10 | optional bool xml_tags = 74001; 11 | } 12 | 13 | extend google.protobuf.FieldOptions { 14 | optional string xml = 75005; 15 | optional string json = 75006; 16 | optional string default = 75007; 17 | optional bool restart = 75008; 18 | optional bool device_id = 75009; 19 | optional string goname = 75010; 20 | optional string gotype = 75011; 21 | } 22 | 23 | extend google.protobuf.EnumValueOptions { 24 | optional string enumgoname = 76010; 25 | } 26 | -------------------------------------------------------------------------------- /proto/lib/config/authmode.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package config; 4 | 5 | import "repos/protobuf/gogoproto/gogo.proto"; 6 | 7 | import "ext.proto"; 8 | 9 | enum AuthMode { 10 | option (gogoproto.goproto_enum_stringer) = false; 11 | 12 | AUTH_MODE_STATIC = 0; 13 | AUTH_MODE_LDAP = 1 [(ext.enumgoname) = "AuthModeLDAP"]; 14 | } 15 | -------------------------------------------------------------------------------- /proto/lib/config/blockpullorder.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package config; 4 | 5 | import "repos/protobuf/gogoproto/gogo.proto"; 6 | 7 | enum BlockPullOrder { 8 | option (gogoproto.goproto_enum_stringer) = false; 9 | 10 | BLOCK_PULL_ORDER_STANDARD = 0; 11 | BLOCK_PULL_ORDER_RANDOM = 1; 12 | BLOCK_PULL_ORDER_IN_ORDER = 2; 13 | } 14 | -------------------------------------------------------------------------------- /proto/lib/config/config.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package config; 4 | 5 | import "lib/config/folderconfiguration.proto"; 6 | import "lib/config/deviceconfiguration.proto"; 7 | import "lib/config/guiconfiguration.proto"; 8 | import "lib/config/ldapconfiguration.proto"; 9 | import "lib/config/optionsconfiguration.proto"; 10 | import "lib/config/observed.proto"; 11 | 12 | import "ext.proto"; 13 | 14 | message Configuration { 15 | int32 version = 1 [(ext.xml) = "version,attr"]; 16 | repeated FolderConfiguration folders = 2; 17 | repeated DeviceConfiguration devices = 3; 18 | GUIConfiguration gui = 4 [(ext.goname) = "GUI"]; 19 | LDAPConfiguration ldap = 5 [(ext.goname) = "LDAP"]; 20 | OptionsConfiguration options = 6; 21 | repeated ObservedDevice ignored_devices = 7 [(ext.json) = "remoteIgnoredDevices", (ext.xml) = "remoteIgnoredDevice"]; 22 | repeated ObservedDevice pending_devices = 8; 23 | } 24 | -------------------------------------------------------------------------------- /proto/lib/config/foldertype.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package config; 4 | 5 | import "repos/protobuf/gogoproto/gogo.proto"; 6 | 7 | enum FolderType { 8 | option (gogoproto.goproto_enum_stringer) = false; 9 | 10 | FOLDER_TYPE_SEND_RECEIVE = 0; 11 | FOLDER_TYPE_SEND_ONLY = 1; 12 | FOLDER_TYPE_RECEIVE_ONLY = 2; 13 | } 14 | -------------------------------------------------------------------------------- /proto/lib/config/ldapconfiguration.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package config; 4 | 5 | import "lib/config/ldaptransport.proto"; 6 | 7 | import "ext.proto"; 8 | 9 | 10 | message LDAPConfiguration { 11 | string address = 1 [(ext.xml) = "address,omitempty"]; 12 | string bind_dn = 2 [(ext.goname) = "BindDN", (ext.xml) = "bindDN,omitempty", (ext.json) = "bindDN"]; 13 | LDAPTransport transport = 3 [(ext.xml) = "transport,omitempty"]; 14 | bool insecure_skip_verify = 4 [(ext.xml) = "insecureSkipVerify,omitempty", (ext.default) = "false"]; 15 | string search_base_dn = 5 [(ext.goname) = "SearchBaseDN", (ext.xml) = "searchBaseDN,omitempty", (ext.json) = "searchBaseDN"]; 16 | string search_filter = 6 [(ext.xml) = "searchFilter,omitempty"]; 17 | } 18 | -------------------------------------------------------------------------------- /proto/lib/config/ldaptransport.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package config; 4 | 5 | import "repos/protobuf/gogoproto/gogo.proto"; 6 | 7 | import "ext.proto"; 8 | 9 | enum LDAPTransport { 10 | option (gogoproto.goproto_enum_stringer) = false; 11 | 12 | LDAP_TRANSPORT_PLAIN = 0 [(ext.enumgoname) = "LDAPTransportPlain"]; 13 | LDAP_TRANSPORT_TLS = 2 [(ext.enumgoname) = "LDAPTransportTLS"]; 14 | LDAP_TRANSPORT_START_TLS = 3 [(ext.enumgoname) = "LDAPTransportStartTLS"]; 15 | } 16 | -------------------------------------------------------------------------------- /proto/lib/config/observed.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package config; 4 | 5 | import "google/protobuf/timestamp.proto"; 6 | 7 | import "ext.proto"; 8 | 9 | message ObservedFolder { 10 | google.protobuf.Timestamp time = 1 [(ext.xml) = "time,attr"]; 11 | string id = 2 [(ext.goname) = "ID", (ext.xml) = "id,attr"]; 12 | string label = 3 [(ext.xml) = "label,attr"]; 13 | } 14 | 15 | message ObservedDevice { 16 | google.protobuf.Timestamp time = 1 [(ext.xml) = "time,attr"]; 17 | bytes id = 2 [(ext.goname) = "ID", (ext.json) = "deviceID", (ext.xml) = "id,attr", (ext.device_id) = true]; 18 | string name = 3 [(ext.xml) = "name,attr"]; 19 | string address = 4 [(ext.xml) = "address,attr"]; 20 | } 21 | -------------------------------------------------------------------------------- /proto/lib/config/pullorder.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package config; 4 | 5 | import "repos/protobuf/gogoproto/gogo.proto"; 6 | 7 | enum PullOrder { 8 | option (gogoproto.goproto_enum_stringer) = false; 9 | 10 | PULL_ORDER_RANDOM = 0; 11 | PULL_ORDER_ALPHABETIC = 1; 12 | PULL_ORDER_SMALLEST_FIRST = 2; 13 | PULL_ORDER_LARGEST_FIRST = 3; 14 | PULL_ORDER_OLDEST_FIRST = 4; 15 | PULL_ORDER_NEWEST_FIRST = 5; 16 | } 17 | -------------------------------------------------------------------------------- /proto/lib/config/size.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package config; 4 | 5 | import "repos/protobuf/gogoproto/gogo.proto"; 6 | 7 | import "ext.proto"; 8 | 9 | message Size { 10 | option (gogoproto.goproto_stringer) = false; 11 | 12 | double value = 1 [(ext.xml) = ",chardata"]; 13 | string unit = 2 [(ext.xml) = "unit,attr"]; 14 | } 15 | -------------------------------------------------------------------------------- /proto/lib/config/tuning.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package config; 4 | 5 | import "repos/protobuf/gogoproto/gogo.proto"; 6 | 7 | enum Tuning { 8 | option (gogoproto.goproto_enum_stringer) = false; 9 | 10 | TUNING_AUTO = 0; 11 | TUNING_SMALL = 1; 12 | TUNING_LARGE = 2; 13 | } 14 | -------------------------------------------------------------------------------- /proto/lib/config/versioningconfiguration.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package config; 4 | 5 | import "ext.proto"; 6 | 7 | // VersioningConfiguration is used in the code and for JSON serialization 8 | message VersioningConfiguration { 9 | option (ext.xml_tags) = false; 10 | 11 | string type = 1; 12 | map parameters = 2 [(ext.goname) = "Params", (ext.json) = "params"]; 13 | int32 cleanup_interval_s = 3 [(ext.default) = "3600"]; 14 | } 15 | -------------------------------------------------------------------------------- /proto/lib/fs/copyrangemethod.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package fs; 4 | 5 | import "repos/protobuf/gogoproto/gogo.proto"; 6 | 7 | enum CopyRangeMethod { 8 | option (gogoproto.goproto_enum_stringer) = false; 9 | 10 | COPY_RANGE_METHOD_STANDARD = 0; 11 | COPY_RANGE_METHOD_IOCTL = 1; 12 | COPY_RANGE_METHOD_COPY_FILE_RANGE = 2; 13 | COPY_RANGE_METHOD_SEND_FILE = 3; 14 | COPY_RANGE_METHOD_DUPLICATE_EXTENTS = 4; 15 | COPY_RANGE_METHOD_ALL_WITH_FALLBACK = 5; 16 | } 17 | -------------------------------------------------------------------------------- /proto/lib/fs/types.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package fs; 4 | 5 | import "repos/protobuf/gogoproto/gogo.proto"; 6 | 7 | enum FilesystemType { 8 | option (gogoproto.goproto_enum_stringer) = false; 9 | 10 | FILESYSTEM_TYPE_BASIC = 0; 11 | FILESYSTEM_TYPE_FAKE = 1; 12 | } 13 | -------------------------------------------------------------------------------- /script/commit-msg.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at https://mozilla.org/MPL/2.0/. 6 | 7 | // +build ignore 8 | 9 | package main 10 | 11 | import ( 12 | "bytes" 13 | "fmt" 14 | "io/ioutil" 15 | "os" 16 | "path/filepath" 17 | "regexp" 18 | ) 19 | 20 | const ( 21 | exitSuccess = 0 22 | exitError = 1 23 | ) 24 | 25 | var subject = regexp.MustCompile(`^[\w/,\. ]+: \w`) 26 | 27 | func main() { 28 | if len(os.Args) != 2 { 29 | fmt.Printf("Usage: %s \n", filepath.Base(os.Args[0])) 30 | os.Exit(exitError) 31 | } 32 | 33 | bs, err := ioutil.ReadFile(os.Args[1]) 34 | if err != nil { 35 | fmt.Println("Reading input:", err) 36 | os.Exit(exitError) 37 | } 38 | 39 | lines := bytes.Split(bs, []byte{'\n'}) 40 | if !subject.Match(lines[0]) { 41 | fmt.Printf(`Commit message subject: 42 | 43 | %s 44 | 45 | doesn't look like "tag: One sentence description". Specifically, it doesn't 46 | match this pattern: 47 | 48 | %s 49 | `, lines[0], subject) 50 | os.Exit(exitError) 51 | } 52 | 53 | os.Exit(exitSuccess) 54 | } 55 | -------------------------------------------------------------------------------- /script/docker-entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eu 4 | 5 | if [ "$(id -u)" = '0' ]; then 6 | chown "${PUID}:${PGID}" "${HOME}" \ 7 | && exec su-exec "${PUID}:${PGID}" \ 8 | env HOME="$HOME" "$@" 9 | else 10 | exec "$@" 11 | fi 12 | -------------------------------------------------------------------------------- /script/post-upgrade: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | pkill -HUP -x syncthing || true 4 | -------------------------------------------------------------------------------- /test/.gitignore: -------------------------------------------------------------------------------- 1 | s1 2 | s2 3 | s3 4 | s4 5 | s12-1 6 | s12-2 7 | s23-2 8 | s23-3 9 | md5-* 10 | genfiles 11 | md5r 12 | json 13 | *.idx.gz 14 | dirs-* 15 | *.out 16 | csrftokens.txt 17 | s4d 18 | http 19 | h*/index* 20 | *.syncthing-reset* 21 | panic-*.log 22 | audit-*.log 23 | h*/config.xml.v* 24 | h*/config.xml.orig 25 | -------------------------------------------------------------------------------- /test/folders.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | for ((id=0;id<200;id++)); do 4 | cat < 6 | fake 7 | 8 | 9 | 10 | EOT 11 | done -------------------------------------------------------------------------------- /test/h2/cert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIBmzCCASCgAwIBAgIIawvqtXNSqBQwCgYIKoZIzj0EAwMwFDESMBAGA1UEAxMJ 3 | c3luY3RoaW5nMB4XDTE1MTEyNzA4MDA1N1oXDTQ5MTIzMTIzNTk1OVowFDESMBAG 4 | A1UEAxMJc3luY3RoaW5nMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE7iI2E5etAs53 5 | 6s+SUV3HKZeK55iHUY6X4PHePjyvNxOCZ6GvbErOXWqumU4+vzVREW1wvNtGXAtv 6 | z/hsHIPJ7EdKIX0QPATms2NplCbaFlUxHBpUzhlNulhsoV5ajn7yoz8wPTAOBgNV 7 | HQ8BAf8EBAMCBaAwHQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMCMAwGA1Ud 8 | EwEB/wQCMAAwCgYIKoZIzj0EAwMDaQAwZgIxAPe+pj6NrQiK720v/9IMDPWIRxqt 9 | hxgy03YGzbQskXRDJVvLU49HCHV+8JNL6WwgKgIxALA+RdYb0qDxhcdtt57Zu3A1 10 | eQZEvsJg9FGJOjYDnxZYqEpNZSgTwgcRvGH1Srt37w== 11 | -----END CERTIFICATE----- 12 | -------------------------------------------------------------------------------- /test/h2/https-cert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIC3zCCAcegAwIBAgIILrHT86p9vYAwDQYJKoZIhvcNAQELBQAwDzENMAsGA1UE 3 | AxMEc3lubzAeFw0xNTExMjcwODA1NTNaFw00OTEyMzEyMzU5NTlaMA8xDTALBgNV 4 | BAMTBHN5bm8wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDdxcS30eEu 5 | D8fKokMseLzBJSXvXL0HI6f33ALG7cLi9cXZBurW7Q+bsrHeq6RiZx8PWT5aUkr6 6 | NI3tp3pSip0psJ6PROnmEN5g1rcT/0sQ2oRc5EEiA6jnS2kHgA3vSgaPvtXPqXow 7 | ZD3J/h4IONVIqoxASMNu9rWHjy0CFKXHKBs4pyygysEaj+fL3fuCdvigdkcs5mro 8 | z9O7QRWj6WWrmRfn0pcavN8fU/1TmisLqyxiheRY5WWelnJ3mdAC4dlj2dIj6oHw 9 | QuUnzB4TCenLsD1i0MZzSi8tSVzx0ajra0zyslDfEbdd1HBQweP45R2rUWet2GnL 10 | MfOyfe5GWwWNAgMBAAGjPzA9MA4GA1UdDwEB/wQEAwIFoDAdBgNVHSUEFjAUBggr 11 | BgEFBQcDAQYIKwYBBQUHAwIwDAYDVR0TAQH/BAIwADANBgkqhkiG9w0BAQsFAAOC 12 | AQEAbOVQB4fKIKVtiGi3SSHzdkG5T4p+1FGdSGCl/HjnpPRJ7Q4ZV4n7c7wXm6ya 13 | Lg9lryJCRjK+gH2jIT16x8XqwUOxnlJEfqF85qqAm9h1Kf40wuCAdt72WjypCvZf 14 | dzdgQT5wZ21A0lMltThf2dREcpD8+meh5qv3GNBOZpz2+OYiKnLlWi1Wh9MCwRNr 15 | M+3amX7sJKnb+/xslx29fPzPpq/uypZKHFNG142fNG6wW3aKHELNA0szlSQGwWfe 16 | 0Aw1k6RrKz45iZPQ9HbRB3bF7t/gJVeN+uo484NZQG7cnej4zXEooL6W5jfo/ECr 17 | vqe+Ym0B+xIRsfn0FApfVUqZkA== 18 | -----END CERTIFICATE----- 19 | -------------------------------------------------------------------------------- /test/h2/key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN EC PRIVATE KEY----- 2 | MIGkAgEBBDBz4/RQhZfObYcjS4t5bZthw0Pj6YliqI357mdB6hfiQgMdTB8v7jnO 3 | Scbil+Rri0+gBwYFK4EEACKhZANiAATuIjYTl60Cznfqz5JRXccpl4rnmIdRjpfg 4 | 8d4+PK83E4Jnoa9sSs5daq6ZTj6/NVERbXC820ZcC2/P+Gwcg8nsR0ohfRA8BOaz 5 | Y2mUJtoWVTEcGlTOGU26WGyhXlqOfvI= 6 | -----END EC PRIVATE KEY----- 7 | -------------------------------------------------------------------------------- /test/logs/.gitignore: -------------------------------------------------------------------------------- 1 | *.out 2 | -------------------------------------------------------------------------------- /test/usage_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at http://mozilla.org/MPL/2.0/. 6 | 7 | // +build integration,benchmark,!windows 8 | 9 | package integration 10 | 11 | import ( 12 | "log" 13 | "os" 14 | "runtime" 15 | "syscall" 16 | "time" 17 | ) 18 | 19 | func printUsage(name string, proc *os.ProcessState, total int64) { 20 | if rusage, ok := proc.SysUsage().(*syscall.Rusage); ok { 21 | mib := total / 1024 / 1024 22 | log.Printf("%s: Utime: %s / MiB", name, time.Duration(rusage.Utime.Nano()/mib)) 23 | log.Printf("%s: Stime: %s / MiB", name, time.Duration(rusage.Stime.Nano()/mib)) 24 | if runtime.GOOS == "darwin" { 25 | // Darwin reports in bytes, Linux seems to report in KiB even 26 | // though the manpage says otherwise. 27 | rusage.Maxrss /= 1024 28 | } 29 | log.Printf("%s: MaxRSS: %d KiB", name, rusage.Maxrss) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /test/usage_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Syncthing Authors. 2 | // 3 | // This Source Code Form is subject to the terms of the Mozilla Public 4 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 | // You can obtain one at http://mozilla.org/MPL/2.0/. 6 | 7 | // +build integration,benchmark,windows 8 | 9 | package integration 10 | 11 | import ( 12 | "log" 13 | "os" 14 | "syscall" 15 | "time" 16 | ) 17 | 18 | func ftToDuration(ft *syscall.Filetime) time.Duration { 19 | n := int64(ft.HighDateTime)<<32 + int64(ft.LowDateTime) // in 100-nanosecond intervals 20 | return time.Duration(n*100) * time.Nanosecond 21 | } 22 | 23 | func printUsage(name string, proc *os.ProcessState, total int64) { 24 | if rusage, ok := proc.SysUsage().(*syscall.Rusage); ok { 25 | mib := total / 1024 / 1024 26 | log.Printf("%s: Utime: %s / MiB", name, time.Duration(rusage.UserTime.Nanoseconds()/mib)) 27 | log.Printf("%s: Stime: %s / MiB", name, time.Duration(rusage.KernelTime.Nanoseconds()/mib)) 28 | } 29 | } 30 | --------------------------------------------------------------------------------