diff --git a/src/routers/funcs.go b/src/routers/funcs.go index 5fcb2fd..6524909 100644 --- a/src/routers/funcs.go +++ b/src/routers/funcs.go @@ -3,7 +3,6 @@ package routers import ( "context" "fmt" - "log" "net/http" "strconv" @@ -87,7 +86,6 @@ func RegisterRoutes(e *echo.Echo, ctx *context.Context, cfg *config.Config) { } numinsert, numupdate, _ := models.InsertIPBulk(session, &ips) msg = fmt.Sprintf("Inserted %d IP, Updated %d IP", numinsert, numupdate) - log.Println(msg) return Result(c, err, msg) }) e.POST("/event", func(c echo.Context) (err error) { diff --git a/src/ws/init.go b/src/ws/init.go index 6ffee2b..d58fb77 100644 --- a/src/ws/init.go +++ b/src/ws/init.go @@ -43,6 +43,15 @@ func WelcomeAgents(ws *websocket.Conn, welcome WSWelcome, t string) { } } +func gcConn(conn *websocket.Conn) (err error) { + for index, value := range LISTENERS { + if value.ConnectionPS == conn || value.ConnectionRR == conn { + delete(LISTENERS, index) + } + } + return err +} + type ConnectionInfo struct { ConnectionPS *websocket.Conn ConnectionRR *websocket.Conn @@ -52,12 +61,3 @@ type ConnectionInfo struct { type WSWelcome struct { Hostname string } - -func gcConn(conn *websocket.Conn, t string) (err error) { - for index, value := range LISTENERS { - if value.ConnectionPS == conn { - delete(LISTENERS, index) - } - } - return err -} diff --git a/src/ws/reqrep.go b/src/ws/reqrep.go index 9815040..bca8628 100644 --- a/src/ws/reqrep.go +++ b/src/ws/reqrep.go @@ -80,11 +80,14 @@ func HandleWSRR(c echo.Context, cfg *config.Config) error { err = websocket.Message.Send(value.ConnectionPS, msg) if err != nil { log.Println(err) + } } default: } + gcConn(ws) + err = websocket.Message.Send(ws, "OK") if err != nil { log.Println(err)