summaryrefslogtreecommitdiff
path: root/internal/configfile/feature_flags.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2016-06-05 12:53:10 +0200
committerJakob Unterwurzacher2016-06-05 12:54:45 +0200
commitf2d208c464a1f157014127bfa97dbb7b84158f95 (patch)
tree11333ee2f932d06a6f1ce6b0f219df3d931fca5b /internal/configfile/feature_flags.go
parentb97268c94824b8047c8d4f97a68549260e4f6835 (diff)
configfile: use map[flagIota] for feature flags
This should make things saner and more extensible. It prepares the infrastructure for "required feature flags" that will be used to deprecate old gocryptfs version.
Diffstat (limited to 'internal/configfile/feature_flags.go')
-rw-r--r--internal/configfile/feature_flags.go41
1 files changed, 41 insertions, 0 deletions
diff --git a/internal/configfile/feature_flags.go b/internal/configfile/feature_flags.go
new file mode 100644
index 0000000..d439363
--- /dev/null
+++ b/internal/configfile/feature_flags.go
@@ -0,0 +1,41 @@
+package configfile
+
+type flagIota int
+
+const (
+ FlagPlaintextNames flagIota = iota
+ FlagDirIV
+ FlagEMENames
+ FlagGCMIV128
+ FlagLongNames
+)
+
+// knownFlags stores the known feature flags and their string representation
+var knownFlags map[flagIota]string = map[flagIota]string{
+ FlagPlaintextNames: "PlaintextNames",
+ FlagDirIV: "DirIV",
+ FlagEMENames: "EMENames",
+ FlagGCMIV128: "GCMIV128",
+ FlagLongNames: "LongNames",
+}
+
+// isFeatureFlagKnown verifies that we understand a feature flag
+func (cf *ConfFile) isFeatureFlagKnown(flag string) bool {
+ for _, knownFlag := range knownFlags {
+ if knownFlag == flag {
+ return true
+ }
+ }
+ return false
+}
+
+// isFeatureFlagSet - is the feature flag "flagWant" enabled?
+func (cf *ConfFile) IsFeatureFlagSet(flagWant flagIota) bool {
+ flagString := knownFlags[flagWant]
+ for _, flag := range cf.FeatureFlags {
+ if flag == flagString {
+ return true
+ }
+ }
+ return false
+}