Skip to content

Commit

Permalink
all: Remove untrusted feature flag (fixes syncthing#109) (syncthing#7567
Browse files Browse the repository at this point in the history
)

No longer hide the web UI controls for the new untrusted/encrypted
device feature. Testing hasn't been very widespread, but there has been
some and quite a few bugs have been caught and fixed. I believe its time
to not hide it anymore, and cautiously recommend usage. E.g. mention
that the feature hasn't been widely used yet and anyone using it is an
early adopter, but drop the bit about not using it with production data.
We can maybe stress the need for backups in general and especially
using this.
  • Loading branch information
imsodin committed Apr 13, 2021
1 parent c2bb11a commit f71fcd4
Show file tree
Hide file tree
Showing 13 changed files with 155 additions and 4,412 deletions.
22 changes: 17 additions & 5 deletions gui/default/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ <h4 class="panel-title">
<span ng-if="folder.type == 'sendreceive'" class="fas fa-fw fa-folder"></span>
<span ng-if="folder.type == 'sendonly'" class="fas fa-fw fa-upload"></span>
<span ng-if="folder.type == 'receiveonly'" class="fas fa-fw fa-download"></span>
<span ng-if="folder.type == 'receiveencrypted'" class="fas fa-fw fa-lock"></span>
</div>
<div class="panel-status pull-right text-{{folderClass(folder)}}" ng-switch="folderStatus(folder)">
<span ng-switch-when="paused"><span class="hidden-xs" translate>Paused</span><span class="visible-xs" aria-label="{{'Paused' | translate}}"><i class="fas fa-fw fa-pause"></i></span></span>
Expand Down Expand Up @@ -374,6 +375,7 @@ <h4 class="panel-title">
</span>
<span ng-switch-when="outofsync"><span class="hidden-xs" translate>Out of Sync</span><span class="visible-xs" aria-label="{{'Out of Sync' | translate}}"><i class="fas fa-fw fa-exclamation-circle"></i></span></span>
<span ng-switch-when="faileditems"><span class="hidden-xs" translate>Failed Items</span><span class="visible-xs" aria-label="{{'Failed Items' | translate}}"><i class="fas fa-fw fa-exclamation-circle"></i></span></span>
<span ng-switch-when="localunencrypted"><span class="hidden-xs">{{'Unexpected Items' | translate}}</span><span class="visible-xs" aria-label="{{'Unexpected Items' | translate}}"><i class="fas fa-fw fa-exclamation-circle"></i></span></span>
</div>
<div class="panel-title-text">
<span tooltip data-original-title="{{folder.label.length != 0 ? folder.id : ''}}">{{folder.label.length != 0 ? folder.label : folder.id}}</span>
Expand Down Expand Up @@ -438,17 +440,24 @@ <h4 class="panel-title">
<a href="" ng-click="showFailed(folder.id)">{{model[folder.id].pullErrors | alwaysNumber | localeNumber}}&nbsp;<span translate>items</span></a>
</td>
</tr>
<tr ng-if="folder.type == 'receiveonly' && canRevert(folder.id)">
<tr ng-if="hasReceiveOnlyChanged(folder)">
<th><span class="fas fa-fw fa-exclamation-circle"></span>&nbsp;<span translate>Locally Changed Items</span></th>
<td class="text-right">
<a href="" ng-click="showLocalChanged(folder.id)">{{model[folder.id].receiveOnlyTotalItems | alwaysNumber | localeNumber}} <span translate>items</span>, ~{{model[folder.id].receiveOnlyChangedBytes | binary}}B</a>
<a href="" ng-click="showLocalChanged(folder.id, folder.type)">{{model[folder.id].receiveOnlyTotalItems | alwaysNumber | localeNumber}} <span translate>items</span>, ~{{model[folder.id].receiveOnlyChangedBytes | binary}}B</a>
</td>
</tr>
<tr ng-if="hasReceiveEncryptedItems(folder)">
<th><span class="fas fa-fw fa-exclamation-circle"></span>&nbsp;<span translate>Locally Changed Items</span></th>
<td class="text-right">
<a href="" ng-click="showLocalChanged(folder.id, folder.type)">{{receiveEncryptedItemsCount(folder) | alwaysNumber | localeNumber}} <span translate>items</span>, ~{{model[folder.id].receiveOnlyChangedBytes | binary}}B</a>
</td>
</tr>
<tr ng-if="folder.type != 'sendreceive'">
<th><span class="fas fa-fw fa-folder"></span>&nbsp;<span translate>Folder Type</span></th>
<td class="text-right">
<span ng-if="folder.type == 'sendonly'" translate>Send Only</span>
<span ng-if="folder.type == 'receiveonly'" translate>Receive Only</span>
<span ng-if="folder.type == 'receiveencrypted'" translate>Receive Encrypted</span>
</td>
</tr>
<tr ng-if="folder.ignorePerms">
Expand Down Expand Up @@ -521,7 +530,7 @@ <h4 class="panel-title">
<span>{{folderStats[folder.id].lastScan | date:'yyyy-MM-dd HH:mm:ss'}}</span>
</td>
</tr>
<tr ng-if="folder.type != 'sendonly' && folderStats[folder.id].lastFile && folderStats[folder.id].lastFile.filename">
<tr ng-if="folder.type != 'sendonly' && folder.type != 'receiveencrypted' && folderStats[folder.id].lastFile && folderStats[folder.id].lastFile.filename">
<th><span class="fas fa-fw fa-exchange-alt"></span>&nbsp;<span translate>Latest Change</span></th>
<td class="text-right">
<span tooltip data-original-title="{{folderStats[folder.id].lastFile.filename}} @ {{folderStats[folder.id].lastFile.at | date:'yyyy-MM-dd HH:mm:ss'}}">
Expand All @@ -541,6 +550,9 @@ <h4 class="panel-title">
<button type="button" class="btn btn-sm btn-danger pull-left" ng-click="revertOverrideConfirmationModal('revert', folder.id)" ng-if="hasReceiveOnlyChanged(folder)">
<span class="fa fa-arrow-circle-down"></span>&nbsp;<span translate>Revert Local Changes</span>
</button>
<button type="button" class="btn btn-sm btn-danger pull-left" ng-click="revertOverrideConfirmationModal('deleteEnc', folder.id)" ng-if="hasReceiveEncryptedItems(folder)">
<span class="fa fa-arrow-lock"></span>&nbsp;<span translate>Delete Unexpected Items</span>
</button>
<span class="pull-right">
<button ng-if="!folder.paused" type="button" class="btn btn-sm btn-default" ng-click="setFolderPause(folder.id, true)">
<span class="fas fa-pause"></span>&nbsp;<span translate>Pause</span>
Expand Down Expand Up @@ -760,8 +772,8 @@ <h4 class="panel-title">
</td>
<td ng-if="!connections[deviceCfg.deviceID].connected" class="text-right">
<span ng-repeat="addr in deviceCfg.addresses">
<span tooltip data-original-title="{{'Configured' | translate}}">{{addr}}</span><br>
<small ng-if="system.lastDialStatus[addr].error" tooltip data-original-title="{{system.lastDialStatus[addr].error}}" class="text-danger">{{abbreviatedError(addr)}}<br></small>
<span tooltip data-original-title="{{'Configured' | translate}}">{{addr}}</span><br>
<small ng-if="system.lastDialStatus[addr].error" tooltip data-original-title="{{system.lastDialStatus[addr].error}}" class="text-danger">{{abbreviatedError(addr)}}<br></small>
</span>
<span ng-repeat="addr in discoveryCache[deviceCfg.deviceID].addresses">
<span tooltip data-original-title="{{'Discovered' | translate}}">{{addr}}</span><br>
Expand Down
94 changes: 85 additions & 9 deletions gui/default/syncthing/core/syncthingController.js
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,7 @@ angular.module('syncthing.core')
$scope.currentSharing.shared = [];
$scope.currentSharing.unrelated = [];
$scope.currentSharing.selected = {};
$scope.currentSharing.encryptionPasswords = {};
if (editing === 'folder') {
initShareEditingFolder();
}
Expand All @@ -779,6 +780,9 @@ angular.module('syncthing.core')
if (n.deviceID !== $scope.myID) {
$scope.currentSharing.shared.push($scope.devices[n.deviceID]);
}
if (n.encryptionPassword !== '') {
$scope.currentSharing.encryptionPasswords[n.deviceID] = n.encryptionPassword;
}
$scope.currentSharing.selected[n.deviceID] = true;
});
$scope.currentSharing.unrelated = $scope.deviceList().filter(function (n) {
Expand Down Expand Up @@ -903,9 +907,12 @@ angular.module('syncthing.core')
if ($scope.hasFailedFiles(folderCfg.id)) {
return 'faileditems';
}
if (folderInfo.receiveOnlyTotalItems) {
if ($scope.hasReceiveOnlyChanged(folderCfg)) {
return 'localadditions';
}
if ($scope.hasReceiveEncryptedItems(folderCfg)) {
return 'localunencrypted';
}
if (folderCfg.devices.length <= 1) {
return 'unshared';
}
Expand All @@ -928,7 +935,7 @@ angular.module('syncthing.core')
if (status === 'unknown') {
return 'info';
}
if (status === 'stopped' || status === 'outofsync' || status === 'error' || status === 'faileditems') {
if (status === 'stopped' || status === 'outofsync' || status === 'error' || status === 'faileditems' || status === 'localunencrypted') {
return 'danger';
}
if (status === 'unshared' || status === 'scan-waiting' || status === 'sync-waiting' || status === 'clean-waiting') {
Expand Down Expand Up @@ -1553,6 +1560,13 @@ angular.module('syncthing.core')
$scope.deviceFolders($scope.currentDevice).forEach(function (folderID) {
$scope.currentSharing.shared.push($scope.folders[folderID]);
$scope.currentSharing.selected[folderID] = true;
var folderdevices = $scope.folders[folderID].devices;
for (var i = 0; i < folderdevices.length; i++) {
if (folderdevices[i].deviceID === deviceCfg.deviceID) {
$scope.currentSharing.encryptionPasswords[folderID] = folderdevices[i].encryptionPassword;
break;
}
}
});
$scope.currentSharing.unrelated = $scope.folderList().filter(function (n) {
return !$scope.currentSharing.selected[n.id];
Expand Down Expand Up @@ -1656,6 +1670,8 @@ angular.module('syncthing.core')
for (i = 0; i < $scope.folders[id].devices.length; i++) {
if ($scope.folders[id].devices[i].deviceID === currentID) {
found = true;
// Update encryption pw
$scope.folders[id].devices[i].encryptionPassword = $scope.currentSharing.encryptionPasswords[id];
break;
}
}
Expand All @@ -1664,6 +1680,7 @@ angular.module('syncthing.core')
// Add device to folder
$scope.folders[id].devices.push({
deviceID: currentID,
encryptionPassword: $scope.currentSharing.encryptionPasswords[id],
});
}
} else {
Expand Down Expand Up @@ -1822,19 +1839,32 @@ angular.module('syncthing.core')
});

$scope.setFSWatcherIntervalDefault = function () {
var defaultRescanIntervals = [60, 3600];
var defaultRescanIntervals = [60, 3600, 3600*24];
if (defaultRescanIntervals.indexOf($scope.currentFolder.rescanIntervalS) === -1) {
return;
}
var idx;
if ($scope.currentFolder.fsWatcherEnabled) {
idx = 1;
} else if ($scope.currentFolder.type === 'receiveencrypted') {
idx = 2;
} else {
idx = 0;
}
$scope.currentFolder.rescanIntervalS = defaultRescanIntervals[idx];
};

$scope.setDefaultsForFolderType = function () {
if ($scope.currentFolder.type === 'receiveencrypted') {
$scope.currentFolder.fsWatcherEnabled = false;
$scope.currentFolder.ignorePerms = true;
delete $scope.currentFolder.versioning;
} else {
$scope.currentFolder.fsWatcherEnabled = true;
}
$scope.setFSWatcherIntervalDefault();
};

$scope.loadFormIntoScope = function (form) {
console.log('loadFormIntoScope', form.$name);
switch (form.$name) {
Expand All @@ -1853,6 +1883,7 @@ angular.module('syncthing.core')

function editFolderModal() {
initVersioningEditing();
$scope.currentFolder._recvEnc = $scope.currentFolder.type === 'receiveencrypted';
$scope.folderPathErrors = {};
$scope.folderEditor.$setPristine();
$('#editFolder').modal().one('shown.bs.tab', function (e) {
Expand Down Expand Up @@ -2003,6 +2034,13 @@ angular.module('syncthing.core')
};
$scope.currentSharing.selected[device] = true;
$scope.currentFolder.label = pendingFolder.offeredBy[device].label;
for (var k in pendingFolder.offeredBy) {
if (pendingFolder.offeredBy[k].receiveEncrypted) {
$scope.currentFolder.type = "receiveencrypted";
$scope.setDefaultsForFolderType();
break;
}
}
editFolderModal();
});
};
Expand Down Expand Up @@ -2039,14 +2077,16 @@ angular.module('syncthing.core')
var newDevices = [];
folderCfg.devices.forEach(function (dev) {
if ($scope.currentSharing.selected[dev.deviceID] === true) {
dev.encryptionPassword = $scope.currentSharing.encryptionPasswords[dev.deviceID];
newDevices.push(dev);
delete $scope.currentSharing.selected[dev.deviceID];
};
});
for (var deviceID in $scope.currentSharing.selected) {
if ($scope.currentSharing.selected[deviceID] === true) {
newDevices.push({
deviceID: deviceID
deviceID: deviceID,
encryptionPassword: $scope.currentSharing.encryptionPasswords[deviceID],
});
}
}
Expand Down Expand Up @@ -2473,23 +2513,40 @@ angular.module('syncthing.core')
return $scope.model[folder].errors !== 0;
};

$scope.showLocalChanged = function (folder) {
$scope.showLocalChanged = function (folder, folderType) {
$scope.localChangedFolder = folder;
$scope.localChangedType = folderType;
$scope.localChanged = $scope.refreshLocalChanged(1, 10);
$('#localChanged').modal().one('hidden.bs.modal', function () {
$scope.localChanged = {};
$scope.localChangedFolder = undefined;
$scope.localChangedType = undefined;
});
};

$scope.canRevert = function (folder) {
var f = $scope.model[folder];
if (!f) {
$scope.hasReceiveOnlyChanged = function (folderCfg) {
if (!folderCfg || folderCfg.type !== "receiveonly") {
return false;
}
return $scope.model[folder].receiveOnlyTotalItems > 0;
var counts = $scope.model[folderCfg.id];
return counts && counts.receiveOnlyTotalItems > 0;
};

$scope.hasReceiveEncryptedItems = function (folderCfg) {
if (!folderCfg || folderCfg.type !== "receiveencrypted") {
return false;
}
return $scope.receiveEncryptedItemsCount(folderCfg) > 0;
};

$scope.receiveEncryptedItemsCount = function (folderCfg) {
var counts = $scope.model[folderCfg.id];
if (!counts) {
return 0;
}
return counts.receiveOnlyTotalItems - counts.receiveOnlyChangedDeletes;
}

$scope.revertOverride = function () {
$http.post(
urlbase + "/db/" + $scope.revertOverrideParams.operation +"?folder="
Expand Down Expand Up @@ -2734,4 +2791,23 @@ angular.module('syncthing.core')
address.indexOf('unix://') == 0 ||
address.indexOf('unixs://') == 0);
}
})
.directive('shareTemplate', function () {
return {
templateUrl: 'syncthing/core/editShareTemplate.html',
scope: {
selected: '=',
encryptionPasswords: '=',
id: '@',
label: '@',
folderType: '@',
untrusted: '=',
},
link: function(scope, elem, attrs) {
var plain = false;
scope.togglePasswordVisibility = function() {
scope.plain = !scope.plain;
};
},
}
});
Loading

0 comments on commit f71fcd4

Please sign in to comment.