all: Add configurable defaults (fixes #4224, fixes #6086) (#7131)

This commit is contained in:
Simon Frei
2021-02-04 21:10:41 +01:00
committed by GitHub
parent 31119ed61a
commit ffc14a77c6
41 changed files with 1708 additions and 1046 deletions
+1
View File
@@ -18,6 +18,7 @@ extend google.protobuf.FieldOptions {
optional bool device_id = 75009;
optional string goname = 75010;
optional string gotype = 75011;
optional bool nodefault = 75012;
}
extend google.protobuf.EnumValueOptions {
+32 -21
View File
@@ -93,6 +93,15 @@ var E_Gotype = &proto.ExtensionDesc{
Filename: "ext.proto",
}
var E_Nodefault = &proto.ExtensionDesc{
ExtendedType: (*descriptor.FieldOptions)(nil),
ExtensionType: (*bool)(nil),
Field: 75012,
Name: "ext.nodefault",
Tag: "varint,75012,opt,name=nodefault",
Filename: "ext.proto",
}
var E_Enumgoname = &proto.ExtensionDesc{
ExtendedType: (*descriptor.EnumValueOptions)(nil),
ExtensionType: (*string)(nil),
@@ -111,31 +120,33 @@ func init() {
proto.RegisterExtension(E_DeviceId)
proto.RegisterExtension(E_Goname)
proto.RegisterExtension(E_Gotype)
proto.RegisterExtension(E_Nodefault)
proto.RegisterExtension(E_Enumgoname)
}
func init() { proto.RegisterFile("ext.proto", fileDescriptor_95fe6908ffcf64d3) }
var fileDescriptor_95fe6908ffcf64d3 = []byte{
// 318 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0xd1, 0xcb, 0x4a, 0x33, 0x31,
0x14, 0xc0, 0x71, 0x86, 0x96, 0xaf, 0x6d, 0x96, 0x5d, 0x7d, 0x08, 0xd6, 0xba, 0xeb, 0x6a, 0x06,
0x11, 0x14, 0x43, 0x57, 0x8a, 0x82, 0x0b, 0x11, 0x8a, 0xb8, 0x70, 0x53, 0xd2, 0x99, 0xd3, 0x34,
0x92, 0xcb, 0x30, 0x39, 0x23, 0xd3, 0x9d, 0x97, 0x27, 0xf0, 0x95, 0x5c, 0x69, 0x57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, 0x88, 0x10, 0xd0, 0xb9, 0x72, 0xa7, 0x6e, 0xaf, 0xe1,
0x63, 0x9d, 0xab, 0x4b, 0x26, 0xf3, 0xdf, 0xff, 0xfc, 0x78, 0xab, 0x06, 0xac, 0xb0, 0xc3, 0xbd,
0xe7, 0x79, 0x27, 0x78, 0x9d, 0x77, 0x82, 0xf7, 0x79, 0x27, 0xb8, 0xea, 0x71, 0x81, 0x93, 0x7c,
0x14, 0xc6, 0x46, 0x45, 0x76, 0xaa, 0x63, 0x9c, 0x08, 0xcd, 0x57, 0x56, 0x8b, 0xd9, 0x11, 0x14,
0xf8, 0x13, 0x00, 0x00, 0xff, 0xff, 0x5a, 0xa4, 0x49, 0x7c, 0x7b, 0x02, 0x00, 0x00,
// 332 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0xd2, 0x4d, 0x4b, 0xfb, 0x30,
0x1c, 0xc0, 0x71, 0xca, 0xc6, 0x7f, 0x6b, 0x8e, 0x3b, 0xfd, 0x11, 0x9c, 0xf3, 0xb6, 0x53, 0x8b,
0x08, 0x8a, 0x61, 0x5e, 0x14, 0x05, 0x0f, 0x22, 0x0c, 0xf1, 0xe0, 0x65, 0x64, 0xed, 0x6f, 0x59,
0x24, 0x0f, 0xa5, 0x49, 0xa5, 0xbb, 0xf9, 0xf4, 0x06, 0x7c, 0x4b, 0x9e, 0x74, 0x27, 0x7d, 0x07,
0xb2, 0xa3, 0xef, 0xc1, 0x07, 0xba, 0xa6, 0x6e, 0xb0, 0x43, 0xbc, 0x95, 0xf2, 0xfd, 0x24, 0xbf,
0x84, 0x20, 0x1f, 0x72, 0x13, 0x24, 0xa9, 0x32, 0xaa, 0x55, 0x83, 0xdc, 0xac, 0x75, 0xa8, 0x52,
0x94, 0x43, 0x38, 0xff, 0x35, 0xcc, 0x46, 0x61, 0x0c, 0x3a, 0x4a, 0x59, 0x62, 0x54, 0x5a, 0x66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b, 0xbb, 0xec, 0x52, 0x66, 0xc6, 0xd9, 0x30, 0x88, 0x94,
0x08, 0xf5, 0x44, 0x46, 0x66, 0xcc, 0x24, 0x5d, 0xfa, 0x9a, 0xaf, 0x1d, 0x42, 0x6e, 0x7e, 0x02,
0x00, 0x00, 0xff, 0xff, 0x65, 0x95, 0xf9, 0xeb, 0xba, 0x02, 0x00, 0x00,
}
+6
View File
@@ -20,4 +20,10 @@ message Configuration {
OptionsConfiguration options = 6;
repeated ObservedDevice ignored_devices = 7 [(ext.json) = "remoteIgnoredDevices", (ext.xml) = "remoteIgnoredDevice"];
repeated ObservedDevice pending_devices = 8 [deprecated=true];
Defaults defaults = 9;
}
message Defaults {
FolderConfiguration folder = 1;
DeviceConfiguration device = 2;
}
+2 -2
View File
@@ -8,14 +8,14 @@ import "lib/config/observed.proto";
import "ext.proto";
message DeviceConfiguration {
bytes device_id = 1 [(ext.goname) = "DeviceID", (ext.xml) = "id,attr", (ext.json) = "deviceID", (ext.device_id) = true];
bytes device_id = 1 [(ext.goname) = "DeviceID", (ext.xml) = "id,attr", (ext.json) = "deviceID", (ext.device_id) = true, (ext.nodefault) = true];
string name = 2 [(ext.xml) = "name,attr,omitempty"];
repeated string addresses = 3 [(ext.xml) = "address,omitempty", (ext.default) = "dynamic"];
protocol.Compression compression = 4 [(ext.xml) = "compression,attr"];
string cert_name = 5 [(ext.xml) = "certName,attr,omitempty"];
bool introducer = 6 [(ext.xml) = "introducer,attr"];
bool skip_introduction_removals = 7 [(ext.xml) = "skipIntroductionRemovals,attr"];
bytes introduced_by = 8 [(ext.xml) = "introducedBy,attr", (ext.device_id) = true];
bytes introduced_by = 8 [(ext.xml) = "introducedBy,attr", (ext.device_id) = true, (ext.nodefault) = true];
bool paused = 9;
repeated string allowed_networks = 10 [(ext.xml) = "allowedNetwork,omitempty"];
bool auto_accept_folders = 11;
+4 -4
View File
@@ -20,10 +20,10 @@ message FolderDeviceConfiguration {
}
message FolderConfiguration {
string id = 1 [(ext.goname) = "ID", (ext.xml) = "id,attr"];
string id = 1 [(ext.goname) = "ID", (ext.xml) = "id,attr", (ext.nodefault) = true];
string label = 2 [(ext.xml) = "label,attr", (ext.restart) = false];
fs.FilesystemType filesystem_type = 3;
string path = 4 [(ext.xml) = "path,attr"];
string path = 4 [(ext.xml) = "path,attr", (ext.default) = "~"];
FolderType type = 5 [(ext.xml) = "type,attr"];
repeated FolderDeviceConfiguration devices = 6;
int32 rescan_interval_s = 7 [(ext.xml) = "rescanIntervalS,attr", (ext.default) = "3600"];
@@ -31,7 +31,7 @@ message FolderConfiguration {
int32 fs_watcher_delay_s = 9 [(ext.goname) = "FSWatcherDelayS", (ext.xml) = "fsWatcherDelayS,attr", (ext.default) = "10"];
bool ignore_perms = 10 [(ext.xml) = "ignorePerms,attr"];
bool auto_normalize = 11 [(ext.xml) = "autoNormalize,attr", (ext.default) = "true"];
Size min_disk_free = 12;
Size min_disk_free = 12 [(ext.default) = "1 %"];
VersioningConfiguration versioning = 13;
int32 copiers = 14;
int32 puller_max_pending_kib = 15 [(ext.goname) = "PullerMaxPendingKiB", (ext.xml) = "pullerMaxPendingKiB", (ext.json) = "pullerMaxPendingKiB"];
@@ -40,7 +40,7 @@ message FolderConfiguration {
bool ignore_delete = 18;
int32 scan_progress_interval_s = 19;
int32 puller_pause_s = 20;
int32 max_conflicts = 21 [(ext.default) = "-1"];
int32 max_conflicts = 21 [(ext.default) = "10"];
bool disable_sparse_files = 22;
bool disable_temp_indexes = 23;
bool paused = 24;
+1 -1
View File
@@ -44,7 +44,7 @@ message OptionsConfiguration {
int32 temp_index_min_blocks = 35 [(ext.default) = "10"];
repeated string unacked_notification_ids = 36 [(ext.goname) = "UnackedNotificationIDs", (ext.xml) = "unackedNotificationID", (ext.json) = "unackedNotificationIDs"];
int32 traffic_class = 37;
string default_folder_path = 38 [(ext.default) = "~"];
string default_folder_path = 38 [deprecated = true];
bool set_low_priority = 39 [(ext.default) = "true"];
int32 max_folder_concurrency = 40 [(ext.goname) = "RawMaxFolderConcurrency"];
string crash_reporting_url = 41 [(ext.goname) = "CRURL", (ext.xml) = "crashReportingURL", (ext.json) = "crURL", (ext.default) = "https://crash.syncthing.net/newcrash"];
+7
View File
@@ -292,6 +292,13 @@ func HandleCustomExtensions(file *descriptor.FileDescriptorProto) func(msg *desc
current += fmt.Sprintf(`default:"%s"`, defaultValue)
}
if nodefaultValue, ok := GetFieldBooleanExtension(field, ext.E_Nodefault); ok {
if len(current) > 0 {
current += " "
}
current += fmt.Sprintf(`nodefault:"%t"`, nodefaultValue)
}
if restartValue, ok := GetFieldBooleanExtension(field, ext.E_Restart); ok {
if len(current) > 0 {
current += " "