From 368ac6e661eaeea24398d204a72622116357ceef Mon Sep 17 00:00:00 2001 From: postmannen Date: Mon, 30 May 2022 07:14:15 +0200 Subject: [PATCH] replaced keys/acl startREQ flags with enable flag --- configuration_flags.go | 120 +++++++++++++++++------------------------ processes.go | 4 +- 2 files changed, 52 insertions(+), 72 deletions(-) diff --git a/configuration_flags.go b/configuration_flags.go index 52f1812..aba2d91 100644 --- a/configuration_flags.go +++ b/configuration_flags.go @@ -93,15 +93,11 @@ type Configuration struct { // Make the current node send hello messages to central at given interval in seconds StartPubREQHello int - // Publisher for asking central for public keys - StartPubREQKeysRequestUpdate bool - // Subscriber for receiving updates of public keys from central - StartSubREQKeysDeliverUpdate bool + // Enable the updates of public keys + EnableKeyUpdates bool - // Publisher for asking central for public acl updates - StartPubREQAclRequestUpdate bool - // Subscriber for receiving updates of acl's from central - StartSubREQAclDeliverUpdate bool + // Enable the updates of acl's + EnableAclUpdates bool // Start the central error logger. StartSubREQErrorLog bool @@ -178,27 +174,25 @@ type ConfigurationFromFile struct { IsCentralAuth *bool EnableDebug *bool - StartPubREQHello *int - StartPubREQKeysRequestUpdate *bool - StartSubREQKeysDeliverUpdate *bool - StartPubREQAclRequestUpdate *bool - StartSubREQAclDeliverUpdate *bool - StartSubREQErrorLog *bool - StartSubREQHello *bool - StartSubREQToFileAppend *bool - StartSubREQToFile *bool - StartSubREQToFileNACK *bool - StartSubREQCopyFileFrom *bool - StartSubREQCopyFileTo *bool - StartSubREQPing *bool - StartSubREQPong *bool - StartSubREQCliCommand *bool - StartSubREQToConsole *bool - StartSubREQHttpGet *bool - StartSubREQHttpGetScheduled *bool - StartSubREQTailFile *bool - StartSubREQCliCommandCont *bool - StartSubREQRelay *bool + StartPubREQHello *int + EnableKeyUpdates *bool + EnableAclUpdates *bool + StartSubREQErrorLog *bool + StartSubREQHello *bool + StartSubREQToFileAppend *bool + StartSubREQToFile *bool + StartSubREQToFileNACK *bool + StartSubREQCopyFileFrom *bool + StartSubREQCopyFileTo *bool + StartSubREQPing *bool + StartSubREQPong *bool + StartSubREQCliCommand *bool + StartSubREQToConsole *bool + StartSubREQHttpGet *bool + StartSubREQHttpGetScheduled *bool + StartSubREQTailFile *bool + StartSubREQCliCommandCont *bool + StartSubREQRelay *bool } // NewConfiguration will return a *Configuration. @@ -246,27 +240,25 @@ func newConfigurationDefaults() Configuration { IsCentralAuth: false, EnableDebug: false, - StartPubREQHello: 30, - StartPubREQKeysRequestUpdate: true, - StartSubREQKeysDeliverUpdate: true, - StartPubREQAclRequestUpdate: true, - StartSubREQAclDeliverUpdate: true, - StartSubREQErrorLog: false, - StartSubREQHello: true, - StartSubREQToFileAppend: true, - StartSubREQToFile: true, - StartSubREQToFileNACK: true, - StartSubREQCopyFileFrom: true, - StartSubREQCopyFileTo: true, - StartSubREQPing: true, - StartSubREQPong: true, - StartSubREQCliCommand: true, - StartSubREQToConsole: true, - StartSubREQHttpGet: true, - StartSubREQHttpGetScheduled: true, - StartSubREQTailFile: true, - StartSubREQCliCommandCont: true, - StartSubREQRelay: false, + StartPubREQHello: 30, + EnableKeyUpdates: true, + EnableAclUpdates: true, + StartSubREQErrorLog: false, + StartSubREQHello: true, + StartSubREQToFileAppend: true, + StartSubREQToFile: true, + StartSubREQToFileNACK: true, + StartSubREQCopyFileFrom: true, + StartSubREQCopyFileTo: true, + StartSubREQPing: true, + StartSubREQPong: true, + StartSubREQCliCommand: true, + StartSubREQToConsole: true, + StartSubREQHttpGet: true, + StartSubREQHttpGetScheduled: true, + StartSubREQTailFile: true, + StartSubREQCliCommandCont: true, + StartSubREQRelay: false, } return c } @@ -460,26 +452,16 @@ func checkConfigValues(cf ConfigurationFromFile) Configuration { } else { conf.StartPubREQHello = *cf.StartPubREQHello } - if cf.StartPubREQKeysRequestUpdate == nil { - conf.StartPubREQKeysRequestUpdate = cd.StartPubREQKeysRequestUpdate + if cf.EnableKeyUpdates == nil { + conf.EnableKeyUpdates = cd.EnableKeyUpdates } else { - conf.StartPubREQKeysRequestUpdate = *cf.StartPubREQKeysRequestUpdate - } - if cf.StartSubREQKeysDeliverUpdate == nil { - conf.StartSubREQKeysDeliverUpdate = cd.StartSubREQKeysDeliverUpdate - } else { - conf.StartSubREQKeysDeliverUpdate = *cf.StartSubREQKeysDeliverUpdate + conf.EnableKeyUpdates = *cf.EnableKeyUpdates } - if cf.StartPubREQAclRequestUpdate == nil { - conf.StartPubREQAclRequestUpdate = cd.StartPubREQAclRequestUpdate + if cf.EnableAclUpdates == nil { + conf.EnableAclUpdates = cd.EnableAclUpdates } else { - conf.StartPubREQAclRequestUpdate = *cf.StartPubREQAclRequestUpdate - } - if cf.StartSubREQAclDeliverUpdate == nil { - conf.StartSubREQAclDeliverUpdate = cd.StartSubREQAclDeliverUpdate - } else { - conf.StartSubREQAclDeliverUpdate = *cf.StartSubREQAclDeliverUpdate + conf.EnableAclUpdates = *cf.EnableAclUpdates } if cf.StartSubREQErrorLog == nil { @@ -634,11 +616,9 @@ func (c *Configuration) CheckFlags() error { flag.IntVar(&c.StartPubREQHello, "startPubREQHello", fc.StartPubREQHello, "Make the current node send hello messages to central at given interval in seconds") - flag.BoolVar(&c.StartPubREQKeysRequestUpdate, "startPubREQKeysRequestUpdate", fc.StartPubREQKeysRequestUpdate, "true/false") - flag.BoolVar(&c.StartSubREQKeysDeliverUpdate, "startSubREQKeysDeliverUpdate", fc.StartSubREQKeysDeliverUpdate, "true/false") + flag.BoolVar(&c.EnableKeyUpdates, "EnableKeyUpdates", fc.EnableKeyUpdates, "true/false") - flag.BoolVar(&c.StartPubREQAclRequestUpdate, "startPubREQAclRequestUpdate", fc.StartPubREQAclRequestUpdate, "true/false") - flag.BoolVar(&c.StartSubREQAclDeliverUpdate, "startSubREQAclDeliverUpdate", fc.StartSubREQAclDeliverUpdate, "true/false") + flag.BoolVar(&c.EnableAclUpdates, "EnableAclUpdates", fc.EnableAclUpdates, "true/false") flag.BoolVar(&c.StartSubREQErrorLog, "startSubREQErrorLog", fc.StartSubREQErrorLog, "true/false") flag.BoolVar(&c.StartSubREQHello, "startSubREQHello", fc.StartSubREQHello, "true/false") diff --git a/processes.go b/processes.go index 4961e1e..a959ad8 100644 --- a/processes.go +++ b/processes.go @@ -173,12 +173,12 @@ func (p *processes) Start(proc process) { proc.startup.pubREQHello(proc) } - if proc.configuration.StartPubREQKeysRequestUpdate { + if proc.configuration.EnableKeyUpdates { proc.startup.pubREQKeysRequestUpdate(proc) proc.startup.subREQKeysDeliverUpdate(proc) } - if proc.configuration.StartPubREQAclRequestUpdate { + if proc.configuration.EnableAclUpdates { proc.startup.pubREQAclRequestUpdate(proc) proc.startup.subREQAclDeliverUpdate(proc) }