diff --git a/go.mod b/go.mod index 83b5b094..036bbd70 100644 --- a/go.mod +++ b/go.mod @@ -1,18 +1,18 @@ module github.com/zekroTJA/shinpuru -go 1.18 +go 1.23 require ( - github.com/bwmarrin/discordgo v0.27.2-0.20240104191117-afc57886f91a + github.com/bwmarrin/discordgo v0.28.1 github.com/bwmarrin/snowflake v0.3.0 github.com/davecgh/go-spew v1.1.1 github.com/esimov/stackblur-go v1.1.0 - github.com/gabriel-vasile/mimetype v1.4.3 + github.com/gabriel-vasile/mimetype v1.4.5 github.com/generaltso/vibrant v0.0.0-20230605224344-08d3d20033fc github.com/go-ping/ping v1.1.0 github.com/go-redis/redis/v8 v8.11.5 - github.com/go-sql-driver/mysql v1.7.1 - github.com/gofiber/fiber/v2 v2.52.0 + github.com/go-sql-driver/mysql v1.8.1 + github.com/gofiber/fiber/v2 v2.52.5 github.com/golang-jwt/jwt/v4 v4.5.0 github.com/joho/godotenv v1.5.1 github.com/kataras/hcaptcha v0.0.2 @@ -20,41 +20,43 @@ require ( github.com/manifoldco/promptui v0.9.0 github.com/minio/minio-go v6.0.14+incompatible github.com/narqo/go-badge v0.0.0-20230821190521-c9a75c019a59 - github.com/prometheus/client_golang v1.18.0 + github.com/prometheus/client_golang v1.20.4 github.com/qiangxue/fasthttp-routing v0.0.0-20160225050629-6ccdc2a18d87 github.com/ranna-go/ranna v0.3.0 github.com/robfig/cron/v3 v3.0.1 - github.com/rs/xid v1.5.0 - github.com/sahilm/fuzzy v0.1.0 - github.com/sarulabs/di/v2 v2.4.2 - github.com/stretchr/testify v1.8.4 - github.com/traefik/paerser v0.2.0 - github.com/valyala/fasthttp v1.51.0 + github.com/rs/xid v1.6.0 + github.com/sahilm/fuzzy v0.1.1 + github.com/sarulabs/di/v2 v2.5.1 + github.com/stretchr/testify v1.9.0 + github.com/traefik/paerser v0.2.1 + github.com/valyala/fasthttp v1.56.0 github.com/wcharczuk/go-chart v2.0.1+incompatible github.com/zekroTJA/colorname v1.0.0 github.com/zekroTJA/ratelimit v1.1.1 github.com/zekroTJA/timedmap v1.5.2 github.com/zekrotja/dgrs v0.5.7 github.com/zekrotja/jwt v1.0.0 - github.com/zekrotja/ken v0.20.0 + github.com/zekrotja/ken v0.20.1 github.com/zekrotja/promtail v0.0.0-20230303162843-4e609d577b74 - github.com/zekrotja/rogu v0.7.0 + github.com/zekrotja/rogu v0.8.0 github.com/zekrotja/safepool v1.1.0 github.com/zekrotja/sop v0.3.1 - golang.org/x/image v0.15.0 - golang.org/x/sys v0.16.0 - golang.org/x/time v0.5.0 + golang.org/x/image v0.20.0 + golang.org/x/sys v0.25.0 + golang.org/x/time v0.6.0 gopkg.in/yaml.v2 v2.4.0 ) require ( - github.com/BurntSushi/toml v1.3.2 // indirect + filippo.io/edwards25519 v1.1.0 // indirect + github.com/BurntSushi/toml v1.4.0 // indirect github.com/andybalholm/brotli v1.1.0 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/blend/go-sdk v2.0.0+incompatible // indirect - github.com/cespare/xxhash/v2 v2.2.0 // indirect - github.com/charmbracelet/lipgloss v0.9.1 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect + github.com/charmbracelet/lipgloss v0.13.0 // indirect + github.com/charmbracelet/x/ansi v0.3.2 // indirect github.com/chzyer/readline v1.5.1 // indirect github.com/dayvonjersen/sadbox v0.0.0-20120828195626-27893f92b8ce // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect @@ -63,32 +65,33 @@ require ( github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect github.com/golang/gddo v0.0.0-20210115222349-20d68f94ee1f // indirect github.com/golang/protobuf v1.5.3 // indirect - github.com/google/uuid v1.5.0 // indirect - github.com/gorilla/websocket v1.5.1 // indirect - github.com/klauspost/compress v1.17.4 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/gorilla/websocket v1.5.3 // indirect + github.com/klauspost/compress v1.17.10 // indirect github.com/lucasb-eyer/go-colorful v1.2.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect - github.com/mattn/go-runewidth v0.0.15 // indirect + github.com/mattn/go-runewidth v0.0.16 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/muesli/reflow v0.3.0 // indirect github.com/muesli/termenv v0.15.2 // indirect + github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/prometheus/client_model v0.5.0 // indirect - github.com/prometheus/common v0.45.0 // indirect - github.com/prometheus/procfs v0.12.0 // indirect - github.com/rivo/uniseg v0.4.4 // indirect - github.com/stretchr/objx v0.5.1 // indirect + github.com/prometheus/client_model v0.6.1 // indirect + github.com/prometheus/common v0.59.1 // indirect + github.com/prometheus/procfs v0.15.1 // indirect + github.com/rivo/uniseg v0.4.7 // indirect + github.com/stretchr/objx v0.5.2 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/tcplisten v1.0.0 // indirect - golang.org/x/crypto v0.18.0 // indirect - golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3 // indirect - golang.org/x/net v0.20.0 // indirect - golang.org/x/sync v0.6.0 // indirect - golang.org/x/text v0.14.0 // indirect - google.golang.org/protobuf v1.32.0 // indirect + golang.org/x/crypto v0.27.0 // indirect + golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 // indirect + golang.org/x/net v0.29.0 // indirect + golang.org/x/sync v0.8.0 // indirect + golang.org/x/text v0.18.0 // indirect + google.golang.org/protobuf v1.34.2 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index e60b6633..a1f78cf3 100644 --- a/go.sum +++ b/go.sum @@ -24,6 +24,8 @@ cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiy cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= +filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= +filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= github.com/Azure/azure-sdk-for-go v16.2.1+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= @@ -41,6 +43,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/BurntSushi/toml v1.0.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8= github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0= +github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/DataDog/datadog-go v2.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/Microsoft/go-winio v0.4.11/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA= @@ -119,6 +123,8 @@ github.com/bwmarrin/discordgo v0.27.2-0.20230704233747-e39e715086d2 h1:QKh8uUg53 github.com/bwmarrin/discordgo v0.27.2-0.20230704233747-e39e715086d2/go.mod h1:NJZpH+1AfhIcyQsPeuBKsUtYrRnjkyu0kIVMCHkZtRY= github.com/bwmarrin/discordgo v0.27.2-0.20240104191117-afc57886f91a h1:I1j/9FoqDN+W0ZXiSU91lJXwKCvnKBLgJKlBLYAbim4= github.com/bwmarrin/discordgo v0.27.2-0.20240104191117-afc57886f91a/go.mod h1:NJZpH+1AfhIcyQsPeuBKsUtYrRnjkyu0kIVMCHkZtRY= +github.com/bwmarrin/discordgo v0.28.1 h1:gXsuo2GBO7NbR6uqmrrBDplPUx2T3nzu775q/Rd1aG4= +github.com/bwmarrin/discordgo v0.28.1/go.mod h1:NJZpH+1AfhIcyQsPeuBKsUtYrRnjkyu0kIVMCHkZtRY= github.com/bwmarrin/snowflake v0.3.0 h1:xm67bEhkKh6ij1790JB83OujPR5CzNe8QuQqAgISZN0= github.com/bwmarrin/snowflake v0.3.0/go.mod h1:NdZxfVWX+oR6y2K0o6qAYv6gIOP9rjG0/E9WsDpxqwE= github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= @@ -129,10 +135,16 @@ github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +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/charmbracelet/lipgloss v0.7.1 h1:17WMwi7N1b1rVWOjMT+rCh7sQkvDU75B2hbZpc5Kc1E= github.com/charmbracelet/lipgloss v0.7.1/go.mod h1:yG0k3giv8Qj8edTCbbg6AlQ5e8KNWpFujkNawKNhE2c= github.com/charmbracelet/lipgloss v0.9.1 h1:PNyd3jvaJbg4jRHKWXnCj1akQm4rh8dbEzN1p/u1KWg= github.com/charmbracelet/lipgloss v0.9.1/go.mod h1:1mPmG4cxScwUQALAAnacHaigiiHB9Pmr+v1VEawJl6I= +github.com/charmbracelet/lipgloss v0.13.0 h1:4X3PPeoWEDCMvzDvGmTajSyYPcZM4+y8sCA/SsA3cjw= +github.com/charmbracelet/lipgloss v0.13.0/go.mod h1:nw4zy0SBX/F/eAO1cWdcvy6qnkDUxr8Lw7dvFrAIbbY= +github.com/charmbracelet/x/ansi v0.3.2 h1:wsEwgAN+C9U06l9dCVMX0/L3x7ptvY1qmjMwyfE6USY= +github.com/charmbracelet/x/ansi v0.3.2/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= github.com/checkpoint-restore/go-criu/v4 v4.1.0/go.mod h1:xUQBLp4RLc5zJtWY++yjOoMoB5lihDt7fai+75m+rGw= github.com/checkpoint-restore/go-criu/v5 v5.0.0/go.mod h1:cfwC0EG7HMUenopBsUf9d89JlCLQIfgVcNsNN0t6T2M= github.com/checkpoint-restore/go-criu/v5 v5.3.0/go.mod h1:E/eQpaFtUKGOOSEBZgmKAcn+zUUwWxqcaKZlF54wK8E= @@ -329,6 +341,8 @@ github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA= github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0= github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk= +github.com/gabriel-vasile/mimetype v1.4.5 h1:J7wGKdGu33ocBOhGy0z653k/lFKLFDPJMG8Gql0kxn4= +github.com/gabriel-vasile/mimetype v1.4.5/go.mod h1:ibHel+/kbxn9x2407k1izTA1S81ku1z/DlgOW2QE0M4= github.com/garyburd/redigo v0.0.0-20150301180006-535138d7bcd7/go.mod h1:NR3MbYisc3/PwhQ00EMzDiPmrwpPxAn5GI05/YaO1SY= github.com/garyburd/redigo v1.1.1-0.20170914051019-70e1b1943d4f/go.mod h1:NR3MbYisc3/PwhQ00EMzDiPmrwpPxAn5GI05/YaO1SY= github.com/generaltso/vibrant v0.0.0-20230605224344-08d3d20033fc h1:xwkNUMlbc7t7tCwA3Lq6lCAka22WSNGn2q86CTFSzGI= @@ -371,6 +385,8 @@ github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo= github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI= github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= +github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y= +github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg= github.com/go-stack/stack v1.6.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= @@ -386,6 +402,8 @@ github.com/gofiber/fiber/v2 v2.48.0 h1:cRVMCb9aUJDsyHxGFLwz/sGzDggdailZZyptU9F9c github.com/gofiber/fiber/v2 v2.48.0/go.mod h1:xqJgfqrc23FJuqGOW6DVgi3HyZEm2Mn9pRqUb2kHSX8= github.com/gofiber/fiber/v2 v2.52.0 h1:S+qXi7y+/Pgvqq4DrSmREGiFwtB7Bu6+QFLuIHYw/UE= github.com/gofiber/fiber/v2 v2.52.0/go.mod h1:KEOE+cXMhXG0zHc9d8+E38hoX+ZN7bhOtgeF2oT6jrQ= +github.com/gofiber/fiber/v2 v2.52.5 h1:tWoP1MJQjGEe4GB5TUGOi7P2E0ZMMRx5ZTG4rT+yGMo= +github.com/gofiber/fiber/v2 v2.52.5/go.mod h1:KEOE+cXMhXG0zHc9d8+E38hoX+ZN7bhOtgeF2oT6jrQ= github.com/gogo/googleapis v1.2.0/go.mod h1:Njal3psf3qN6dwBtQfUmBZh2ybovJ0tlu3o/AC7HYjU= github.com/gogo/googleapis v1.4.0/go.mod h1:5YRNX2z1oM5gXdAkurHa942MDgEJyk02w4OecKY87+c= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= @@ -473,6 +491,8 @@ github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU= github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +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/googleapis/gax-go v2.0.0+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= @@ -489,6 +509,8 @@ github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWm github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= +github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= +github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gregjones/httpcache v0.0.0-20170920190843-316c5e0ff04e/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= @@ -579,6 +601,8 @@ github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGC github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/klauspost/compress v1.17.4 h1:Ej5ixsIri7BrIjBkRZLTo6ghwrEtHFk7ijlczPW4fZ4= github.com/klauspost/compress v1.17.4/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM= +github.com/klauspost/compress v1.17.10 h1:oXAz+Vh0PMUvJczoi+flxpnBEPxoER1IaAnU/NMPtT0= +github.com/klauspost/compress v1.17.10/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0= 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/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= @@ -624,6 +648,8 @@ github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWV github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= +github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-shellwords v1.0.3/go.mod h1:3xCvwCdWdlDJUrvuMn7Wuy9eWs4pE8vqg+NOMyg4B2o= github.com/mattn/go-shellwords v1.0.6/go.mod h1:3xCvwCdWdlDJUrvuMn7Wuy9eWs4pE8vqg+NOMyg4B2o= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= @@ -674,6 +700,7 @@ github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKt github.com/muesli/termenv v0.15.2 h1:GohcuySI0QmI3wN8Ok9PtKGkgkFIk7y6Vpb5PvrY+Wo= github.com/muesli/termenv v0.15.2/go.mod h1:Epx+iuz8sNs7mNKhxzH4fWXGNpZwUaJKRS1noLXviQ8= github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= +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/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= @@ -770,6 +797,8 @@ github.com/prometheus/client_golang v1.16.0 h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626 github.com/prometheus/client_golang v1.16.0/go.mod h1:Zsulrv/L9oM40tJ7T815tM89lFEugiJ9HzIqaAx4LKc= github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= +github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI= +github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= github.com/prometheus/client_model v0.0.0-20171117100541-99fa1f4be8e5/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= 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= @@ -780,6 +809,8 @@ github.com/prometheus/client_model v0.4.0 h1:5lQXD3cAg1OXBf4Wq03gTrXHeaV0TQvGfUo github.com/prometheus/client_model v0.4.0/go.mod h1:oMQmHW1/JoDwqLtg57MGgP/Fb1CJEYF2imWWhWtMkYU= github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw= github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI= +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.0.0-20180110214958-89604d197083/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/common v0.0.0-20181126121408-4724e9255275/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= @@ -792,6 +823,8 @@ github.com/prometheus/common v0.44.0 h1:+5BrQJwiBB9xsMygAB3TNvpQKOwlkc25LbISbrdO github.com/prometheus/common v0.44.0/go.mod h1:ofAIvZbQ1e/nugmZGz4/qCb9Ap1VoSTIO7x0VV9VvuY= github.com/prometheus/common v0.45.0 h1:2BGz0eBc2hdMDLnO/8n0jeB3oPrt2D08CekT0lneoxM= github.com/prometheus/common v0.45.0/go.mod h1:YJmSTw9BoKxJplESWWxlbyttQR4uaEcGyv9MZjVOJsY= +github.com/prometheus/common v0.59.1 h1:LXb1quJHWm1P6wq/U824uxYi4Sg0oGvNeUm1z5dJoX0= +github.com/prometheus/common v0.59.1/go.mod h1:GpWM7dewqmVYcd7SmRaiWVe9SSqjf0UrwnYnpEZNuT0= github.com/prometheus/procfs v0.0.0-20180125133057-cb4147076ac7/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= @@ -809,6 +842,8 @@ github.com/prometheus/procfs v0.11.0 h1:5EAgkfkMl659uZPbe9AS2N68a7Cc1TJbPEuGzFuR github.com/prometheus/procfs v0.11.0/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM= github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= +github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= +github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/qiangxue/fasthttp-routing v0.0.0-20160225050629-6ccdc2a18d87 h1:u7uCM+HS2caoEKSPtSFQvvUDXQtqZdu3MYtF+QEw7vA= github.com/qiangxue/fasthttp-routing v0.0.0-20160225050629-6ccdc2a18d87/go.mod h1:zwr0xP4ZJxwCS/g2d+AUOUwfq/j2NC7a1rK3F0ZbVYM= @@ -818,6 +853,8 @@ github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJ github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis= github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= +github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= +github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= @@ -826,6 +863,8 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc= github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= +github.com/rs/xid v1.6.0 h1:fV591PaemRlL6JfRxGDEPl69wICngIQ3shQtzfy2gxU= +github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= @@ -833,8 +872,12 @@ github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIH github.com/safchain/ethtool v0.0.0-20190326074333-42ed695e3de8/go.mod h1:Z0q5wiBQGYcxhMZ6gUqHn6pYNLypFAvaL3UvgZLR0U4= github.com/sahilm/fuzzy v0.1.0 h1:FzWGaw2Opqyu+794ZQ9SYifWv2EIXpwP4q8dY1kDAwI= github.com/sahilm/fuzzy v0.1.0/go.mod h1:VFvziUEIMCrT6A6tw2RFIXPXXmzXbOsSHF0DOI8ZK9Y= +github.com/sahilm/fuzzy v0.1.1 h1:ceu5RHF8DGgoi+/dR5PsECjCDH1BE3Fnmpo7aVXOdRA= +github.com/sahilm/fuzzy v0.1.1/go.mod h1:VFvziUEIMCrT6A6tw2RFIXPXXmzXbOsSHF0DOI8ZK9Y= github.com/sarulabs/di/v2 v2.4.2 h1:A/PDVU41gHYeUbZZKco8dOwPAB2rrFfiwWLJrZsi+h8= github.com/sarulabs/di/v2 v2.4.2/go.mod h1:trZu4KPwNLE623mBIIsljn1LLkNE6ee/Pk24b7yzSf8= +github.com/sarulabs/di/v2 v2.5.1 h1:3b/4R0F6XYH6hdBLftnBy522LDMHz4ffk0kfuKQAxWs= +github.com/sarulabs/di/v2 v2.5.1/go.mod h1:u+6Y0O5XqKzzjLz2zXdqxgfO1TnEYivLVqgScAgKQa8= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/sclevine/spec v1.2.0/go.mod h1:W4J29eT/Kzv7/b9IWLB055Z+qvVC9vt0Arko24q7p+U= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= @@ -881,6 +924,8 @@ github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/objx v0.5.1 h1:4VhoImhV/Bm0ToFkXFi8hXNXwpDRZ/ynw3amt82mzq0= github.com/stretchr/objx v0.5.1/go.mod h1:/iHQpkQwBD6DLUmQ4pE+s1TXdob1mORJ4/UFdrifcy0= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v0.0.0-20180303142811-b89eecf5ca5d/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= @@ -894,6 +939,8 @@ github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/syndtr/gocapability v0.0.0-20170704070218-db04d3cc01c8/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= @@ -902,6 +949,8 @@ github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1 github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/traefik/paerser v0.2.0 h1:zqCLGSXoNlcBd+mzqSCLjon/I6phqIjeJL2xFB2ysgQ= github.com/traefik/paerser v0.2.0/go.mod h1:afzaVcgF8A+MpTnPG4wBr4whjanCSYA6vK5RwaYVtRc= +github.com/traefik/paerser v0.2.1 h1:LFgeak1NmjEHF53c9ENdXdL1UMkF/lD5t+7Evsz4hH4= +github.com/traefik/paerser v0.2.1/go.mod h1:7BBDd4FANoVgaTZG+yh26jI6CA2nds7D/4VTEdIsh24= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= github.com/urfave/cli v0.0.0-20171014202726-7bc6a0acffa5/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= @@ -915,6 +964,8 @@ github.com/valyala/fasthttp v1.48.0 h1:oJWvHb9BIZToTQS3MuQ2R3bJZiNSa2KiNdeI8A+79 github.com/valyala/fasthttp v1.48.0/go.mod h1:k2zXd82h/7UZc3VOdJ2WaUqt1uZ/XpXAfE9i+HBC3lA= github.com/valyala/fasthttp v1.51.0 h1:8b30A5JlZ6C7AS81RsWjYMQmrZG6feChmgAolCl1SqA= github.com/valyala/fasthttp v1.51.0/go.mod h1:oI2XroL+lI7vdXyYoQk03bXBThfFl2cVdIA3Xl7cH8g= +github.com/valyala/fasthttp v1.56.0 h1:bEZdJev/6LCBlpdORfrLu/WOZXXxvrUQSiyniuaoW8U= +github.com/valyala/fasthttp v1.56.0/go.mod h1:sReBt3XZVnudxuLOx4J/fMrJVorWRiWY2koQKgABiVI= github.com/valyala/tcplisten v1.0.0 h1:rBHj/Xf+E1tRGZyWIWwJDiRY0zc1Js+CV5DqwacVSA8= github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc= github.com/vishvananda/netlink v0.0.0-20181108222139-023a6dafdcdf/go.mod h1:+SR5DhBJrl6ZM7CoCKvpw5BKroDKQ+PJqOg65H/2ktk= @@ -967,12 +1018,16 @@ github.com/zekrotja/ken v0.19.1-0.20230721145756-874555f2ff12 h1:wEucpG45D/rT4+i github.com/zekrotja/ken v0.19.1-0.20230721145756-874555f2ff12/go.mod h1:ubT/5aG5v88pOyFHwgp3I4sLb90QeUbCRuR0f/lYqt4= github.com/zekrotja/ken v0.20.0 h1:qeGvKp10mIBIyPurvIrDwOdkpwERRphryOr128YKiMc= github.com/zekrotja/ken v0.20.0/go.mod h1:7Y+H+C1XZPZrA4j7JKpVZoxg10k2Y+t3mDbTy2whcMQ= +github.com/zekrotja/ken v0.20.1 h1:bYlU4Bgs3URVqN9lLOKiAfqCKAKKOtJHYCIP9OKdX5Y= +github.com/zekrotja/ken v0.20.1/go.mod h1:c5gWJAF/QBYrHqHD2gts9YW6i9r6UZAbHxJxISlP2jU= github.com/zekrotja/promtail v0.0.0-20230303162843-4e609d577b74 h1:rpswW7PqwNBGUA5w7h3d1EDgrpIdRZuofT4QSFpl5Mg= github.com/zekrotja/promtail v0.0.0-20230303162843-4e609d577b74/go.mod h1:19bfcNBGlBCdz30MvoYX6bc6BlEYIG0aiv2Ji1/WCV4= github.com/zekrotja/rogu v0.5.1 h1:uGV2W62+dLt7hR57xGJEBqzEKTW+kWBKlRpFpxIaTms= github.com/zekrotja/rogu v0.5.1/go.mod h1:4pOJq4Qyv20znbSIpLEWIxq+P5MvgtGIFAMrOA75sXE= github.com/zekrotja/rogu v0.7.0 h1:3YEUOt/JXQMpfsB1X6YbivhzSNqJP3sWJeG5PK4Uypk= github.com/zekrotja/rogu v0.7.0/go.mod h1:4pOJq4Qyv20znbSIpLEWIxq+P5MvgtGIFAMrOA75sXE= +github.com/zekrotja/rogu v0.8.0 h1:pav+WsvssaQ671x4yAgVvZU5c+nbfCDWWHUJ6l3dpew= +github.com/zekrotja/rogu v0.8.0/go.mod h1:4pOJq4Qyv20znbSIpLEWIxq+P5MvgtGIFAMrOA75sXE= github.com/zekrotja/safepool v1.0.0 h1:dcrSChiJ46hd0BQ0ksceCqWWqkd3HYxozwnM1y2guhk= github.com/zekrotja/safepool v1.0.0/go.mod h1:TIeAz8hLF0HR9lv9VPS89M/UwYhnmbkbyQQ0quJ3t8k= github.com/zekrotja/safepool v1.1.0 h1:Fc9smZ5eI1TxVqAcRsLPl6rGiWybm4v8YxAqX6ECJEY= @@ -1025,6 +1080,8 @@ golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA= golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= +golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A= +golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1039,12 +1096,16 @@ golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 h1:MGwJjxBy0HJshjDNfLsYO8xpp golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3 h1:hNQpMuAJe5CtcUqCXaWga3FHu+kQvCqcsoVaQgSV60o= golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08= +golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 h1:e66Fs6Z+fZTbFBAxKfP3PALWBtpfqks2bwGcexMxgtk= +golang.org/x/exp v0.0.0-20240909161429-701f63a606c0/go.mod h1:2TbTHSBQa924w8M6Xs1QcRcFwyucIwBGpK1p2f1YFFY= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/image v0.9.0 h1:QrzfX26snvCM20hIhBwuHI/ThTg18b/+kcKdXHvnR+g= golang.org/x/image v0.9.0/go.mod h1:jtrku+n79PfroUbvDdeUWMAI+heR786BofxrbiSF+J0= golang.org/x/image v0.15.0 h1:kOELfmgrmJlw4Cdb7g/QGuB3CvDrXbqEIww/pNtNBm8= golang.org/x/image v0.15.0/go.mod h1:HUYqC05R2ZcZ3ejNQsIHQDQiwWM4JBqmm6MKANTp4LE= +golang.org/x/image v0.20.0 h1:7cVCUjQwfL18gyBJOmYvptfSHS8Fb3YUDtfLIZ7Nbpw= +golang.org/x/image v0.20.0/go.mod h1:0a88To4CYVBAHp5FXJm8o7QbUl37Vd85ply1vyD8auM= 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= @@ -1118,6 +1179,8 @@ golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50= golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= +golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= +golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= golang.org/x/oauth2 v0.0.0-20170912212905-13449ad91cb2/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= 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= @@ -1142,6 +1205,8 @@ golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= 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= @@ -1234,6 +1299,8 @@ golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= +golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -1252,6 +1319,8 @@ golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4= golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= +golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/time v0.0.0-20170424234030-8be79e1e0910/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1263,6 +1332,8 @@ golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= +golang.org/x/time v0.6.0 h1:eTDhh4ZXt5Qf0augr54TN6suAUudPcawVZeIAPU7D4U= +golang.org/x/time v0.6.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/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-20181011042414-1f849cf54d09/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -1399,6 +1470,8 @@ google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d/go.mod h1:cuepJuh7vyXfUyUwEgHQXw849cJrilpS5NeIjOWESAw= diff --git a/internal/inits/commandhandler.go b/internal/inits/commandhandler.go index 5f10d06a..ce975b1c 100644 --- a/internal/inits/commandhandler.go +++ b/internal/inits/commandhandler.go @@ -1,148 +1,156 @@ -package inits - -import ( - "fmt" - - "github.com/bwmarrin/discordgo" - "github.com/go-redis/redis/v8" - "github.com/sarulabs/di/v2" - "github.com/zekroTJA/shinpuru/internal/messagecommands" - "github.com/zekroTJA/shinpuru/internal/middleware" - "github.com/zekroTJA/shinpuru/internal/services/permissions" - "github.com/zekroTJA/shinpuru/internal/slashcommands" - "github.com/zekroTJA/shinpuru/internal/usercommands" - "github.com/zekroTJA/shinpuru/internal/util/embedded" - "github.com/zekroTJA/shinpuru/internal/util/static" - "github.com/zekroTJA/shinpuru/pkg/rediscmdstore" - "github.com/zekrotja/dgrs" - "github.com/zekrotja/ken" - "github.com/zekrotja/ken/middlewares/cmdhelp" - "github.com/zekrotja/ken/state" - "github.com/zekrotja/ken/store" - "github.com/zekrotja/rogu/log" -) - -func InitCommandHandler(container di.Container) (k *ken.Ken, err error) { - session := container.Get(static.DiDiscordSession).(*discordgo.Session) - st := container.Get(static.DiState).(*dgrs.State) - perms := container.Get(static.DiPermissions).(*permissions.Permissions) - rd, _ := container.Get(static.DiRedis).(*redis.Client) - - log := log.Tagged("CmdHandler") - log.Info().Msg("Initializing command handler ...") - - var cmdStore store.CommandStore - if rd != nil { - cmdStore = rediscmdstore.New(rd, fmt.Sprintf("snp:cmdstore:%s", embedded.AppCommit)) - } - - k, err = ken.New(session, ken.Options{ - State: state.NewDgrs(st), - CommandStore: cmdStore, - DependencyProvider: container, - OnSystemError: systemErrorHandler, - OnCommandError: commandErrorHandler, - OnEventError: eventErrorHandler, - EmbedColors: ken.EmbedColors{ - Default: static.ColorEmbedDefault, - Error: static.ColorEmbedError, - }, - }) - if err != nil { - return - } - - err = k.RegisterCommands( - new(usercommands.User), - - new(messagecommands.Quote), - - new(slashcommands.Autorole), - new(slashcommands.Autovc), - new(slashcommands.Backup), - new(slashcommands.Bug), - new(slashcommands.Clear), - new(slashcommands.Vote), - new(slashcommands.Report), - new(slashcommands.Mute), - new(slashcommands.Perms), - new(slashcommands.Chanstats), - new(slashcommands.Exec), - new(slashcommands.Say), - new(slashcommands.Notify), - new(slashcommands.Mvall), - new(slashcommands.Lock), - new(slashcommands.Inviteblock), - new(slashcommands.Ghostping), - new(slashcommands.Voicelog), - new(slashcommands.Modlog), - new(slashcommands.Announcements), - new(slashcommands.Starboard), - new(slashcommands.Colorreation), - new(slashcommands.User), - new(slashcommands.Twitchnotify), - new(slashcommands.Tag), - new(slashcommands.Presence), - new(slashcommands.Login), - new(slashcommands.Quote), - new(slashcommands.Stats), - new(slashcommands.Karma), - new(slashcommands.Guild), - new(slashcommands.Id), - new(slashcommands.Snowflake), - new(slashcommands.Maintenance), - new(slashcommands.Info), - new(slashcommands.Help), - new(slashcommands.Birthday), - new(slashcommands.Kick), - new(slashcommands.Ban), - new(slashcommands.Roleselect), - new(slashcommands.Modnot), - ) - if err != nil { - return - } - - if !embedded.IsRelease() { - err = k.RegisterCommands(new(slashcommands.Debug)) - if err != nil { - return - } - } - - err = k.RegisterMiddlewares( - middleware.NewDisableCommandsMiddleware(container), - perms, - cmdhelp.New("help"), - middleware.NewCommandStatsMiddleware(), - middleware.NewCommandLoggingMiddleware(container), - ) - - return -} - -func systemErrorHandler(context string, err error, args ...interface{}) { - log.Error().Err(err).Field("ctx", context).Msg("Ken System Error") -} - -func eventErrorHandler(context string, err error) { - log.Error().Err(err).Field("context", context).Msg("Ken Event Error") -} - -func commandErrorHandler(err error, ctx *ken.Ctx) { - // Is ignored if interaction has already been responded - ctx.Defer() - - if err == ken.ErrNotDMCapable { - ctx.FollowUpError("This command can not be used in DMs.", "").Send() - return - } - - log.Tagged("Ken").Error(). - Err(err). - Field("cmd", ctx.Command.Name()). - Msg("Unexpected command result") - ctx.FollowUpError( - fmt.Sprintf("The command execution failed unexpectedly:\n```\n%s\n```", err.Error()), - "Command execution failed").Send() -} +package inits + +import ( + "fmt" + + "github.com/bwmarrin/discordgo" + "github.com/go-redis/redis/v8" + "github.com/sarulabs/di/v2" + "github.com/zekroTJA/shinpuru/internal/messagecommands" + "github.com/zekroTJA/shinpuru/internal/middleware" + "github.com/zekroTJA/shinpuru/internal/services/permissions" + "github.com/zekroTJA/shinpuru/internal/slashcommands" + "github.com/zekroTJA/shinpuru/internal/usercommands" + "github.com/zekroTJA/shinpuru/internal/util/embedded" + "github.com/zekroTJA/shinpuru/internal/util/static" + "github.com/zekroTJA/shinpuru/pkg/rediscmdstore" + "github.com/zekrotja/dgrs" + "github.com/zekrotja/ken" + "github.com/zekrotja/ken/middlewares/cmdhelp" + "github.com/zekrotja/ken/state" + "github.com/zekrotja/ken/store" + "github.com/zekrotja/rogu/log" +) + +type ContainerWrapper struct { + container di.Container +} + +func (t *ContainerWrapper) Get(key string) any { + return t.container.Get(key) +} + +func InitCommandHandler(container di.Container) (k *ken.Ken, err error) { + session := container.Get(static.DiDiscordSession).(*discordgo.Session) + st := container.Get(static.DiState).(*dgrs.State) + perms := container.Get(static.DiPermissions).(*permissions.Permissions) + rd, _ := container.Get(static.DiRedis).(*redis.Client) + + log := log.Tagged("CmdHandler") + log.Info().Msg("Initializing command handler ...") + + var cmdStore store.CommandStore + if rd != nil { + cmdStore = rediscmdstore.New(rd, fmt.Sprintf("snp:cmdstore:%s", embedded.AppCommit)) + } + + k, err = ken.New(session, ken.Options{ + State: state.NewDgrs(st), + CommandStore: cmdStore, + DependencyProvider: &ContainerWrapper{container}, + OnSystemError: systemErrorHandler, + OnCommandError: commandErrorHandler, + OnEventError: eventErrorHandler, + EmbedColors: ken.EmbedColors{ + Default: static.ColorEmbedDefault, + Error: static.ColorEmbedError, + }, + }) + if err != nil { + return + } + + err = k.RegisterCommands( + new(usercommands.User), + + new(messagecommands.Quote), + + new(slashcommands.Autorole), + new(slashcommands.Autovc), + new(slashcommands.Backup), + new(slashcommands.Bug), + new(slashcommands.Clear), + new(slashcommands.Vote), + new(slashcommands.Report), + new(slashcommands.Mute), + new(slashcommands.Perms), + new(slashcommands.Chanstats), + new(slashcommands.Exec), + new(slashcommands.Say), + new(slashcommands.Notify), + new(slashcommands.Mvall), + new(slashcommands.Lock), + new(slashcommands.Inviteblock), + new(slashcommands.Ghostping), + new(slashcommands.Voicelog), + new(slashcommands.Modlog), + new(slashcommands.Announcements), + new(slashcommands.Starboard), + new(slashcommands.Colorreation), + new(slashcommands.User), + new(slashcommands.Twitchnotify), + new(slashcommands.Tag), + new(slashcommands.Presence), + new(slashcommands.Login), + new(slashcommands.Quote), + new(slashcommands.Stats), + new(slashcommands.Karma), + new(slashcommands.Guild), + new(slashcommands.Id), + new(slashcommands.Snowflake), + new(slashcommands.Maintenance), + new(slashcommands.Info), + new(slashcommands.Help), + new(slashcommands.Birthday), + new(slashcommands.Kick), + new(slashcommands.Ban), + new(slashcommands.Roleselect), + new(slashcommands.Modnot), + ) + if err != nil { + return + } + + if !embedded.IsRelease() { + err = k.RegisterCommands(new(slashcommands.Debug)) + if err != nil { + return + } + } + + err = k.RegisterMiddlewares( + middleware.NewDisableCommandsMiddleware(container), + perms, + cmdhelp.New("help"), + middleware.NewCommandStatsMiddleware(), + middleware.NewCommandLoggingMiddleware(container), + ) + + return +} + +func systemErrorHandler(context string, err error, args ...interface{}) { + log.Error().Err(err).Field("ctx", context).Msg("Ken System Error") +} + +func eventErrorHandler(context string, err error) { + log.Error().Err(err).Field("context", context).Msg("Ken Event Error") +} + +func commandErrorHandler(err error, ctx *ken.Ctx) { + // Is ignored if interaction has already been responded + ctx.Defer() + + if err == ken.ErrNotDMCapable { + ctx.FollowUpError("This command can not be used in DMs.", "").Send() + return + } + + log.Tagged("Ken").Error(). + Err(err). + Field("cmd", ctx.Command.Name()). + Msg("Unexpected command result") + ctx.FollowUpError( + fmt.Sprintf("The command execution failed unexpectedly:\n```\n%s\n```", err.Error()), + "Command execution failed").Send() +} diff --git a/internal/services/webserver/v1/controllers/auth.go b/internal/services/webserver/v1/controllers/auth.go index da645dcd..2159e998 100644 --- a/internal/services/webserver/v1/controllers/auth.go +++ b/internal/services/webserver/v1/controllers/auth.go @@ -1,263 +1,263 @@ -package controllers - -import ( - "sync" - "time" - - "github.com/bwmarrin/discordgo" - "github.com/gofiber/fiber/v2" - "github.com/rs/xid" - "github.com/sarulabs/di/v2" - "github.com/zekroTJA/shinpuru/internal/services/database" - "github.com/zekroTJA/shinpuru/internal/services/webserver/auth" - "github.com/zekroTJA/shinpuru/internal/services/webserver/v1/models" - "github.com/zekroTJA/shinpuru/internal/util" - "github.com/zekroTJA/shinpuru/internal/util/static" - "github.com/zekroTJA/shinpuru/pkg/acceptmsg/v2" - "github.com/zekroTJA/shinpuru/pkg/discordoauth/v2" - "github.com/zekroTJA/timedmap" - "github.com/zekrotja/dgrs" - "github.com/zekrotja/ken" - "github.com/zekrotja/rogu/log" -) - -const pushcodeTimeout = 60 * time.Second - -type AuthController struct { - discordOAuth *discordoauth.DiscordOAuth - rth auth.RefreshTokenHandler - ath auth.AccessTokenHandler - authMw auth.Middleware - st *dgrs.State - session *discordgo.Session - cmdHandler *ken.Ken - oauthHandler auth.RequestHandler - - pushcodeSubs *timedmap.TimedMap -} - -type pushCodeWaiter struct { - mtx sync.Mutex - code string - am *acceptmsg.AcceptMessage - subscription func() error - fin chan *discordgo.Message - closed bool -} - -func (pcw *pushCodeWaiter) close() bool { - pcw.mtx.Lock() - defer pcw.mtx.Unlock() - - if pcw.am != nil { - pcw.am.Ken.Session().ChannelMessageEditComplex(&discordgo.MessageEdit{ - Channel: pcw.am.ChannelID, - ID: pcw.am.ID, - Embeds: []*discordgo.MessageEmbed{ - { - Title: "Login", - Description: "The code has been timed out.", - }, - }, - Components: []discordgo.MessageComponent{}, - }) - pcw.am = nil - } - - if !pcw.closed { - close(pcw.fin) - pcw.subscription() - pcw.closed = true - - return true - } - - return false -} - -func (c *AuthController) Setup(container di.Container, router fiber.Router) { - c.discordOAuth = container.Get(static.DiDiscordOAuthModule).(*discordoauth.DiscordOAuth) - c.rth = container.Get(static.DiAuthRefreshTokenHandler).(auth.RefreshTokenHandler) - c.ath = container.Get(static.DiAuthAccessTokenHandler).(auth.AccessTokenHandler) - c.authMw = container.Get(static.DiAuthMiddleware).(auth.Middleware) - c.st = container.Get(static.DiState).(*dgrs.State) - c.session = container.Get(static.DiDiscordSession).(*discordgo.Session) - c.oauthHandler = container.Get(static.DiOAuthHandler).(auth.RequestHandler) - c.cmdHandler = container.Get(static.DiCommandHandler).(*ken.Ken) - - c.pushcodeSubs = timedmap.New(10 * time.Second) - - router.Get("/login", c.getLogin) - router.Get("/oauthcallback", c.discordOAuth.HandlerCallback) - router.Post("/accesstoken", c.postAccessToken) - router.Post("/pushcode", c.pushCode) - router.Get("/check", c.authMw.Handle, c.getCheck) - router.Post("/logout", c.authMw.Handle, c.postLogout) -} - -func (c *AuthController) getLogin(ctx *fiber.Ctx) error { - state := make(map[string]string) - - if redirect := ctx.Query("redirect"); redirect != "" { - state["redirect"] = redirect - } - - return c.discordOAuth.HandlerInitWithState(ctx, state) -} - -// @Summary Access Token Exchange -// @Description Exchanges the cookie-passed refresh token with a generated access token. -// @Tags Authorization -// @Accept json -// @Produce json -// @Success 200 {object} models.AccessTokenResponse -// @Failure 401 {object} models.Error -// @Router /auth/accesstoken [post] -func (c *AuthController) postAccessToken(ctx *fiber.Ctx) error { - refreshToken := ctx.Cookies(static.RefreshTokenCookieName) - if refreshToken == "" { - return fiber.ErrUnauthorized - } - - ident, err := c.rth.ValidateRefreshToken(refreshToken) - if err != nil && !database.IsErrDatabaseNotFound(err) { - ctlLog.Error().Err(err).Msg("Failed validating refresh token") - } - if ident == "" { - return fiber.ErrUnauthorized - } - - token, expires, err := c.ath.GetAccessToken(ident) - if err != nil { - return err - } - - return ctx.JSON(&models.AccessTokenResponse{ - Token: token, - Expires: expires, - }) -} - -// @Summary Authorization Check -// @Description Returns OK if the request is authorized. -// @Tags Authorization -// @Accept json -// @Produce json -// @Success 200 {object} models.Status -// @Failure 401 {object} models.Error -// @Router /auth/check [get] -func (c *AuthController) getCheck(ctx *fiber.Ctx) error { - return ctx.JSON(models.Ok) -} - -// @Summary Logout -// @Description Reovkes the currently used access token and clears the refresh token. -// @Tags Authorization -// @Accept json -// @Produce json -// @Success 200 {object} models.Status -// @Router /auth/logout [post] -func (c *AuthController) postLogout(ctx *fiber.Ctx) error { - uid := ctx.Locals("uid").(string) - - err := c.rth.RevokeToken(uid) - if err != nil && !database.IsErrDatabaseNotFound(err) { - return err - } - - ctx.ClearCookie(static.RefreshTokenCookieName) - - return ctx.JSON(models.Ok) -} - -// @Summary Pushcode -// @Description Send a login push code resulting in a long-fetch request waiting for the code to be sent to shinpurus DMs. -// @Tags Authorization -// @Accept json -// @Produce json -// @Param payload body models.PushCodeRequest true "The push code." -// @Success 200 {object} models.Status -// @Success 400 {object} models.Status -// @Success 410 {object} models.Status -// @Router /auth/pushcode [post] -func (c *AuthController) pushCode(ctx *fiber.Ctx) (err error) { - var req models.PushCodeRequest - if err = ctx.BodyParser(&req); err != nil { - return - } - - if req.Code == "" { - return fiber.NewError(fiber.StatusBadRequest, "empty code") - } - - ipaddr := ctx.IP() - if ipaddr == "" { - // When the IP address is empty, which might happen, just - // generate a new pcw for each request to avoid conflicts. - ipaddr = xid.New().String() - } - - pcw, ok := c.pushcodeSubs.GetValue(ipaddr).(*pushCodeWaiter) - if !ok { - pcw = new(pushCodeWaiter) - c.pushcodeSubs.Set(ipaddr, pcw, pushcodeTimeout, func(_ any) { - pcw.close() - }) - - pcw.code = req.Code - pcw.fin = make(chan *discordgo.Message) - pcw.subscription = c.st.Subscribe("dms", func(scan func(v any) error) { - var msg discordgo.Message - if err = scan(&msg); err != nil { - ctlLog.Error().Err(err).Msg("failed scanning message from 'dms' event bus") - return - } - if msg.Content == pcw.code && msg.Author != nil { - am, err := acceptmsg.New(). - WithKen(c.cmdHandler). - DeleteAfterAnswer().WithEmbed(&discordgo.MessageEmbed{ - Title: "Login", - Description: "Do you really want to log in to the web interface using this " + - "login code?\n\n⚠️ **Never __ever__ enter a login code here you got from someone else!**\n" + - "If you got this login code from someone else, press `Cancel` or do nothing!", - Color: static.ColorEmbedOrange, - }).WithAcceptButton(discordgo.Button{ - Label: "Accept", - Style: discordgo.SuccessButton, - }).WithDeclineButton(discordgo.Button{ - Label: "Cancel", - Style: discordgo.DangerButton, - }).DoOnAccept(func(ctx ken.ComponentContext) error { - pcw.am = nil - pcw.fin <- &msg - return nil - }).Send(msg.ChannelID) - if err == nil { - pcw.am = am - } - } - }) - } else { - log.Debug().Field("ipaddr", ipaddr).Msg("Reusing pushcode handler for this client") - pcw.code = req.Code - } - - res := <-pcw.fin - if res == nil { - err = fiber.NewError(fiber.StatusGone, "timeout") - return - } - - c.pushcodeSubs.Remove(ipaddr) - if pcw.close() { - util.SendEmbed(c.session, res.ChannelID, - "You are now being logged in!", "", static.ColorEmbedGreen) - } - - err = c.oauthHandler.BindRefreshToken(ctx, res.Author.ID) - if err != nil { - return - } - - return ctx.JSON(models.Ok) -} +package controllers + +import ( + "sync" + "time" + + "github.com/bwmarrin/discordgo" + "github.com/gofiber/fiber/v2" + "github.com/rs/xid" + "github.com/sarulabs/di/v2" + "github.com/zekroTJA/shinpuru/internal/services/database" + "github.com/zekroTJA/shinpuru/internal/services/webserver/auth" + "github.com/zekroTJA/shinpuru/internal/services/webserver/v1/models" + "github.com/zekroTJA/shinpuru/internal/util" + "github.com/zekroTJA/shinpuru/internal/util/static" + "github.com/zekroTJA/shinpuru/pkg/acceptmsg/v2" + "github.com/zekroTJA/shinpuru/pkg/discordoauth/v2" + "github.com/zekroTJA/timedmap" + "github.com/zekrotja/dgrs" + "github.com/zekrotja/ken" + "github.com/zekrotja/rogu/log" +) + +const pushcodeTimeout = 60 * time.Second + +type AuthController struct { + discordOAuth *discordoauth.DiscordOAuth + rth auth.RefreshTokenHandler + ath auth.AccessTokenHandler + authMw auth.Middleware + st *dgrs.State + session *discordgo.Session + cmdHandler *ken.Ken + oauthHandler auth.RequestHandler + + pushcodeSubs *timedmap.TimedMap +} + +type pushCodeWaiter struct { + mtx sync.Mutex + code string + am *acceptmsg.AcceptMessage + subscription func() error + fin chan *discordgo.Message + closed bool +} + +func (pcw *pushCodeWaiter) close() bool { + pcw.mtx.Lock() + defer pcw.mtx.Unlock() + + if pcw.am != nil { + _, _ = pcw.am.Ken.Session().ChannelMessageEditComplex(&discordgo.MessageEdit{ + Channel: pcw.am.ChannelID, + ID: pcw.am.ID, + Embeds: &[]*discordgo.MessageEmbed{ + { + Title: "Login", + Description: "The code has been timed out.", + }, + }, + Components: &[]discordgo.MessageComponent{}, + }) + pcw.am = nil + } + + if !pcw.closed { + close(pcw.fin) + pcw.subscription() + pcw.closed = true + + return true + } + + return false +} + +func (c *AuthController) Setup(container di.Container, router fiber.Router) { + c.discordOAuth = container.Get(static.DiDiscordOAuthModule).(*discordoauth.DiscordOAuth) + c.rth = container.Get(static.DiAuthRefreshTokenHandler).(auth.RefreshTokenHandler) + c.ath = container.Get(static.DiAuthAccessTokenHandler).(auth.AccessTokenHandler) + c.authMw = container.Get(static.DiAuthMiddleware).(auth.Middleware) + c.st = container.Get(static.DiState).(*dgrs.State) + c.session = container.Get(static.DiDiscordSession).(*discordgo.Session) + c.oauthHandler = container.Get(static.DiOAuthHandler).(auth.RequestHandler) + c.cmdHandler = container.Get(static.DiCommandHandler).(*ken.Ken) + + c.pushcodeSubs = timedmap.New(10 * time.Second) + + router.Get("/login", c.getLogin) + router.Get("/oauthcallback", c.discordOAuth.HandlerCallback) + router.Post("/accesstoken", c.postAccessToken) + router.Post("/pushcode", c.pushCode) + router.Get("/check", c.authMw.Handle, c.getCheck) + router.Post("/logout", c.authMw.Handle, c.postLogout) +} + +func (c *AuthController) getLogin(ctx *fiber.Ctx) error { + state := make(map[string]string) + + if redirect := ctx.Query("redirect"); redirect != "" { + state["redirect"] = redirect + } + + return c.discordOAuth.HandlerInitWithState(ctx, state) +} + +// @Summary Access Token Exchange +// @Description Exchanges the cookie-passed refresh token with a generated access token. +// @Tags Authorization +// @Accept json +// @Produce json +// @Success 200 {object} models.AccessTokenResponse +// @Failure 401 {object} models.Error +// @Router /auth/accesstoken [post] +func (c *AuthController) postAccessToken(ctx *fiber.Ctx) error { + refreshToken := ctx.Cookies(static.RefreshTokenCookieName) + if refreshToken == "" { + return fiber.ErrUnauthorized + } + + ident, err := c.rth.ValidateRefreshToken(refreshToken) + if err != nil && !database.IsErrDatabaseNotFound(err) { + ctlLog.Error().Err(err).Msg("Failed validating refresh token") + } + if ident == "" { + return fiber.ErrUnauthorized + } + + token, expires, err := c.ath.GetAccessToken(ident) + if err != nil { + return err + } + + return ctx.JSON(&models.AccessTokenResponse{ + Token: token, + Expires: expires, + }) +} + +// @Summary Authorization Check +// @Description Returns OK if the request is authorized. +// @Tags Authorization +// @Accept json +// @Produce json +// @Success 200 {object} models.Status +// @Failure 401 {object} models.Error +// @Router /auth/check [get] +func (c *AuthController) getCheck(ctx *fiber.Ctx) error { + return ctx.JSON(models.Ok) +} + +// @Summary Logout +// @Description Reovkes the currently used access token and clears the refresh token. +// @Tags Authorization +// @Accept json +// @Produce json +// @Success 200 {object} models.Status +// @Router /auth/logout [post] +func (c *AuthController) postLogout(ctx *fiber.Ctx) error { + uid := ctx.Locals("uid").(string) + + err := c.rth.RevokeToken(uid) + if err != nil && !database.IsErrDatabaseNotFound(err) { + return err + } + + ctx.ClearCookie(static.RefreshTokenCookieName) + + return ctx.JSON(models.Ok) +} + +// @Summary Pushcode +// @Description Send a login push code resulting in a long-fetch request waiting for the code to be sent to shinpurus DMs. +// @Tags Authorization +// @Accept json +// @Produce json +// @Param payload body models.PushCodeRequest true "The push code." +// @Success 200 {object} models.Status +// @Success 400 {object} models.Status +// @Success 410 {object} models.Status +// @Router /auth/pushcode [post] +func (c *AuthController) pushCode(ctx *fiber.Ctx) (err error) { + var req models.PushCodeRequest + if err = ctx.BodyParser(&req); err != nil { + return + } + + if req.Code == "" { + return fiber.NewError(fiber.StatusBadRequest, "empty code") + } + + ipaddr := ctx.IP() + if ipaddr == "" { + // When the IP address is empty, which might happen, just + // generate a new pcw for each request to avoid conflicts. + ipaddr = xid.New().String() + } + + pcw, ok := c.pushcodeSubs.GetValue(ipaddr).(*pushCodeWaiter) + if !ok { + pcw = new(pushCodeWaiter) + c.pushcodeSubs.Set(ipaddr, pcw, pushcodeTimeout, func(_ any) { + pcw.close() + }) + + pcw.code = req.Code + pcw.fin = make(chan *discordgo.Message) + pcw.subscription = c.st.Subscribe("dms", func(scan func(v any) error) { + var msg discordgo.Message + if err = scan(&msg); err != nil { + ctlLog.Error().Err(err).Msg("failed scanning message from 'dms' event bus") + return + } + if msg.Content == pcw.code && msg.Author != nil { + am, err := acceptmsg.New(). + WithKen(c.cmdHandler). + DeleteAfterAnswer().WithEmbed(&discordgo.MessageEmbed{ + Title: "Login", + Description: "Do you really want to log in to the web interface using this " + + "login code?\n\n⚠️ **Never __ever__ enter a login code here you got from someone else!**\n" + + "If you got this login code from someone else, press `Cancel` or do nothing!", + Color: static.ColorEmbedOrange, + }).WithAcceptButton(discordgo.Button{ + Label: "Accept", + Style: discordgo.SuccessButton, + }).WithDeclineButton(discordgo.Button{ + Label: "Cancel", + Style: discordgo.DangerButton, + }).DoOnAccept(func(ctx ken.ComponentContext) error { + pcw.am = nil + pcw.fin <- &msg + return nil + }).Send(msg.ChannelID) + if err == nil { + pcw.am = am + } + } + }) + } else { + log.Debug().Field("ipaddr", ipaddr).Msg("Reusing pushcode handler for this client") + pcw.code = req.Code + } + + res := <-pcw.fin + if res == nil { + err = fiber.NewError(fiber.StatusGone, "timeout") + return + } + + c.pushcodeSubs.Remove(ipaddr) + if pcw.close() { + util.SendEmbed(c.session, res.ChannelID, + "You are now being logged in!", "", static.ColorEmbedGreen) + } + + err = c.oauthHandler.BindRefreshToken(ctx, res.Author.ID) + if err != nil { + return + } + + return ctx.JSON(models.Ok) +} diff --git a/pkg/discordutil/isession.go b/pkg/discordutil/isession.go index 8bf1598b..400b3e43 100644 --- a/pkg/discordutil/isession.go +++ b/pkg/discordutil/isession.go @@ -206,15 +206,15 @@ type ISession interface { UserChannelPermissions(userID, channelID string, fetchOptions ...RequestOption) (apermissions int64, err error) UserConnections(options ...RequestOption) (conn []*UserConnection, err error) UserGuildMember(guildID string, options ...RequestOption) (st *Member, err error) - UserGuilds(limit int, beforeID, afterID string, options ...RequestOption) (st []*UserGuild, err error) + UserGuilds(limit int, beforeID, afterID string, withCounts bool, options ...RequestOption) (st []*UserGuild, err error) UserUpdate(username, avatar string, options ...RequestOption) (st *User, err error) VoiceRegions(options ...RequestOption) (st []*VoiceRegion, err error) Webhook(webhookID string, options ...RequestOption) (st *Webhook, err error) WebhookCreate(channelID, name, avatar string, options ...RequestOption) (st *Webhook, err error) WebhookDelete(webhookID string, options ...RequestOption) (err error) WebhookDeleteWithToken(webhookID, token string, options ...RequestOption) (st *Webhook, err error) - WebhookEdit(webhookID, name, avatar, channelID string, options ...RequestOption) (st *Role, err error) - WebhookEditWithToken(webhookID, token, name, avatar string, options ...RequestOption) (st *Role, err error) + WebhookEdit(webhookID, name, avatar, channelID string, options ...RequestOption) (st *Webhook, err error) + WebhookEditWithToken(webhookID, token, name, avatar string, options ...RequestOption) (st *Webhook, err error) WebhookExecute(webhookID, token string, wait bool, data *WebhookParams, options ...RequestOption) (st *Message, err error) WebhookMessage(webhookID, token, messageID string, options ...RequestOption) (message *Message, err error) WebhookMessageDelete(webhookID, token, messageID string, options ...RequestOption) (err error)