Skip to content

Commit

Permalink
Refactor module startup
Browse files Browse the repository at this point in the history
  • Loading branch information
joshrendek committed Nov 3, 2024
1 parent 98c83e9 commit c2ed1a7
Show file tree
Hide file tree
Showing 9 changed files with 392 additions and 391 deletions.
7 changes: 4 additions & 3 deletions elasticsearch/es.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package elasticsearch

import (
"fmt"
"github.com/joshrendek/threat.gg-agent/honeypots"
"net/http"
"strings"

"github.com/joshrendek/threat.gg-agent/honeypots"
"github.com/joshrendek/threat.gg-agent/persistence"
"github.com/joshrendek/threat.gg-agent/proto"
"github.com/joshrendek/threat.gg-agent/stats"
Expand Down Expand Up @@ -76,8 +76,9 @@ func (e *ES) ServeHTTP(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, resp)
}

func init() {
honeypots.Register(&honeypot{logger: zerolog.New(os.Stdout).With().Str("honeypot", "elasticsearch").Logger()})
func New() honeypots.Honeypot {
h := &honeypot{logger: zerolog.New(os.Stdout).With().Caller().Str("honeypot", "elasticsearch").Logger()}
return h
}

func (h *honeypot) Name() string {
Expand Down
5 changes: 3 additions & 2 deletions ftp/go-ftp.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ type honeypot struct {
logger zerolog.Logger
}

func init() {
honeypots.Register(&honeypot{logger: zerolog.New(os.Stdout).With().Caller().Str("honeypot", "ftp").Logger()})
func New() honeypots.Honeypot {
h := &honeypot{logger: zerolog.New(os.Stdout).With().Caller().Str("honeypot", "ftp").Logger()}
return h
}

func (h *honeypot) Name() string {
Expand Down
3 changes: 0 additions & 3 deletions honeypots/honeypots.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package honeypots

import (
"fmt"

"github.com/jellydator/ttlcache/v3"
"github.com/rs/zerolog/log"
)
Expand All @@ -22,7 +20,6 @@ func Register(h Honeypot) {
}

func StartHoneypots() {
fmt.Println("--------> honeypots: ", honeypots)
for _, h := range honeypots {
log.Info().Str("honeypot", h.Name()).Msg("starting")
go h.Start()
Expand Down
Loading

0 comments on commit c2ed1a7

Please sign in to comment.