diff options
author | Daniel Langesten <daniel.langest@gmail.com> | 2015-03-12 11:05:29 +0100 |
---|---|---|
committer | Daniel Langesten <daniel.langest@gmail.com> | 2015-03-12 11:05:29 +0100 |
commit | dc28b63102b26c34db2e056972d0b7173e263652 (patch) | |
tree | 4083daae3d9d6234e1604240c487954d8e84f6f8 | |
parent | 5a1a9adba51f858c45b6cba7e7a8c174d8cda481 (diff) |
removed constants from cleaner and added them as parameters so the code is more modular
-rw-r--r-- | cleaner.go | 11 | ||||
-rw-r--r-- | config.json | 2 | ||||
-rw-r--r-- | main.go | 9 | ||||
-rw-r--r-- | sqlQueries.go | 1 |
4 files changed, 12 insertions, 11 deletions
@@ -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, @@ -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 { |