Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion sdk/proto/events/event.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/core/topics.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ const (
Events = "events"
FileWatcherEnabled = "file.watcher.enabled"
ConfigRollbackResponse = "config.rollback.response"
NginxAppProtectDetailsGenerated = "nap.details.generated"
DataplaneSoftwareDetailsUpdated = "dataplane.software.details.updated"
EnableExtension = "enable.extension"
)
28 changes: 12 additions & 16 deletions src/plugins/dataplane_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,19 @@ func (dps *DataPlaneStatus) Info() *core.Info {
func (dps *DataPlaneStatus) Process(msg *core.Message) {
switch {
case msg.Exact(core.AgentConfigChanged):
log.Tracef("DataplaneStatus: %T message from topic %s received", msg.Data(), msg.Topic())
// If the agent config on disk changed update DataPlaneStatus with relevant config info
dps.syncAgentConfigChange()

case msg.Exact(core.NginxAppProtectDetailsGenerated):
// If a NAP report was generated sync it
dps.syncNAPDetails(msg)
case msg.Exact(core.DataplaneSoftwareDetailsUpdated):
log.Tracef("DataplaneStatus: %T message from topic %s received", msg.Data(), msg.Topic())
switch data := msg.Data().(type) {
case *proto.DataplaneSoftwareDetails_AppProtectWafDetails:
log.Debugf("DataplaneStatus is syncing with NAP details - %+v", data.AppProtectWafDetails)
dps.napDetailsMutex.Lock()
dps.napDetails = data
dps.napDetailsMutex.Unlock()
}

case msg.Exact(core.NginxConfigValidationPending):
log.Tracef("DataplaneStatus: %T message from topic %s received", msg.Data(), msg.Topic())
Expand All @@ -100,6 +107,7 @@ func (dps *DataPlaneStatus) Process(msg *core.Message) {
default:
log.Errorf("Expected the type %T but got %T", &proto.AgentActivityStatus{}, data)
}

case msg.Exact(core.NginxConfigApplyFailed) || msg.Exact(core.NginxConfigApplySucceeded):
log.Tracef("DataplaneStatus: %T message from topic %s received", msg.Data(), msg.Topic())
switch data := msg.Data().(type) {
Expand All @@ -116,7 +124,7 @@ func (dps *DataPlaneStatus) Process(msg *core.Message) {
func (dps *DataPlaneStatus) Subscriptions() []string {
return []string{
core.AgentConfigChanged,
core.NginxAppProtectDetailsGenerated,
core.DataplaneSoftwareDetailsUpdated,
core.NginxConfigValidationPending,
core.NginxConfigApplyFailed,
core.NginxConfigApplySucceeded,
Expand Down Expand Up @@ -330,15 +338,3 @@ func (dps *DataPlaneStatus) syncAgentConfigChange() {
dps.tags = &conf.Tags
dps.configDirs = conf.ConfigDirs
}

func (dps *DataPlaneStatus) syncNAPDetails(msg *core.Message) {
switch commandData := msg.Data().(type) {
case *proto.DataplaneSoftwareDetails_AppProtectWafDetails:
log.Debugf("DataPlaneStatus is syncing with NAP details - %+v", commandData.AppProtectWafDetails)
dps.napDetailsMutex.Lock()
dps.napDetails = commandData
dps.napDetailsMutex.Unlock()
default:
log.Errorf("Expected the type %T but got %T", &proto.DataplaneSoftwareDetails_AppProtectWafDetails{}, commandData)
}
}
4 changes: 2 additions & 2 deletions src/plugins/dataplane_status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ func TestDPSSyncNAPDetails(t *testing.T) {
assert.Equal(t, tc.initialNAPDetails, dataPlaneStatus.napDetails)

// Send updated NAP details message
dataPlaneStatus.Process(core.NewMessage(core.NginxAppProtectDetailsGenerated, tc.updatedNAPDetails))
dataPlaneStatus.Process(core.NewMessage(core.DataplaneSoftwareDetailsUpdated, tc.updatedNAPDetails))

// Check if NAP details were updated
assert.Equal(t, tc.updatedNAPDetails, dataPlaneStatus.napDetails)
Expand All @@ -326,7 +326,7 @@ func TestDPSSyncNAPDetails(t *testing.T) {
func TestDataPlaneSubscriptions(t *testing.T) {
expectedSubscriptions := []string{
core.AgentConfigChanged,
core.NginxAppProtectDetailsGenerated,
core.DataplaneSoftwareDetailsUpdated,
core.NginxConfigValidationPending,
core.NginxConfigApplyFailed,
core.NginxConfigApplySucceeded,
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/nginx_app_protect.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (n *NginxAppProtect) addSoftwareDetailsToRegistration(msg *core.Message) {
func (n *NginxAppProtect) monitor() {
initialDetails := n.generateNAPDetailsProtoCommand()
log.Infof("Initial Nginx App Protect details: %+v", initialDetails)
n.messagePipeline.Process(core.NewMessage(core.NginxAppProtectDetailsGenerated, initialDetails))
n.messagePipeline.Process(core.NewMessage(core.DataplaneSoftwareDetailsUpdated, initialDetails))

napUpdateChannel := n.nap.Monitor(n.reportInterval)

Expand All @@ -119,7 +119,7 @@ func (n *NginxAppProtect) monitor() {
// Communicate the update in NAP status via message pipeline
log.Infof("Change in NAP detected... Previous: %+v... Updated: %+v", updateMsg.PreviousReport, updateMsg.UpdatedReport)
napReportMsg := n.generateNAPDetailsProtoCommand()
n.messagePipeline.Process(core.NewMessage(core.NginxAppProtectDetailsGenerated, napReportMsg))
n.messagePipeline.Process(core.NewMessage(core.DataplaneSoftwareDetailsUpdated, napReportMsg))

case <-time.After(n.reportInterval):
log.Infof("No NAP changes detected after %v seconds... NAP Values: %+v", n.reportInterval.Seconds(), n.nap.GenerateNAPReport())
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.