1
4
mirror of https://github.com/yunginnanet/HellPot synced 2024-06-28 08:40:48 +00:00

gofmt and refine logging

This commit is contained in:
kayos 2021-06-11 17:15:02 -07:00
parent 3f75a2c7de
commit db7f5d7103
7 changed files with 61 additions and 41 deletions

@ -32,3 +32,21 @@ Live example: <a href="https://vx-underground.org/wp-login.php" rel="nofollow">D
If the configuration file is missing, the default settings will automatically drop itself in the current working directory as `config.toml`.
```
title = "HellPot"
[logger]
debug = false
log_directory = "./logs/"
[http]
bind_addr = "127.0.0.1"
bind_port = "8080"
# paths to be added to robots.txt that we will respond to
paths = [
"wp-login.php",
"wp-login",
]
```

@ -1,7 +1,7 @@
title = "HellPot"
[logger]
debug = false
debug = true
log_directory = "./logs/"
[http]

10
http.go

@ -39,6 +39,12 @@ func NewHoneypot(mm MarkovMap, buffsize int) http.HandlerFunc {
paths = paths + "Disallow: " + p + "\r\n"
}
log.Debug().
Str("UserAgent", r.UserAgent()).
Strs("REMOTE_ADDR", r.Header.Values("X-Real-IP")).
Strs("PATHS", config.Paths).
Msg("SERVE_ROBOTS")
if _, err := io.WriteString(w, robotsTxt+paths+"\r\n"); err != nil {
log.Error().Err(err).Msg("SERVE_ROBOTS_ERROR")
}
@ -69,13 +75,13 @@ func NewHoneypot(mm MarkovMap, buffsize int) http.HandlerFunc {
buf := getBuffer()
defer putBuffer(buf)
io.WriteString(w, "<HTML>\n<BODY>\n")
n, err := io.CopyBuffer(w, mm, buf)
n, _ := io.CopyBuffer(w, mm, buf)
log.Info().
Str("UserAgent", r.UserAgent()).
Interface("URL", r.URL.RequestURI()).
Strs("REMOTE_ADDR", r.Header.Values("X-Real-IP")).
Int64("BYTES", n).
Dur("DURATION", time.Since(s)).
Err(err).Msg("FINISH")
Msg("FINISH")
}
}

@ -10,10 +10,8 @@ import (
// ascii banners and other aesthetic shit
"HellPot/src/decorate"
// bitcask embedded key/value database
//"HellPot/src/casket"
)
var log zerolog.Logger

@ -169,7 +169,7 @@ func Blueprint() {
buf, err := ioutil.ReadAll(f)
err2 := Config.ReadConfig(bytes.NewBuffer(buf))
if (err != nil || err2 != nil) {
if err != nil || err2 != nil {
println("Error reading specified config file: " + os.Args[i+1])
if err != nil {
panic("config file read fatal error: " + err.Error())
@ -274,7 +274,6 @@ func associate() {
zerolog.SetGlobalLevel(zerolog.DebugLevel)
}
for _, key := range Config.AllKeys() {
log.Debug().Str("key", key).Msg("LOAD_CONFIG_DIRECTIVE")
}

@ -26,4 +26,3 @@ func LogInit() {
multi := zerolog.MultiLevelWriter(zerolog.ConsoleWriter{Out: os.Stderr}, logFile)
GlobalLogger = zerolog.New(multi).With().Timestamp().Logger()
}