Compare commits
93 Commits
Author | SHA1 | Date | |
---|---|---|---|
c0aa73c1bf | |||
078c5fc785 | |||
73c8486fc8 | |||
ed4d970723 | |||
9b54cec29c | |||
1230fb52d7 | |||
cd0d5c469f | |||
398160e6eb | |||
3a5fa290e2 | |||
e4327cd3a8 | |||
cdbcf0e03b | |||
46d9f4d64a | |||
49553fa965 | |||
aa5b9588d1 | |||
858c11b853 | |||
85fd24180a | |||
b2e3632b56 | |||
73dce3d1f3 | |||
d86bc2be07 | |||
39a682fd41 | |||
a0e661eca3 | |||
db294c171d | |||
2c75603046 | |||
a7b1ba584f | |||
89237c2b84 | |||
5ade1c0593 | |||
ec6c0cc45b | |||
9f9e0524f5 | |||
13f126ccbc | |||
80ac8148e7 | |||
d7f0ba7486 | |||
5682777bfe | |||
4a3c022958 | |||
53ae82727c | |||
fb2fb5de5e | |||
ca96115fe2 | |||
e9d2f3581c | |||
8084362d22 | |||
837f89e5d3 | |||
38ff8949b9 | |||
fce78d234d | |||
940a512d56 | |||
52c2bd1060 | |||
d2fa727990 | |||
0ed71be705 | |||
4ff47521b4 | |||
07fe16b72a | |||
4c77b5ef9b | |||
329d93a759 | |||
ecc7f9bdc0 | |||
cd376a0d00 | |||
73a26193bf | |||
bd7e36e98b | |||
ae21fd8a11 | |||
b70d057cb8 | |||
603d70334e | |||
4912eef00a | |||
ed66cd5492 | |||
631bec38d0 | |||
9db21cb15d | |||
056ac87eee | |||
a1526c9334 | |||
21ce2e32d7 | |||
87794ee634 | |||
801dc967f8 | |||
f213d9cc29 | |||
c952c8d3cf | |||
db8372f6db | |||
8ba601a2b1 | |||
a19fb3086b | |||
b2edb2b4bf | |||
bd6eafd9f7 | |||
492c88c5b2 | |||
0560e2a76c | |||
e7074257b1 | |||
03525cdad8 | |||
47f3ae2b81 | |||
0fd4e00c02 | |||
bc9c5dbe0e | |||
94e7faae78 | |||
a71ff52ab4 | |||
047478b9eb | |||
5535a88fb1 | |||
6810202f3f | |||
6e6e4ff8c4 | |||
b371dca158 | |||
a76a95b300 | |||
2b016aecb2 | |||
64ee43d75b | |||
756e9d661c | |||
a13e9c0eba | |||
36a487cb0c | |||
59c401b1dc |
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,3 +1,5 @@
|
||||
**/node_modules
|
||||
**/dist
|
||||
honeypot/Geoacumen-Country.mmdb
|
||||
result
|
||||
frontend/.parcel-cache
|
||||
|
32
Dockerfile
32
Dockerfile
@ -1,12 +1,16 @@
|
||||
FROM node:latest as frontend-builder
|
||||
RUN mkdir -p /app/frontend
|
||||
COPY web/frontend/yarn.lock /app/frontend/yarn.lock
|
||||
COPY web/frontend/package.json /app/frontend/package.json
|
||||
WORKDIR /app/frontend
|
||||
RUN yarn install
|
||||
COPY web/frontend /app/frontend
|
||||
WORKDIR /app/frontend
|
||||
RUN GENERATE_SOURCEMAP=false yarn build
|
||||
FROM node:alpine as frontend-builder
|
||||
WORKDIR /app
|
||||
COPY frontend/package.json /app
|
||||
COPY frontend/package-lock.json /app
|
||||
RUN npm install
|
||||
COPY frontend .
|
||||
RUN npm run build
|
||||
|
||||
FROM alpine:latest as geoip-fetcher
|
||||
RUN apk add --no-cache git
|
||||
WORKDIR /app
|
||||
RUN git clone https://github.com/geoacumen/geoacumen-country.git
|
||||
RUN find .
|
||||
|
||||
FROM golang:latest as builder
|
||||
WORKDIR /app
|
||||
@ -14,15 +18,15 @@ COPY go.mod /app/go.mod
|
||||
COPY go.sum /app/go.sum
|
||||
RUN go mod download
|
||||
COPY . /app
|
||||
RUN rm -rf /app/server/frontend
|
||||
COPY --from=frontend-builder /app/frontend/dist /app/web/frontend/dist
|
||||
RUN CGO_ENABLED=0 INSTALL_PREFIX=/app make install
|
||||
COPY --from=geoip-fetcher /app/geoacumen-country/Geoacumen-Country.mmdb honeypot/ssh
|
||||
COPY --from=frontend-builder /app/dist /app/web/frontend/dist
|
||||
RUN CGO_ENABLED=0 go build -tags embed cmd/apiary/apiary.go
|
||||
|
||||
FROM alpine:latest
|
||||
RUN apk add --no-cache curl
|
||||
WORKDIR /app
|
||||
COPY --from=builder /app/etc/apiary/apiary.toml /app/apiary.toml
|
||||
COPY --from=builder /app/bin/apiary /app/apiary
|
||||
COPY --from=builder /app/apiary.toml /app/apiary.toml
|
||||
COPY --from=builder /app/apiary /app/apiary
|
||||
EXPOSE 8080
|
||||
EXPOSE 2222
|
||||
CMD ["/app/apiary", "serve"]
|
62
Makefile
62
Makefile
@ -1,62 +0,0 @@
|
||||
NAME = apiary
|
||||
|
||||
.DEFAULT_GOAL := all
|
||||
.PHONY: all clean
|
||||
|
||||
INSTALL_PREFIX ?= /usr/local
|
||||
|
||||
VERSION = $(shell cat version.go |grep "var Version"| cut -d "=" -f2| tr -d "\" ")
|
||||
ARCH = $(shell go env | grep GOHOSTARCH | cut -d"=" -f2 | tr -d "\"")
|
||||
OS = $(shell go env | grep GOHOSTOS | cut -d"=" -f2 | tr -d "\"")
|
||||
GIT_COMMIT := $(shell git rev-parse --short HEAD)
|
||||
|
||||
BUILD_DIR = build/binary/current
|
||||
BUILD_OUTPUT = $(BUILD_DIR)/$(NAME)-$(VERSION)-$(OS)-$(ARCH)
|
||||
BUILD_FLAGS = -tags embed -ldflags "-X github.uio.no/torjus/apiary.Build=$(GIT_COMMIT)" -o $(BUILD_OUTPUT)
|
||||
|
||||
GEODB_URL = https://raw.githubusercontent.com/geoacumen/geoacumen-country/master/Geoacumen-Country.mmdb
|
||||
GEODB_PATH = honeypot/Geoacumen-Country.mmdb
|
||||
|
||||
FRONTEND_BUILD_DIR = web/frontend/dist
|
||||
|
||||
ifeq ($(INSTALL_PREFIX), /)
|
||||
INSTALL_BIN_DIR=/usr/bin
|
||||
INSTALL_ETC_DIR=/etc/$(NAME)
|
||||
else
|
||||
INSTALL_BIN_DIR=$(INSTALL_PREFIX)/bin
|
||||
INSTALL_ETC_DIR=$(INSTALL_PREFIX)/etc/$(NAME)
|
||||
endif
|
||||
|
||||
$(GEODB_PATH):
|
||||
curl $(GEODB_URL) -o $(GEODB_PATH)
|
||||
|
||||
$(BUILD_DIR):
|
||||
mkdir -p $(BUILD_DIR)
|
||||
|
||||
$(FRONTEND_BUILD_DIR):
|
||||
cd web/frontend && yarn install && yarn build
|
||||
|
||||
$(BUILD_OUTPUT): $(BUILD_DIR) $(GEODB_PATH) $(FRONTEND_BUILD_DIR)
|
||||
CGO_ENABLED=0 go build $(BUILD_FLAGS) cmd/apiary.go
|
||||
|
||||
frontend:
|
||||
cd web/frontend && yarn install && yarn build
|
||||
|
||||
clean:
|
||||
rm -rv $(BUILD_DIR)
|
||||
rm -rv $(FRONTEND_BUILD_DIR)
|
||||
|
||||
geodb: $(GEODB_PATH)
|
||||
|
||||
build: $(BUILD_OUTPUT)
|
||||
|
||||
install: build
|
||||
mkdir -p $(INSTALL_BIN_DIR)
|
||||
mkdir -p $(INSTALL_ETC_DIR)
|
||||
install -m 755 $(BUILD_OUTPUT) $(INSTALL_BIN_DIR)/$(NAME)
|
||||
install -m 755 apiary.toml $(INSTALL_ETC_DIR)/apiary.toml
|
||||
|
||||
uninstall:
|
||||
rm -v $(INSTALL_ETC_DIR)/apiary.toml
|
||||
rmdir -v $(INSTALL_ETC_DIR)
|
||||
rm -v $(INSTALL_BIN_DIR)/$(NAME)
|
42
README.md
42
README.md
@ -2,34 +2,32 @@
|
||||
|
||||
SSH honeypot with web-frontend.
|
||||
|
||||
## TODO
|
||||
## Build using nix
|
||||
|
||||
* Fix janky ass Makefile
|
||||
```console
|
||||
$ nix build .#
|
||||
|
||||
## Requirements
|
||||
|
||||
* `go >= 1.16`
|
||||
|
||||
Requires a postgres database if you want data to persist through server restart.
|
||||
|
||||
## Build
|
||||
|
||||
```text
|
||||
# make frontend
|
||||
# make build
|
||||
$ ./result/bin/apiary --version
|
||||
apiary version v0.2.1-d86bc2be079c6b18a9f941752ebad45d925366d1 (go1.23.6)
|
||||
```
|
||||
|
||||
## Build without nix
|
||||
|
||||
See [Dockerfile](./Dockerfile) for how to build frontend and backend. Or use Dockerfile
|
||||
and copy binary from image.
|
||||
|
||||
## Install
|
||||
|
||||
```text
|
||||
# Build and install
|
||||
INSTALL_PREFIX=/ sudo make install
|
||||
```console
|
||||
Build or download binary
|
||||
$ cp ./apiary /usr/local/bin/apiary
|
||||
|
||||
# Edit config file
|
||||
vim /etc/apiary/apiary.toml
|
||||
Edit config file, should use postgres if you want persistent storage.
|
||||
See example config for the different options.
|
||||
$ vim /etc/apiary/apiary.toml
|
||||
|
||||
# Run
|
||||
/usr/bin/apiary serve
|
||||
# 2021-04-10T11:27:42.783+0200 INFO APP Starting SSH server
|
||||
# 2021-04-10T11:27:42.783+0200 INFO APP Starting web server
|
||||
$ /usr/bin/apiary serve
|
||||
2021-04-10T11:27:42.783+0200 INFO APP Starting SSH server
|
||||
2021-04-10T11:27:42.783+0200 INFO APP Starting web server
|
||||
```
|
||||
|
||||
|
@ -3,6 +3,8 @@ Description=Apiary SSH Honeypot
|
||||
After=postgresql.service
|
||||
|
||||
[Service]
|
||||
Type=notify
|
||||
WatchdogSec=10
|
||||
User=apiary
|
||||
ExecStart=/usr/bin/apiary serve
|
||||
Restart=on-failure
|
||||
|
12
apiary.toml
12
apiary.toml
@ -4,6 +4,9 @@
|
||||
# Must be "memory" or "postgres"
|
||||
# Default: "memory"
|
||||
Type = "memory"
|
||||
# Enable caching
|
||||
# Default: false
|
||||
EnableCache = false
|
||||
|
||||
[Store.Postgres]
|
||||
# Connection string for postgres
|
||||
@ -18,7 +21,7 @@ HostKeyPath = ""
|
||||
# Log level for SSH Honeypot
|
||||
# Must be either "DEBUG", "INFO", "WARN", "ERROR", "FATAL", "NONE"
|
||||
# Default: "INFO"
|
||||
LogLevel = "INFO"
|
||||
LogLevel = "DEBUG"
|
||||
# Address and port to listen to
|
||||
# Default: ":2222"
|
||||
ListenAddr = ":2222"
|
||||
@ -32,9 +35,15 @@ ThrottleSpeed = 10240.0
|
||||
# Must be either "DEBUG", "INFO", "WARN", "ERROR", "FATAL", "NONE"
|
||||
# Default: "INFO"
|
||||
LogLevel = "INFO"
|
||||
# Enable metrics endpoint
|
||||
# Default: false
|
||||
MetricsEnable = false
|
||||
# Enable access logging
|
||||
# Default: true
|
||||
AccessLogEnable = true
|
||||
# Disable logging of requests to metrics endpoint
|
||||
# Default: false
|
||||
AccessLogIgnoreMetrics = false
|
||||
# Address and port to listen to
|
||||
# Default: ":8080"
|
||||
ListenAddr = ":8080"
|
||||
@ -56,3 +65,4 @@ CacheDir = "/var/apiary/certs"
|
||||
# Redirect HTTP to HTTPS
|
||||
# Default: true
|
||||
RedirectHTTP = true
|
||||
|
||||
|
214
cmd/apiary.go
214
cmd/apiary.go
@ -1,214 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/signal"
|
||||
"time"
|
||||
|
||||
"github.com/gliderlabs/ssh"
|
||||
"github.com/urfave/cli/v2"
|
||||
"github.uio.no/torjus/apiary"
|
||||
"github.uio.no/torjus/apiary/config"
|
||||
"github.uio.no/torjus/apiary/honeypot"
|
||||
"github.uio.no/torjus/apiary/honeypot/store"
|
||||
"github.uio.no/torjus/apiary/web"
|
||||
"go.uber.org/zap"
|
||||
"go.uber.org/zap/zapcore"
|
||||
"golang.org/x/crypto/acme/autocert"
|
||||
)
|
||||
|
||||
func main() {
|
||||
app := &cli.App{
|
||||
Name: "apiary",
|
||||
Version: apiary.FullVersion(),
|
||||
Authors: []*cli.Author{
|
||||
{
|
||||
Name: "Torjus Håkestad",
|
||||
Email: "torjus@usit.uio.no",
|
||||
},
|
||||
},
|
||||
Commands: []*cli.Command{
|
||||
{
|
||||
Name: "serve",
|
||||
Action: ActionServe,
|
||||
Usage: "Start Apiary server",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
if err := app.Run(os.Args); err != nil {
|
||||
fmt.Printf("Error: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func ActionServe(c *cli.Context) error {
|
||||
cfg, err := getConfig()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Setup logging
|
||||
loggers := setupLoggers(cfg)
|
||||
|
||||
// Setup store
|
||||
var s store.LoginAttemptStore
|
||||
switch cfg.Store.Type {
|
||||
case "MEMORY", "memory":
|
||||
s = &store.MemoryStore{}
|
||||
case "POSTGRES", "postgres":
|
||||
pgStore, err := store.NewPostgresStore(cfg.Store.Postgres.DSN)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := pgStore.InitDB(); err != nil {
|
||||
return err
|
||||
}
|
||||
s = pgStore
|
||||
default:
|
||||
return fmt.Errorf("Invalid store configured")
|
||||
}
|
||||
|
||||
// Setup honeypot
|
||||
hs, err := honeypot.NewHoneypotServer(cfg.Honeypot, s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
hs.Logger = loggers.honeypotLogger
|
||||
|
||||
// Setup webserver
|
||||
web := web.NewServer(cfg.Frontend, hs, s)
|
||||
web.AccessLogger = loggers.webAccessLogger
|
||||
web.ServerLogger = loggers.webServerLogger
|
||||
if cfg.Frontend.Autocert.Enable {
|
||||
certManager := autocert.Manager{
|
||||
Prompt: autocert.AcceptTOS,
|
||||
HostPolicy: autocert.HostWhitelist(cfg.Frontend.Autocert.Domains...),
|
||||
Email: cfg.Frontend.Autocert.Email,
|
||||
}
|
||||
if cfg.Frontend.Autocert.CacheDir != "" {
|
||||
certManager.Cache = autocert.DirCache(cfg.Frontend.Autocert.CacheDir)
|
||||
}
|
||||
|
||||
tlsConfig := certManager.TLSConfig()
|
||||
web.TLSConfig = tlsConfig
|
||||
}
|
||||
|
||||
// Setup interrupt handling
|
||||
interruptChan := make(chan os.Signal, 1)
|
||||
signal.Notify(interruptChan, os.Interrupt)
|
||||
|
||||
rootCtx, rootCancel := context.WithCancel(c.Context)
|
||||
serversCtx, serversCancel := context.WithCancel(rootCtx)
|
||||
|
||||
// Handle interrupt
|
||||
go func() {
|
||||
<-interruptChan
|
||||
loggers.rootLogger.Info("Interrupt received, shutting down")
|
||||
serversCancel()
|
||||
}()
|
||||
|
||||
// Start ssh server
|
||||
go func() {
|
||||
loggers.rootLogger.Info("Starting SSH server")
|
||||
if err := hs.ListenAndServe(); err != nil && err != ssh.ErrServerClosed {
|
||||
loggers.rootLogger.Warnw("SSH server returned error", "error", err)
|
||||
}
|
||||
}()
|
||||
|
||||
// Start web server
|
||||
go func() {
|
||||
loggers.rootLogger.Info("Starting web server")
|
||||
if err := web.StartServe(); err != nil && err != http.ErrServerClosed {
|
||||
loggers.rootLogger.Warnw("Web server returned error", "error", err)
|
||||
}
|
||||
}()
|
||||
|
||||
go func() {
|
||||
<-serversCtx.Done()
|
||||
|
||||
// Stop SSH server
|
||||
sshShutdownCtx, sshShutdownCancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer sshShutdownCancel()
|
||||
loggers.rootLogger.Info("SSH server shutdown started")
|
||||
if err := hs.Shutdown(sshShutdownCtx); err != nil {
|
||||
loggers.rootLogger.Infow("Error shutting down SSH server", "error", err)
|
||||
}
|
||||
loggers.rootLogger.Info("SSH server shutdown complete")
|
||||
|
||||
// Stop Web server
|
||||
webShutdownCtx, webShutdownCancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer webShutdownCancel()
|
||||
|
||||
loggers.rootLogger.Info("Web server shutdown started")
|
||||
if err := web.Shutdown(webShutdownCtx); err != nil {
|
||||
loggers.rootLogger.Infow("Error shutting down web server", "error", err)
|
||||
}
|
||||
loggers.rootLogger.Info("Web server shutdown complete")
|
||||
rootCancel()
|
||||
}()
|
||||
|
||||
<-rootCtx.Done()
|
||||
|
||||
return nil
|
||||
|
||||
}
|
||||
|
||||
type loggerCollection struct {
|
||||
rootLogger *zap.SugaredLogger
|
||||
honeypotLogger *zap.SugaredLogger
|
||||
webAccessLogger *zap.SugaredLogger
|
||||
webServerLogger *zap.SugaredLogger
|
||||
}
|
||||
|
||||
func setupLoggers(cfg config.Config) *loggerCollection {
|
||||
logEncoderCfg := zap.NewProductionEncoderConfig()
|
||||
logEncoderCfg.EncodeCaller = func(caller zapcore.EntryCaller, enc zapcore.PrimitiveArrayEncoder) {}
|
||||
|
||||
level := zap.NewAtomicLevelAt(zap.InfoLevel)
|
||||
logEncoderCfg.EncodeLevel = zapcore.CapitalColorLevelEncoder
|
||||
logEncoderCfg.EncodeTime = zapcore.ISO8601TimeEncoder
|
||||
logEncoderCfg.EncodeDuration = zapcore.NanosDurationEncoder
|
||||
rootLoggerCfg := &zap.Config{
|
||||
Level: level,
|
||||
OutputPaths: []string{"stdout"},
|
||||
ErrorOutputPaths: []string{"stderr"},
|
||||
Encoding: "console",
|
||||
EncoderConfig: logEncoderCfg,
|
||||
}
|
||||
rootLogger, err := rootLoggerCfg.Build()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return &loggerCollection{
|
||||
rootLogger: rootLogger.Named("APP").Sugar(),
|
||||
honeypotLogger: rootLogger.Named("HON").Sugar(),
|
||||
webAccessLogger: rootLogger.Named("ACC").Sugar(),
|
||||
webServerLogger: rootLogger.Named("WEB").Sugar(),
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func getConfig() (config.Config, error) {
|
||||
defaultLocations := []string{
|
||||
"apiary.toml",
|
||||
"/etc/apiary.toml",
|
||||
"/etc/apiary/apiary.toml",
|
||||
}
|
||||
|
||||
for _, fname := range defaultLocations {
|
||||
if _, err := os.Stat(fname); os.IsNotExist(err) {
|
||||
continue
|
||||
}
|
||||
cfg, err := config.FromFile(fname)
|
||||
if err != nil {
|
||||
return config.Config{}, err
|
||||
}
|
||||
return cfg, nil
|
||||
}
|
||||
return config.Config{}, fmt.Errorf("Could not find config file")
|
||||
}
|
279
cmd/apiary/apiary.go
Normal file
279
cmd/apiary/apiary.go
Normal file
@ -0,0 +1,279 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/signal"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.t-juice.club/torjus/apiary"
|
||||
"git.t-juice.club/torjus/apiary/config"
|
||||
"git.t-juice.club/torjus/apiary/honeypot/ssh"
|
||||
"git.t-juice.club/torjus/apiary/honeypot/ssh/store"
|
||||
"git.t-juice.club/torjus/apiary/web"
|
||||
"github.com/coreos/go-systemd/daemon"
|
||||
sshlib "github.com/gliderlabs/ssh"
|
||||
"github.com/urfave/cli/v3"
|
||||
"golang.org/x/crypto/acme/autocert"
|
||||
)
|
||||
|
||||
func main() {
|
||||
app := &cli.Command{
|
||||
Name: "apiary",
|
||||
Version: apiary.FullVersion(),
|
||||
Commands: []*cli.Command{
|
||||
{
|
||||
Name: "serve",
|
||||
Action: ActionServe,
|
||||
Usage: "Start Apiary server",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
if err := app.Run(context.Background(), os.Args); err != nil {
|
||||
fmt.Printf("Error: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func ActionServe(ctx context.Context, cmd *cli.Command) error {
|
||||
cfg, err := getConfig()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Setup logging
|
||||
loggers := setupLoggers(cfg)
|
||||
loggers.rootLogger.Info("Starting apiary.", "version", apiary.FullVersion())
|
||||
|
||||
// Setup store
|
||||
var s store.LoginAttemptStore
|
||||
switch cfg.Store.Type {
|
||||
case "MEMORY", "memory":
|
||||
loggers.rootLogger.Info("Initialized store.", "store_type", "memory")
|
||||
s = &store.MemoryStore{}
|
||||
case "POSTGRES", "postgres":
|
||||
pgStartTime := time.Now()
|
||||
loggers.rootLogger.Debug("Initializing store.", "store_type", "postgres")
|
||||
pgStore, err := store.NewPostgresStore(cfg.Store.Postgres.DSN)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := pgStore.InitDB(); err != nil {
|
||||
return err
|
||||
}
|
||||
loggers.rootLogger.Info("Initialized store.", "store_type", "postgres", "init_time", time.Since(pgStartTime))
|
||||
if cfg.Store.EnableCache {
|
||||
loggers.rootLogger.Debug("Initializing store.", "store_type", "cache-postgres")
|
||||
startTime := time.Now()
|
||||
cachingStore := store.NewCachingStore(pgStore)
|
||||
s = cachingStore
|
||||
loggers.rootLogger.Info("Initialized store.", "store_type", "cache-postgres", "init_time", time.Since(startTime))
|
||||
} else {
|
||||
s = pgStore
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("Invalid store configured")
|
||||
}
|
||||
|
||||
// Setup interrupt handling
|
||||
interruptChan := make(chan os.Signal, 1)
|
||||
signal.Notify(interruptChan, os.Interrupt)
|
||||
|
||||
rootCtx, rootCancel := context.WithCancel(ctx)
|
||||
defer rootCancel()
|
||||
serversCtx, serversCancel := context.WithCancel(rootCtx)
|
||||
defer serversCancel()
|
||||
|
||||
// Setup metrics collection
|
||||
s = store.NewMetricsCollectingStore(rootCtx, s)
|
||||
|
||||
// Setup honeypot
|
||||
hs, err := ssh.NewHoneypotServer(cfg.Honeypot, s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
hs.Logger = loggers.honeypotLogger
|
||||
|
||||
// Setup webserver
|
||||
web := web.NewServer(cfg.Frontend, hs, s)
|
||||
web.AccessLogger = loggers.webAccessLogger
|
||||
web.ServerLogger = loggers.webServerLogger
|
||||
if cfg.Frontend.Autocert.Enable {
|
||||
certManager := autocert.Manager{
|
||||
Prompt: autocert.AcceptTOS,
|
||||
HostPolicy: autocert.HostWhitelist(cfg.Frontend.Autocert.Domains...),
|
||||
Email: cfg.Frontend.Autocert.Email,
|
||||
}
|
||||
if cfg.Frontend.Autocert.CacheDir != "" {
|
||||
certManager.Cache = autocert.DirCache(cfg.Frontend.Autocert.CacheDir)
|
||||
}
|
||||
|
||||
tlsConfig := certManager.TLSConfig()
|
||||
web.TLSConfig = tlsConfig
|
||||
}
|
||||
|
||||
// Handle interrupt
|
||||
go func() {
|
||||
<-interruptChan
|
||||
loggers.rootLogger.Info("Interrupt received, shutting down.")
|
||||
serversCancel()
|
||||
}()
|
||||
|
||||
// Start ssh server
|
||||
go func() {
|
||||
loggers.rootLogger.Info("Starting SSH server.", "addr", cfg.Honeypot.ListenAddr)
|
||||
if err := hs.ListenAndServe(); err != nil && err != sshlib.ErrServerClosed {
|
||||
loggers.rootLogger.Warn("SSH server returned error.", "error", err)
|
||||
}
|
||||
loggers.rootLogger.Info("SSH server stopped.")
|
||||
}()
|
||||
|
||||
// Start web server
|
||||
go func() {
|
||||
loggers.rootLogger.Info("Starting web server.", "addr", cfg.Frontend.ListenAddr)
|
||||
if err := web.StartServe(); err != nil && err != http.ErrServerClosed {
|
||||
loggers.rootLogger.Warn("Web server returned error.", "error", err)
|
||||
}
|
||||
}()
|
||||
|
||||
// If run by systemd, enable watchdog and notify ready
|
||||
go func() {
|
||||
notifyCtx, cancel := context.WithCancel(rootCtx)
|
||||
defer cancel()
|
||||
|
||||
_, ok := os.LookupEnv("NOTIFY_SOCKET")
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
loggers.rootLogger.Info("Systemd notify socket detected. Sending ready and enabling watchdog.")
|
||||
ok, err := daemon.SdNotify(false, daemon.SdNotifyReady)
|
||||
if !ok {
|
||||
loggers.rootLogger.Info("Systemd notify not enabled.")
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
loggers.rootLogger.Warn("Unable to connect to NOTIFY_SOCKET.", "error", err)
|
||||
return
|
||||
}
|
||||
loggers.rootLogger.Debug("Sent READY=1 to NOTIFY_SOCKET.")
|
||||
|
||||
// Setup timer
|
||||
timeout, err := daemon.SdWatchdogEnabled(false)
|
||||
if err != nil {
|
||||
loggers.rootLogger.Warn("Unable to get watchdog timeout.", "error", err)
|
||||
return
|
||||
}
|
||||
if timeout == 0 {
|
||||
loggers.rootLogger.Info("Systemd watchdog not enabled.")
|
||||
return
|
||||
}
|
||||
|
||||
ticker := time.NewTicker(timeout / 2)
|
||||
for {
|
||||
// TODO: Consider using ctx with deadline to avoid healthcheck taking more time than ticker,
|
||||
// which will result in being killed by watchdog.
|
||||
healthy := s.IsHealthy()
|
||||
select {
|
||||
case <-ticker.C:
|
||||
if healthy == nil {
|
||||
if _, err := daemon.SdNotify(false, daemon.SdNotifyWatchdog); err != nil {
|
||||
loggers.rootLogger.Warn("Error notifying watchdog.", "err", err)
|
||||
}
|
||||
continue
|
||||
}
|
||||
// TODO: If unhealthy, should we retry healthcheck immediately, otherwise service will most likely get killed by watchdog.
|
||||
loggers.rootLogger.Error("Store reported not healthy, might get killed by watchdog.", "err", healthy)
|
||||
case <-notifyCtx.Done():
|
||||
loggers.rootLogger.Debug("Notify context cancelled.")
|
||||
return
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
go func() {
|
||||
<-serversCtx.Done()
|
||||
|
||||
// Stop SSH server
|
||||
sshShutdownCtx, sshShutdownCancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer sshShutdownCancel()
|
||||
loggers.rootLogger.Info("SSH server shutdown started.")
|
||||
if err := hs.Shutdown(sshShutdownCtx); err != nil {
|
||||
loggers.rootLogger.Info("Error shutting down SSH server.", "error", err)
|
||||
}
|
||||
loggers.rootLogger.Info("SSH server shutdown complete.")
|
||||
|
||||
// Stop Web server
|
||||
webShutdownCtx, webShutdownCancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer webShutdownCancel()
|
||||
|
||||
loggers.rootLogger.Info("Web server shutdown started.")
|
||||
if err := web.Shutdown(webShutdownCtx); err != nil {
|
||||
loggers.rootLogger.Info("Error shutting down web server.", "error", err)
|
||||
}
|
||||
loggers.rootLogger.Info("Web server shutdown complete.")
|
||||
rootCancel()
|
||||
}()
|
||||
|
||||
<-rootCtx.Done()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type loggerCollection struct {
|
||||
rootLogger *slog.Logger
|
||||
honeypotLogger *slog.Logger
|
||||
webAccessLogger *slog.Logger
|
||||
webServerLogger *slog.Logger
|
||||
}
|
||||
|
||||
func setupLoggers(cfg config.Config) *loggerCollection {
|
||||
opts := &slog.HandlerOptions{}
|
||||
switch strings.ToUpper(cfg.Honeypot.LogLevel) {
|
||||
case "INFO":
|
||||
opts.Level = slog.LevelInfo
|
||||
case "DEBUG":
|
||||
opts.Level = slog.LevelDebug
|
||||
opts.AddSource = true
|
||||
case "WARN", "WARNING":
|
||||
opts.Level = slog.LevelWarn
|
||||
case "ERR", "ERROR":
|
||||
opts.Level = slog.LevelError
|
||||
default:
|
||||
opts.Level = slog.LevelInfo
|
||||
}
|
||||
|
||||
handler := slog.NewTextHandler(os.Stdout, opts)
|
||||
rootLogger := slog.New(handler)
|
||||
|
||||
return &loggerCollection{
|
||||
rootLogger: rootLogger.With("module", "application"),
|
||||
honeypotLogger: rootLogger.With("module", "honeypot"),
|
||||
webAccessLogger: rootLogger.With("module", "web-access-log"),
|
||||
webServerLogger: rootLogger.With("module", "web-server"),
|
||||
}
|
||||
}
|
||||
|
||||
func getConfig() (config.Config, error) {
|
||||
defaultLocations := []string{
|
||||
"apiary.toml",
|
||||
"/etc/apiary.toml",
|
||||
"/etc/apiary/apiary.toml",
|
||||
}
|
||||
|
||||
for _, fname := range defaultLocations {
|
||||
if _, err := os.Stat(fname); os.IsNotExist(err) {
|
||||
continue
|
||||
}
|
||||
cfg, err := config.FromFile(fname)
|
||||
if err != nil {
|
||||
return config.Config{}, err
|
||||
}
|
||||
return cfg, nil
|
||||
}
|
||||
return config.Config{}, fmt.Errorf("Could not find config file")
|
||||
}
|
@ -6,7 +6,7 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/pelletier/go-toml"
|
||||
"github.com/pelletier/go-toml/v2"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
@ -16,6 +16,7 @@ type Config struct {
|
||||
}
|
||||
type StoreConfig struct {
|
||||
Type string `toml:"Type"`
|
||||
EnableCache bool `toml:"EnableCache"`
|
||||
Postgres PostgresStoreConfig `toml:"Postgres"`
|
||||
}
|
||||
|
||||
@ -33,7 +34,9 @@ type HoneypotConfig struct {
|
||||
type FrontendConfig struct {
|
||||
ListenAddr string `toml:"ListenAddr"`
|
||||
LogLevel string `toml:"LogLevel"`
|
||||
MetricsEnable bool `toml:"MetricsEnable"`
|
||||
AccessLogEnable bool `toml:"AccessLogEnable"`
|
||||
AccessLogIgnoreMetrics bool `toml:"AccessLogIgnoreMetrics"`
|
||||
Autocert FrontendAutocertConfig `toml:"Autocert"`
|
||||
}
|
||||
|
||||
@ -61,7 +64,7 @@ func FromReader(r io.Reader) (Config, error) {
|
||||
return c, fmt.Errorf("unable to parse config: %w", err)
|
||||
}
|
||||
|
||||
//c.readEnv()
|
||||
// c.readEnv()
|
||||
|
||||
return c, nil
|
||||
}
|
||||
|
27
flake.lock
generated
Normal file
27
flake.lock
generated
Normal file
@ -0,0 +1,27 @@
|
||||
{
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1742288794,
|
||||
"narHash": "sha256-Txwa5uO+qpQXrNG4eumPSD+hHzzYi/CdaM80M9XRLCo=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "b6eaf97c6960d97350c584de1b6dcff03c9daf42",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
123
flake.nix
Normal file
123
flake.nix
Normal file
@ -0,0 +1,123 @@
|
||||
{
|
||||
description = "SSH honeypot with frontend";
|
||||
|
||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
|
||||
outputs =
|
||||
{ self, nixpkgs }:
|
||||
let
|
||||
allSystems = [
|
||||
"x86_64-linux"
|
||||
"aarch64-linux"
|
||||
"x86_64-darwin"
|
||||
"aarch64-darwin"
|
||||
];
|
||||
forAllSystems =
|
||||
f:
|
||||
nixpkgs.lib.genAttrs allSystems (
|
||||
system:
|
||||
f {
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
}
|
||||
);
|
||||
in
|
||||
{
|
||||
overlays.default = final: prev: {
|
||||
apiary = self.packages.${prev.system}.default;
|
||||
};
|
||||
|
||||
packages = forAllSystems (
|
||||
{ pkgs }:
|
||||
{
|
||||
default = self.packages.${pkgs.system}.apiary;
|
||||
apiary =
|
||||
let
|
||||
src = pkgs.lib.sourceFilesBySuffices ./. [
|
||||
"go.mod"
|
||||
"go.sum"
|
||||
".go"
|
||||
];
|
||||
version = pkgs.lib.strings.removePrefix "v" (
|
||||
builtins.elemAt (pkgs.lib.strings.split "\"" (
|
||||
pkgs.lib.lists.findFirst (x: pkgs.lib.strings.hasInfix "Version" x) null (
|
||||
pkgs.lib.strings.splitString "\n" (builtins.readFile ./version.go)
|
||||
)
|
||||
)) 2
|
||||
);
|
||||
rev = self.rev or "";
|
||||
geoDb = pkgs.fetchFromGitHub {
|
||||
owner = "geoacumen";
|
||||
repo = "geoacumen-country";
|
||||
rev = "5f770af620465f40427c3f421446a7b7845e2699";
|
||||
sha256 = "sha256-t3ELkhAbJC40z6r6wJeQI4Kutfw26fRg6n7a6FmhvkA=";
|
||||
};
|
||||
|
||||
frontend = pkgs.buildNpmPackage {
|
||||
inherit version;
|
||||
name = "apiary-frontend";
|
||||
|
||||
src = ./frontend;
|
||||
|
||||
npmDepsHash = "sha256-7gjPEiQAMOpteLwHT4AIY9QLpDozpXb7xy0bDiOpDf4=";
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
cp -r dist/* $out
|
||||
'';
|
||||
};
|
||||
in
|
||||
pkgs.buildGoModule {
|
||||
inherit version;
|
||||
pname = "apiary";
|
||||
src = src;
|
||||
prePatch = ''
|
||||
cp ${geoDb}/Geoacumen-Country.mmdb honeypot/ssh
|
||||
mkdir -p web/frontend/dist
|
||||
cp -r ${frontend}/* web/frontend/dist
|
||||
'';
|
||||
vendorHash = "sha256-t/DNKefG+UxZEfNYNUmOPSw6aqgNuz6v7qxow5JRXsE=";
|
||||
ldflags = [ "-X git.t-juice.club/torjus/apiary.Build=${rev}" ];
|
||||
tags = [
|
||||
"embed"
|
||||
];
|
||||
};
|
||||
|
||||
tarball =
|
||||
let
|
||||
version = self.packages.${pkgs.system}.apiary.version;
|
||||
in
|
||||
pkgs.stdenv.mkDerivation {
|
||||
name = "apiary-tarballs-${version}";
|
||||
phases = [ "installPhase" ];
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
mkdir apiary
|
||||
cp ${self.packages.${pkgs.system}.apiary}/bin/apiary apiary/apiary-${pkgs.system}-${version}
|
||||
tar cvzf $out/apiary-${pkgs.system}-${version}.tar.gz apiary
|
||||
pushd apiary
|
||||
sha256sum apiary-${pkgs.system}-${version} > apiary-${pkgs.system}-${version}.sha256sum
|
||||
popd
|
||||
cp apiary/apiary-${pkgs.system}-${version}.sha256sum $out
|
||||
'';
|
||||
};
|
||||
}
|
||||
);
|
||||
devShells = forAllSystems (
|
||||
{ pkgs }:
|
||||
{
|
||||
default = pkgs.mkShell {
|
||||
packages = with pkgs; [
|
||||
go
|
||||
golangci-lint
|
||||
];
|
||||
};
|
||||
frontend = pkgs.mkShell {
|
||||
packages = with pkgs; [
|
||||
nodejs
|
||||
yarn
|
||||
];
|
||||
};
|
||||
}
|
||||
);
|
||||
};
|
||||
}
|
7
frontend/jest.config.js
Normal file
7
frontend/jest.config.js
Normal file
@ -0,0 +1,7 @@
|
||||
/** @type {import('ts-jest').JestConfigWithTsJest} **/
|
||||
module.exports = {
|
||||
testEnvironment: "jsdom",
|
||||
transform: {
|
||||
"^.+\.tsx?$": ["ts-jest",{}],
|
||||
},
|
||||
};
|
9405
frontend/package-lock.json
generated
Normal file
9405
frontend/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
37
frontend/package.json
Normal file
37
frontend/package.json
Normal file
@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "apiary-frontend",
|
||||
"scripts": {
|
||||
"start": "parcel src/index.html",
|
||||
"build": "parcel build src/index.html",
|
||||
"test": "jest"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ngneat/falso": "^7.3.0",
|
||||
"@parcel/transformer-css": "^2.13.3",
|
||||
"@testing-library/dom": "^10.4.0",
|
||||
"@testing-library/jest-dom": "^6.6.3",
|
||||
"@testing-library/react": "^16.2.0",
|
||||
"@testing-library/user-event": "^14.6.1",
|
||||
"@types/humanize-duration": "^3.27.4",
|
||||
"@types/jest": "^29.5.14",
|
||||
"@types/node": "^22.13.9",
|
||||
"@types/react": "^19.0.10",
|
||||
"@types/react-dom": "^19.0.4",
|
||||
"jest": "^29.7.0",
|
||||
"jest-environment-jsdom": "^29.7.0",
|
||||
"parcel": "^2.13.3",
|
||||
"process": "^0.11.10",
|
||||
"svgo": "^3.3.2",
|
||||
"ts-jest": "^29.2.6",
|
||||
"ts-loader": "^9.5.2",
|
||||
"typescript": "^5.8.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"chart.js": "^4.4.8",
|
||||
"humanize-duration": "^3.32.1",
|
||||
"react": "^19.0.0",
|
||||
"react-chartjs-2": "^5.3.0",
|
||||
"react-dom": "^19.0.0",
|
||||
"react-router": "^7.2.0"
|
||||
}
|
||||
}
|
77
frontend/src/assets/apiary.svg
Normal file
77
frontend/src/assets/apiary.svg
Normal file
@ -0,0 +1,77 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||
<svg height="800px" width="800px" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
viewBox="0 0 511.573 511.573" xml:space="preserve">
|
||||
<g transform="translate(1 1)">
|
||||
<polygon style="fill:#FFE100;" points="254.787,7.107 84.12,143.64 425.453,143.64 "/>
|
||||
<polygon style="fill:#FFFFFF;" points="84.12,143.64 254.787,7.107 41.453,143.64 "/>
|
||||
<polygon style="fill:#FFA800;" points="254.787,7.107 425.453,143.64 468.12,143.64 "/>
|
||||
<g>
|
||||
<polygon style="fill:#FFE100;" points="41.453,502.04 92.653,502.04 92.653,450.84 41.453,450.84 "/>
|
||||
<polygon style="fill:#FFE100;" points="416.92,502.04 468.12,502.04 468.12,450.84 416.92,450.84 "/>
|
||||
<polygon style="fill:#FFE100;" points="41.453,450.84 468.12,450.84 468.12,143.64 41.453,143.64 "/>
|
||||
</g>
|
||||
<polygon style="fill:#FFA800;" points="442.52,126.573 442.52,502.04 468.12,502.04 468.12,146.2 "/>
|
||||
<polygon style="fill:#FFFFFF;" points="41.453,143.64 41.453,502.04 67.053,502.04 67.053,126.573 "/>
|
||||
<path style="fill:#63D3FD;" d="M314.52,450.84H195.053V341.613c0-15.36,12.8-27.307,27.307-27.307h64
|
||||
c15.36,0,27.307,12.8,27.307,27.307V450.84H314.52z"/>
|
||||
<path style="fill:#3DB9F9;" d="M287.213,314.307h-25.6c15.36,0,27.307,12.8,27.307,27.307V450.84h25.6V341.613
|
||||
C314.52,327.107,302.573,314.307,287.213,314.307"/>
|
||||
<path d="M468.12,459.373H41.453c-5.12,0-8.533-3.413-8.533-8.533v-307.2c0-2.56,1.707-5.973,4.267-6.827L250.52,0.28
|
||||
c2.56-1.707,5.973-1.707,9.387,0L473.24,136.813c2.56,1.707,4.267,4.267,4.267,6.827v307.2
|
||||
C476.653,455.96,473.24,459.373,468.12,459.373z M49.987,442.307h409.6v-294.4l-204.8-130.56l-204.8,130.56V442.307z"/>
|
||||
<path d="M92.653,510.573h-51.2c-5.12,0-8.533-3.413-8.533-8.533v-51.2c0-5.12,3.413-8.533,8.533-8.533h51.2
|
||||
c5.12,0,8.533,3.413,8.533,8.533v51.2C101.187,507.16,97.773,510.573,92.653,510.573z M49.987,493.507H84.12v-34.133H49.987
|
||||
V493.507z"/>
|
||||
<path d="M468.12,510.573h-51.2c-5.12,0-8.533-3.413-8.533-8.533v-51.2c0-5.12,3.413-8.533,8.533-8.533h51.2
|
||||
c5.12,0,8.533,3.413,8.533,8.533v51.2C476.653,507.16,473.24,510.573,468.12,510.573z M425.453,493.507h34.133v-34.133h-34.133
|
||||
V493.507z"/>
|
||||
<path d="M7.32,177.773c-2.56,0-5.12-0.853-6.827-3.413c-2.56-3.413-1.707-9.387,1.707-11.947l34.133-25.6
|
||||
c3.413-2.56,9.387-1.707,11.947,1.707c2.56,3.413,1.707,9.387-1.707,11.947l-34.133,25.6C10.733,176.92,9.027,177.773,7.32,177.773
|
||||
z"/>
|
||||
<path d="M502.253,177.773c-1.707,0-3.413-0.853-5.12-1.707L463,150.467c-3.413-2.56-4.267-8.533-1.707-11.947
|
||||
c2.56-3.413,8.533-4.267,11.947-1.707l34.133,25.6c3.413,2.56,4.267,8.533,1.707,11.947
|
||||
C507.373,176.92,504.813,177.773,502.253,177.773z"/>
|
||||
<path d="M468.12,254.573H41.453c-5.12,0-8.533-3.413-8.533-8.533v-102.4c0-5.12,3.413-8.533,8.533-8.533H468.12
|
||||
c5.12,0,8.533,3.413,8.533,8.533v102.4C476.653,251.16,473.24,254.573,468.12,254.573z M49.987,237.507h409.6v-85.333h-409.6
|
||||
V237.507z"/>
|
||||
<path d="M314.52,459.373H195.053c-5.12,0-8.533-3.413-8.533-8.533V341.613c0-19.627,16.213-35.84,35.84-35.84h64
|
||||
c19.627,0,35.84,16.213,35.84,35.84V450.84C323.053,455.96,319.64,459.373,314.52,459.373z M203.587,442.307h102.4V341.613
|
||||
c0-10.24-8.533-18.773-18.773-18.773h-64c-11.093,0-19.627,8.533-19.627,18.773V442.307z"/>
|
||||
<path d="M195.053,459.373h-153.6c-5.12,0-8.533-3.413-8.533-8.533v-102.4c0-5.12,3.413-8.533,8.533-8.533h153.6
|
||||
c5.12,0,8.533,3.413,8.533,8.533v102.4C203.587,455.96,200.173,459.373,195.053,459.373z M49.987,442.307H186.52v-85.333H49.987
|
||||
V442.307z"/>
|
||||
<path d="M468.12,459.373h-153.6c-5.12,0-8.533-3.413-8.533-8.533v-102.4c0-5.12,3.413-8.533,8.533-8.533h153.6
|
||||
c5.12,0,8.533,3.413,8.533,8.533v102.4C476.653,455.96,473.24,459.373,468.12,459.373z M323.053,442.307h136.533v-85.333H323.053
|
||||
V442.307z"/>
|
||||
<path d="M468.12,356.973h-153.6c-5.12,0-8.533-3.413-8.533-8.533v-6.827c0-10.24-8.533-18.773-18.773-18.773h-64
|
||||
c-11.093,0-19.627,8.533-19.627,18.773v6.827c0,5.12-3.413,8.533-8.533,8.533h-153.6c-5.12,0-8.533-3.413-8.533-8.533v-102.4
|
||||
c0-5.12,3.413-8.533,8.533-8.533H468.12c5.12,0,8.533,3.413,8.533,8.533v102.4C476.653,353.56,473.24,356.973,468.12,356.973z
|
||||
M323.053,339.907h136.533v-85.333h-409.6v85.333H186.52c0.853-18.773,17.067-34.133,35.84-34.133h64
|
||||
C305.987,305.773,322.2,321.133,323.053,339.907z"/>
|
||||
<path d="M468.12,288.707h-59.733c-5.12,0-8.533-3.413-8.533-8.533c0-5.12,3.413-8.533,8.533-8.533h59.733
|
||||
c5.12,0,8.533,3.413,8.533,8.533S473.24,288.707,468.12,288.707z"/>
|
||||
<path d="M468.12,322.84h-34.133c-5.12,0-8.533-3.413-8.533-8.533c0-5.12,3.413-8.533,8.533-8.533h34.133
|
||||
c5.12,0,8.533,3.413,8.533,8.533C476.653,319.427,473.24,322.84,468.12,322.84z"/>
|
||||
<path d="M101.187,288.707H41.453c-5.12,0-8.533-3.413-8.533-8.533c0-5.12,3.413-8.533,8.533-8.533h59.733
|
||||
c5.12,0,8.533,3.413,8.533,8.533S106.307,288.707,101.187,288.707z"/>
|
||||
<path d="M75.587,322.84H41.453c-5.12,0-8.533-3.413-8.533-8.533c0-5.12,3.413-8.533,8.533-8.533h34.133
|
||||
c5.12,0,8.533,3.413,8.533,8.533C84.12,319.427,80.707,322.84,75.587,322.84z"/>
|
||||
<path d="M468.12,186.307h-59.733c-5.12,0-8.533-3.413-8.533-8.533c0-5.12,3.413-8.533,8.533-8.533h59.733
|
||||
c5.12,0,8.533,3.413,8.533,8.533C476.653,182.893,473.24,186.307,468.12,186.307z"/>
|
||||
<path d="M468.12,220.44h-34.133c-5.12,0-8.533-3.413-8.533-8.533c0-5.12,3.413-8.533,8.533-8.533h34.133
|
||||
c5.12,0,8.533,3.413,8.533,8.533C476.653,217.027,473.24,220.44,468.12,220.44z"/>
|
||||
<path d="M101.187,186.307H41.453c-5.12,0-8.533-3.413-8.533-8.533c0-5.12,3.413-8.533,8.533-8.533h59.733
|
||||
c5.12,0,8.533,3.413,8.533,8.533C109.72,182.893,106.307,186.307,101.187,186.307z"/>
|
||||
<path d="M75.587,220.44H41.453c-5.12,0-8.533-3.413-8.533-8.533c0-5.12,3.413-8.533,8.533-8.533h34.133
|
||||
c5.12,0,8.533,3.413,8.533,8.533C84.12,217.027,80.707,220.44,75.587,220.44z"/>
|
||||
<path d="M468.12,391.107h-59.733c-5.12,0-8.533-3.413-8.533-8.533c0-5.12,3.413-8.533,8.533-8.533h59.733
|
||||
c5.12,0,8.533,3.413,8.533,8.533C476.653,387.693,473.24,391.107,468.12,391.107z"/>
|
||||
<path d="M468.12,425.24h-34.133c-5.12,0-8.533-3.413-8.533-8.533s3.413-8.533,8.533-8.533h34.133c5.12,0,8.533,3.413,8.533,8.533
|
||||
S473.24,425.24,468.12,425.24z"/>
|
||||
<path d="M101.187,391.107H41.453c-5.12,0-8.533-3.413-8.533-8.533c0-5.12,3.413-8.533,8.533-8.533h59.733
|
||||
c5.12,0,8.533,3.413,8.533,8.533C109.72,387.693,106.307,391.107,101.187,391.107z"/>
|
||||
<path d="M75.587,425.24H41.453c-5.12,0-8.533-3.413-8.533-8.533s3.413-8.533,8.533-8.533h34.133c5.12,0,8.533,3.413,8.533,8.533
|
||||
S80.707,425.24,75.587,425.24z"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 6.4 KiB |
2
frontend/src/css/fonts.css
Normal file
2
frontend/src/css/fonts.css
Normal file
@ -0,0 +1,2 @@
|
||||
@import url("https://fonts.googleapis.com/css2?family=Prompt:wght@300;600&display=swap");
|
||||
@import url('https://fonts.googleapis.com/css2?family=Secular+One&display=swap');
|
211
frontend/src/css/style.module.css
Normal file
211
frontend/src/css/style.module.css
Normal file
@ -0,0 +1,211 @@
|
||||
:root {
|
||||
--main-color-bg: white;
|
||||
--main-color: black;
|
||||
/* Menu */
|
||||
--menu-color-bg: #212529;
|
||||
--menu-color-text: hsla(0,0%,100%,.5);
|
||||
--menu-color-text-hover: white;
|
||||
--menu-color-title-text: white;
|
||||
|
||||
/* Table */
|
||||
--table-color-header-bg: var(--menu-color-bg);
|
||||
--table-color-header-text: #dddddd;
|
||||
--table-row-odd: #dddddd;
|
||||
--table-row-even: #f3f3f3;
|
||||
}
|
||||
|
||||
.dark_mode {
|
||||
--main-color-bg: #15141a;
|
||||
--main-color: white;
|
||||
/* Menu */
|
||||
--menu-color-bg: #35393d;
|
||||
--menu-color-text: hsla(0,0%,100%,.5);
|
||||
--menu-color-text-hover: white;
|
||||
--menu-color-title-text: white;
|
||||
|
||||
/* Table */
|
||||
--table-color-header-bg: var(--menu-color-bg);
|
||||
--table-color-header-text: var(--menu-color-text);
|
||||
--table-row-odd: #302f36;
|
||||
--table-row-even: #232229;
|
||||
}
|
||||
|
||||
#root {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
body {
|
||||
background-color: var(--main-color-bg);
|
||||
color: var(--main-color);
|
||||
margin: 0;
|
||||
margin-top: 100px;
|
||||
}
|
||||
|
||||
*,
|
||||
*::before,
|
||||
*::after {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
canvas {
|
||||
width: 100%;
|
||||
display: block;
|
||||
padding-left: 0;
|
||||
padding-right: 0;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
form {
|
||||
width: 100%;
|
||||
}
|
||||
input[type=text] {
|
||||
width: 100%;
|
||||
height: 30px;
|
||||
box-sizing: border-box;
|
||||
border: 2px solid var(--menu-color-bg);
|
||||
border-radius: 5px;
|
||||
padding-left: 5px;
|
||||
}
|
||||
|
||||
.navbar {
|
||||
background-color: var(--menu-color-bg);
|
||||
display: flex;
|
||||
font-size: 1.2rem;
|
||||
font-family: "Prompt", sans-serif;
|
||||
height: 40px;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.navbar ul {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.root .navbar {
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.navbar ul li {
|
||||
list-style-type: none;
|
||||
color: var(--menu-color-text);
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
line-height: 40px;
|
||||
}
|
||||
|
||||
.navbar h2 {
|
||||
line-height: 40px;
|
||||
align-items: center;
|
||||
padding-right: 10px;
|
||||
}
|
||||
|
||||
.navbar a {
|
||||
height: 1;
|
||||
}
|
||||
|
||||
.navbar a:hover {
|
||||
color: var(--menu-color-text-hover);
|
||||
}
|
||||
|
||||
.submenu nav {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.totals {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
grid-template-rows: 1fr;
|
||||
grid-column-gap: 0px;
|
||||
grid-row-gap: 0px;
|
||||
margin-top: 5px;
|
||||
margin-bottom: 5px;
|
||||
font-family: "Secular One", sans-serif;
|
||||
font-size: 20px;
|
||||
font-weight: 200;
|
||||
}
|
||||
.totals_key {
|
||||
grid-area: 1 / 1 / 2 / 2;
|
||||
text-align: right;
|
||||
}
|
||||
.totals_value {
|
||||
grid-area: 1 / 2 / 2 / 3;
|
||||
padding-left: 10px;
|
||||
text-align: left;
|
||||
}
|
||||
#menu_title {
|
||||
color: var(--menu-color-text-hover);
|
||||
font-family: "Secular One", sans-serif;
|
||||
font-size: 30px;
|
||||
font-weight: 300;
|
||||
}
|
||||
#menu_logo {
|
||||
padding: 5px;
|
||||
content: url("../assets/apiary.svg");
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
}
|
||||
.menu_link {
|
||||
color: var(--menu-color-text);
|
||||
}
|
||||
.menu_link:hover {
|
||||
color: var(--menu-color-text-hover);
|
||||
}
|
||||
.menu_link_active {
|
||||
color: var(--menu-color-text-hover);
|
||||
}
|
||||
.stats_pie {
|
||||
max-height: 70vh;
|
||||
text-align: left;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.live_table {
|
||||
border-collapse: collapse;
|
||||
margin: 25px 0;
|
||||
font-size: 0.9em;
|
||||
font-family: sans-serif;
|
||||
min-width: 400px;
|
||||
width: 100%;
|
||||
box-shadow: 0 0 20px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
.live_table thead tr {
|
||||
background-color: var(--table-color-header-bg);
|
||||
color: var(--table-color-header-text);
|
||||
text-align: left;
|
||||
}
|
||||
.live_table th,
|
||||
.live_table td {
|
||||
padding: 12px 15px;
|
||||
text-align: left;
|
||||
}
|
||||
.live_table tbody tr {
|
||||
border-bottom: 1px solid var(--table-row-odd);
|
||||
}
|
||||
.live_table tbody tr:nth-of-type(even) {
|
||||
background-color: var(--table-row-even);
|
||||
}
|
||||
.live_table tbody tr:last-of-type {
|
||||
border-bottom: 2px solid var(--table-color-bg);
|
||||
}
|
||||
.live_table tbody tr.active-row {
|
||||
font-weight: bold;
|
||||
color: var(--table-color-bg);
|
||||
}
|
||||
|
||||
.content {
|
||||
margin-left: 10vw;
|
||||
width: 50vw;
|
||||
text-align: center;
|
||||
}
|
12
frontend/src/index.html
Normal file
12
frontend/src/index.html
Normal file
@ -0,0 +1,12 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title></title>
|
||||
<link rel="stylesheet" href="./css/fonts.css" />
|
||||
<script type="module" src="./js/app.tsx"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
</body>
|
||||
</html>
|
154
frontend/src/js/api.ts
Normal file
154
frontend/src/js/api.ts
Normal file
@ -0,0 +1,154 @@
|
||||
import { randUserName, randRecentDate, randIp, randPassword, randUuid, randNumber } from '@ngneat/falso';
|
||||
import { r } from 'react-router/dist/development/fog-of-war-Cm1iXIp7';
|
||||
|
||||
export interface LoginAttempt {
|
||||
readonly date: string;
|
||||
readonly remoteIP: string;
|
||||
readonly username: string;
|
||||
readonly password: string;
|
||||
readonly sshClientVersion: string;
|
||||
readonly connectionUUID: string;
|
||||
readonly country: string;
|
||||
}
|
||||
|
||||
export interface TotalStats {
|
||||
readonly password: number;
|
||||
readonly username: number;
|
||||
readonly ip: number;
|
||||
readonly country: number;
|
||||
readonly attempts: number;
|
||||
}
|
||||
|
||||
export interface StatsResult {
|
||||
name: string;
|
||||
count: number;
|
||||
}
|
||||
|
||||
export type StatsType = 'password' | 'username' | 'ip' | 'country' | 'attempts';
|
||||
|
||||
export interface ApiaryAPI {
|
||||
live(fn: (a: LoginAttempt) => void): void;
|
||||
stats(statsType: StatsType, limit: number): Promise<StatsResult[]>;
|
||||
query(queryType: string, query: string): Promise<LoginAttempt[]>;
|
||||
totals(): Promise<TotalStats>;
|
||||
}
|
||||
|
||||
function fakeLoginAttempt(): LoginAttempt {
|
||||
return {
|
||||
date: randRecentDate({ days: 2 }).toISOString(),
|
||||
remoteIP: randIp().toString(),
|
||||
username: randUserName().toString(),
|
||||
password: randPassword().toString(),
|
||||
sshClientVersion: '1.0',
|
||||
connectionUUID: randUuid().toString(),
|
||||
country: 'NO'
|
||||
}
|
||||
}
|
||||
|
||||
export class DummyApiaryAPIClient implements ApiaryAPI {
|
||||
live(fn: (a: LoginAttempt) => void): () => void {
|
||||
const interval = setInterval(() => {
|
||||
let a = fakeLoginAttempt();
|
||||
fn(a);
|
||||
}, 1000);
|
||||
|
||||
return () => { clearInterval(interval) }
|
||||
}
|
||||
async stats(_type: StatsType, limit: number): Promise<StatsResult[]> {
|
||||
const stats = Array.from({ length: limit }, () => {
|
||||
switch (_type) {
|
||||
case 'password':
|
||||
return { name: randPassword().toString(), count: randNumber().valueOf() }
|
||||
case 'username':
|
||||
return { name: randUserName().toString(), count: randNumber().valueOf() }
|
||||
case 'ip':
|
||||
return { name: randIp().toString(), count: randNumber().valueOf() }
|
||||
case 'country':
|
||||
return { name: 'NO', count: randNumber().valueOf() }
|
||||
}
|
||||
return { name: randUserName().toString(), count: randNumber().valueOf() }
|
||||
});
|
||||
|
||||
const sorted = stats.sort((a, b) => b.count - a.count)
|
||||
return Promise.resolve(sorted);
|
||||
}
|
||||
async query(_type: string, _query: string): Promise<LoginAttempt[]> {
|
||||
const attempts = Array.from({ length: 10 }, () => {
|
||||
return fakeLoginAttempt();
|
||||
})
|
||||
return Promise.resolve(attempts);
|
||||
}
|
||||
|
||||
async totals(): Promise<TotalStats> {
|
||||
return Promise.resolve({ password: 1, username: 1, ip: 1, country: 1, attempts: 1 })
|
||||
}
|
||||
}
|
||||
|
||||
export class ApiaryAPIClient implements ApiaryAPI {
|
||||
live(fn: (a: LoginAttempt) => void): () => void {
|
||||
const es = new EventSource('/api/stream');
|
||||
const updateFn = (ev: MessageEvent<string>) => {
|
||||
const attempt: LoginAttempt = JSON.parse(ev.data);
|
||||
fn(attempt);
|
||||
};
|
||||
es.addEventListener('message', updateFn)
|
||||
|
||||
return () => {
|
||||
es.removeEventListener('message', updateFn);
|
||||
es.close();
|
||||
}
|
||||
}
|
||||
async stats(statsType: StatsType, limit: number): Promise<StatsResult[]> {
|
||||
const resp = await fetch(`/api/stats?type=${statsType}&limit=${limit}`)
|
||||
if (!resp.ok) {
|
||||
throw new Error('Failed to fetch query')
|
||||
}
|
||||
const data: StatsResult[] | null = await resp.json()
|
||||
if (!data) {
|
||||
return []
|
||||
}
|
||||
return data.sort((a, b) => b.count - a.count)
|
||||
}
|
||||
async query(queryType: string, query: string): Promise<LoginAttempt[]> {
|
||||
const resp = await fetch(`/api/query?type=${queryType}&query=${query}`)
|
||||
if (!resp.ok) {
|
||||
throw new Error('Failed to fetch query')
|
||||
}
|
||||
const data: LoginAttempt[] = await resp.json()
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
async totals(): Promise<TotalStats> {
|
||||
let password: number = -1
|
||||
let username: number = -1
|
||||
let ip: number = -1
|
||||
let attempts: number = -1
|
||||
let country: number = -1
|
||||
|
||||
const resp = await fetch('/api/stats?type=total')
|
||||
const data: Array<StatsResult> = await resp.json()
|
||||
|
||||
for (const stat of data) {
|
||||
switch (stat.name) {
|
||||
case 'UniquePasswords':
|
||||
password = stat.count
|
||||
break
|
||||
case 'UniqueUsernames':
|
||||
username = stat.count
|
||||
break
|
||||
case 'UniqueIPs':
|
||||
ip = stat.count
|
||||
break
|
||||
case 'TotalLoginAttempts':
|
||||
attempts = stat.count
|
||||
break
|
||||
case 'UniqueCountries':
|
||||
country = stat.count
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return { password, username, ip, attempts, country }
|
||||
}
|
||||
}
|
467
frontend/src/js/app.tsx
Normal file
467
frontend/src/js/app.tsx
Normal file
@ -0,0 +1,467 @@
|
||||
import React from "react";
|
||||
import { createRoot } from "react-dom/client";
|
||||
import { useState, useEffect } from 'react';
|
||||
import { ApiaryAPI, LoginAttempt, DummyApiaryAPIClient, ApiaryAPIClient, TotalStats, StatsResult, StatsType } from "./api";
|
||||
import { BrowserRouter, NavLink, Routes, Route } from "react-router";
|
||||
import { Chart as ChartJS, Tooltip, ArcElement, Legend, ChartOptions } from "chart.js";
|
||||
import { Pie } from "react-chartjs-2";
|
||||
import humanizeDuration from "humanize-duration";
|
||||
import * as classes from "../css/style.module.css";
|
||||
|
||||
ChartJS.register(Tooltip, ArcElement, Legend);
|
||||
console.log(classes);
|
||||
|
||||
interface AppProps {
|
||||
api: ApiaryAPI
|
||||
}
|
||||
|
||||
let chartColors = [
|
||||
"#1abc9c",
|
||||
"#2ecc71",
|
||||
"#3498db",
|
||||
"#9b59b6",
|
||||
"#34495e",
|
||||
"#16a085",
|
||||
"#27ae60",
|
||||
"#2980b9",
|
||||
"#8e44ad",
|
||||
"#2c3e50",
|
||||
"#f1c40f",
|
||||
"#e67e22",
|
||||
"#e74c3c",
|
||||
"#ecf0f1",
|
||||
"#95a5a6",
|
||||
"#f39c12",
|
||||
"#d35400",
|
||||
"#c0392b",
|
||||
"#bdc3c7",
|
||||
"#7f8c8d",
|
||||
]
|
||||
|
||||
export function App({ api }: AppProps) {
|
||||
const [mode, setMode] = useState("light");
|
||||
const headerProps: HeaderMenuProps = {
|
||||
title: "apiary.home.2rjus.net",
|
||||
items: [
|
||||
{
|
||||
name: "Totals",
|
||||
path: "/",
|
||||
},
|
||||
{
|
||||
name: "Passwords",
|
||||
path: "/stats/password",
|
||||
},
|
||||
{
|
||||
name: "Usernames",
|
||||
path: "/stats/username",
|
||||
},
|
||||
{
|
||||
name: "IPs",
|
||||
path: "/stats/ip",
|
||||
},
|
||||
{
|
||||
name: "Live",
|
||||
path: "/live",
|
||||
},
|
||||
{
|
||||
name: "Query",
|
||||
path: "/query",
|
||||
}
|
||||
]
|
||||
}
|
||||
const onSelectMode = (mode: string) => {
|
||||
setMode(mode);
|
||||
|
||||
if (mode === "dark") {
|
||||
document.body.classList.add(classes.dark_mode);
|
||||
} else {
|
||||
document.body.classList.remove(classes.dark_mode);
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', (e) => onSelectMode(e.matches ? "dark" : "light"));
|
||||
onSelectMode(window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')
|
||||
return () => {
|
||||
window.matchMedia('(prefers-color-scheme: dark)').removeEventListener('change', (e) => onSelectMode(e.matches ? "dark" : "light"));
|
||||
}
|
||||
}, [])
|
||||
return (
|
||||
<>
|
||||
<BrowserRouter>
|
||||
<div id="app">
|
||||
<HeaderMenu title={headerProps.title} items={headerProps.items} />
|
||||
<div className={classes.content}>
|
||||
<Routes>
|
||||
<Route path="/" element={<Home api={api} />} />
|
||||
<Route path="/stats/password" element={<Stats api={api} type="password" />} />
|
||||
<Route path="/stats/username" element={<Stats api={api} type="username" />} />
|
||||
<Route path="/stats/ip" element={<Stats api={api} type="ip" />} />
|
||||
<Route path="/live" element={<Live api={api} />} />
|
||||
<Route path="/query" element={<Query api={api} />} />
|
||||
</Routes>
|
||||
</div>
|
||||
</div>
|
||||
</BrowserRouter >
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export interface StatsProps {
|
||||
api: ApiaryAPI
|
||||
type: StatsType
|
||||
}
|
||||
|
||||
export function Stats({ api, type }: StatsProps) {
|
||||
const [stats, setStats] = useState<StatsResult[] | null>(null)
|
||||
const [currentType, setCurrentType] = useState(type)
|
||||
|
||||
useEffect(() => {
|
||||
async function getStats() {
|
||||
try {
|
||||
let newStats = await api.stats(type, 10);
|
||||
if (JSON.stringify(newStats) !== JSON.stringify(stats)) {
|
||||
setStats(newStats)
|
||||
}
|
||||
} catch (e) {
|
||||
console.log("Error getting stats", e)
|
||||
}
|
||||
}
|
||||
|
||||
if (currentType !== type) {
|
||||
setCurrentType(type)
|
||||
getStats()
|
||||
}
|
||||
|
||||
if (stats === null) {
|
||||
getStats()
|
||||
}
|
||||
|
||||
const interval = setInterval(() => {
|
||||
getStats()
|
||||
}, 60000)
|
||||
|
||||
return () => {
|
||||
clearInterval(interval);
|
||||
}
|
||||
}, [stats, type])
|
||||
|
||||
return (
|
||||
<>
|
||||
{(stats != null && stats.length > 0) ? <StatsPie data={stats} /> : <p>Loading...</p>}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export interface StatsPieProps {
|
||||
data: StatsResult[]
|
||||
}
|
||||
|
||||
export function StatsPie({ data }: StatsPieProps) {
|
||||
const labels = data.map((d) => d.name);
|
||||
const values = data.map((d) => d.count);
|
||||
const piedata = {
|
||||
labels,
|
||||
datasets: [{
|
||||
label: "# of attempts",
|
||||
data: values,
|
||||
backgroundColor: chartColors,
|
||||
borderWidth: 1
|
||||
}]
|
||||
};
|
||||
console.log(piedata)
|
||||
const getTextColor = () => {
|
||||
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'white' : 'black'
|
||||
}
|
||||
const options: ChartOptions<"pie"> = {
|
||||
plugins: {
|
||||
legend: {
|
||||
display: true,
|
||||
align: "start",
|
||||
labels: {
|
||||
color: getTextColor(),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return (
|
||||
<div className={classes.stats_pie}>
|
||||
<Pie data={piedata} options={options} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export function Home({ api }: AppProps) {
|
||||
const [totals, setTotals] = useState<TotalStats | null>(null)
|
||||
useEffect(() => {
|
||||
async function getTotals() {
|
||||
let totals = await api.totals();
|
||||
setTotals(totals);
|
||||
}
|
||||
|
||||
if (!totals) {
|
||||
getTotals();
|
||||
}
|
||||
|
||||
const interval = setInterval(() => {
|
||||
getTotals();
|
||||
}, 5000)
|
||||
|
||||
return () => {
|
||||
clearInterval(interval);
|
||||
}
|
||||
})
|
||||
return (
|
||||
<>
|
||||
{totals ? <Totals totals={totals} /> : <p>Loading...</p>}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export interface TotalsProps {
|
||||
totals: TotalStats
|
||||
}
|
||||
|
||||
export function Totals({ totals }: TotalsProps) {
|
||||
return (
|
||||
<div className={classes.totals}>
|
||||
<div className={classes.totals_key}>
|
||||
<h2>Unique passwords</h2>
|
||||
<h2>Unique username</h2>
|
||||
<h2>Unique IPs</h2>
|
||||
<h2>Total attempts</h2>
|
||||
</div>
|
||||
<div className={classes.totals_value}>
|
||||
<h2>{totals.password}</h2>
|
||||
<h2>{totals.username}</h2>
|
||||
<h2>{totals.ip}</h2>
|
||||
<h2>{totals.attempts}</h2>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export function Live({ api }: AppProps) {
|
||||
let list: LoginAttempt[] = [];
|
||||
let [liveList, setLiveList] = useState(list);
|
||||
|
||||
useEffect(() => {
|
||||
const cleanup = api.live((a) => {
|
||||
setLiveList((list) => {
|
||||
return [a, ...list];
|
||||
});
|
||||
});
|
||||
|
||||
return cleanup
|
||||
|
||||
}, [liveList, api]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<LiveList list={liveList} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export interface LiveListProps {
|
||||
list: LoginAttempt[]
|
||||
};
|
||||
|
||||
export interface DateTDProps {
|
||||
date: Date
|
||||
now: Date
|
||||
}
|
||||
|
||||
export function DateTD({ date, now }: DateTDProps) {
|
||||
const [displayDate, setDisplayDate] = useState(date.toLocaleString());
|
||||
|
||||
useEffect(() => {
|
||||
if (now.getTime() - date.getTime() < 14400000) {
|
||||
const newDate = humanizeDuration(now.getTime() - date.getTime(), { largest: 1, round: true }) + " ago";
|
||||
if (newDate !== displayDate) {
|
||||
setDisplayDate(newDate);
|
||||
}
|
||||
}
|
||||
}, [displayDate, now])
|
||||
|
||||
return (
|
||||
<td className={classes.live_table_date}>{displayDate}</td>
|
||||
)
|
||||
}
|
||||
|
||||
export function LiveList({ list }: LiveListProps) {
|
||||
const [now, setNow] = useState(new Date())
|
||||
|
||||
let items = list.map((a) => {
|
||||
const attemptDate = new Date(a.date);
|
||||
const key = `${a.username}-${a.password}-${a.remoteIP}-${a.date}`;
|
||||
return (
|
||||
<tr key={a.date}>
|
||||
<DateTD date={attemptDate} now={now} />
|
||||
<td className={classes.live_table_username}>{a.username}</td>
|
||||
<td className={classes.live_table_password}>{a.password}</td>
|
||||
<td className={classes.live_table_ip}>{a.remoteIP}</td>
|
||||
<td className={classes.live_table_country}>{a.country}</td>
|
||||
</tr>
|
||||
)
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
const interval = setInterval(() => {
|
||||
setNow(new Date())
|
||||
}, 1000)
|
||||
|
||||
return () => {
|
||||
clearInterval(interval)
|
||||
}
|
||||
}, [now])
|
||||
|
||||
return (
|
||||
<>
|
||||
<table className={classes.live_table}>
|
||||
<thead>
|
||||
<tr>
|
||||
<th className={classes.live_table_date}>Date</th>
|
||||
<th className={classes.live_table_username}>Username</th>
|
||||
<th className={classes.live_table_password}>Password</th>
|
||||
<th className={classes.live_table_ip}>IP</th>
|
||||
<th className={classes.live_table_country}>Country</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{items}
|
||||
</tbody>
|
||||
</table>
|
||||
</>
|
||||
)
|
||||
};
|
||||
|
||||
|
||||
export function Query({ api }: AppProps) {
|
||||
const [liveList, setLiveList] = useState<LoginAttempt[]>([]);
|
||||
const [queryErr, setQueryErr] = useState<Error | null>(null);
|
||||
|
||||
async function handleSubmit(event: React.FormEvent<HTMLFormElement>) {
|
||||
event.preventDefault();
|
||||
const value = event.currentTarget.query.value;
|
||||
if (value === "") {
|
||||
setQueryErr(new Error("Query cannot be empty"));
|
||||
return
|
||||
}
|
||||
try {
|
||||
const results = await api.query("", value)
|
||||
setQueryErr(null);
|
||||
setLiveList(results);
|
||||
} catch (e) {
|
||||
if (e instanceof Error) {
|
||||
setQueryErr(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<form onSubmit={handleSubmit}>
|
||||
<input placeholder="Search..." name="query" type="text" />
|
||||
</form>
|
||||
{queryErr ? <ErrorBox message={queryErr.message} /> : null}
|
||||
<LiveList list={liveList} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
interface ErrorBoxProps {
|
||||
message: string | null
|
||||
};
|
||||
|
||||
export function ErrorBox({ message }: ErrorBoxProps) {
|
||||
return (
|
||||
<div className={classes.error_box}>
|
||||
<p>Error: {message}</p>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export function Header() {
|
||||
return (
|
||||
<div className={classes.navbar}>
|
||||
<h2 id="menu-title">apiary.home.2rjus.net</h2>
|
||||
<nav className={classes.nav_flex}>
|
||||
<ul>
|
||||
<li><NavLink to="/" className={({ isActive }) => isActive ? classes.menu_link_active : classes.menu_link}>Home</NavLink></li>
|
||||
<li><NavLink to="/stats/password" className={({ isActive }) => isActive ? classes.menu_link_active : classes.menu_link}>Stats</NavLink></li>
|
||||
<li><NavLink to="/live" className={({ isActive }) => isActive ? classes.menu_link_active : classes.menu_link}>Live</NavLink></li>
|
||||
<li><NavLink to="/query" className={({ isActive }) => isActive ? classes.menu_link_active : classes.menu_link}>Query</NavLink></li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div >
|
||||
);
|
||||
}
|
||||
|
||||
interface HeaderItem {
|
||||
name: string
|
||||
path: string
|
||||
}
|
||||
|
||||
interface HeaderMenuProps {
|
||||
title: string
|
||||
items: Array<HeaderItem>
|
||||
}
|
||||
|
||||
export function HeaderMenu({ title, items }: HeaderMenuProps) {
|
||||
const menuItems = items.map((item) => {
|
||||
return (
|
||||
<li key={item.path}>
|
||||
<NavLink to={item.path} className={({ isActive }) => isActive ? classes.menu_link_active : classes.menu_link}>{item.name}</NavLink>
|
||||
</li>
|
||||
)
|
||||
})
|
||||
|
||||
return (
|
||||
<div className={classes.navbar}>
|
||||
<img id={classes.menu_logo}></img>
|
||||
<h2 id={classes.menu_title}>{title}</h2>
|
||||
<nav className={classes.nav_flex}>
|
||||
<ul>
|
||||
{menuItems}
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export interface SubMenuProps {
|
||||
items: Array<{ name: string, active: () => boolean, onClick: () => void }>
|
||||
}
|
||||
|
||||
export function SubMenu({ items }: SubMenuProps) {
|
||||
return (
|
||||
<nav className={classes.submenu}>
|
||||
<ul>
|
||||
{items.map((item) => {
|
||||
return <li>
|
||||
<a
|
||||
href="#"
|
||||
className={item.active() ? classes.sub_menu_active : classes.sub_menu_link}
|
||||
onClick={item.onClick}>{item.name}</a>
|
||||
</li>
|
||||
})}
|
||||
</ul>
|
||||
</nav>
|
||||
)
|
||||
}
|
||||
|
||||
const rootElement = document.getElementById('root');
|
||||
if (rootElement) {
|
||||
const root = createRoot(rootElement);
|
||||
let api: ApiaryAPI;
|
||||
if (process.env.NODE_ENV === "production") {
|
||||
api = new ApiaryAPIClient();
|
||||
} else {
|
||||
api = new DummyApiaryAPIClient();
|
||||
}
|
||||
|
||||
|
||||
root.render(
|
||||
<App api={api} />
|
||||
);
|
||||
}
|
17
frontend/src/tests/api.test.ts
Normal file
17
frontend/src/tests/api.test.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { DummyApiaryAPIClient, TotalStats } from "../js/api";
|
||||
|
||||
describe("DummyApiaryAPIClient", () => {
|
||||
const api = new DummyApiaryAPIClient()
|
||||
test("totals returns expeced value", async () => {
|
||||
let totals = await api.totals()
|
||||
const expected: TotalStats = {
|
||||
password: 1,
|
||||
username: 1,
|
||||
ip: 1,
|
||||
attempts: 1,
|
||||
country: 1,
|
||||
}
|
||||
|
||||
expect(totals).toEqual(expected)
|
||||
})
|
||||
});
|
16
frontend/tsconfig.json
Normal file
16
frontend/tsconfig.json
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"esModuleInterop": true,
|
||||
"jsx": "react",
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"lib": ["dom", "esnext"],
|
||||
"strict": true,
|
||||
"sourceMap": true,
|
||||
"target": "esnext",
|
||||
"types": ["node", "jest"]
|
||||
},
|
||||
"exclude": ["node_modules"],
|
||||
"include": ["src/**/*.ts", "src/**/*.tsx"]
|
||||
}
|
||||
|
61
go.mod
61
go.mod
@ -1,22 +1,49 @@
|
||||
module github.uio.no/torjus/apiary
|
||||
module git.t-juice.club/torjus/apiary
|
||||
|
||||
go 1.16
|
||||
go 1.24.0
|
||||
|
||||
toolchain go1.24.1
|
||||
|
||||
require (
|
||||
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf
|
||||
github.com/fujiwara/shapeio v1.0.0
|
||||
github.com/gliderlabs/ssh v0.3.8
|
||||
github.com/go-chi/chi/v5 v5.2.1
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/jackc/pgx/v5 v5.7.2
|
||||
github.com/oschwald/maxminddb-golang v1.13.1
|
||||
github.com/pelletier/go-toml/v2 v2.2.3
|
||||
github.com/prometheus/client_golang v1.21.1
|
||||
github.com/urfave/cli/v3 v3.0.0-beta1
|
||||
golang.org/x/crypto v0.36.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be // indirect
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect
|
||||
github.com/fujiwara/shapeio v1.0.0
|
||||
github.com/gliderlabs/ssh v0.3.2
|
||||
github.com/go-chi/chi/v5 v5.0.2
|
||||
github.com/google/uuid v1.2.0
|
||||
github.com/jackc/pgx/v4 v4.11.0
|
||||
github.com/oschwald/maxminddb-golang v1.8.0
|
||||
github.com/pelletier/go-toml v1.9.0
|
||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||
github.com/stretchr/testify v1.7.0 // indirect
|
||||
github.com/urfave/cli/v2 v2.3.0
|
||||
go.uber.org/zap v1.13.0
|
||||
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2
|
||||
golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1 // indirect
|
||||
golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||
github.com/icholy/gomajor v0.14.0 // indirect
|
||||
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
|
||||
github.com/jackc/puddle/v2 v2.2.2 // indirect
|
||||
github.com/klauspost/compress v1.18.0 // indirect
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||
github.com/prometheus/client_model v0.6.1 // indirect
|
||||
github.com/prometheus/common v0.63.0 // indirect
|
||||
github.com/prometheus/procfs v0.16.0 // indirect
|
||||
golang.org/x/mod v0.22.0 // indirect
|
||||
golang.org/x/net v0.37.0 // indirect
|
||||
golang.org/x/sync v0.12.0 // indirect
|
||||
golang.org/x/sys v0.31.0 // indirect
|
||||
golang.org/x/telemetry v0.0.0-20240522233618-39ace7a40ae7 // indirect
|
||||
golang.org/x/text v0.23.0 // indirect
|
||||
golang.org/x/time v0.11.0 // indirect
|
||||
golang.org/x/tools v0.29.0 // indirect
|
||||
golang.org/x/vuln v1.1.4 // indirect
|
||||
google.golang.org/protobuf v1.36.5 // indirect
|
||||
)
|
||||
|
||||
tool (
|
||||
github.com/icholy/gomajor
|
||||
golang.org/x/vuln/cmd/govulncheck
|
||||
)
|
||||
|
560
go.sum
560
go.sum
@ -1,509 +1,93 @@
|
||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
|
||||
github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc=
|
||||
github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs=
|
||||
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
|
||||
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
|
||||
github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g=
|
||||
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c=
|
||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8=
|
||||
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4=
|
||||
github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
|
||||
github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
|
||||
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
|
||||
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
|
||||
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
|
||||
github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A=
|
||||
github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU=
|
||||
github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
|
||||
github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g=
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
|
||||
github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ=
|
||||
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I=
|
||||
github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
|
||||
github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8=
|
||||
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI=
|
||||
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||
github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||
github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||
github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
|
||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf h1:iW4rZ826su+pqaw19uhpSCzhj44qo35pNgKFGqzDKkU=
|
||||
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
||||
github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
||||
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
|
||||
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
||||
github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
|
||||
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
|
||||
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
|
||||
github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
|
||||
github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g=
|
||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||
github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4=
|
||||
github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/fujiwara/shapeio v1.0.0 h1:xG5D9oNqCSUUbryZ/jQV3cqe1v2suEjwPIcEg1gKM8M=
|
||||
github.com/fujiwara/shapeio v1.0.0/go.mod h1:LmEmu6L/8jetyj1oewewFb7bZCNRwE7wLCUNzDLaLVA=
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/gliderlabs/ssh v0.3.2 h1:gcfd1Aj/9RQxvygu4l3sak711f/5+VOwBw9C/7+N4EI=
|
||||
github.com/gliderlabs/ssh v0.3.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
|
||||
github.com/go-chi/chi/v5 v5.0.2 h1:4xKeALZdMEsuI5s05PU2Bm89Uc5iM04qFubUCl5LfAQ=
|
||||
github.com/go-chi/chi/v5 v5.0.2/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
|
||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o=
|
||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
||||
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
|
||||
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/gofrs/uuid v3.2.0+incompatible h1:y12jRkkFxsd7GpqdSZ+/KCs/fJbqpEXSGd4+jfEaewE=
|
||||
github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
||||
github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s=
|
||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/gliderlabs/ssh v0.3.8 h1:a4YXD1V7xMF9g5nTkdfnja3Sxy1PVDCj1Zg4Wb8vY6c=
|
||||
github.com/gliderlabs/ssh v0.3.8/go.mod h1:xYoytBv1sV0aL3CavoDuJIQNURXkkfPA/wxQ1pL1fAU=
|
||||
github.com/go-chi/chi/v5 v5.2.1 h1:KOIHODQj58PmL80G2Eak4WdvUzjSJSm0vG72crDCqb8=
|
||||
github.com/go-chi/chi/v5 v5.2.1/go.mod h1:L2yAIGWB3H+phAw1NxKwWM+7eUH/lU8pOMm5hHcoops=
|
||||
github.com/google/go-cmdtest v0.4.1-0.20220921163831-55ab3332a786 h1:rcv+Ippz6RAtvaGgKxc+8FQIpxHgsF+HBzPyYL2cyVU=
|
||||
github.com/google/go-cmdtest v0.4.1-0.20220921163831-55ab3332a786/go.mod h1:apVn/GCasLZUVpAJ6oWAuyP7Ne7CEsQbTnc0plM3m+o=
|
||||
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||
github.com/google/renameio v0.1.0 h1:GOZbcHa3HfsPKPlmyPyN2KEohoMXOhdMbHrvbpl2QaA=
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.2.0 h1:qJYtXnJRWmpe7m/3XlyhrsLrEURqHRM2kxzoxXqyUDs=
|
||||
github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
|
||||
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
||||
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
||||
github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
||||
github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
|
||||
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
|
||||
github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE=
|
||||
github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8=
|
||||
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
||||
github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
|
||||
github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
|
||||
github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
|
||||
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
|
||||
github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU=
|
||||
github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU=
|
||||
github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4=
|
||||
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
||||
github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
||||
github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
|
||||
github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90=
|
||||
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
|
||||
github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ=
|
||||
github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I=
|
||||
github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg=
|
||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||
github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo=
|
||||
github.com/jackc/chunkreader v1.0.0 h1:4s39bBR8ByfqH+DKm8rQA3E1LHZWB9XWcrz8fqaZbe0=
|
||||
github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo=
|
||||
github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
|
||||
github.com/jackc/chunkreader/v2 v2.0.1 h1:i+RDz65UE+mmpjTfyz0MoVTnzeYxroil2G82ki7MGG8=
|
||||
github.com/jackc/chunkreader/v2 v2.0.1/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
|
||||
github.com/jackc/pgconn v0.0.0-20190420214824-7e0022ef6ba3/go.mod h1:jkELnwuX+w9qN5YIfX0fl88Ehu4XC3keFuOJJk9pcnA=
|
||||
github.com/jackc/pgconn v0.0.0-20190824142844-760dd75542eb/go.mod h1:lLjNuW/+OfW9/pnVKPazfWOgNfH2aPem8YQ7ilXGvJE=
|
||||
github.com/jackc/pgconn v0.0.0-20190831204454-2fabfa3c18b7/go.mod h1:ZJKsE/KZfsUgOEh9hBm+xYTstcNHg7UPMVJqRfQxq4s=
|
||||
github.com/jackc/pgconn v1.4.0/go.mod h1:Y2O3ZDF0q4mMacyWV3AstPJpeHXWGEetiFttmq5lahk=
|
||||
github.com/jackc/pgconn v1.5.0/go.mod h1:QeD3lBfpTFe8WUnPZWN5KY/mB8FGMIYRdd8P8Jr0fAI=
|
||||
github.com/jackc/pgconn v1.5.1-0.20200601181101-fa742c524853/go.mod h1:QeD3lBfpTFe8WUnPZWN5KY/mB8FGMIYRdd8P8Jr0fAI=
|
||||
github.com/jackc/pgconn v1.8.1 h1:ySBX7Q87vOMqKU2bbmKbUvtYhauDFclYbNDYIE1/h6s=
|
||||
github.com/jackc/pgconn v1.8.1/go.mod h1:JV6m6b6jhjdmzchES0drzCcYcAHS1OPD5xu3OZ/lE2g=
|
||||
github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE=
|
||||
github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8=
|
||||
github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2 h1:JVX6jT/XfzNqIjye4717ITLaNwV9mWbJx0dLCpcRzdA=
|
||||
github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2/go.mod h1:fGZlG77KXmcq05nJLRkk0+p82V8B8Dw8KN2/V9c/OAE=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/icholy/gomajor v0.14.0 h1:qr0eGSMyLcZa7lmSuiplH3kr6j4oH6ET8nkdZqpDcks=
|
||||
github.com/icholy/gomajor v0.14.0/go.mod h1:oJuk5dppdmnvUQRKsUNelWZ7KmYpvYKVupt/OQ0y9UI=
|
||||
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
|
||||
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
|
||||
github.com/jackc/pgproto3 v1.1.0 h1:FYYE4yRw+AgI8wXIinMlNjBbp/UitDJwfj5LqqewP1A=
|
||||
github.com/jackc/pgproto3 v1.1.0/go.mod h1:eR5FA3leWg7p9aeAqi37XOTgTIbkABlvcPB3E5rlc78=
|
||||
github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190420180111-c116219b62db/go.mod h1:bhq50y+xrl9n5mRYyCBFKkpRVTLYJVWeCc+mEAI3yXA=
|
||||
github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190609003834-432c2951c711/go.mod h1:uH0AWtUmuShn0bcesswc4aBTWGvw0cAxIJp+6OB//Wg=
|
||||
github.com/jackc/pgproto3/v2 v2.0.0-rc3/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM=
|
||||
github.com/jackc/pgproto3/v2 v2.0.0-rc3.0.20190831210041-4c03ce451f29/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM=
|
||||
github.com/jackc/pgproto3/v2 v2.0.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
|
||||
github.com/jackc/pgproto3/v2 v2.0.6 h1:b1105ZGEMFe7aCvrT1Cca3VoVb4ZFMaFJLJcg/3zD+8=
|
||||
github.com/jackc/pgproto3/v2 v2.0.6/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
|
||||
github.com/jackc/pgservicefile v0.0.0-20200307190119-3430c5407db8/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E=
|
||||
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b h1:C8S2+VttkHFdOOCXJe+YGfa4vHYwlt4Zx+IVXQ97jYg=
|
||||
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E=
|
||||
github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01CGwFsrv11mJRHWJ6aifDLfdV3aVjFF0zg=
|
||||
github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCMSo2DXpzsoWOAfFkdEtEJpPbVLq8eE+mc=
|
||||
github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59/go.mod h1:MWlu30kVJrUS8lot6TQqcg7mtthZ9T0EoIBFiJcmcyw=
|
||||
github.com/jackc/pgtype v1.2.0/go.mod h1:5m2OfMh1wTK7x+Fk952IDmI4nw3nPrvtQdM0ZT4WpC0=
|
||||
github.com/jackc/pgtype v1.3.1-0.20200510190516-8cd94a14c75a/go.mod h1:vaogEUkALtxZMCH411K+tKzNpwzCKU+AnPzBKZ+I+Po=
|
||||
github.com/jackc/pgtype v1.3.1-0.20200606141011-f6355165a91c/go.mod h1:cvk9Bgu/VzJ9/lxTO5R5sf80p0DiucVtN7ZxvaC4GmQ=
|
||||
github.com/jackc/pgtype v1.7.0 h1:6f4kVsW01QftE38ufBYxKciO6gyioXSC0ABIRLcZrGs=
|
||||
github.com/jackc/pgtype v1.7.0/go.mod h1:ZnHF+rMePVqDKaOfJVI4Q8IVvAQMryDlDkZnKOI75BE=
|
||||
github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y=
|
||||
github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9WuGR0JG/JseM9irFbnEPbuWV2EELPNuM=
|
||||
github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQnOEnf1dqHGpw7JmHqHc1NxDoalibchSk9/RWuDc=
|
||||
github.com/jackc/pgx/v4 v4.5.0/go.mod h1:EpAKPLdnTorwmPUUsqrPxy5fphV18j9q3wrfRXgo+kA=
|
||||
github.com/jackc/pgx/v4 v4.6.1-0.20200510190926-94ba730bb1e9/go.mod h1:t3/cdRQl6fOLDxqtlyhe9UWgfIi9R8+8v8GKV5TRA/o=
|
||||
github.com/jackc/pgx/v4 v4.6.1-0.20200606145419-4e5062306904/go.mod h1:ZDaNWkt9sW1JMiNn0kdYBaLelIhw7Pg4qd+Vk6tw7Hg=
|
||||
github.com/jackc/pgx/v4 v4.11.0 h1:J86tSWd3Y7nKjwT/43xZBvpi04keQWx8gNC2YkdJhZI=
|
||||
github.com/jackc/pgx/v4 v4.11.0/go.mod h1:i62xJgdrtVDsnL3U8ekyrQXEwGNTRoG7/8r+CIdYfcc=
|
||||
github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
|
||||
github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
|
||||
github.com/jackc/puddle v1.1.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
|
||||
github.com/jackc/puddle v1.1.1/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
|
||||
github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
|
||||
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
|
||||
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
||||
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||
github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/lib/pq v1.3.0 h1:/qkRGz8zljWiDcFvgpwUpwIAPu3r07TDvs3Rws+o/pU=
|
||||
github.com/lib/pq v1.3.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM=
|
||||
github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4=
|
||||
github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ=
|
||||
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
||||
github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ=
|
||||
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
||||
github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||
github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ=
|
||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
|
||||
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
|
||||
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
|
||||
github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg=
|
||||
github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY=
|
||||
github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg=
|
||||
github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU=
|
||||
github.com/nats-io/nats-server/v2 v2.1.2/go.mod h1:Afk+wRZqkMQs/p45uXdrVLuab3gwv3Z8C4HTBu8GD/k=
|
||||
github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzEE/Zbp4w=
|
||||
github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w=
|
||||
github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w=
|
||||
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
|
||||
github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs=
|
||||
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
|
||||
github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
|
||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk=
|
||||
github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis=
|
||||
github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74=
|
||||
github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
|
||||
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
|
||||
github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5/go.mod h1:/wsWhb9smxSfWAKL3wpBW7V8scJMt8N8gnaMCS9E/cA=
|
||||
github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw=
|
||||
github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4=
|
||||
github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4=
|
||||
github.com/oschwald/maxminddb-golang v1.8.0 h1:Uh/DSnGoxsyp/KYbY1AuP0tYEwfs0sCph9p/UMXK/Hk=
|
||||
github.com/oschwald/maxminddb-golang v1.8.0/go.mod h1:RXZtst0N6+FY/3qCNmZMBApR19cdQj43/NM9VkrNAis=
|
||||
github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM=
|
||||
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
|
||||
github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
|
||||
github.com/pelletier/go-toml v1.9.0 h1:NOd0BRdOKpPf0SxkL3HxSQOG7rNh+4kl6PHcBPFs7Q0=
|
||||
github.com/pelletier/go-toml v1.9.0/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
|
||||
github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac=
|
||||
github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc=
|
||||
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA=
|
||||
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo=
|
||||
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
|
||||
github.com/jackc/pgx/v5 v5.7.2 h1:mLoDLV6sonKlvjIEsV56SkWNCnuNv531l94GaIzO+XI=
|
||||
github.com/jackc/pgx/v5 v5.7.2/go.mod h1:ncY89UGWxg82EykZUwSpUKEfccBGGYq1xjrOpsbsfGQ=
|
||||
github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
|
||||
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
|
||||
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
|
||||
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
|
||||
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
|
||||
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
|
||||
github.com/oschwald/maxminddb-golang v1.13.1 h1:G3wwjdN9JmIK2o/ermkHM+98oX5fS+k5MbwsmL4MRQE=
|
||||
github.com/oschwald/maxminddb-golang v1.13.1/go.mod h1:K4pgV9N/GcK694KSTmVSDTODk4IsCNThNdTmnaBZ/F8=
|
||||
github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M=
|
||||
github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
|
||||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||
github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs=
|
||||
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
|
||||
github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og=
|
||||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
||||
github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
||||
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/client_model v0.1.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||
github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA=
|
||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
||||
github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
|
||||
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
|
||||
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
|
||||
github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU=
|
||||
github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc=
|
||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
|
||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
|
||||
github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E=
|
||||
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
|
||||
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
|
||||
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
|
||||
github.com/shopspring/decimal v0.0.0-20200227202807-02e2044944cc h1:jUIKcSPO9MoMJBbEoyE/RJoE8vz7Mb8AjvifMMwSyvY=
|
||||
github.com/shopspring/decimal v0.0.0-20200227202807-02e2044944cc/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
||||
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
||||
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
|
||||
github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY=
|
||||
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
|
||||
github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||
github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
|
||||
github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
|
||||
github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI=
|
||||
github.com/prometheus/client_golang v1.21.1 h1:DOvXXTqVzvkIewV/CDPFdejpMCGeMcbGCQ8YOmu+Ibk=
|
||||
github.com/prometheus/client_golang v1.21.1/go.mod h1:U9NM32ykUErtVBxdvD3zfi+EuFkkaBvMb09mIfe0Zgg=
|
||||
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
|
||||
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
|
||||
github.com/prometheus/common v0.63.0 h1:YR/EIY1o3mEFP/kZCD7iDMnLPlGyuU2Gb3HIcXnA98k=
|
||||
github.com/prometheus/common v0.63.0/go.mod h1:VVFF/fBIoToEnWRVkYoXEkq3R3paCoxG9PXP74SnV18=
|
||||
github.com/prometheus/procfs v0.16.0 h1:xh6oHhKwnOJKMYiYBDWmkHqQPyiY40sny36Cmx2bbsM=
|
||||
github.com/prometheus/procfs v0.16.0/go.mod h1:8veyXUu3nGP7oaCxhX6yeaM5u4stL2FeMXnCqhDthZg=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
||||
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
|
||||
github.com/urfave/cli v1.22.1 h1:+mkCCcOFKPnCmVYVcURKps1Xe+3zP90gSYGNfRkjoIY=
|
||||
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
||||
github.com/urfave/cli/v2 v2.3.0 h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M=
|
||||
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
|
||||
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
|
||||
github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q=
|
||||
go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
|
||||
go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg=
|
||||
go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
|
||||
go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
|
||||
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
||||
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
||||
go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
|
||||
go.uber.org/atomic v1.6.0 h1:Ezj3JGmsOnG1MoRWQkPBsKLe9DwWD9QeXzTRzzldNVk=
|
||||
go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
|
||||
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
|
||||
go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4=
|
||||
go.uber.org/multierr v1.5.0 h1:KCa4XfM8CWFCpxXRGok+Q0SS/0XBhMDbHHGABQLvD2A=
|
||||
go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU=
|
||||
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee h1:0mgffUl7nfd+FpvXMVz4IDEaUSmT1ysygQC7qYo7sG4=
|
||||
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA=
|
||||
go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
||||
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
||||
go.uber.org/zap v1.13.0 h1:nR6NoDBgAf67s68NhaXbsojM+2gxp3S1hWkHDl27pVU=
|
||||
go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
|
||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 h1:It14KIkyBFYkHkwZ7k45minvA9aorojkyjGk9KJ5B/w=
|
||||
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs=
|
||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
|
||||
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
||||
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1 h1:4qWs8cYYH6PoEFy4dfhDFgoMGkwAcETd+MmPdCPMzUc=
|
||||
golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191224085550-c709ea063b76/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57 h1:F5Gozwx4I1xtr/sr/8CFbb57iKi3297KFs0QDbGN60A=
|
||||
golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba h1:O8mE0/t419eoIwhTFpKVkHiTs/Igowgfkj25AcZrtiE=
|
||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/urfave/cli/v3 v3.0.0-beta1 h1:6DTaaUarcM0wX7qj5Hcvs+5Dm3dyUTBbEwIWAjcw9Zg=
|
||||
github.com/urfave/cli/v3 v3.0.0-beta1/go.mod h1:FnIeEMYu+ko8zP1F9Ypr3xkZMIDqW3DR92yUtY39q1Y=
|
||||
golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34=
|
||||
golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc=
|
||||
golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4=
|
||||
golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
|
||||
golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c=
|
||||
golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
|
||||
golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw=
|
||||
golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
|
||||
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
|
||||
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||
golang.org/x/telemetry v0.0.0-20240522233618-39ace7a40ae7 h1:FemxDzfMUcK2f3YY4H+05K9CDzbSVr2+q/JKN45pey0=
|
||||
golang.org/x/telemetry v0.0.0-20240522233618-39ace7a40ae7/go.mod h1:pRgIJT+bRLFKnoM1ldnzKoxTIn14Yxz928LQRYYgIN0=
|
||||
golang.org/x/term v0.30.0 h1:PQ39fJZ+mfadBm0y5WlL4vlM7Sx1Hgf13sMIY2+QS9Y=
|
||||
golang.org/x/term v0.30.0/go.mod h1:NYYFdzHoI5wRh/h5tDMdMqCqPJZEuNqVR5xJLd/n67g=
|
||||
golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=
|
||||
golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=
|
||||
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190425163242-31fd60d6bfdc/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190823170909-c4a336ef6a2f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20200103221440-774c71fcf114 h1:DnSr2mCsxyCE6ZgIkmcWUQY2R5cH/6wL7eIxEmQOMSE=
|
||||
golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190530194941-fb225487d101/go.mod h1:z3L6/3dTEVtUr6QSP8miRzeRqwQOioJ9I66odjN4I7s=
|
||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||
google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM=
|
||||
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
|
||||
google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
|
||||
google.golang.org/grpc v1.22.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||
golang.org/x/time v0.11.0 h1:/bpjEDfN9tkoN/ryeYHnv5hcMlc8ncjMcM4XBk5NWV0=
|
||||
golang.org/x/time v0.11.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg=
|
||||
golang.org/x/tools v0.29.0 h1:Xx0h3TtM9rzQpQuR4dKLrdglAmCEN5Oi+P74JdhdzXE=
|
||||
golang.org/x/tools v0.29.0/go.mod h1:KMQVMRsVxU6nHCFXrBPhDB8XncLNLM0lIy/F14RP588=
|
||||
golang.org/x/vuln v1.1.4 h1:Ju8QsuyhX3Hk8ma3CesTbO8vfJD9EvUBgHvkxHBzj0I=
|
||||
golang.org/x/vuln v1.1.4/go.mod h1:F+45wmU18ym/ca5PLTPLsSzr2KppzswxPP603ldA67s=
|
||||
google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM=
|
||||
google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||
gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o=
|
||||
gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s=
|
||||
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
|
||||
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM=
|
||||
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
|
||||
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
@ -1,11 +0,0 @@
|
||||
package honeypot
|
||||
|
||||
type ActionType int
|
||||
|
||||
const (
|
||||
ActionTypeLogPassword ActionType = iota
|
||||
ActionTypeLogPasswordSlow
|
||||
ActionTypeLogCommandAndExit
|
||||
ActionTypeSendGarbage
|
||||
)
|
||||
const ActionTypeDefault ActionType = ActionTypeLogPassword
|
BIN
honeypot/ssh/Geoacumen-Country.mmdb
Normal file
BIN
honeypot/ssh/Geoacumen-Country.mmdb
Normal file
Binary file not shown.
@ -1,4 +1,4 @@
|
||||
package honeypot
|
||||
package ssh
|
||||
|
||||
import (
|
||||
"net"
|
@ -1,4 +1,4 @@
|
||||
package honeypot
|
||||
package ssh
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
@ -13,7 +13,7 @@ var mmdb []byte
|
||||
func (s *HoneypotServer) LookupCountry(ip net.IP) string {
|
||||
db, err := maxminddb.FromBytes(mmdb)
|
||||
if err != nil {
|
||||
s.Logger.Warnw("Error opening geoip database", "error", err)
|
||||
s.Logger.Warn("Error opening geoip database", "error", err)
|
||||
return "??"
|
||||
}
|
||||
|
||||
@ -25,7 +25,10 @@ func (s *HoneypotServer) LookupCountry(ip net.IP) string {
|
||||
|
||||
err = db.Lookup(ip, &record)
|
||||
if err != nil {
|
||||
s.Logger.Warnw("Error doing geoip lookup", "error", err)
|
||||
s.Logger.Warn("Error doing geoip lookup", "error", err)
|
||||
return "??"
|
||||
}
|
||||
if record.Country.ISOCode == "None" {
|
||||
return "??"
|
||||
}
|
||||
return record.Country.ISOCode
|
@ -1,27 +1,28 @@
|
||||
package honeypot
|
||||
package ssh
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"log/slog"
|
||||
"net"
|
||||
"os"
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
|
||||
gossh "golang.org/x/crypto/ssh"
|
||||
|
||||
"github.uio.no/torjus/apiary/config"
|
||||
"git.t-juice.club/torjus/apiary/config"
|
||||
|
||||
"github.com/gliderlabs/ssh"
|
||||
"git.t-juice.club/torjus/apiary/honeypot/ssh/store"
|
||||
"git.t-juice.club/torjus/apiary/models"
|
||||
sshlib "github.com/gliderlabs/ssh"
|
||||
"github.com/google/uuid"
|
||||
"github.uio.no/torjus/apiary/honeypot/store"
|
||||
"github.uio.no/torjus/apiary/models"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type HoneypotServer struct {
|
||||
Logger *zap.SugaredLogger
|
||||
Logger *slog.Logger
|
||||
|
||||
sshServer *ssh.Server
|
||||
sshServer *sshlib.Server
|
||||
|
||||
attemptStore store.LoginAttemptStore
|
||||
attemptsCallbacks []func(l models.LoginAttempt)
|
||||
@ -32,9 +33,9 @@ type HoneypotServer struct {
|
||||
func NewHoneypotServer(cfg config.HoneypotConfig, store store.LoginAttemptStore) (*HoneypotServer, error) {
|
||||
var hs HoneypotServer
|
||||
hs.attemptStore = store
|
||||
hs.Logger = zap.NewNop().Sugar()
|
||||
hs.Logger = slog.New(slog.NewTextHandler(io.Discard, nil))
|
||||
|
||||
hs.sshServer = &ssh.Server{
|
||||
hs.sshServer = &sshlib.Server{
|
||||
Addr: cfg.ListenAddr,
|
||||
PasswordHandler: hs.passwordHandler,
|
||||
ConnCallback: hs.connCallback,
|
||||
@ -59,6 +60,8 @@ func NewHoneypotServer(cfg config.HoneypotConfig, store store.LoginAttemptStore)
|
||||
hs.sshServer.AddHostKey(signer)
|
||||
}
|
||||
|
||||
hs.throttleSpeed = 1024 * 1024
|
||||
|
||||
return &hs, nil
|
||||
}
|
||||
|
||||
@ -74,7 +77,7 @@ func (hs *HoneypotServer) AddLoginCallback(c func(l models.LoginAttempt)) {
|
||||
hs.attemptsCallbacks = append(hs.attemptsCallbacks, c)
|
||||
}
|
||||
|
||||
func (hs *HoneypotServer) passwordHandler(ctx ssh.Context, password string) bool {
|
||||
func (hs *HoneypotServer) passwordHandler(ctx sshlib.Context, password string) bool {
|
||||
sessUUID, ok := ctx.Value("uuid").(uuid.UUID)
|
||||
if !ok {
|
||||
hs.Logger.Warn("Unable to get session UUID")
|
||||
@ -90,14 +93,20 @@ func (hs *HoneypotServer) passwordHandler(ctx ssh.Context, password string) bool
|
||||
ConnectionUUID: sessUUID,
|
||||
}
|
||||
country := hs.LookupCountry(la.RemoteIP)
|
||||
if utf8.RuneCountInString(country) > 2 {
|
||||
hs.Logger.Warn("Too many characters in country", "country", country, "runecount", utf8.RuneCountInString(country))
|
||||
country = "??"
|
||||
}
|
||||
|
||||
la.Country = country
|
||||
hs.Logger.Infow("Login attempt",
|
||||
hs.Logger.Info("Login attempt",
|
||||
"remote_ip", la.RemoteIP.String(),
|
||||
"username", la.Username,
|
||||
"password", la.Password)
|
||||
"password", la.Password,
|
||||
"country", la.Country)
|
||||
|
||||
if err := hs.attemptStore.AddAttempt(&la); err != nil {
|
||||
hs.Logger.Warnf("Error adding attempt to store")
|
||||
hs.Logger.Warn("Error adding attempt to store", "error", err)
|
||||
}
|
||||
|
||||
for _, cFunc := range hs.attemptsCallbacks {
|
||||
@ -107,17 +116,18 @@ func (hs *HoneypotServer) passwordHandler(ctx ssh.Context, password string) bool
|
||||
return false
|
||||
}
|
||||
|
||||
func (s *HoneypotServer) connCallback(ctx ssh.Context, conn net.Conn) net.Conn {
|
||||
func (s *HoneypotServer) connCallback(ctx sshlib.Context, conn net.Conn) net.Conn {
|
||||
s.Logger.Debug("Connection received.", "remote_addr", conn.RemoteAddr())
|
||||
|
||||
throttledConn := newThrottledConn(conn)
|
||||
throttledConn.SetSpeed(s.throttleSpeed)
|
||||
ctx.SetValue("uuid", throttledConn.ID)
|
||||
throttledConn.SetSpeed(s.throttleSpeed)
|
||||
return throttledConn
|
||||
}
|
||||
|
||||
func handler(session ssh.Session) {
|
||||
func handler(session sshlib.Session) {
|
||||
_, _ = io.WriteString(session, "[root@hostname ~]#")
|
||||
session.Exit(1)
|
||||
_ = session.Exit(1)
|
||||
}
|
||||
|
||||
func ipFromAddr(addr string) net.IP {
|
118
honeypot/ssh/store/cache.go
Normal file
118
honeypot/ssh/store/cache.go
Normal file
@ -0,0 +1,118 @@
|
||||
package store
|
||||
|
||||
import "git.t-juice.club/torjus/apiary/models"
|
||||
|
||||
var _ LoginAttemptStore = &CachingStore{}
|
||||
|
||||
type CachingStore struct {
|
||||
backend LoginAttemptStore
|
||||
|
||||
totalStatsCache []StatsResult
|
||||
usernameQueryCache map[string][]models.LoginAttempt
|
||||
passwordQueryCache map[string][]models.LoginAttempt
|
||||
ipQueryCache map[string][]models.LoginAttempt
|
||||
uniqueUsernames map[string]struct{}
|
||||
uniquePasswords map[string]struct{}
|
||||
uniqueIPs map[string]struct{}
|
||||
uniqueCountries map[string]struct{}
|
||||
totalLoginsCount int
|
||||
}
|
||||
|
||||
func NewCachingStore(backend LoginAttemptStore) *CachingStore {
|
||||
cs := &CachingStore{
|
||||
backend: backend,
|
||||
usernameQueryCache: make(map[string][]models.LoginAttempt),
|
||||
passwordQueryCache: make(map[string][]models.LoginAttempt),
|
||||
ipQueryCache: make(map[string][]models.LoginAttempt),
|
||||
uniqueUsernames: make(map[string]struct{}),
|
||||
uniquePasswords: make(map[string]struct{}),
|
||||
uniqueIPs: make(map[string]struct{}),
|
||||
uniqueCountries: make(map[string]struct{}),
|
||||
}
|
||||
|
||||
all, err := backend.All()
|
||||
if err != nil {
|
||||
//TODO: Handle better maybe?
|
||||
panic(err)
|
||||
}
|
||||
var loginCount int
|
||||
|
||||
for attempt := range all {
|
||||
cs.uniqueUsernames[attempt.Username] = struct{}{}
|
||||
cs.uniquePasswords[attempt.Password] = struct{}{}
|
||||
cs.uniqueIPs[attempt.RemoteIP.String()] = struct{}{}
|
||||
cs.uniqueCountries[attempt.Country] = struct{}{}
|
||||
loginCount++
|
||||
}
|
||||
cs.totalLoginsCount = loginCount
|
||||
|
||||
return cs
|
||||
}
|
||||
|
||||
func (s *CachingStore) AddAttempt(l *models.LoginAttempt) error {
|
||||
s.totalStatsCache = nil
|
||||
delete(s.ipQueryCache, l.RemoteIP.String())
|
||||
delete(s.passwordQueryCache, l.Password)
|
||||
delete(s.usernameQueryCache, l.Username)
|
||||
s.totalLoginsCount++
|
||||
s.uniqueUsernames[l.Username] = struct{}{}
|
||||
s.uniquePasswords[l.Password] = struct{}{}
|
||||
s.uniqueIPs[l.RemoteIP.String()] = struct{}{}
|
||||
s.uniqueCountries[l.Country] = struct{}{}
|
||||
return s.backend.AddAttempt(l)
|
||||
}
|
||||
|
||||
func (s *CachingStore) All() (<-chan models.LoginAttempt, error) {
|
||||
return s.backend.All()
|
||||
}
|
||||
|
||||
func (s *CachingStore) Stats(statType LoginStats, limit int) ([]StatsResult, error) {
|
||||
// Only cache totals for now, as they are the most queried
|
||||
if statType == LoginStatsTotals {
|
||||
return []StatsResult{
|
||||
{Name: "UniquePasswords", Count: len(s.uniquePasswords)},
|
||||
{Name: "UniqueUsernames", Count: len(s.uniqueUsernames)},
|
||||
{Name: "UniqueIPs", Count: len(s.uniqueIPs)},
|
||||
{Name: "UniqueCountries", Count: len(s.uniqueCountries)},
|
||||
{Name: "TotalLoginAttempts", Count: s.totalLoginsCount},
|
||||
}, nil
|
||||
}
|
||||
|
||||
return s.backend.Stats(statType, limit)
|
||||
}
|
||||
|
||||
func (s *CachingStore) Query(query AttemptQuery) ([]models.LoginAttempt, error) {
|
||||
switch query.QueryType {
|
||||
case AttemptQueryTypeIP:
|
||||
if attempts, ok := s.ipQueryCache[query.Query]; ok {
|
||||
return attempts, nil
|
||||
}
|
||||
case AttemptQueryTypePassword:
|
||||
if attempts, ok := s.passwordQueryCache[query.Query]; ok {
|
||||
return attempts, nil
|
||||
}
|
||||
case AttemptQueryTypeUsername:
|
||||
if attempts, ok := s.usernameQueryCache[query.Query]; ok {
|
||||
return attempts, nil
|
||||
}
|
||||
}
|
||||
attempts, err := s.backend.Query(query)
|
||||
if err != nil {
|
||||
return attempts, err
|
||||
}
|
||||
|
||||
switch query.QueryType {
|
||||
case AttemptQueryTypeIP:
|
||||
s.ipQueryCache[query.Query] = attempts
|
||||
case AttemptQueryTypeUsername:
|
||||
s.ipQueryCache[query.Query] = attempts
|
||||
case AttemptQueryTypePassword:
|
||||
s.ipQueryCache[query.Query] = attempts
|
||||
}
|
||||
|
||||
return attempts, err
|
||||
}
|
||||
|
||||
func (s *CachingStore) IsHealthy() error {
|
||||
return s.backend.IsHealthy()
|
||||
}
|
69
honeypot/ssh/store/cache_test.go
Normal file
69
honeypot/ssh/store/cache_test.go
Normal file
@ -0,0 +1,69 @@
|
||||
package store_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"git.t-juice.club/torjus/apiary/honeypot/ssh/store"
|
||||
)
|
||||
|
||||
func TestCacheStore(t *testing.T) {
|
||||
backend := &store.MemoryStore{}
|
||||
s := store.NewCachingStore(backend)
|
||||
testLoginAttemptStore(s, t)
|
||||
}
|
||||
|
||||
func TestCacheTotalStats(t *testing.T) {
|
||||
backend := &store.MemoryStore{}
|
||||
// Add initial attempts, to ensure that the cache is correcly initialized with existing attempts
|
||||
attempts := randomAttempts(50000)
|
||||
for _, attempt := range attempts {
|
||||
err := backend.AddAttempt(attempt)
|
||||
if err != nil {
|
||||
t.Fatalf("Error adding attempts: %s", err)
|
||||
}
|
||||
}
|
||||
s := store.NewCachingStore(backend)
|
||||
cacheTotals, err := s.Stats(store.LoginStatsTotals, 0)
|
||||
if err != nil {
|
||||
t.Fatalf("Error getting cached stats: %s", err)
|
||||
}
|
||||
backendTotals, err := backend.Stats(store.LoginStatsTotals, 0)
|
||||
if err != nil {
|
||||
t.Fatalf("Error getting cached stats: %s", err)
|
||||
}
|
||||
for i := range cacheTotals {
|
||||
if cacheTotals[i].Count != backendTotals[i].Count || cacheTotals[i].Name != backendTotals[i].Name {
|
||||
t.Fatalf("Mismatched totals: Cache: %+v Backend: %+v", cacheTotals[i], backendTotals[i])
|
||||
}
|
||||
}
|
||||
|
||||
// Add the same attempts again, to ensure that duplicates are handled correctly
|
||||
for _, attempt := range attempts {
|
||||
err := s.AddAttempt(attempt)
|
||||
if err != nil {
|
||||
t.Fatalf("Error adding attempts: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Add some new attempts
|
||||
attempts = randomAttempts(10000)
|
||||
for _, attempt := range attempts {
|
||||
err := s.AddAttempt(attempt)
|
||||
if err != nil {
|
||||
t.Fatalf("Error adding attempts: %s", err)
|
||||
}
|
||||
}
|
||||
cacheTotals, err = s.Stats(store.LoginStatsTotals, 0)
|
||||
if err != nil {
|
||||
t.Fatalf("Error getting cached stats: %s", err)
|
||||
}
|
||||
backendTotals, err = backend.Stats(store.LoginStatsTotals, 0)
|
||||
if err != nil {
|
||||
t.Fatalf("Error getting cached stats: %s", err)
|
||||
}
|
||||
for i := range cacheTotals {
|
||||
if cacheTotals[i].Count != backendTotals[i].Count || cacheTotals[i].Name != backendTotals[i].Name {
|
||||
t.Fatalf("Mismatched totals: Cache: %+v Backend: %+v", cacheTotals[i], backendTotals[i])
|
||||
}
|
||||
}
|
||||
}
|
@ -6,9 +6,11 @@ import (
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.uio.no/torjus/apiary/models"
|
||||
"git.t-juice.club/torjus/apiary/models"
|
||||
)
|
||||
|
||||
var _ LoginAttemptStore = &MemoryStore{}
|
||||
|
||||
type MemoryStore struct {
|
||||
lock sync.RWMutex
|
||||
attempts []models.LoginAttempt
|
||||
@ -32,8 +34,17 @@ func (ms *MemoryStore) AddAttempt(l *models.LoginAttempt) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ms *MemoryStore) All() ([]models.LoginAttempt, error) {
|
||||
return ms.attempts, nil
|
||||
func (ms *MemoryStore) All() (<-chan models.LoginAttempt, error) {
|
||||
ch := make(chan models.LoginAttempt)
|
||||
go func() {
|
||||
ms.lock.RLock()
|
||||
defer ms.lock.RUnlock()
|
||||
for _, attempt := range ms.attempts {
|
||||
ch <- attempt
|
||||
}
|
||||
close(ch)
|
||||
}()
|
||||
return ch, nil
|
||||
}
|
||||
|
||||
func (ms *MemoryStore) Stats(statType LoginStats, limit int) ([]StatsResult, error) {
|
||||
@ -57,7 +68,7 @@ func (ms *MemoryStore) Stats(statType LoginStats, limit int) ([]StatsResult, err
|
||||
case LoginStatsUsername:
|
||||
counts[a.Username]++
|
||||
default:
|
||||
return nil, fmt.Errorf("Invalid stat type")
|
||||
return nil, fmt.Errorf("invalid stat type")
|
||||
}
|
||||
}
|
||||
|
||||
@ -142,6 +153,10 @@ func (ms *MemoryStore) Query(query AttemptQuery) ([]models.LoginAttempt, error)
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func (s *MemoryStore) IsHealthy() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func toResults(m map[string]int) []StatsResult {
|
||||
var results []StatsResult
|
||||
|
30
honeypot/ssh/store/memory_test.go
Normal file
30
honeypot/ssh/store/memory_test.go
Normal file
@ -0,0 +1,30 @@
|
||||
package store_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"git.t-juice.club/torjus/apiary/honeypot/ssh/store"
|
||||
)
|
||||
|
||||
func TestMemoryStore(t *testing.T) {
|
||||
s := &store.MemoryStore{}
|
||||
testLoginAttemptStore(s, t)
|
||||
}
|
||||
|
||||
func TestMemoryStoreWithCache(t *testing.T) {
|
||||
backend := &store.MemoryStore{}
|
||||
s := store.NewCachingStore(backend)
|
||||
testLoginAttemptStore(s, t)
|
||||
}
|
||||
|
||||
func BenchmarkMemoryStore(b *testing.B) {
|
||||
setupFunc := func() store.LoginAttemptStore {
|
||||
return &store.MemoryStore{}
|
||||
}
|
||||
benchmarkLoginAttemptStore(setupFunc, b)
|
||||
}
|
||||
|
||||
func FuzzMemoryStore(f *testing.F) {
|
||||
s := &store.MemoryStore{}
|
||||
fuzzLoginAttemptStore(s, f)
|
||||
}
|
127
honeypot/ssh/store/metrics.go
Normal file
127
honeypot/ssh/store/metrics.go
Normal file
@ -0,0 +1,127 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"git.t-juice.club/torjus/apiary/models"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
var _ LoginAttemptStore = &MetricsCollectingStore{}
|
||||
|
||||
const tickDuration = 5 * time.Second
|
||||
|
||||
type MetricsCollectingStore struct {
|
||||
store LoginAttemptStore
|
||||
|
||||
attemptsCounter *prometheus.CounterVec
|
||||
uniqueUsernamesCount prometheus.Gauge
|
||||
uniquePasswordsCount prometheus.Gauge
|
||||
uniqueIPsCount prometheus.Gauge
|
||||
totalAttemptsCount prometheus.Gauge
|
||||
|
||||
statsTicker *time.Ticker
|
||||
}
|
||||
|
||||
func NewMetricsCollectingStore(ctx context.Context, store LoginAttemptStore) *MetricsCollectingStore {
|
||||
mcs := &MetricsCollectingStore{store: store}
|
||||
|
||||
mcs.attemptsCounter = prometheus.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Name: "apiary_ssh_attempt_counter",
|
||||
Help: "Total count of login attempts toward SSH",
|
||||
ConstLabels: prometheus.Labels{"service": "honeypot_ssh"},
|
||||
},
|
||||
[]string{"CountryCode"},
|
||||
)
|
||||
mcs.uniqueUsernamesCount = prometheus.NewGauge(
|
||||
prometheus.GaugeOpts{
|
||||
Name: "apiary_ssh_unique_usernames_count",
|
||||
Help: "Counter of unique usernames.",
|
||||
ConstLabels: prometheus.Labels{"service": "honeypot_ssh"},
|
||||
})
|
||||
|
||||
mcs.uniquePasswordsCount = prometheus.NewGauge(
|
||||
prometheus.GaugeOpts{
|
||||
Name: "apiary_ssh_unique_passwords_count",
|
||||
Help: "Counter of unique passwords.",
|
||||
ConstLabels: prometheus.Labels{"service": "honeypot_ssh"},
|
||||
})
|
||||
|
||||
mcs.uniqueIPsCount = prometheus.NewGauge(
|
||||
prometheus.GaugeOpts{
|
||||
Name: "apiary_ssh_unique_ips_count",
|
||||
Help: "Counter of unique IPs.",
|
||||
ConstLabels: prometheus.Labels{"service": "honeypot_ssh"},
|
||||
})
|
||||
|
||||
mcs.totalAttemptsCount = prometheus.NewGauge(
|
||||
prometheus.GaugeOpts{
|
||||
Name: "apiary_ssh_total_login_attempts",
|
||||
Help: "Total amount of login attempts made.",
|
||||
ConstLabels: prometheus.Labels{"service": "honeypot_ssh"},
|
||||
})
|
||||
|
||||
prometheus.MustRegister(mcs.attemptsCounter)
|
||||
prometheus.MustRegister(mcs.uniqueUsernamesCount)
|
||||
prometheus.MustRegister(mcs.uniquePasswordsCount)
|
||||
prometheus.MustRegister(mcs.uniqueIPsCount)
|
||||
prometheus.MustRegister(mcs.totalAttemptsCount)
|
||||
|
||||
mcs.statsTicker = time.NewTicker(tickDuration)
|
||||
go func() {
|
||||
defer mcs.statsTicker.Stop()
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case <-mcs.statsTicker.C:
|
||||
mcs.Stats(LoginStatsTotals, 0) // nolint: errcheck
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
return mcs
|
||||
}
|
||||
|
||||
func (s *MetricsCollectingStore) AddAttempt(l *models.LoginAttempt) error {
|
||||
err := s.store.AddAttempt(l)
|
||||
s.attemptsCounter.WithLabelValues(l.Country).Inc()
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *MetricsCollectingStore) All() (<-chan models.LoginAttempt, error) {
|
||||
return s.store.All()
|
||||
}
|
||||
|
||||
func (s *MetricsCollectingStore) Stats(statType LoginStats, limit int) ([]StatsResult, error) {
|
||||
stats, err := s.store.Stats(statType, limit)
|
||||
if statType == LoginStatsTotals {
|
||||
// Reset ticker to avoid updating twice within the duration
|
||||
s.statsTicker.Reset(tickDuration)
|
||||
for _, element := range stats {
|
||||
switch element.Name {
|
||||
case "UniquePasswords":
|
||||
s.uniquePasswordsCount.Set(float64(element.Count))
|
||||
case "UniqueUsernames":
|
||||
s.uniqueUsernamesCount.Set(float64(element.Count))
|
||||
case "UniqueIPs":
|
||||
s.uniqueIPsCount.Set(float64(element.Count))
|
||||
case "TotalLoginAttempts":
|
||||
s.totalAttemptsCount.Set(float64(element.Count))
|
||||
default:
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
return stats, err
|
||||
}
|
||||
|
||||
func (s *MetricsCollectingStore) Query(query AttemptQuery) ([]models.LoginAttempt, error) {
|
||||
return s.store.Query(query)
|
||||
}
|
||||
|
||||
func (s *MetricsCollectingStore) IsHealthy() error {
|
||||
return s.store.IsHealthy()
|
||||
}
|
@ -5,10 +5,12 @@ import (
|
||||
"fmt"
|
||||
"net"
|
||||
|
||||
_ "github.com/jackc/pgx/v4/stdlib"
|
||||
"github.uio.no/torjus/apiary/models"
|
||||
"git.t-juice.club/torjus/apiary/models"
|
||||
_ "github.com/jackc/pgx/v5/stdlib"
|
||||
)
|
||||
|
||||
var _ LoginAttemptStore = &PostgresStore{}
|
||||
|
||||
const DBSchema = `
|
||||
CREATE TABLE IF NOT EXISTS login_attempts(
|
||||
id serial PRIMARY KEY,
|
||||
@ -51,7 +53,7 @@ RETURNING id;`
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer tx.Rollback()
|
||||
defer tx.Rollback() // nolint: errcheck
|
||||
|
||||
var id int
|
||||
if err := tx.QueryRow(stmt, l.Date, l.RemoteIP.String(), l.Username, l.Password, l.SSHClientVersion, l.ConnectionUUID, l.Country).Scan(&id); err != nil {
|
||||
@ -61,25 +63,30 @@ RETURNING id;`
|
||||
return tx.Commit()
|
||||
}
|
||||
|
||||
func (s *PostgresStore) All() ([]models.LoginAttempt, error) {
|
||||
func (s *PostgresStore) All() (<-chan models.LoginAttempt, error) {
|
||||
stmt := `SELECT date, remote_ip, username, password, client_version, connection_uuid, country FROM login_attempts`
|
||||
|
||||
rows, err := s.db.Query(stmt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
var attempts []models.LoginAttempt
|
||||
ch := make(chan models.LoginAttempt)
|
||||
go func() {
|
||||
defer rows.Close()
|
||||
for rows.Next() {
|
||||
var a models.LoginAttempt
|
||||
if err := rows.Scan(&a.Date, &a.RemoteIP, &a.Username, &a.Password, &a.SSHClientVersion, &a.SSHClientVersion, &a.Country); err != nil {
|
||||
return nil, err
|
||||
var ip string
|
||||
if err := rows.Scan(&a.Date, &ip, &a.Username, &a.Password, &a.SSHClientVersion, &a.SSHClientVersion, &a.Country); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
attempts = append(attempts, a)
|
||||
a.RemoteIP = net.ParseIP(ip)
|
||||
ch <- a
|
||||
}
|
||||
close(ch)
|
||||
}()
|
||||
|
||||
return attempts, nil
|
||||
return ch, nil
|
||||
}
|
||||
|
||||
func (s *PostgresStore) Stats(statType LoginStats, limit int) ([]StatsResult, error) {
|
||||
@ -124,6 +131,13 @@ func (s *PostgresStore) Stats(statType LoginStats, limit int) ([]StatsResult, er
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func (s *PostgresStore) IsHealthy() error {
|
||||
if err := s.db.Ping(); err != nil {
|
||||
return ErrStoreUnhealthy
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *PostgresStore) statsTotal(limit int) ([]StatsResult, error) {
|
||||
uniquePasswordStmt := `select count(*) from (select distinct password from login_attempts) as temp`
|
||||
uniqueUsernameStmt := `select count(*) from (select distinct username from login_attempts) as temp`
|
||||
@ -164,25 +178,25 @@ func (s *PostgresStore) Query(query AttemptQuery) ([]models.LoginAttempt, error)
|
||||
var stmt string
|
||||
queryString := query.Query
|
||||
|
||||
const limit = 10000
|
||||
|
||||
switch query.QueryType {
|
||||
case AttemptQueryTypeIP:
|
||||
stmt = `SELECT id, date, remote_ip, username, password, client_version, connection_uuid, country
|
||||
FROM login_attempts WHERE remote_ip = $1`
|
||||
FROM login_attempts WHERE remote_ip = $1 order by date desc limit $2`
|
||||
case AttemptQueryTypePassword:
|
||||
stmt = `SELECT id, date, remote_ip, username, password, client_version, connection_uuid, country
|
||||
FROM login_attempts WHERE password like $1`
|
||||
queryString = fmt.Sprintf("%%%s%%", queryString)
|
||||
FROM login_attempts WHERE password = $1 order by date desc limit $2`
|
||||
case AttemptQueryTypeUsername:
|
||||
stmt = `SELECT id, date, remote_ip, username, password, client_version, connection_uuid, country
|
||||
FROM login_attempts WHERE username like $1`
|
||||
queryString = fmt.Sprintf("%%%s%%", queryString)
|
||||
FROM login_attempts WHERE username = $1 order by date desc limit $2`
|
||||
default:
|
||||
return nil, fmt.Errorf("Invalid query type")
|
||||
return nil, fmt.Errorf("invalid query type")
|
||||
}
|
||||
|
||||
rows, err := s.db.Query(stmt, queryString)
|
||||
rows, err := s.db.Query(stmt, queryString, limit)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Unable to query database: %w", err)
|
||||
return nil, fmt.Errorf("unable to query database: %w", err)
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
@ -191,11 +205,10 @@ func (s *PostgresStore) Query(query AttemptQuery) ([]models.LoginAttempt, error)
|
||||
var la models.LoginAttempt
|
||||
var ipString string
|
||||
if err := rows.Scan(&la.ID, &la.Date, &ipString, &la.Username, &la.Password, &la.SSHClientVersion, &la.ConnectionUUID, &la.Country); err != nil {
|
||||
return nil, fmt.Errorf("Unable to unmarshal data from database: %w", err)
|
||||
return nil, fmt.Errorf("unable to unmarshal data from database: %w", err)
|
||||
}
|
||||
la.RemoteIP = net.ParseIP(ipString)
|
||||
results = append(results, la)
|
||||
|
||||
}
|
||||
|
||||
return results, nil
|
82
honeypot/ssh/store/postgres_test.go
Normal file
82
honeypot/ssh/store/postgres_test.go
Normal file
@ -0,0 +1,82 @@
|
||||
// nolint: errcheck
|
||||
package store_test
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"git.t-juice.club/torjus/apiary/honeypot/ssh/store"
|
||||
_ "github.com/jackc/pgx/v5/stdlib"
|
||||
)
|
||||
|
||||
func TestPostgresStore(t *testing.T) {
|
||||
var dsn string
|
||||
var found bool
|
||||
dsn, found = os.LookupEnv("APIARY_TEST_POSTGRES_DSN")
|
||||
if !found {
|
||||
t.Skipf("APIARY_TEST_POSTGRES_DSN not set. Skipping.")
|
||||
}
|
||||
|
||||
dropPGDatabase(dsn)
|
||||
|
||||
s, err := store.NewPostgresStore(dsn)
|
||||
if err != nil {
|
||||
t.Fatalf("Error getting store: %s", err)
|
||||
}
|
||||
|
||||
s.InitDB()
|
||||
|
||||
testLoginAttemptStore(s, t)
|
||||
}
|
||||
|
||||
func TestPostgresStoreWithCache(t *testing.T) {
|
||||
var dsn string
|
||||
var found bool
|
||||
dsn, found = os.LookupEnv("APIARY_TEST_POSTGRES_DSN")
|
||||
if !found {
|
||||
t.Skipf("APIARY_TEST_POSTGRES_DSN not set. Skipping.")
|
||||
}
|
||||
|
||||
dropPGDatabase(dsn)
|
||||
|
||||
pgs, err := store.NewPostgresStore(dsn)
|
||||
if err != nil {
|
||||
t.Fatalf("Error getting store: %s", err)
|
||||
}
|
||||
|
||||
pgs.InitDB()
|
||||
s := store.NewCachingStore(pgs)
|
||||
|
||||
testLoginAttemptStore(s, t)
|
||||
}
|
||||
|
||||
func BenchmarkPostgresStore(b *testing.B) {
|
||||
var dsn string
|
||||
var found bool
|
||||
dsn, found = os.LookupEnv("APIARY_TEST_POSTGRES_DSN")
|
||||
if !found {
|
||||
b.Skipf("APIARY_TEST_POSTGRES_DSN not set. Skipping.")
|
||||
}
|
||||
dropPGDatabase(dsn)
|
||||
setupFunc := func() store.LoginAttemptStore {
|
||||
dropPGDatabase(dsn)
|
||||
pgs, err := store.NewPostgresStore(dsn)
|
||||
if err != nil {
|
||||
b.Fatalf("Error getting store: %s", err)
|
||||
}
|
||||
pgs.InitDB()
|
||||
return pgs
|
||||
}
|
||||
benchmarkLoginAttemptStore(setupFunc, b)
|
||||
dropPGDatabase(dsn)
|
||||
}
|
||||
|
||||
func dropPGDatabase(dsn string) {
|
||||
db, err := sql.Open("pgx", dsn)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
_, _ = db.Exec("DROP TABLE login_attempts")
|
||||
}
|
@ -1,6 +1,12 @@
|
||||
package store
|
||||
|
||||
import "github.uio.no/torjus/apiary/models"
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"git.t-juice.club/torjus/apiary/models"
|
||||
)
|
||||
|
||||
var ErrStoreUnhealthy = errors.New("store is unhealthy")
|
||||
|
||||
type LoginStats string
|
||||
|
||||
@ -32,7 +38,12 @@ type AttemptQuery struct {
|
||||
}
|
||||
type LoginAttemptStore interface {
|
||||
AddAttempt(l *models.LoginAttempt) error
|
||||
All() ([]models.LoginAttempt, error)
|
||||
All() (<-chan models.LoginAttempt, error)
|
||||
Stats(statType LoginStats, limit int) ([]StatsResult, error)
|
||||
Query(query AttemptQuery) ([]models.LoginAttempt, error)
|
||||
HealthCheker
|
||||
}
|
||||
|
||||
type HealthCheker interface {
|
||||
IsHealthy() error
|
||||
}
|
344
honeypot/ssh/store/store_test.go
Normal file
344
honeypot/ssh/store/store_test.go
Normal file
@ -0,0 +1,344 @@
|
||||
package store_test
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"net"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.t-juice.club/torjus/apiary/honeypot/ssh/store"
|
||||
"git.t-juice.club/torjus/apiary/models"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
func testLoginAttemptStore(s store.LoginAttemptStore, t *testing.T) {
|
||||
t.Run("Simple", func(t *testing.T) {
|
||||
testAttempts := randomAttempts(10)
|
||||
|
||||
for _, attempt := range testAttempts {
|
||||
if err := s.AddAttempt(attempt); err != nil {
|
||||
t.Fatalf("Error adding attempt: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
all, err := s.All()
|
||||
if err != nil {
|
||||
t.Fatalf("Error getting all attempts: %s", err)
|
||||
}
|
||||
var count int
|
||||
for range all {
|
||||
count++
|
||||
}
|
||||
if count != len(testAttempts) {
|
||||
t.Errorf("All returned wrong amount. Got %d want %d", count, len(testAttempts))
|
||||
}
|
||||
stats, err := s.Stats(store.LoginStatsTotals, 1)
|
||||
if err != nil {
|
||||
t.Errorf("Stats returned error: %s", err)
|
||||
}
|
||||
for _, stat := range stats {
|
||||
if stat.Name == "TotalLoginAttempts" && stat.Count != len(testAttempts) {
|
||||
t.Errorf("Stats for total attempts is wrong. Got %d want %d", stat.Count, len(testAttempts))
|
||||
}
|
||||
}
|
||||
})
|
||||
t.Run("Query", func(t *testing.T) {
|
||||
testAttempts := []*models.LoginAttempt{
|
||||
{
|
||||
Date: time.Now(),
|
||||
RemoteIP: net.ParseIP("127.0.0.1"),
|
||||
Username: "corndog",
|
||||
Password: "corndog",
|
||||
},
|
||||
{
|
||||
Date: time.Now(),
|
||||
RemoteIP: net.ParseIP("127.0.0.1"),
|
||||
Username: "corndog",
|
||||
Password: "c0rnd0g",
|
||||
},
|
||||
{
|
||||
Date: time.Now(),
|
||||
RemoteIP: net.ParseIP("10.0.0.1"),
|
||||
Username: "root",
|
||||
Password: "password",
|
||||
},
|
||||
{
|
||||
Date: time.Now(),
|
||||
RemoteIP: net.ParseIP("10.0.0.2"),
|
||||
Username: "ubnt",
|
||||
Password: "password",
|
||||
},
|
||||
}
|
||||
|
||||
for _, attempt := range testAttempts {
|
||||
err := s.AddAttempt(attempt)
|
||||
if err != nil {
|
||||
t.Fatalf("Unable to add attempt: %s", err)
|
||||
}
|
||||
}
|
||||
testCases := []struct {
|
||||
Name string
|
||||
Query store.AttemptQuery
|
||||
ExpectedResult []models.LoginAttempt
|
||||
}{
|
||||
{
|
||||
Name: "password one result",
|
||||
Query: store.AttemptQuery{QueryType: store.AttemptQueryTypePassword, Query: "corndog"},
|
||||
ExpectedResult: []models.LoginAttempt{
|
||||
{
|
||||
RemoteIP: net.ParseIP("127.0.0.1"),
|
||||
Username: "corndog",
|
||||
Password: "corndog",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "username one result",
|
||||
Query: store.AttemptQuery{QueryType: store.AttemptQueryTypeUsername, Query: "root"},
|
||||
ExpectedResult: []models.LoginAttempt{
|
||||
{
|
||||
RemoteIP: net.ParseIP("10.0.0.1"),
|
||||
Username: "root",
|
||||
Password: "password",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "username two results",
|
||||
Query: store.AttemptQuery{QueryType: store.AttemptQueryTypeUsername, Query: "corndog"},
|
||||
ExpectedResult: []models.LoginAttempt{
|
||||
{
|
||||
RemoteIP: net.ParseIP("127.0.0.1"),
|
||||
Username: "corndog",
|
||||
Password: "c0rnd0g",
|
||||
},
|
||||
{
|
||||
RemoteIP: net.ParseIP("127.0.0.1"),
|
||||
Username: "corndog",
|
||||
Password: "corndog",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
res, err := s.Query(tc.Query)
|
||||
if err != nil {
|
||||
t.Errorf("Error performing query: %s", err)
|
||||
}
|
||||
if !equalAttempts(res, tc.ExpectedResult) {
|
||||
t.Errorf("Query did not return expected results")
|
||||
t.Logf("%+v", res)
|
||||
t.Logf("%+v", tc.ExpectedResult)
|
||||
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("QueryCache", func(t *testing.T) {
|
||||
err := s.AddAttempt(&models.LoginAttempt{RemoteIP: net.ParseIP("127.0.0.1"), Username: "test", Password: "test"})
|
||||
if err != nil {
|
||||
t.Fatalf("Error adding attempt: %s", err)
|
||||
}
|
||||
|
||||
res, err := s.Query(store.AttemptQuery{QueryType: store.AttemptQueryTypeUsername, Query: "test"})
|
||||
if err != nil {
|
||||
t.Fatalf("Error adding attempt: %s", err)
|
||||
}
|
||||
if len(res) != 1 {
|
||||
t.Errorf("Wrong amount of results")
|
||||
}
|
||||
|
||||
err = s.AddAttempt(&models.LoginAttempt{RemoteIP: net.ParseIP("127.0.0.1"), Username: "test", Password: "best"})
|
||||
if err != nil {
|
||||
t.Fatalf("Error adding attempt: %s", err)
|
||||
}
|
||||
res, err = s.Query(store.AttemptQuery{QueryType: store.AttemptQueryTypeUsername, Query: "test"})
|
||||
if err != nil {
|
||||
t.Fatalf("Error adding attempt: %s", err)
|
||||
}
|
||||
if len(res) != 2 {
|
||||
t.Errorf("Wrong amount of results")
|
||||
}
|
||||
})
|
||||
t.Run("QueryStats", func(t *testing.T) {
|
||||
firstStats, err := s.Stats(store.LoginStatsTotals, 1)
|
||||
if err != nil {
|
||||
t.Fatalf("Error getting stats: %s", err)
|
||||
}
|
||||
err = s.AddAttempt(&models.LoginAttempt{RemoteIP: net.ParseIP("127.0.0.1"), Username: "test", Password: "best"})
|
||||
if err != nil {
|
||||
t.Fatalf("Error adding attempt: %s", err)
|
||||
}
|
||||
secondStats, err := s.Stats(store.LoginStatsTotals, 1)
|
||||
if err != nil {
|
||||
t.Fatalf("Error getting stats: %s", err)
|
||||
}
|
||||
var firstCount, secondCount int
|
||||
for _, stat := range firstStats {
|
||||
if stat.Name == "TotalLoginAttempts" {
|
||||
firstCount = stat.Count
|
||||
}
|
||||
}
|
||||
for _, stat := range secondStats {
|
||||
if stat.Name == "TotalLoginAttempts" {
|
||||
secondCount = stat.Count
|
||||
}
|
||||
}
|
||||
|
||||
if secondCount != firstCount+1 {
|
||||
t.Errorf("TotalLoginAttempts did not increment")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func benchmarkLoginAttemptStore(setupFunc func() store.LoginAttemptStore, b *testing.B) {
|
||||
b.Run("BenchmarkAdd", func(b *testing.B) {
|
||||
s := setupFunc()
|
||||
for i := 0; i < b.N; i++ {
|
||||
attempt := randomAttempts(1)
|
||||
err := s.AddAttempt(attempt[0])
|
||||
if err != nil {
|
||||
b.Fatalf("Error adding attempt: %s", err)
|
||||
}
|
||||
}
|
||||
})
|
||||
b.Run("BenchmarkAdd10k", func(b *testing.B) {
|
||||
attempts := randomAttempts(10_000)
|
||||
for i := 0; i < b.N; i++ {
|
||||
b.StopTimer()
|
||||
s := setupFunc()
|
||||
b.StartTimer()
|
||||
for _, attempt := range attempts {
|
||||
err := s.AddAttempt(attempt)
|
||||
if err != nil {
|
||||
b.Fatalf("Error adding attempt: %s", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
b.Run("BenchmarkAll10k", func(b *testing.B) {
|
||||
s := setupFunc()
|
||||
attempts := randomAttempts(10_000)
|
||||
for _, attempt := range attempts {
|
||||
err := s.AddAttempt(attempt)
|
||||
if err != nil {
|
||||
b.Fatalf("Error adding attempt: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
all, err := s.All()
|
||||
if err != nil {
|
||||
b.Fatalf("Error fetchin all: %s", err)
|
||||
}
|
||||
var count int
|
||||
for range all {
|
||||
count++
|
||||
}
|
||||
_ = count
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func randomAttempts(count int) []*models.LoginAttempt {
|
||||
var attempts []*models.LoginAttempt
|
||||
for i := 0; i < count; i++ {
|
||||
attempt := &models.LoginAttempt{
|
||||
Date: time.Now(),
|
||||
RemoteIP: randomIP(),
|
||||
Username: randomString(8),
|
||||
Password: randomString(8),
|
||||
Country: randomCountry(),
|
||||
ConnectionUUID: uuid.Must(uuid.NewRandom()),
|
||||
SSHClientVersion: "SSH TEST LOL",
|
||||
}
|
||||
attempts = append(attempts, attempt)
|
||||
}
|
||||
return attempts
|
||||
}
|
||||
|
||||
func randomIP() net.IP {
|
||||
a := byte(rand.Intn(254))
|
||||
b := byte(rand.Intn(254))
|
||||
c := byte(rand.Intn(254))
|
||||
d := byte(rand.Intn(254))
|
||||
return net.IPv4(a, b, c, d)
|
||||
}
|
||||
|
||||
func randomString(n int) string {
|
||||
const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
|
||||
b := make([]byte, n)
|
||||
for i := range b {
|
||||
b[i] = letterBytes[rand.Intn(len(letterBytes))]
|
||||
}
|
||||
return string(b)
|
||||
}
|
||||
|
||||
func randomCountry() string {
|
||||
switch rand.Intn(10) {
|
||||
case 1:
|
||||
return "CN"
|
||||
case 2:
|
||||
return "US"
|
||||
case 3:
|
||||
return "NO"
|
||||
case 4:
|
||||
return "RU"
|
||||
case 5:
|
||||
return "DE"
|
||||
case 6:
|
||||
return "FI"
|
||||
case 7:
|
||||
return "BR"
|
||||
default:
|
||||
return "SE"
|
||||
}
|
||||
}
|
||||
|
||||
func equalAttempts(a, b []models.LoginAttempt) bool {
|
||||
if len(a) != len(b) {
|
||||
return false
|
||||
}
|
||||
|
||||
aFound := make([]bool, len(a))
|
||||
|
||||
for i, aAttempt := range a {
|
||||
for _, bAttempt := range b {
|
||||
if aAttempt.Username == bAttempt.Username &&
|
||||
aAttempt.Password == bAttempt.Password &&
|
||||
aAttempt.RemoteIP.String() == bAttempt.RemoteIP.String() {
|
||||
aFound[i] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for _, found := range aFound {
|
||||
if !found {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func fuzzLoginAttemptStore(s store.LoginAttemptStore, f *testing.F) {
|
||||
usernames := []string{"username", "root", "ubnt", "pi", "admin"}
|
||||
for _, username := range usernames {
|
||||
f.Add(username)
|
||||
}
|
||||
f.Fuzz(func(t *testing.T, orig string) {
|
||||
attempt := models.LoginAttempt{
|
||||
Date: time.Now(),
|
||||
Username: orig,
|
||||
Password: randomString(8),
|
||||
Country: "NO",
|
||||
}
|
||||
|
||||
if err := s.AddAttempt(&attempt); err != nil {
|
||||
t.Fatalf("error adding: %s", err)
|
||||
}
|
||||
})
|
||||
}
|
@ -1,119 +0,0 @@
|
||||
package store
|
||||
|
||||
/*
|
||||
func TestStatItems(t *testing.T) {
|
||||
var tc = []struct {
|
||||
Input StatItems
|
||||
ExpectedOutput StatItems
|
||||
}{
|
||||
{
|
||||
Input: StatItems{
|
||||
{Key: "a", Count: 5},
|
||||
{Key: "b", Count: 100},
|
||||
{Key: "c", Count: 99},
|
||||
{Key: "d", Count: 98},
|
||||
{Key: "f", Count: 18},
|
||||
},
|
||||
ExpectedOutput: StatItems{
|
||||
{Key: "a", Count: 5},
|
||||
{Key: "f", Count: 18},
|
||||
{Key: "d", Count: 98},
|
||||
{Key: "c", Count: 99},
|
||||
{Key: "b", Count: 100},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, testCase := range tc {
|
||||
sort.Sort(testCase.Input)
|
||||
|
||||
for i := range testCase.Input {
|
||||
if testCase.Input[i] != testCase.ExpectedOutput[i] {
|
||||
t.Fatalf("Not sorted correctly")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestStats(t *testing.T) {
|
||||
var exampleAttempts = []models.LoginAttempt{
|
||||
{Username: "root", Password: "root", Country: "NO"},
|
||||
{Username: "root", Password: "root", Country: "US"},
|
||||
{Username: "user", Password: "passWord", Country: "US"},
|
||||
{Username: "ibm", Password: "ibm", Country: "US"},
|
||||
{Username: "ubnt", Password: "ubnt", Country: "GB"},
|
||||
{Username: "ubnt", Password: "ubnt", Country: "FI"},
|
||||
{Username: "root", Password: "root", Country: "CH"},
|
||||
{Username: "ubnt", Password: "12345", Country: "DE"},
|
||||
{Username: "oracle", Password: "oracle", Country: "FI"},
|
||||
}
|
||||
var tc = []struct {
|
||||
Attempts []models.LoginAttempt
|
||||
StatType LoginStats
|
||||
Limit int
|
||||
ExpectedOutput map[string]int
|
||||
}{
|
||||
{
|
||||
Attempts: exampleAttempts,
|
||||
StatType: LoginStatsPasswords,
|
||||
Limit: 2,
|
||||
ExpectedOutput: map[string]int{
|
||||
"root": 3,
|
||||
"ubnt": 2,
|
||||
},
|
||||
},
|
||||
{
|
||||
Attempts: exampleAttempts,
|
||||
StatType: LoginStatsPasswords,
|
||||
Limit: 1,
|
||||
ExpectedOutput: map[string]int{
|
||||
"root": 3,
|
||||
},
|
||||
},
|
||||
{
|
||||
Attempts: exampleAttempts,
|
||||
StatType: LoginStatsCountry,
|
||||
Limit: 2,
|
||||
ExpectedOutput: map[string]int{
|
||||
"US": 3,
|
||||
"FI": 2,
|
||||
},
|
||||
},
|
||||
{
|
||||
Attempts: exampleAttempts,
|
||||
StatType: LoginStatsCountry,
|
||||
Limit: 0,
|
||||
ExpectedOutput: map[string]int{
|
||||
"US": 3,
|
||||
"FI": 2,
|
||||
"NO": 1,
|
||||
"GB": 1,
|
||||
"CH": 1,
|
||||
"DE": 1,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, c := range tc {
|
||||
ms := MemoryStore{}
|
||||
for _, a := range c.Attempts {
|
||||
if err := ms.AddAttempt(a); err != nil {
|
||||
t.Fatalf("Unable to add attempt: %s", err)
|
||||
}
|
||||
}
|
||||
stats, err := ms.Stats(c.StatType, c.Limit)
|
||||
if err != nil {
|
||||
t.Fatalf("Error getting stats: %s", err)
|
||||
}
|
||||
if len(stats) != len(c.ExpectedOutput) {
|
||||
t.Fatalf("Stats have wrong length")
|
||||
}
|
||||
for key := range stats {
|
||||
if c.ExpectedOutput[key] != stats[key] {
|
||||
t.Fatalf("Stats does not match expected output")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
@ -1,32 +0,0 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
)
|
||||
|
||||
var ErrInvalidPassword = fmt.Errorf("invalid password")
|
||||
|
||||
type User struct {
|
||||
Username string `json:"username"`
|
||||
PasswordHash []byte `json:"passwordHash"`
|
||||
}
|
||||
|
||||
func (u *User) SetPassword(password string) error {
|
||||
newHash, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error hashing new password: %w", err)
|
||||
}
|
||||
|
||||
u.PasswordHash = newHash
|
||||
return nil
|
||||
}
|
||||
|
||||
func (u *User) VerifyPassword(password string) error {
|
||||
err := bcrypt.CompareHashAndPassword([]byte(u.PasswordHash), []byte(password))
|
||||
if err != nil {
|
||||
return ErrInvalidPassword
|
||||
}
|
||||
return nil
|
||||
}
|
@ -5,8 +5,10 @@ import (
|
||||
"runtime"
|
||||
)
|
||||
|
||||
var Version = "v0.1.5"
|
||||
var Build string
|
||||
var (
|
||||
Version = "v0.2.4"
|
||||
Build string
|
||||
)
|
||||
|
||||
func FullVersion() string {
|
||||
if Build != "" {
|
||||
|
@ -1,3 +1,4 @@
|
||||
//go:build !embed
|
||||
// +build !embed
|
||||
|
||||
package web
|
||||
@ -21,7 +22,7 @@ func (s *Server) IndexHandler(frontendDir string) http.HandlerFunc {
|
||||
fname := filepath.Join(frontendDir, r.URL.Path)
|
||||
_, err := os.Stat(fname)
|
||||
if os.IsNotExist(err) {
|
||||
serveIndex(frontendDir).ServeHTTP(w, r)
|
||||
s.serveIndex(frontendDir).ServeHTTP(w, r)
|
||||
return
|
||||
}
|
||||
fs.ServeHTTP(w, r)
|
||||
@ -29,7 +30,7 @@ func (s *Server) IndexHandler(frontendDir string) http.HandlerFunc {
|
||||
return http.HandlerFunc(fn)
|
||||
}
|
||||
|
||||
func serveIndex(frontendDir string) http.HandlerFunc {
|
||||
func (s *Server) serveIndex(frontendDir string) http.HandlerFunc {
|
||||
fn := func(w http.ResponseWriter, r *http.Request) {
|
||||
fname := filepath.Join(frontendDir, "index.html")
|
||||
f, err := os.Open(fname)
|
||||
@ -38,7 +39,9 @@ func serveIndex(frontendDir string) http.HandlerFunc {
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
io.Copy(w, f)
|
||||
if _, err := io.Copy(w, f); err != nil {
|
||||
s.ServerLogger.Warn("Error writing frontend to client.", "err", err)
|
||||
}
|
||||
}
|
||||
return fn
|
||||
}
|
||||
|
@ -1,3 +0,0 @@
|
||||
> 1%
|
||||
last 2 versions
|
||||
not dead
|
@ -1,7 +0,0 @@
|
||||
[*.{js,jsx,ts,tsx,vue}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
end_of_line = lf
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
max_line_length = 100
|
@ -1,20 +0,0 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
env: {
|
||||
node: true,
|
||||
},
|
||||
extends: [
|
||||
'plugin:vue/essential',
|
||||
'@vue/airbnb',
|
||||
'@vue/typescript/recommended',
|
||||
'prettier'
|
||||
],
|
||||
parserOptions: {
|
||||
ecmaVersion: 2020,
|
||||
},
|
||||
rules: {
|
||||
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
||||
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
||||
'implicit-arrow-linebreak': 'warn',
|
||||
},
|
||||
};
|
23
web/frontend/.gitignore
vendored
23
web/frontend/.gitignore
vendored
@ -1,23 +0,0 @@
|
||||
.DS_Store
|
||||
node_modules
|
||||
/dist
|
||||
|
||||
|
||||
# local env files
|
||||
.env.local
|
||||
.env.*.local
|
||||
|
||||
# Log files
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
|
||||
# Editor directories and files
|
||||
.idea
|
||||
.vscode
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
@ -1,24 +0,0 @@
|
||||
# vue-frontend
|
||||
|
||||
## Project setup
|
||||
```
|
||||
yarn install
|
||||
```
|
||||
|
||||
### Compiles and hot-reloads for development
|
||||
```
|
||||
yarn serve
|
||||
```
|
||||
|
||||
### Compiles and minifies for production
|
||||
```
|
||||
yarn build
|
||||
```
|
||||
|
||||
### Lints and fixes files
|
||||
```
|
||||
yarn lint
|
||||
```
|
||||
|
||||
### Customize configuration
|
||||
See [Configuration Reference](https://cli.vuejs.org/config/).
|
@ -1,5 +0,0 @@
|
||||
module.exports = {
|
||||
presets: [
|
||||
'@vue/cli-plugin-babel/preset',
|
||||
],
|
||||
};
|
@ -1,50 +0,0 @@
|
||||
{
|
||||
"name": "apiary-frontend",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"serve": "vue-cli-service serve",
|
||||
"build": "vue-cli-service build",
|
||||
"lint": "vue-cli-service lint"
|
||||
},
|
||||
"dependencies": {
|
||||
"@fontsource/rubik": "^4.2.2",
|
||||
"@fontsource/secular-one": "^4.2.2",
|
||||
"axios": "^0.21.1",
|
||||
"bootstrap": "^4.6.0",
|
||||
"bootstrap-vue": "^2.21.2",
|
||||
"chart.js": "^3.0.2",
|
||||
"core-js": "^3.6.5",
|
||||
"d3": "^6.6.2",
|
||||
"d3-svg-legend": "^2.25.6",
|
||||
"faker": "^5.5.2",
|
||||
"randomcolor": "^0.6.2",
|
||||
"s-ago": "^2.2.0",
|
||||
"vue": "^2.6.11",
|
||||
"vue-class-component": "^7.2.3",
|
||||
"vue-property-decorator": "^9.1.2",
|
||||
"vue-router": "^3.5.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/chart.js": "^2.9.32",
|
||||
"@types/d3": "^6.3.0",
|
||||
"@types/faker": "^5.5.1",
|
||||
"@types/randomcolor": "^0.5.5",
|
||||
"@typescript-eslint/eslint-plugin": "^4.18.0",
|
||||
"@typescript-eslint/parser": "^4.18.0",
|
||||
"@vue/cli-plugin-babel": "~4.5.0",
|
||||
"@vue/cli-plugin-eslint": "~4.5.0",
|
||||
"@vue/cli-plugin-typescript": "~4.5.0",
|
||||
"@vue/cli-service": "~4.5.0",
|
||||
"@vue/eslint-config-airbnb": "^5.0.2",
|
||||
"@vue/eslint-config-typescript": "^7.0.0",
|
||||
"eslint": "^6.7.2",
|
||||
"eslint-config-prettier": "^8.1.0",
|
||||
"eslint-plugin-import": "^2.20.2",
|
||||
"eslint-plugin-vue": "^6.2.2",
|
||||
"sass": "^1.26.5",
|
||||
"sass-loader": "^8.0.2",
|
||||
"typescript": "~4.1.5",
|
||||
"vue-template-compiler": "^2.6.11"
|
||||
}
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 15 KiB |
@ -1,22 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="description" content="Stats about logins, usernames and passwords received by the SSH honeypot.">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
|
||||
<title>apiary.t-juice.club</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<noscript>
|
||||
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled.
|
||||
Please enable it to continue.</strong>
|
||||
</noscript>
|
||||
<div id="app"></div>
|
||||
<!-- built files will be auto injected -->
|
||||
</body>
|
||||
|
||||
</html>
|
Binary file not shown.
Before Width: | Height: | Size: 13 KiB |
@ -1,3 +0,0 @@
|
||||
# https://www.robotstxt.org/robotstxt.html
|
||||
User-agent: *
|
||||
Disallow:
|
@ -1,75 +0,0 @@
|
||||
<template>
|
||||
<div id="app">
|
||||
<div id="apiary-navbar">
|
||||
<b-navbar toggleable="md" type="dark" variant="dark">
|
||||
<b-navbar-brand href="#">
|
||||
<img
|
||||
alt="logo"
|
||||
src="logo192.png"
|
||||
width="29"
|
||||
height="29"
|
||||
class="d-inline-block align-top"
|
||||
/>
|
||||
apiary.t-juice.club
|
||||
</b-navbar-brand>
|
||||
<b-navbar-toggle target="nav-collapse"></b-navbar-toggle>
|
||||
<b-collapse id="nav-collapse" is-nav>
|
||||
<b-navbar-nav class="mr-auto">
|
||||
<b-nav-item :to="'/'">Home</b-nav-item>
|
||||
<b-nav-item :to="'/stats'">Stats</b-nav-item>
|
||||
<b-nav-item :to="'/attempts'">Attempts</b-nav-item>
|
||||
<b-nav-item :to="'/search'">Search</b-nav-item>
|
||||
</b-navbar-nav>
|
||||
</b-collapse>
|
||||
</b-navbar>
|
||||
</div>
|
||||
<b-container id="main-content-container" fluid="md">
|
||||
<router-view></router-view>
|
||||
</b-container>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { Component, Vue } from 'vue-property-decorator';
|
||||
import AttemptList from '@/components/AttemptList.vue';
|
||||
import Stats from '@/components/Stats.vue';
|
||||
import Home from '@/components/Home.vue';
|
||||
|
||||
@Component({
|
||||
components: {
|
||||
AttemptList,
|
||||
Stats,
|
||||
Home,
|
||||
},
|
||||
})
|
||||
export default class App extends Vue {}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
$font-stack-header: 'Secular One', sans-serif;
|
||||
$font-stack-content: 'Rubik', sans-serif;
|
||||
#app {
|
||||
font-family: $font-stack-content;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
text-align: center;
|
||||
color: #2c3e50;
|
||||
margin-top: 0;
|
||||
}
|
||||
.navbar-brand {
|
||||
font-family: $font-stack-header;
|
||||
}
|
||||
.navbar-nav a {
|
||||
font-family: $font-stack-content;
|
||||
}
|
||||
|
||||
h1 h2 h3 {
|
||||
font-family: $font-stack-header;
|
||||
}
|
||||
|
||||
#main-content-container {
|
||||
margin-top: 50px;
|
||||
text-align: center;
|
||||
display: inline-block;
|
||||
}
|
||||
</style>
|
@ -1,8 +0,0 @@
|
||||
import { ApiaryAPI, LoginAttempt } from "@/apiary/apiary";
|
||||
|
||||
|
||||
export class ApiaryDummyClient implements ApiaryAPI {
|
||||
streamLoginAttempts(): any {
|
||||
return 'a';
|
||||
}
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
import FakerStatic from 'faker';
|
||||
|
||||
export interface LoginAttempt {
|
||||
readonly date: string;
|
||||
readonly remoteIP: string;
|
||||
readonly username: string;
|
||||
readonly password: string;
|
||||
readonly sshClientVersion: string;
|
||||
readonly connectionUUID: string;
|
||||
}
|
||||
|
||||
export interface StatResult {
|
||||
name: string;
|
||||
count: number;
|
||||
}
|
||||
|
||||
export interface ApiaryAPI {
|
||||
streamLoginAttempts(): ReadableStream<LoginAttempt>;
|
||||
}
|
||||
|
||||
export function fakeAttempt(): LoginAttempt {
|
||||
return {
|
||||
date: FakerStatic.date.recent().toLocaleDateString(),
|
||||
remoteIP: FakerStatic.internet.ip(),
|
||||
username: FakerStatic.internet.userName(),
|
||||
password: FakerStatic.internet.password(),
|
||||
sshClientVersion: FakerStatic.lorem.words(2),
|
||||
connectionUUID: FakerStatic.datatype.uuid(),
|
||||
};
|
||||
}
|
||||
|
||||
export function fakeAttemptStream(): EventSource {
|
||||
const es = new EventSource('/stream');
|
||||
return es;
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 6.7 KiB |
@ -1,79 +0,0 @@
|
||||
<template>
|
||||
<div class="attemptlist">
|
||||
<h1>Live Attempts</h1>
|
||||
<p>
|
||||
<b-table
|
||||
responsive="md"
|
||||
striped
|
||||
hover
|
||||
:items="attempts"
|
||||
:fields="fields"
|
||||
/>
|
||||
</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { Component, Prop, Vue } from 'vue-property-decorator';
|
||||
import { BvTableFieldArray, BvTableFormatterCallback } from 'bootstrap-vue';
|
||||
import { LoginAttempt } from '@/apiary/apiary';
|
||||
|
||||
@Component
|
||||
export default class AttemptList extends Vue {
|
||||
@Prop() private items!: LoginAttempt[];
|
||||
|
||||
attempts: LoginAttempt[];
|
||||
|
||||
fields: BvTableFieldArray = [
|
||||
{
|
||||
key: 'date',
|
||||
sortable: true,
|
||||
formatter: (value: string): string => {
|
||||
const d = new Date(value);
|
||||
// This seems stupid...
|
||||
return d.toTimeString().split(' ')[0];
|
||||
},
|
||||
sortByFormatted: false,
|
||||
},
|
||||
{
|
||||
key: 'username',
|
||||
},
|
||||
{
|
||||
key: 'password',
|
||||
},
|
||||
{
|
||||
key: 'remoteIP',
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
key: 'country',
|
||||
},
|
||||
];
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.attempts = [];
|
||||
}
|
||||
|
||||
mounted(): void {
|
||||
/**
|
||||
console.log(this);
|
||||
const at: LoginAttempt[] = [];
|
||||
|
||||
for (let i = 0; i < 5; i += 1) {
|
||||
at.push(fakeAttempt());
|
||||
}
|
||||
|
||||
setInterval(() => {
|
||||
at.push(fakeAttempt());
|
||||
}, 1000);
|
||||
*/
|
||||
|
||||
const attemptStream = new EventSource('/api/stream');
|
||||
attemptStream.addEventListener('message', (ev: MessageEvent<string>) => {
|
||||
const parsed: LoginAttempt = JSON.parse(ev.data);
|
||||
this.attempts.unshift(parsed);
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
@ -1,145 +0,0 @@
|
||||
<template>
|
||||
<div class="home">
|
||||
<b-container v-if="ready">
|
||||
<b-row>
|
||||
<b-col class="total-title">
|
||||
<h2>Total login attempts</h2>
|
||||
</b-col>
|
||||
<b-col class="total-count">
|
||||
<h2>{{ totalLoginAttempts }}</h2>
|
||||
</b-col>
|
||||
</b-row>
|
||||
<b-row>
|
||||
<b-col class="total-title">
|
||||
<h2>Unique passwords</h2>
|
||||
</b-col>
|
||||
<b-col class="total-count">
|
||||
<h2>{{ uniquePasswords }}</h2>
|
||||
</b-col>
|
||||
</b-row>
|
||||
<b-row>
|
||||
<b-col class="total-title">
|
||||
<h2>Unique usernames</h2>
|
||||
</b-col>
|
||||
<b-col class="total-count">
|
||||
<h2>{{ uniqueUsernames }}</h2>
|
||||
</b-col>
|
||||
</b-row>
|
||||
<b-row>
|
||||
<b-col class="total-title">
|
||||
<h2>Unique IPs</h2>
|
||||
</b-col>
|
||||
<b-col class="total-count">
|
||||
<h2>{{ uniqueIPs }}</h2>
|
||||
</b-col>
|
||||
</b-row>
|
||||
</b-container>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { Component, Vue, Watch } from 'vue-property-decorator';
|
||||
import axios from 'axios';
|
||||
|
||||
type TotalStatsHeaders =
|
||||
| 'UniquePasswords'
|
||||
| 'UniqueUsernames'
|
||||
| 'UniqueIPs'
|
||||
| 'UniqueCountries'
|
||||
| 'TotalLoginAttempts';
|
||||
|
||||
interface TotalStatsResult {
|
||||
name: TotalStatsHeaders;
|
||||
count: number;
|
||||
}
|
||||
|
||||
@Component
|
||||
export default class Home extends Vue {
|
||||
totalLoginAttempts: number;
|
||||
|
||||
uniquePasswords: number;
|
||||
|
||||
uniqueUsernames: number;
|
||||
|
||||
uniqueIPs: number;
|
||||
|
||||
uniqueCountries: number;
|
||||
|
||||
private updaterHandle?: number;
|
||||
|
||||
ready = false;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.totalLoginAttempts = 0;
|
||||
this.uniquePasswords = 0;
|
||||
this.uniqueUsernames = 0;
|
||||
this.uniqueIPs = 0;
|
||||
this.uniqueCountries = 0;
|
||||
}
|
||||
|
||||
updateStats(): void {
|
||||
const url = `/api/stats?type=total`;
|
||||
axios
|
||||
.get<TotalStatsResult[]>(url)
|
||||
.then((resp) => {
|
||||
const totals = resp.data.find((e) => e.name === 'TotalLoginAttempts')
|
||||
?.count;
|
||||
if (totals) {
|
||||
this.totalLoginAttempts = totals;
|
||||
}
|
||||
|
||||
const passwords = resp.data.find((e) => e.name === 'UniquePasswords')
|
||||
?.count;
|
||||
if (passwords) {
|
||||
this.uniquePasswords = passwords;
|
||||
}
|
||||
|
||||
const usernames = resp.data.find((e) => e.name === 'UniqueUsernames')
|
||||
?.count;
|
||||
if (usernames) {
|
||||
this.uniqueUsernames = usernames;
|
||||
}
|
||||
|
||||
const ips = resp.data.find((e) => e.name === 'UniqueIPs')?.count;
|
||||
if (ips) {
|
||||
this.uniqueIPs = ips;
|
||||
}
|
||||
|
||||
const countries = resp.data.find((e) => e.name === 'UniqueCountries')
|
||||
?.count;
|
||||
if (countries) {
|
||||
this.uniqueCountries = countries;
|
||||
}
|
||||
|
||||
this.ready = true;
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log(e);
|
||||
});
|
||||
}
|
||||
|
||||
created(): void {
|
||||
this.updateStats();
|
||||
|
||||
this.updaterHandle = setInterval(() => {
|
||||
this.updateStats();
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
beforeDestroy(): void {
|
||||
clearInterval(this.updaterHandle);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
.home {
|
||||
text-align: left;
|
||||
}
|
||||
.total-title {
|
||||
text-align: right;
|
||||
}
|
||||
.total-count {
|
||||
text-align: left;
|
||||
}
|
||||
</style>
|
@ -1,81 +0,0 @@
|
||||
<template>
|
||||
<div class="search-result-container">
|
||||
<h1>Search</h1>
|
||||
<b-form @submit="onSubmit">
|
||||
<b-form-input v-model="searchString" placeholder="" />
|
||||
</b-form>
|
||||
<b-table
|
||||
class="search-results-table"
|
||||
responsive="md"
|
||||
striped
|
||||
hover
|
||||
:items="attempts"
|
||||
:fields="fields"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { Component, Vue } from 'vue-property-decorator';
|
||||
import { LoginAttempt } from '@/apiary/apiary';
|
||||
import { BvTableFieldArray, BvTableFormatterCallback } from 'bootstrap-vue';
|
||||
import Axios from 'axios';
|
||||
|
||||
@Component
|
||||
export default class SearchResult extends Vue {
|
||||
attempts: LoginAttempt[];
|
||||
|
||||
searchString: string;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.attempts = [];
|
||||
this.searchString = '';
|
||||
}
|
||||
|
||||
fields: BvTableFieldArray = [
|
||||
{
|
||||
key: 'date',
|
||||
sortable: true,
|
||||
formatter: (value: string): string => {
|
||||
const d = new Date(value);
|
||||
// This seems stupid...
|
||||
return d.toTimeString().split(' ')[0];
|
||||
},
|
||||
sortByFormatted: false,
|
||||
},
|
||||
{
|
||||
key: 'username',
|
||||
},
|
||||
{
|
||||
key: 'password',
|
||||
},
|
||||
{
|
||||
key: 'remoteIP',
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
key: 'country',
|
||||
},
|
||||
];
|
||||
|
||||
onSubmit(event: Event) {
|
||||
event.preventDefault();
|
||||
|
||||
console.log(this.searchString);
|
||||
const resp = Axios.get<LoginAttempt[]>(
|
||||
`/api/query?query=${this.searchString}`,
|
||||
);
|
||||
|
||||
resp.then((r) => {
|
||||
this.attempts = r.data;
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.search-results-table {
|
||||
margin-top: 50px;
|
||||
}
|
||||
</style>
|
@ -1,52 +0,0 @@
|
||||
<template>
|
||||
<div class="stats">
|
||||
<h1>Login Stats</h1>
|
||||
<b-card no-body>
|
||||
<b-tabs card>
|
||||
<b-tab title="Totals">
|
||||
<b-card-body>
|
||||
<home></home>
|
||||
</b-card-body>
|
||||
</b-tab>
|
||||
<b-tab title="Usernames">
|
||||
<b-card-body>
|
||||
<stats-pie statType="username" />
|
||||
</b-card-body>
|
||||
</b-tab>
|
||||
<b-tab title="Passwords">
|
||||
<b-card-body>
|
||||
<stats-pie statType="password"></stats-pie>
|
||||
</b-card-body>
|
||||
</b-tab>
|
||||
<b-tab title="Countries">
|
||||
<b-card-body>
|
||||
<stats-pie statType="country"></stats-pie>
|
||||
</b-card-body>
|
||||
</b-tab>
|
||||
<b-tab title="IPs">
|
||||
<b-card-body>
|
||||
<stats-pie statType="ip"></stats-pie>
|
||||
</b-card-body>
|
||||
</b-tab>
|
||||
</b-tabs>
|
||||
</b-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { Component, Prop, Vue } from 'vue-property-decorator';
|
||||
import StatsUsername from '@/components/StatsUsername.vue';
|
||||
import StatsPie from '@/components/StatsPie.vue';
|
||||
import Home from '@/components/Home.vue';
|
||||
|
||||
@Component({
|
||||
components: {
|
||||
StatsUsername,
|
||||
StatsPie,
|
||||
Home,
|
||||
},
|
||||
})
|
||||
export default class Stats extends Vue {}
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
@ -1,187 +0,0 @@
|
||||
<template>
|
||||
<div class="stats-container" :class="containerClass">
|
||||
<h2>
|
||||
{{ title() }}
|
||||
<b-icon :id="chartSettingsID()" icon="gear-fill"></b-icon>
|
||||
</h2>
|
||||
<div class="chart-container">
|
||||
<canvas :id="chartID()" width="300" height="300"></canvas>
|
||||
</div>
|
||||
<b-popover
|
||||
:target="chartSettingsID()"
|
||||
triggers="click"
|
||||
:show.sync="settingsShow"
|
||||
placement="auto"
|
||||
container="stats-container"
|
||||
ref="popover"
|
||||
@show="onShow"
|
||||
>
|
||||
<template #title>
|
||||
<b-button @click="onClose" class="close" aria-label="Close">
|
||||
<span class="d-inline-block" aria-hidden="true">×</span>
|
||||
</b-button>
|
||||
Settings
|
||||
</template>
|
||||
|
||||
<div>
|
||||
<b-form-group
|
||||
label="Limit"
|
||||
label-for="limitinput"
|
||||
label-cols="3"
|
||||
class="mb-1"
|
||||
description="Limit number of items"
|
||||
invalid-feedback="This field is required"
|
||||
>
|
||||
<b-form-input
|
||||
ref="limitinput"
|
||||
id="limitinput"
|
||||
v-model="limitState"
|
||||
type="number"
|
||||
size="sm"
|
||||
></b-form-input>
|
||||
</b-form-group>
|
||||
|
||||
<b-button @click="onClose" size="sm" variant="danger">Cancel</b-button>
|
||||
<b-button @click="onOk" size="sm" variant="primary">Ok</b-button>
|
||||
</div>
|
||||
</b-popover>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { Component, Prop, Vue, Watch } from 'vue-property-decorator';
|
||||
import { StatResult } from '@/apiary/apiary';
|
||||
import axios from 'axios';
|
||||
import { Chart, ArcElement, Legend, DoughnutController, Title } from 'chart.js';
|
||||
import randomColor from 'randomcolor';
|
||||
|
||||
export type StatType = 'username' | 'password' | 'ip' | 'country' | 'total';
|
||||
|
||||
Chart.register(ArcElement, Legend, DoughnutController, Title);
|
||||
|
||||
@Component
|
||||
export default class StatsPie extends Vue {
|
||||
@Prop() private statType!: StatType;
|
||||
|
||||
limit: number;
|
||||
|
||||
limitState: number;
|
||||
|
||||
settingsShow = false;
|
||||
|
||||
stats: StatResult[];
|
||||
|
||||
chart?: Chart;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.stats = [];
|
||||
this.limit = 10;
|
||||
this.limitState = 10;
|
||||
}
|
||||
|
||||
title(): string {
|
||||
switch (this.statType) {
|
||||
case 'password':
|
||||
return `Top ${this.limit} Passwords`;
|
||||
case 'username':
|
||||
return `Top ${this.limit} Usernames`;
|
||||
case 'ip':
|
||||
return `Top ${this.limit} IPs`;
|
||||
case 'country':
|
||||
return `Top ${this.limit} Countries`;
|
||||
case 'total':
|
||||
return 'Totals';
|
||||
// Why doesn't eslint know that this switch is exhaustive?
|
||||
default:
|
||||
return 'Top 10 Passwords';
|
||||
}
|
||||
}
|
||||
|
||||
containerClass(): string {
|
||||
return `stats-container-${this.statType}`;
|
||||
}
|
||||
|
||||
chartID(): string {
|
||||
return `chart-${this.statType}`;
|
||||
}
|
||||
|
||||
chartSettingsID(): string {
|
||||
return `chartsettings-${this.statType}`;
|
||||
}
|
||||
|
||||
settingsID(): string {
|
||||
return `settings-${this.statType}`;
|
||||
}
|
||||
|
||||
onClose(): void {
|
||||
this.settingsShow = false;
|
||||
}
|
||||
|
||||
onOk(): void {
|
||||
if (this.limitState) {
|
||||
this.limit = this.limitState;
|
||||
this.settingsShow = false;
|
||||
}
|
||||
}
|
||||
|
||||
onShow(): void {
|
||||
// This is called just before the popover is shown
|
||||
// Reset our popover form variables
|
||||
this.limitState = this.limit;
|
||||
}
|
||||
|
||||
@Watch('limit')
|
||||
limitChanged(value: number, oldValue: number): void {
|
||||
this.fetchData();
|
||||
}
|
||||
|
||||
fetchData(): void {
|
||||
const url = `/api/stats?type=${this.statType}&limit=${this.limit}`;
|
||||
axios.get<StatResult[]>(url).then((resp) => {
|
||||
this.stats = resp.data;
|
||||
this.renderPie();
|
||||
});
|
||||
}
|
||||
|
||||
mounted(): void {
|
||||
this.fetchData();
|
||||
}
|
||||
|
||||
renderPie(): void {
|
||||
const elem = document.getElementById(this.chartID()) as HTMLCanvasElement;
|
||||
const ctx = elem.getContext('2d') as CanvasRenderingContext2D;
|
||||
const sortedStats = this.stats.sort();
|
||||
const values = sortedStats.map((s) => s.count);
|
||||
const headers = sortedStats.map((s) => s.name);
|
||||
const colors = sortedStats.map(() => randomColor());
|
||||
|
||||
if (this.chart) {
|
||||
this.chart.destroy();
|
||||
}
|
||||
this.chart = new Chart(ctx, {
|
||||
type: 'doughnut',
|
||||
data: {
|
||||
labels: headers,
|
||||
datasets: [
|
||||
{
|
||||
data: values,
|
||||
backgroundColor: colors,
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
canvas {
|
||||
width: 70%;
|
||||
height: auto;
|
||||
max-height: 60vmin;
|
||||
}
|
||||
.stats-container {
|
||||
align-content: center;
|
||||
}
|
||||
</style>
|
@ -1,67 +0,0 @@
|
||||
<template>
|
||||
<div class="stats-container">
|
||||
<h2>Top 10 usernames</h2>
|
||||
<div class="chart-container">
|
||||
<canvas id="chart" widht="400" height="400"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { Component, Prop, Vue } from 'vue-property-decorator';
|
||||
import { StatResult } from '@/apiary/apiary';
|
||||
import axios from 'axios';
|
||||
import Chart from 'chart.js/auto';
|
||||
import randomColor from 'randomcolor';
|
||||
|
||||
@Component
|
||||
export default class StatsUsername extends Vue {
|
||||
@Prop() private msg!: string;
|
||||
|
||||
stats: StatResult[];
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.stats = [];
|
||||
}
|
||||
|
||||
mounted(): void {
|
||||
axios
|
||||
.get<StatResult[]>('/api/stats?type=username&limit=10')
|
||||
.then((resp) => {
|
||||
this.stats = resp.data;
|
||||
this.renderPie();
|
||||
});
|
||||
}
|
||||
|
||||
renderPie(): void {
|
||||
const elem = document.getElementById('chart') as HTMLCanvasElement;
|
||||
const ctx = elem.getContext('2d') as CanvasRenderingContext2D;
|
||||
const sortedStats = this.stats.sort();
|
||||
const values = sortedStats.map((s) => s.count);
|
||||
const headers = sortedStats.map((s) => s.name);
|
||||
const colors = sortedStats.map(() => randomColor());
|
||||
|
||||
const chart = new Chart(ctx, {
|
||||
type: 'doughnut',
|
||||
data: {
|
||||
labels: headers,
|
||||
options: {},
|
||||
datasets: [
|
||||
{
|
||||
data: values,
|
||||
backgroundColor: colors,
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.chart-container {
|
||||
max-width: 500px;
|
||||
max-height: 500px;
|
||||
}
|
||||
</style>
|
@ -1,58 +0,0 @@
|
||||
import Vue from 'vue';
|
||||
import { BootstrapVue, IconsPlugin } from 'bootstrap-vue';
|
||||
import VueRouter, { RouteConfig } from 'vue-router';
|
||||
import AttemptList from '@/components/AttemptList.vue';
|
||||
import Home from '@/components/Home.vue';
|
||||
import Stats from '@/components/Stats.vue';
|
||||
import SearchResult from '@/components/SearchResult.vue';
|
||||
import 'bootstrap/dist/css/bootstrap.css';
|
||||
import 'bootstrap-vue/dist/bootstrap-vue.css';
|
||||
import '@fontsource/rubik';
|
||||
import '@fontsource/secular-one';
|
||||
import App from './App.vue';
|
||||
|
||||
Vue.config.productionTip = false;
|
||||
// Make BootstrapVue available throughout your project
|
||||
Vue.use(BootstrapVue);
|
||||
// Optionally install the BootstrapVue icon components plugin
|
||||
Vue.use(IconsPlugin);
|
||||
|
||||
Vue.use(VueRouter);
|
||||
|
||||
const routes: Array<RouteConfig> = [
|
||||
{
|
||||
path: '/',
|
||||
name: 'Home',
|
||||
component: Home,
|
||||
alias: '/home',
|
||||
},
|
||||
{
|
||||
path: '/attempts',
|
||||
name: 'Attempt List',
|
||||
component: AttemptList,
|
||||
props: {
|
||||
// items: testAttempts,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/stats',
|
||||
name: 'Stats',
|
||||
component: Stats,
|
||||
},
|
||||
{
|
||||
path: '/search',
|
||||
name: 'Search',
|
||||
component: SearchResult,
|
||||
}
|
||||
];
|
||||
|
||||
const router = new VueRouter({
|
||||
mode: 'history',
|
||||
base: process.env.BASE_URL,
|
||||
routes,
|
||||
});
|
||||
|
||||
new Vue({
|
||||
router,
|
||||
render: (h) => h(App),
|
||||
}).$mount('#app');
|
13
web/frontend/src/shims-tsx.d.ts
vendored
13
web/frontend/src/shims-tsx.d.ts
vendored
@ -1,13 +0,0 @@
|
||||
import Vue, { VNode } from 'vue';
|
||||
|
||||
declare global {
|
||||
namespace JSX {
|
||||
// tslint:disable no-empty-interface
|
||||
interface Element extends VNode {}
|
||||
// tslint:disable no-empty-interface
|
||||
interface ElementClass extends Vue {}
|
||||
interface IntrinsicElements {
|
||||
[elem: string]: any
|
||||
}
|
||||
}
|
||||
}
|
5
web/frontend/src/shims-vue.d.ts
vendored
5
web/frontend/src/shims-vue.d.ts
vendored
@ -1,5 +0,0 @@
|
||||
declare module '*.vue' {
|
||||
import Vue from 'vue';
|
||||
|
||||
export default Vue;
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "esnext",
|
||||
"module": "esnext",
|
||||
"strict": true,
|
||||
"jsx": "preserve",
|
||||
"importHelpers": true,
|
||||
"moduleResolution": "node",
|
||||
"experimentalDecorators": true,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"sourceMap": true,
|
||||
"baseUrl": ".",
|
||||
"types": [
|
||||
"webpack-env"
|
||||
],
|
||||
"paths": {
|
||||
"@/*": [
|
||||
"src/*"
|
||||
]
|
||||
},
|
||||
"lib": [
|
||||
"esnext",
|
||||
"dom",
|
||||
"dom.iterable",
|
||||
"scripthost"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.ts",
|
||||
"src/**/*.tsx",
|
||||
"src/**/*.vue",
|
||||
"tests/**/*.ts",
|
||||
"tests/**/*.tsx"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
]
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -5,6 +5,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/go-chi/chi/v5/middleware"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
// LoggingMiddleware is used for logging info about requests to the servers configured accesslogger.
|
||||
@ -16,13 +17,11 @@ func (s *Server) LoggingMiddleware(next http.Handler) http.Handler {
|
||||
reqID := middleware.GetReqID(r.Context())
|
||||
|
||||
defer func() {
|
||||
/*s.AccessLogger.Debugw(r.Method,
|
||||
"path", r.URL.Path,
|
||||
"request-headers", r.Header,
|
||||
"response-headers", ww.Header(),
|
||||
)
|
||||
*/
|
||||
s.AccessLogger.Infow(r.Method,
|
||||
// If AccessLogIgnoreMetrics is true, do not log successful requests to metrics endpoint
|
||||
if s.cfg.AccessLogIgnoreMetrics && r.URL.Path == "/metrics" && ww.Status() == http.StatusOK {
|
||||
return
|
||||
}
|
||||
s.AccessLogger.Info(r.Method,
|
||||
"path", r.URL.Path,
|
||||
"status", ww.Status(),
|
||||
"written", ww.BytesWritten(),
|
||||
@ -35,3 +34,46 @@ func (s *Server) LoggingMiddleware(next http.Handler) http.Handler {
|
||||
}
|
||||
return http.HandlerFunc(fn)
|
||||
}
|
||||
|
||||
type MetricsMiddleware struct {
|
||||
requests *prometheus.CounterVec
|
||||
latency *prometheus.HistogramVec
|
||||
}
|
||||
|
||||
func (mm *MetricsMiddleware) handler(next http.Handler) http.Handler {
|
||||
fn := func(w http.ResponseWriter, r *http.Request) {
|
||||
ww := middleware.NewWrapResponseWriter(w, r.ProtoMajor)
|
||||
start := time.Now()
|
||||
defer func() {
|
||||
mm.requests.WithLabelValues(http.StatusText(ww.Status()), r.Method, r.URL.Path).Inc()
|
||||
mm.latency.WithLabelValues(http.StatusText(ww.Status()), r.Method, r.URL.Path).Observe(float64(time.Since(start).Milliseconds()))
|
||||
}()
|
||||
next.ServeHTTP(ww, r)
|
||||
}
|
||||
|
||||
return http.HandlerFunc(fn)
|
||||
}
|
||||
|
||||
func NewMetricsMiddleware() func(next http.Handler) http.Handler {
|
||||
mm := &MetricsMiddleware{}
|
||||
mm.requests = prometheus.NewCounterVec(prometheus.CounterOpts{
|
||||
Name: "apiary_http_requests_total",
|
||||
Help: "Total requests processed.",
|
||||
ConstLabels: prometheus.Labels{"service": "http"},
|
||||
},
|
||||
[]string{"code", "method", "path"},
|
||||
)
|
||||
|
||||
mm.latency = prometheus.NewHistogramVec(
|
||||
prometheus.HistogramOpts{
|
||||
Name: "apiary_http_request_duration_milliseconds",
|
||||
Help: "Request processing time.",
|
||||
ConstLabels: prometheus.Labels{"service": "http"},
|
||||
Buckets: []float64{100, 500, 1500},
|
||||
},
|
||||
[]string{"code", "method", "path"},
|
||||
)
|
||||
prometheus.MustRegister(mm.requests)
|
||||
prometheus.MustRegister(mm.latency)
|
||||
return mm.handler
|
||||
}
|
||||
|
@ -6,20 +6,21 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"git.t-juice.club/torjus/apiary"
|
||||
"git.t-juice.club/torjus/apiary/config"
|
||||
"git.t-juice.club/torjus/apiary/honeypot/ssh"
|
||||
"git.t-juice.club/torjus/apiary/honeypot/ssh/store"
|
||||
"git.t-juice.club/torjus/apiary/models"
|
||||
"github.com/go-chi/chi/v5"
|
||||
"github.com/go-chi/chi/v5/middleware"
|
||||
"github.com/google/uuid"
|
||||
"github.uio.no/torjus/apiary"
|
||||
"github.uio.no/torjus/apiary/config"
|
||||
"github.uio.no/torjus/apiary/honeypot"
|
||||
"github.uio.no/torjus/apiary/honeypot/store"
|
||||
"github.uio.no/torjus/apiary/models"
|
||||
"go.uber.org/zap"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
"golang.org/x/crypto/acme/autocert"
|
||||
)
|
||||
|
||||
@ -31,21 +32,22 @@ type Server struct {
|
||||
|
||||
cfg config.FrontendConfig
|
||||
|
||||
honeypotServer *honeypot.HoneypotServer
|
||||
honeypotServer *ssh.HoneypotServer
|
||||
store store.LoginAttemptStore
|
||||
|
||||
ServerLogger *zap.SugaredLogger
|
||||
AccessLogger *zap.SugaredLogger
|
||||
ServerLogger *slog.Logger
|
||||
AccessLogger *slog.Logger
|
||||
|
||||
attemptListenersLock sync.RWMutex
|
||||
attemptListeners map[string]chan models.LoginAttempt
|
||||
streamContext context.Context
|
||||
}
|
||||
|
||||
func NewServer(cfg config.FrontendConfig, hs *honeypot.HoneypotServer, store store.LoginAttemptStore) *Server {
|
||||
func NewServer(cfg config.FrontendConfig, hs *ssh.HoneypotServer, store store.LoginAttemptStore) *Server {
|
||||
discardLogger := slog.New(slog.NewTextHandler(io.Discard, nil))
|
||||
s := &Server{
|
||||
ServerLogger: zap.NewNop().Sugar(),
|
||||
AccessLogger: zap.NewNop().Sugar(),
|
||||
ServerLogger: discardLogger,
|
||||
AccessLogger: discardLogger,
|
||||
store: store,
|
||||
cfg: cfg,
|
||||
}
|
||||
@ -66,7 +68,7 @@ func NewServer(cfg config.FrontendConfig, hs *honeypot.HoneypotServer, store sto
|
||||
s.RegisterOnShutdown(func() {
|
||||
timeoutCtx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
|
||||
defer cancel()
|
||||
s.httpRedirectServer.Shutdown(timeoutCtx)
|
||||
s.httpRedirectServer.Shutdown(timeoutCtx) // nolint: errcheck
|
||||
})
|
||||
s.Addr = ":443"
|
||||
|
||||
@ -84,16 +86,20 @@ func NewServer(cfg config.FrontendConfig, hs *honeypot.HoneypotServer, store sto
|
||||
r.Use(middleware.RealIP)
|
||||
r.Use(middleware.RequestID)
|
||||
r.Use(s.LoggingMiddleware)
|
||||
r.Use(middleware.SetHeader("Server", apiary.FullVersion()))
|
||||
r.Use(middleware.SetHeader("Server", fmt.Sprintf("apiary/%s", apiary.FullVersion())))
|
||||
|
||||
if cfg.MetricsEnable {
|
||||
r.Use(NewMetricsMiddleware())
|
||||
r.Handle("/metrics", promhttp.Handler())
|
||||
}
|
||||
r.Route("/", func(r chi.Router) {
|
||||
r.Get("/*", s.IndexHandler("web/vue-frontend/dist"))
|
||||
r.Get("/stream", s.HandlerAttemptStream)
|
||||
r.Route("/api", func(r chi.Router) {
|
||||
r.Use(middleware.SetHeader("Content-Type", "application/json"))
|
||||
r.Get("/stats", s.HandlerStats)
|
||||
r.Get("/stream", s.HandlerAttemptStream)
|
||||
r.Get("/query", s.HandlerQuery)
|
||||
r.Get("/health", s.HandlerHealth)
|
||||
})
|
||||
})
|
||||
s.Handler = r
|
||||
@ -122,7 +128,7 @@ func (s *Server) StartServe() error {
|
||||
s.ServerLogger.Debug("Starting HTTP redirect server")
|
||||
go func() {
|
||||
if err := s.httpRedirectServer.ListenAndServe(); err != nil && err != http.ErrServerClosed {
|
||||
s.ServerLogger.Warnw("HTTP redirect server returned error", "error", err)
|
||||
s.ServerLogger.Warn("HTTP redirect server returned error", "error", err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
@ -148,6 +154,7 @@ func (s *Server) closeAttemptListener(id string) {
|
||||
close(ch)
|
||||
delete(s.attemptListeners, id)
|
||||
}
|
||||
|
||||
func (s *Server) HandlerAttemptStream(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/event-stream")
|
||||
w.Header().Set("Cache-Control", "no-cache")
|
||||
@ -170,7 +177,7 @@ func (s *Server) HandlerAttemptStream(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
_, err = io.WriteString(w, fmt.Sprintf("data: %s\n\n", string(data)))
|
||||
if err != nil {
|
||||
s.ServerLogger.Warnw("Error writing event", "error", err)
|
||||
s.ServerLogger.Warn("Error writing event", "error", err)
|
||||
}
|
||||
flusher.Flush()
|
||||
ticker.Reset(streamKeepAliveDuration)
|
||||
@ -180,7 +187,7 @@ func (s *Server) HandlerAttemptStream(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
case <-ticker.C:
|
||||
if _, err := io.WriteString(w, ": keep-alive\n\n"); err != nil {
|
||||
s.ServerLogger.Warnw("Error writing event", "error", err)
|
||||
s.ServerLogger.Warn("Error writing event", "error", err)
|
||||
}
|
||||
flusher.Flush()
|
||||
}
|
||||
@ -203,16 +210,17 @@ func (s *Server) HandlerStats(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
stats, err := s.store.Stats(statType, limit)
|
||||
if err != nil {
|
||||
s.ServerLogger.Warnw("Error fetching stats", "error", err)
|
||||
s.ServerLogger.Warn("Error fetching stats", "error", err)
|
||||
s.WriteAPIError(w, r, http.StatusInternalServerError, "Error fetching stats")
|
||||
return
|
||||
}
|
||||
|
||||
encoder := json.NewEncoder(w)
|
||||
if err := encoder.Encode(stats); err != nil {
|
||||
s.ServerLogger.Debugf("Error encoding or writing response", "remote_ip", r.RemoteAddr, "error", err)
|
||||
s.ServerLogger.Debug("Error encoding or writing response", "remote_ip", r.RemoteAddr, "error", err)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) HandlerQuery(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Add("Content-Type", "application/json")
|
||||
queryType := r.URL.Query().Get("type")
|
||||
@ -236,13 +244,13 @@ func (s *Server) HandlerQuery(w http.ResponseWriter, r *http.Request) {
|
||||
userResults, err := s.store.Query(uq)
|
||||
if err != nil {
|
||||
s.WriteAPIError(w, r, http.StatusInternalServerError, "Unable to perform query")
|
||||
s.ServerLogger.Warnw("Error performing query", "error", err)
|
||||
s.ServerLogger.Warn("Error performing query", "error", err)
|
||||
return
|
||||
}
|
||||
passwordResults, err := s.store.Query(pq)
|
||||
if err != nil {
|
||||
s.WriteAPIError(w, r, http.StatusInternalServerError, "Unable to perform query")
|
||||
s.ServerLogger.Warnw("Error performing query", "error", err)
|
||||
s.ServerLogger.Warn("Error performing query", "error", err)
|
||||
return
|
||||
}
|
||||
|
||||
@ -258,7 +266,7 @@ func (s *Server) HandlerQuery(w http.ResponseWriter, r *http.Request) {
|
||||
queryResults, err := s.store.Query(aq)
|
||||
if err != nil {
|
||||
s.WriteAPIError(w, r, http.StatusInternalServerError, "Unable to perform query")
|
||||
s.ServerLogger.Warnw("Error performing query", "error", err)
|
||||
s.ServerLogger.Warn("Error performing query", "error", err)
|
||||
return
|
||||
}
|
||||
|
||||
@ -267,10 +275,19 @@ func (s *Server) HandlerQuery(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
encoder := json.NewEncoder(w)
|
||||
if err := encoder.Encode(&results); err != nil {
|
||||
s.ServerLogger.Warnw("Error writing query results", "error", err)
|
||||
s.ServerLogger.Warn("Error writing query results", "error", err)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) HandlerHealth(w http.ResponseWriter, r *http.Request) {
|
||||
err := s.store.IsHealthy()
|
||||
if err != nil {
|
||||
s.WriteAPIError(w, r, http.StatusInternalServerError, fmt.Sprintf("Health error: %s", err))
|
||||
return
|
||||
}
|
||||
w.Write([]byte(`{}`)) // nolint: errcheck
|
||||
}
|
||||
|
||||
type APIErrorResponse struct {
|
||||
Error string `json:"error"`
|
||||
}
|
||||
@ -280,6 +297,6 @@ func (s *Server) WriteAPIError(w http.ResponseWriter, r *http.Request, status in
|
||||
apiErr := APIErrorResponse{Error: message}
|
||||
w.WriteHeader(status)
|
||||
if err := encoder.Encode(&apiErr); err != nil {
|
||||
s.ServerLogger.Debugf("Error encoding or writing error response", "remote_ip", r.RemoteAddr, "error", err)
|
||||
s.ServerLogger.Debug("Error encoding or writing error response", "remote_ip", r.RemoteAddr, "error", err)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user