summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cleaner.go11
-rw-r--r--config.json2
-rw-r--r--main.go9
-rw-r--r--sqlQueries.go1
4 files changed, 12 insertions, 11 deletions
diff --git a/cleaner.go b/cleaner.go
index 588dbec..45811b8 100644
--- a/cleaner.go
+++ b/cleaner.go
@@ -9,16 +9,9 @@ import (
"time"
)
-const (
- DATABASE_USER = "cleaner"
- DATABASE_PASS = "nil"
- DATABASE_CONNECTION = "" //e.g. "tcp(localhost:55555)
- DATABASE_NAME = "netflow"
-)
-
-func cleanData(conf Config) (err error) {
+func cleanData(conf Config, db_user, db_pass, db_conn, db_name string) (err error) {
- db, err := sql.Open("mysql", DATABASE_USER+":"+DATABASE_PASS+"@/"+DATABASE_NAME)
+ db, err := sql.Open("mysql", db_user+":"+db_pass+"@"+db_conn+"/"+db_name)
if err != nil {
log.Println("Failed to connect to db")
return
diff --git a/config.json b/config.json
index 204ac18..4447a1b 100644
--- a/config.json
+++ b/config.json
@@ -1,6 +1,6 @@
{
"comment Interval": "Interval is how large time intervals that the data should be grouped into",
- "interval": "5min",
+ "interval": "day",
"comment Epsilon": "Epsilon is the epsilon value for differential privacy. epsilon < 1 high privacy, 10 < epsilon low privacy. If epsilon is set to 0, differential privacy will not be used.",
"epsilon": 0,
diff --git a/main.go b/main.go
index 0631041..894a778 100644
--- a/main.go
+++ b/main.go
@@ -7,6 +7,13 @@ import (
//"strings"
)
+const (
+ DATABASE_USER = "cleaner"
+ DATABASE_PASS = "nil"
+ DATABASE_CONNECTION = "" //e.g. "tcp(localhost:55555)
+ DATABASE_NAME = "netflow"
+)
+
func main() {
conf, err := readConfig()
if err != nil {
@@ -23,7 +30,7 @@ func main() {
}
}
*/
- err = cleanData(conf)
+ err = cleanData(conf, DATABASE_USER, DATABASE_PASS, DATABASE_CONNECTION, DATABASE_NAME)
if err != nil {
log.Println(err)
}
diff --git a/sqlQueries.go b/sqlQueries.go
index ef0c791..99a35d2 100644
--- a/sqlQueries.go
+++ b/sqlQueries.go
@@ -85,6 +85,7 @@ func purgeProcessed(db *sql.DB, tim time.Time) (err error) {
return
}
+//Removes all rawdata that is in rDat from the database
func purgeRawData(tx *sql.Tx, rDat []RawData) (err error) {
prepStmt, err := tx.Prepare("DELETE FROM raw_data WHERE ip_src = ? AND ip_dst = ? AND time = ? AND port = ? AND packet_size = ? AND process_time IS NOT NULL LIMIT 1")
if err != nil {