summaryrefslogtreecommitdiff
path: root/cleaner.go
diff options
context:
space:
mode:
Diffstat (limited to 'cleaner.go')
-rw-r--r--cleaner.go21
1 files changed, 8 insertions, 13 deletions
diff --git a/cleaner.go b/cleaner.go
index fa93aa4..1e713b2 100644
--- a/cleaner.go
+++ b/cleaner.go
@@ -65,7 +65,7 @@ func cleanData(conf Config, db_user, db_pass, db_conn, db_name string) (err erro
//save cleaned data
for _, cd := range cDat {
- err = insertCleanData(tx, cd.ipbSrc, cd.ipbDst, cd.volume, cd.time, cd.port, cd.occurances)
+ err = insertCleanData(tx, cd)
if err != nil {
tx.Rollback()
log.Println("Failed to save cleaned data")
@@ -122,7 +122,7 @@ func getTimespan(t time.Time, conf Config) (span time.Time, err error) {
func clean(rDat []RawData, conf Config) (cDat []CleanData, err error) {
// collect all ips so we can query for their ip blocks
- ips := make(map[string]*asnipPair)
+ ips := make(map[string]struct{})
for _, rd := range rDat {
ips[rd.ipSrc] = nil
ips[rd.ipDst] = nil
@@ -137,16 +137,8 @@ func clean(rDat []RawData, conf Config) (cDat []CleanData, err error) {
if err != nil {
return
}
- for ix, p := range pairs {
- ips[p.ipAdr] = &pairs[ix]
- }
- var vol string
for _, rd := range rDat {
- vol, err = rd.getVolSize(conf)
- if err != nil {
- return
- }
var tim time.Time
tim, err = getTimespan(rd.time, conf)
if err != nil {
@@ -156,10 +148,13 @@ func clean(rDat []RawData, conf Config) (cDat []CleanData, err error) {
CleanData{
ipbSrc: ips[rd.ipSrc].ipBlock,
ipbDst: ips[rd.ipDst].ipBlock,
- time: tim,
- port: rd.port,
- volume: vol,
+ asSrc: rd.asSrc,
+ asDst: rd.asDst,
+ portSrc: rd.portSrc,
+ portDst: rd.portDst,
occurances: 1,
+ volume: rd.pktLenDist,
+ time: tim,
})
}