aboutsummaryrefslogtreecommitdiff
path: root/application_context.go
diff options
context:
space:
mode:
authorEmiliano Ciavatta2020-07-17 09:12:09 +0000
committerEmiliano Ciavatta2020-07-17 09:12:09 +0000
commitdb8ff43c5e1595c02e2ba67c3c78f239723f95bd (patch)
tree7350c2aa72cbc875e15bb6f3ddd67fb0d2f15310 /application_context.go
parent0f0a28c81cc73d2eade3188ba470343f16dc5478 (diff)
Added support for cidr addresses when checking server ip
Diffstat (limited to 'application_context.go')
-rw-r--r--application_context.go15
1 files changed, 7 insertions, 8 deletions
diff --git a/application_context.go b/application_context.go
index 6960c7d..e4be74d 100644
--- a/application_context.go
+++ b/application_context.go
@@ -3,13 +3,12 @@ package main
import (
"github.com/gin-gonic/gin"
log "github.com/sirupsen/logrus"
- "net"
)
type Config struct {
- ServerIP string `json:"server_ip" binding:"required,ip" bson:"server_ip"`
- FlagRegex string `json:"flag_regex" binding:"required,min=8" bson:"flag_regex"`
- AuthRequired bool `json:"auth_required" bson:"auth_required"`
+ ServerAddress string `json:"server_address" binding:"required,ip|cidr" bson:"server_address"`
+ FlagRegex string `json:"flag_regex" binding:"required,min=8" bson:"flag_regex"`
+ AuthRequired bool `json:"auth_required" bson:"auth_required"`
}
type ApplicationContext struct {
@@ -77,11 +76,11 @@ func (sm *ApplicationContext) configure() {
if sm.IsConfigured {
return
}
- if sm.Config.ServerIP == "" || sm.Config.FlagRegex == "" {
+ if sm.Config.ServerAddress == "" || sm.Config.FlagRegex == "" {
return
}
- serverIP := net.ParseIP(sm.Config.ServerIP)
- if serverIP == nil {
+ serverNet := ParseIPNet(sm.Config.ServerAddress)
+ if serverNet == nil {
return
}
@@ -90,7 +89,7 @@ func (sm *ApplicationContext) configure() {
log.WithError(err).Panic("failed to create a RulesManager")
}
sm.RulesManager = rulesManager
- sm.PcapImporter = NewPcapImporter(sm.Storage, serverIP, sm.RulesManager)
+ sm.PcapImporter = NewPcapImporter(sm.Storage, *serverNet, sm.RulesManager)
sm.ServicesController = NewServicesController(sm.Storage)
sm.ConnectionsController = NewConnectionsController(sm.Storage, sm.ServicesController)
sm.ConnectionStreamsController = NewConnectionStreamsController(sm.Storage)