From e92d332269b457b9699578592ef0a6967900c606 Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Sun, 11 Sep 2022 23:34:51 +0200 Subject: [PATCH] updated ipbl to handle init of ipblc --- src/config/main.go | 8 ++++---- src/models/ip.go | 1 + src/zmqrouter/main.go | 16 +++++++++------- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/config/main.go b/src/config/main.go index d8c61fd..658c90e 100644 --- a/src/config/main.go +++ b/src/config/main.go @@ -55,18 +55,18 @@ func (cfg *Config) GetConfig() error { } type Config struct { - Db *xorm.Engine `json:"-"` + Db *xorm.Engine DbParams struct { DbHostname string DbUsername string DbPassword string DbDatabase string - } `json:"-"` + } Options struct { Version string HideBanner bool ZMQChannel string - } `json:"-"` + } Switchs struct { Port int NoFeed bool @@ -75,5 +75,5 @@ type Config struct { Init bool Version bool NoScanIP bool - } `json:"-"` + } } diff --git a/src/models/ip.go b/src/models/ip.go index ff76159..6f9524d 100644 --- a/src/models/ip.go +++ b/src/models/ip.go @@ -219,4 +219,5 @@ type APIIP struct { City string `json:"city"` Country string `json:"country"` Date string `json:"date"` + Mode string `json:"mode"` } diff --git a/src/zmqrouter/main.go b/src/zmqrouter/main.go index e9ffe7c..c4feda0 100644 --- a/src/zmqrouter/main.go +++ b/src/zmqrouter/main.go @@ -49,16 +49,18 @@ func Handle(cfg *config.Config, reqsock *goczmq.Sock, pubsock *goczmq.Sock, chan log.Println("unable to parse ip address", err) continue } - ip = *apiip.APIConvert() + if apiip.Mode != "init" { + ip = *apiip.APIConvert() - numinsert, numupdate, err := ip.InsertOrUpdate(cfg) - if err != nil { - log.Println(err) + numinsert, numupdate, err := ip.InsertOrUpdate(cfg) + if err != nil { + log.Println(err) + } + log.Printf("zmq: Inserted %d IP, Updated %d IP\n", numinsert, numupdate) } - log.Printf("zmq: Inserted %d IP, Updated %d IP\n", numinsert, numupdate) tmpval := fmt.Sprintf("%s %s", channel, string(val)) - val = []byte(tmpval) - topub = append(topub, val) + ipjson := []byte(tmpval) + topub = append(topub, ipjson) } err = pubsock.SendMessage(topub)