-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* some cleanup of the status reporting infrastructure
- Loading branch information
Showing
7 changed files
with
40 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Johan Stenstam, [email protected] | ||
* Copyright (c) 2024Johan Stenstam, [email protected] | ||
*/ | ||
|
||
package main | ||
|
@@ -183,7 +183,3 @@ func ValidateBySection(config *Config, configsections map[string]interface{}, cf | |
} | ||
return nil | ||
} | ||
|
||
func (td *TemData) ProcessTapirGlobalConfig(tpkg tapir.TapirMsg) { | ||
log.Printf("TapirProcessGlobalConfig: %+v", tpkg) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Johan Stenstam, [email protected] | ||
* Copyright (c) 2024 Johan Stenstam, [email protected] | ||
*/ | ||
package main | ||
|
||
|
@@ -102,41 +102,41 @@ func (td *TemData) RefreshEngine(conf *Config, stopch chan struct{}) { | |
_, err := td.ProcessTapirUpdate(tm) | ||
if err != nil { | ||
Gconfig.Internal.ComponentStatusCh <- tapir.ComponentStatusUpdate{ | ||
Status: "fail", | ||
Status: tapir.StatusFail, | ||
Component: "tapir-observation", | ||
Msg: fmt.Sprintf("ProcessTapirUpdate error: %v", err), | ||
} | ||
log.Printf("RefreshEngine: Error from ProcessTapirUpdate(): %v", err) | ||
} | ||
Gconfig.Internal.ComponentStatusCh <- tapir.ComponentStatusUpdate{ | ||
Status: "ok", | ||
Status: tapir.StatusOK, | ||
Component: "tapir-observation", | ||
Msg: fmt.Sprintf("ProcessTapirUpdate: MQTT observation message received"), | ||
} | ||
log.Printf("RefreshEngine: Tapir Observation update evaluated.") | ||
|
||
case "global-config": | ||
if !strings.HasSuffix(tpkg.Topic, "config") { | ||
log.Printf("RefreshEngine: received global-config message on wrong topic: %s. Ignored", tpkg.Topic) | ||
Gconfig.Internal.ComponentStatusCh <- tapir.ComponentStatusUpdate{ | ||
Status: "fail", | ||
Component: "mqtt-config", | ||
Msg: fmt.Sprintf("RefreshEngine: received global-config message on wrong topic: %s. Ignored", tpkg.Topic), | ||
} | ||
continue | ||
} | ||
td.ProcessTapirGlobalConfig(tm) | ||
log.Printf("RefreshEngine: Tapir Global Config evaluated.") | ||
Gconfig.Internal.ComponentStatusCh <- tapir.ComponentStatusUpdate{ | ||
Status: "ok", | ||
Component: "mqtt-config", | ||
Msg: fmt.Sprintf("RefreshEngine: Tapir Global Config evaluated."), | ||
} | ||
// case "global-config": | ||
// if !strings.HasSuffix(tpkg.Topic, "config") { | ||
// log.Printf("RefreshEngine: received global-config message on wrong topic: %s. Ignored", tpkg.Topic) | ||
// Gconfig.Internal.ComponentStatusCh <- tapir.ComponentStatusUpdate{ | ||
// Status: "fail", | ||
// Component: "mqtt-config", | ||
// Msg: fmt.Sprintf("RefreshEngine: received global-config message on wrong topic: %s. Ignored", tpkg.Topic), | ||
// } | ||
// continue | ||
// } | ||
// td.ProcessTapirGlobalConfig(tm) | ||
// log.Printf("RefreshEngine: Tapir Global Config evaluated.") | ||
// Gconfig.Internal.ComponentStatusCh <- tapir.ComponentStatusUpdate{ | ||
// Status: "ok", | ||
// Component: "mqtt-config", | ||
// Msg: fmt.Sprintf("RefreshEngine: Tapir Global Config evaluated."), | ||
// } | ||
|
||
default: | ||
log.Printf("RefreshEngine: Tapir Message: unknown msg type: %s", tm.MsgType) | ||
Gconfig.Internal.ComponentStatusCh <- tapir.ComponentStatusUpdate{ | ||
Status: "fail", | ||
Status: tapir.StatusFail, | ||
Component: "mqtt-unknown", | ||
Msg: fmt.Sprintf("RefreshEngine: Tapir Message: unknown msg type: %s", tm.MsgType), | ||
} | ||
|
@@ -446,7 +446,7 @@ func (td *TemData) NotifyDownstreams() error { | |
dest := net.JoinHostPort(d.Address, strconv.Itoa(d.Port)) | ||
csu := tapir.ComponentStatusUpdate{ | ||
Component: "downstream-notify", | ||
Status: "fail", | ||
Status: tapir.StatusFail, | ||
Msg: fmt.Sprintf("Notifying downstream %s about new SOA serial (%d) for RPZ zone %s", dest, td.Rpz.Axfr.SOA.Serial, td.Rpz.ZoneName), | ||
TimeStamp: time.Now(), | ||
} | ||
|
@@ -478,7 +478,7 @@ func (td *TemData) NotifyDownstreams() error { | |
td.Logger.Println(csu.Msg) | ||
continue | ||
} | ||
csu.Status = "success" | ||
csu.Status = tapir.StatusOK | ||
csu.Msg = fmt.Sprintf("Downstream %s responded correctly to NOTIFY(%s) about new SOA serial (%d)", dest, td.Rpz.ZoneName, td.Rpz.Axfr.SOA.Serial) | ||
Gconfig.Internal.ComponentStatusCh <- csu | ||
td.Logger.Println(csu.Msg) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (c) DNS TAPIR | ||
* Copyright (c) 2024 Johan Stenstam, [email protected] | ||
*/ | ||
package main | ||
|
||
|
@@ -172,24 +172,6 @@ func (td *TemData) ParseSourcesNG() error { | |
td.Logger.Printf("ParseSourcesNG: MQTT Engine already created") | ||
} | ||
|
||
// Ensure that the MQTT Engine listens on the DNS TAPIR config topic | ||
cfgtopic := viper.GetString("tapir.config.topic") | ||
if cfgtopic != "" { | ||
if td.Debug { | ||
td.Logger.Printf("ParseSourcesNG: Fetching MQTT validator key for topic %s", cfgtopic) | ||
} | ||
valkey, err := tapir.FetchMqttValidatorKey(cfgtopic, viper.GetString("tapir.config.validatorkey")) | ||
if err != nil { | ||
TEMExiter("Error fetching MQTT validator key for topic %s: %v", cfgtopic, err) | ||
} | ||
// err = td.MqttEngine.AddTopic(cfgtopic, nil, valkey) | ||
topicdata, err := td.MqttEngine.SubToTopic(cfgtopic, valkey, nil, "struct", true) // XXX: should have a channel to the config processor | ||
if err != nil { | ||
TEMExiter("Error adding topic %s to MQTT Engine: %v", cfgtopic, err) | ||
} | ||
td.Logger.Printf("ParseSourcesNG: Topic data for topic %s: %+v", cfgtopic, topicdata) | ||
} | ||
|
||
for name, src := range srcs { | ||
if !*src.Active { | ||
td.Logger.Printf("*** ParseSourcesNG: Source \"%s\" is not active. Ignored.", name) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters