From d4bac2d6741f7a291522c29c9ecc87c3e32e21d4 Mon Sep 17 00:00:00 2001
From: Emiliano Ciavatta
Date: Fri, 16 Oct 2020 14:16:44 +0200
Subject: Add notification when pcap have been processed
---
application_context.go | 12 +-
caronte.go | 2 +
frontend/src/components/App.js | 6 +-
frontend/src/components/Notifications.js | 17 +-
frontend/src/components/Timeline.js | 88 +++++----
frontend/src/components/fields/ButtonField.js | 2 +-
frontend/src/components/fields/ChoiceField.js | 10 +-
frontend/src/components/objects/Connection.js | 36 +---
.../components/objects/ConnectionMatchedRules.js | 10 +-
frontend/src/components/objects/CopyLinkPopover.js | 54 ++++++
frontend/src/components/objects/MessageAction.js | 15 +-
frontend/src/components/panels/ConnectionsPane.js | 107 +++++------
frontend/src/components/panels/PcapsPane.js | 40 ++--
frontend/src/components/panels/RulesPane.js | 51 ++---
frontend/src/components/panels/SearchPane.js | 34 ++--
frontend/src/components/panels/ServicesPane.js | 68 ++++---
frontend/src/serviceWorker.js | 208 ++++++++++-----------
parsers/http_request_parser.go | 12 +-
pcap_importer.go | 39 ++--
19 files changed, 458 insertions(+), 353 deletions(-)
create mode 100644 frontend/src/components/objects/CopyLinkPopover.js
diff --git a/application_context.go b/application_context.go
index 8abb6f4..0410b88 100644
--- a/application_context.go
+++ b/application_context.go
@@ -39,6 +39,7 @@ type ApplicationContext struct {
ConnectionStreamsController ConnectionStreamsController
SearchController *SearchController
StatisticsController StatisticsController
+ NotificationController *NotificationController
IsConfigured bool
Version string
}
@@ -70,13 +71,12 @@ func CreateApplicationContext(storage Storage, version string) (*ApplicationCont
Version: version,
}
- applicationContext.configure()
return applicationContext, nil
}
func (sm *ApplicationContext) SetConfig(config Config) {
sm.Config = config
- sm.configure()
+ sm.Configure()
var upsertResults interface{}
if _, err := sm.Storage.Update(Settings).Upsert(&upsertResults).
Filter(OrderedDocument{{"_id", "config"}}).One(UnorderedDocument{"config": config}); err != nil {
@@ -93,7 +93,11 @@ func (sm *ApplicationContext) SetAccounts(accounts gin.Accounts) {
}
}
-func (sm *ApplicationContext) configure() {
+func (sm *ApplicationContext) SetNotificationController(notificationController *NotificationController) {
+ sm.NotificationController = notificationController
+}
+
+func (sm *ApplicationContext) Configure() {
if sm.IsConfigured {
return
}
@@ -110,7 +114,7 @@ func (sm *ApplicationContext) configure() {
log.WithError(err).Panic("failed to create a RulesManager")
}
sm.RulesManager = rulesManager
- sm.PcapImporter = NewPcapImporter(sm.Storage, *serverNet, sm.RulesManager)
+ sm.PcapImporter = NewPcapImporter(sm.Storage, *serverNet, sm.RulesManager, sm.NotificationController)
sm.ServicesController = NewServicesController(sm.Storage)
sm.SearchController = NewSearchController(sm.Storage)
sm.ConnectionsController = NewConnectionsController(sm.Storage, sm.SearchController, sm.ServicesController)
diff --git a/caronte.go b/caronte.go
index 2d24af6..95f00ef 100644
--- a/caronte.go
+++ b/caronte.go
@@ -51,10 +51,12 @@ func main() {
notificationController := NewNotificationController(applicationContext)
go notificationController.Run()
+ applicationContext.SetNotificationController(notificationController)
resourcesController := NewResourcesController(notificationController)
go resourcesController.Run()
+ applicationContext.Configure()
applicationRouter := CreateApplicationRouter(applicationContext, notificationController, resourcesController)
if applicationRouter.Run(fmt.Sprintf("%s:%v", *bindAddress, *bindPort)) != nil {
log.WithError(err).WithFields(logFields).Fatal("failed to create the server")
diff --git a/frontend/src/components/App.js b/frontend/src/components/App.js
index 0f700db..888ff86 100644
--- a/frontend/src/components/App.js
+++ b/frontend/src/components/App.js
@@ -15,10 +15,10 @@
* along with this program. If not, see
{n.description}