From 468690c60ee2e57ed2ccb4375e9ada5d2fed9473 Mon Sep 17 00:00:00 2001 From: Emiliano Ciavatta Date: Tue, 7 Apr 2020 20:46:36 +0200 Subject: Before storage refactor --- caronte.go | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'caronte.go') diff --git a/caronte.go b/caronte.go index 6b33318..a32b619 100644 --- a/caronte.go +++ b/caronte.go @@ -1,26 +1,33 @@ package main import ( + "flag" "fmt" - "net" + "github.com/gin-gonic/gin" + "log" ) func main() { - // pattern.Flags |= hyperscan.SomLeftMost + // test(); return + mongoHost := flag.String("mongo-host", "localhost", "address of MongoDB") + mongoPort := flag.Int("mongo-port", 27017, "port of MongoDB") + dbName := flag.String("db-name", "caronte", "name of database to use") - storage := NewMongoStorage("localhost", 27017, "testing") + bindAddress := flag.String("bind-address", "0.0.0.0", "address where server is bind") + bindPort := flag.Int("bind-port", 3333, "port where server is bind") + + flag.Parse() + + storage := NewMongoStorage(*mongoHost, *mongoPort, *dbName) err := storage.Connect(nil) if err != nil { - panic(err) + log.Panicln("failed to connect to MongoDB:", err) } - importer := NewPcapImporter(storage, net.ParseIP("10.10.10.10")) - - sessionId, err := importer.ImportPcap("capture_00459_20190627165500.pcap") + router := gin.Default() + ApplicationRoutes(router) + err = router.Run(fmt.Sprintf("%s:%v", *bindAddress, *bindPort)) if err != nil { - fmt.Println(err) - } else { - fmt.Println(sessionId) + log.Panicln("failed to create the server:", err) } - } -- cgit v1.2.3-70-g09d2