Skip to content
Draft
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
146c5c1
Add optional `-b`/`--book` flag to choose source file other than Niet…
ginger51011 Jan 18, 2024
0ba61ed
Remove globals from heffalump/*, add NewDefault{Heffalump,MarkovMap}()
ginger51011 Jan 19, 2024
3671a67
Add short flags to help, add `--help` flag
ginger51011 Jan 20, 2024
3024b2d
Rename --book to --grimoire, fix comments
ginger51011 Feb 2, 2024
0a18454
TeeHee: Essentially rewrite HellPot :^)
yunginnanet Jun 21, 2024
f02f6bf
Fix: build and vet errors
yunginnanet Jun 21, 2024
b9702c2
Fix: Remove unused git stash lint
yunginnanet Jun 21, 2024
a9a3e52
SAST: Resolve gosec G304
yunginnanet Jun 21, 2024
f0fcb56
Fix: don't parse flags during unit tests
yunginnanet Jun 21, 2024
a09adb6
Chore: prune deps
yunginnanet Jun 21, 2024
5c0d345
Resolve https://github.com/yunginnanet/HellPot/pull/162#discussion_r1…
yunginnanet Jun 21, 2024
51ff751
Fix: nil check on buffer pointer
yunginnanet Jun 21, 2024
c1977ba
WIP rewrite progress, config loading broken atm
yunginnanet Jun 26, 2024
072ea6f
Fix: fix configuration file loading
yunginnanet Jun 26, 2024
982a076
Security (logger): Resolve gosec G301 (CWE-276)
yunginnanet Jun 26, 2024
4977844
Security (logger): Resolve gosec G302 (CWE-276)
yunginnanet Jun 26, 2024
d662ee9
Chore: Tidy up, split up files in main package
yunginnanet Jun 26, 2024
8b9603b
Chore: go mod tidy
yunginnanet Jun 26, 2024
92818e4
Fix: cli arg, config, and logger fixes
yunginnanet Jun 26, 2024
578aea0
Fix: Embolden main package test, improve default config warning
yunginnanet Jun 26, 2024
23c65b9
Fix: add missing `util.go`
yunginnanet Jun 26, 2024
93dcb98
Fix: fix CLI arg <-> config <-> env parity
yunginnanet Jun 26, 2024
5724075
Fix (cli): dupe/invalid flag alias, fix test case send on closed channel
yunginnanet Jun 26, 2024
e0b4c0a
Fix (grimoire): check for opening and closing brackets in source
yunginnanet Jun 26, 2024
0bc411a
Entropy: improve markov map randomness, decrease detectability
yunginnanet Jun 26, 2024
e43c603
Security (heffalump): nosec gosec G404 (entropy)
yunginnanet Jun 26, 2024
e31113b
Fix (config): Logger config persistence, implement syslog (tested wor…
yunginnanet Jun 26, 2024
38b0e05
Fix: Logger and main package init fixes
yunginnanet Jun 28, 2024
0d8af97
Feat: internal toml (Marshal)
yunginnanet Jun 30, 2024
42c3b2a
Bump github.com/knadh/koanf/providers/file from 0.1.0 to 1.0.0
dependabot[bot] Jul 1, 2024
043fb93
Merge branch 'main' into development
yunginnanet Jul 2, 2024
97bfa7c
Feat: internal toml (Unmarshal) (WIP)
yunginnanet Jul 2, 2024
22f01d3
Merge branch 'development' into internal_toml
yunginnanet Jul 2, 2024
3008d84
Feat: Internal Toml (Unmarshal): Fix decoder, add test
yunginnanet Jul 2, 2024
d7ff3c3
Fix: wrap error
yunginnanet Jul 22, 2024
445008e
Fix+Test: marshalling int slices + decoder progress
yunginnanet Jul 27, 2024
12f18cb
Checkpoint: initial toml decoding success
yunginnanet Jul 27, 2024
9a1d012
Chore: bump deps
yunginnanet Mar 6, 2025
87a34ef
Merge main -> dev (#197)
yunginnanet Mar 6, 2025
8703a33
Chore: deps
yunginnanet Apr 2, 2025
776d50d
Fix: functioning toml serde
yunginnanet Apr 2, 2025
4aca277
CI: update workflow, run on all branches
yunginnanet Apr 2, 2025
e4bc51c
CI: update workflow, run on all branches
yunginnanet Apr 2, 2025
34683d5
Security: resolve gosec G115 (CWE-190)
yunginnanet Sep 4, 2024
fe9f516
Security: resolve gosec G115 (CWE-190)
yunginnanet Apr 2, 2025
0257881
Fix[#199]: bump go version in Dockerfile
yunginnanet Mar 31, 2025
9c6c95c
Slimfast: remove toml in favor of yunginnanet/toml
yunginnanet Jul 3, 2025
58d8ca8
Merge branch 'internal_toml' into development
yunginnanet Jul 3, 2025
78cfd1a
Dist[gomod]: fix common package path
yunginnanet Jul 3, 2025
7315489
Merge branch 'main' into development
yunginnanet Jul 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
all: deps check build
format:
format :
find . -iname "*.go" -exec gofmt -s -l -w {} \;
check:
check :
go vet ./...
run:
run :
go run cmd/HellPot/*.go
deps:
go mod tidy -v
build:
go build -trimpath -ldflags "-s -w -X main.version=`git tag --sort=-version:refname | head -n 1`" cmd/HellPot/*.go
test :
go test -v ./...
build :
go build -x -trimpath -ldflags "-s -w -X main.version=`git tag --sort=-version:refname | head -n 1`" cmd/HellPot/*.go
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Clients (hopefully bots) that disregard `robots.txt` and connect to your instanc

HellPot will send an infinite stream of data that is _just close enough_ to being a real website that they might just stick around until their soul is ripped apart and they cease to exist.

Under the hood of this eternal suffering is a markov engine that chucks bits and pieces of [The Birth of Tragedy (Hellenism and Pessimism)](https://www.gutenberg.org/files/51356/51356-h/51356-h.htm) by Friedrich Nietzsche at the client using [fasthttp](https://github.com/valyala/fasthttp).
Under the hood of this eternal suffering is a markov engine that chucks bits and pieces of [The Birth of Tragedy (Hellenism and Pessimism)](https://www.gutenberg.org/files/51356/51356-h/51356-h.htm) by Friedrich Nietzsche at the client~~~~ using [fasthttp](https://github.com/valyala/fasthttp), or optionally you may synchronize HellPot with your nightmares by using the `-g`/`--grimoire` flag

## Building From Source

Expand Down
54 changes: 11 additions & 43 deletions cmd/HellPot/HellPot.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,58 +2,26 @@ package main

import (
"os"
"os/signal"
"syscall"

"github.com/rs/zerolog"

"github.com/yunginnanet/HellPot/internal/config"
"github.com/yunginnanet/HellPot/internal/extra"
"github.com/yunginnanet/HellPot/internal/http"
)

var (
log zerolog.Logger
version string // set by linker
)

func init() {
if version != "" {
config.Version = version[1:]
}
config.Init()
if config.BannerOnly {
extra.Banner()
os.Exit(0)
}
func main() {
stopChan := make(chan os.Signal, 1)
log, resolvedConf, realConf, err := setup(stopChan)

switch config.DockerLogging {
case true:
config.CurrentLogFile = "/dev/stdout"
config.NoColor = true
log = config.StartLogger(false, os.Stdout)
default:
log = config.StartLogger(true)
if err != nil {
println("failed to start: " + err.Error())
os.Exit(1)
}

extra.Banner()

log.Info().Str("caller", "config").Str("file", config.Filename).Msg(config.Filename)
log.Info().Str("caller", "logger").Msg(config.CurrentLogFile)
log.Debug().Str("caller", "logger").Msg("debug enabled")
log.Trace().Str("caller", "logger").Msg("trace enabled")

}

func main() {
stopChan := make(chan os.Signal, 1)
signal.Notify(stopChan, syscall.SIGINT, syscall.SIGTERM)
printInfo(log, resolvedConf, realConf)

go func() {
log.Fatal().Err(http.Serve()).Msg("HTTP error")
log.Fatal().Err(http.Serve(realConf)).Msg("HTTP error")
}()

<-stopChan // wait for SIGINT
log.Warn().Msg("Shutting down server...")

sig := <-stopChan // wait for SIGINT
log.Warn().Interface("signal_received", sig).
Msg("Shutting down server...")
}
102 changes: 102 additions & 0 deletions cmd/HellPot/HellPot_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
package main

import (
"os"
"path/filepath"
"strconv"
"strings"
"testing"
"time"

"github.com/yunginnanet/HellPot/internal/config"
"github.com/yunginnanet/HellPot/internal/http"
"github.com/yunginnanet/HellPot/internal/logger"
)

func testMain(t *testing.T) (string, chan os.Signal, *logger.Log, *config.Parameters, error) {
t.Setenv("HELLPOT_TEST_MODE", "true")
t.Helper()
stopChan := make(chan os.Signal, 1)

log, resolvedConf, realConfig, err := setup(stopChan)
if err == nil {
printInfo(log, resolvedConf, realConfig)
go func() {
terr := http.Serve(realConfig)
if terr != nil {
t.Error("failed to serve HTTP: " + terr.Error())
return
}
}()
}
//goland:noinspection GoNilness
return resolvedConf, stopChan, log, realConfig, err
}

func TestHellPot(t *testing.T) {
tDir := filepath.Join(t.TempDir(), strconv.Itoa(int(time.Now().Unix())))
logDir := filepath.Join(tDir, "logs")
if err := os.MkdirAll(logDir, 0755); err != nil {
t.Fatal(err)
}
confFile := filepath.Join(tDir, "HellPot_test.toml")
t.Setenv("HELLPOT_LOGGER_DIRECTORY", logDir)
t.Setenv("HELLPOT_LOGGER_RSYSLOG__ADDRESS", "local")
t.Setenv("HELLPOT_LOGGER_DEBUG", "true")
t.Setenv("HELLPOT_CONFIG", confFile)

resolvedConf, stopChan, log, realConfig, err := testMain(t)

if err != nil {
t.Fatal(err)
}
if log == nil {
t.Fatal("log is nil")
}
if realConfig == nil {
t.Fatal("realConfig is nil")
}

logFile := log.Config.ActiveLogFileName

if stopChan == nil {
t.Fatal("stopChan is nil")
}
if resolvedConf == "" {
t.Fatal("resolvedConf is empty")
}
if logFile == "" {
t.Fatal("logFile is empty")
}
if _, err = os.Stat(logFile); err != nil {
t.Fatal(err)
}
if resolvedConf != confFile {
t.Errorf("expected %s, got %s", confFile, resolvedConf)
}
if logFile != filepath.Join(logDir, "HellPot.log") {
t.Errorf("expected %s, got %s", filepath.Join(logDir, "HellPot.log"), logFile)
}
time.Sleep(25 * time.Millisecond) // sync maybe
logDat, err := os.ReadFile(logFile)
if err != nil {
t.Error(err)
}
if !strings.Contains(string(logDat), "🔥 Starting HellPot 🔥") {
t.Errorf("expected log to contain '🔥 Starting HellPot 🔥', got %s", logDat)
}
if !strings.Contains(string(logDat), logFile) {
t.Errorf("expected log to contain '%s'", logFile)
}
if !strings.Contains(string(logDat), resolvedConf) {
t.Errorf("expected log to contain '%s'", resolvedConf)
}
if !strings.Contains(string(logDat), strconv.Itoa(os.Getpid())+",") {
t.Errorf("expected log to contain 'PID: %d', got %s", os.Getpid(), logDat)
}
t.Log("resolvedConf: ", resolvedConf)
t.Log("logFile: ", logFile)
t.Log("realConfig: ", realConfig)
time.Sleep(100 * time.Millisecond)
stopChan <- os.Interrupt
}
Loading