Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,19 @@ Arch:
pacman -S gcc libpcap iptables
```

Fedora:
```
sudo dnf install gcc libpcap-devel iptables
```

Build glutton:
```
make build
```

To run/test glutton:
```
bin/server
sudo bin/server
```

To get this to work on WSL, use this kernel: https://github.com/Locietta/xanmod-kernel-WSL2
2 changes: 2 additions & 0 deletions config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ rules_path: config/rules.yaml

addresses: ["1.2.3.4", "5.4.3.2"]

interface: eth0

producers:
enabled: false
http:
Expand Down
7 changes: 7 additions & 0 deletions glutton.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"context"
_ "embed"
"flag"
"fmt"
"io"
"log/slog"
Expand Down Expand Up @@ -44,6 +45,10 @@ type Glutton struct {
var defaultRules []byte

func (g *Glutton) initConfig() error {
var interfaceName string
flag.StringVar(&interfaceName, "i", "", "Network interface name")
flag.Parse()

viper.SetConfigName("config")
viper.AddConfigPath(viper.GetString("confpath"))
if _, err := os.Stat(viper.GetString("confpath")); !os.IsNotExist(err) {
Expand All @@ -58,6 +63,8 @@ func (g *Glutton) initConfig() error {
viper.SetDefault("max_tcp_payload", 4096)
viper.SetDefault("conn_timeout", 45)
viper.SetDefault("rules_path", "rules/rules.yaml")
viper.SetDefault("interface", "eth0") // Default interface name

g.Logger.Debug("configuration set successfully", slog.String("reporter", "glutton"))
return nil
}
Expand Down