From 2fb8993008752063fa13f253784e9e92552e339d Mon Sep 17 00:00:00 2001
From: Emiliano Ciavatta
Date: Fri, 16 Oct 2020 11:13:21 +0200
Subject: Refactor js files
---
frontend/src/serviceWorker.js | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
(limited to 'frontend/src/serviceWorker.js')
diff --git a/frontend/src/serviceWorker.js b/frontend/src/serviceWorker.js
index b04b771..c633a91 100644
--- a/frontend/src/serviceWorker.js
+++ b/frontend/src/serviceWorker.js
@@ -57,7 +57,7 @@ export function register(config) {
function registerValidSW(swUrl, config) {
navigator.serviceWorker
.register(swUrl)
- .then(registration => {
+ .then((registration) => {
registration.onupdatefound = () => {
const installingWorker = registration.installing;
if (installingWorker == null) {
@@ -93,7 +93,7 @@ function registerValidSW(swUrl, config) {
};
};
})
- .catch(error => {
+ .catch((error) => {
console.error('Error during service worker registration:', error);
});
}
@@ -103,7 +103,7 @@ function checkValidServiceWorker(swUrl, config) {
fetch(swUrl, {
headers: { 'Service-Worker': 'script' },
})
- .then(response => {
+ .then((response) => {
// Ensure service worker exists, and that we really are getting a JS file.
const contentType = response.headers.get('content-type');
if (
@@ -111,7 +111,7 @@ function checkValidServiceWorker(swUrl, config) {
(contentType != null && contentType.indexOf('javascript') === -1)
) {
// No service worker found. Probably a different app. Reload the page.
- navigator.serviceWorker.ready.then(registration => {
+ navigator.serviceWorker.ready.then((registration) => {
registration.unregister().then(() => {
window.location.reload();
});
@@ -131,10 +131,10 @@ function checkValidServiceWorker(swUrl, config) {
export function unregister() {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.ready
- .then(registration => {
+ .then((registration) => {
registration.unregister();
})
- .catch(error => {
+ .catch((error) => {
console.error(error.message);
});
}
--
cgit v1.2.3-70-g09d2
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
(limited to 'frontend/src/serviceWorker.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}