From 9366f6e56e3cf7406f362d9d102bb2c74b0d2f17 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sat, 22 Jun 2024 18:05:41 +0800 Subject: [PATCH] :arrow_up: Upgrade to support the latest version Hydrogen Project standard --- go.mod | 20 +- go.sum | 182 +++++++++++++++++- pkg/grpc/client.go | 44 ----- pkg/{ => internal}/database/migrator.go | 2 +- pkg/{ => internal}/database/source.go | 0 pkg/{ => internal}/embed.go | 0 pkg/internal/gap/client.go | 12 ++ pkg/internal/gap/net.go | 15 ++ pkg/internal/gap/server.go | 40 ++++ pkg/internal/grpc/health.go | 26 +++ pkg/internal/grpc/server.go | 33 ++++ pkg/{ => internal}/meta.go | 0 pkg/{ => internal}/models/accounts.go | 0 pkg/{ => internal}/models/base.go | 0 pkg/{ => internal}/models/calls.go | 0 pkg/{ => internal}/models/channels.go | 0 pkg/{ => internal}/models/messages.go | 0 pkg/{ => internal}/models/realms.go | 0 pkg/{ => internal}/models/unified.go | 0 pkg/{ => internal}/models/utils.go | 0 .../server/api}/calls_api.go | 8 +- .../server/api}/channel_members_api.go | 15 +- .../server/api}/channels_api.go | 13 +- .../server/api}/direct_channels_api.go | 11 +- pkg/internal/server/api/index.go | 49 +++++ .../server/api}/messages_api.go | 13 +- .../server/api}/messages_ws.go | 6 +- .../server/api}/realms_api.go | 4 +- .../server/api}/users_api.go | 6 +- pkg/internal/server/exts/auth.go | 19 ++ pkg/{server => internal/server/exts}/utils.go | 2 +- pkg/internal/server/server.go | 86 +++++++++ pkg/{ => internal}/services/accounts.go | 20 +- pkg/internal/services/attachments.go | 22 +++ pkg/{ => internal}/services/auth.go | 33 +--- pkg/{ => internal}/services/calls.go | 4 +- .../services/channel_members.go | 4 +- pkg/{ => internal}/services/channels.go | 4 +- pkg/{ => internal}/services/cleaner.go | 2 +- pkg/{ => internal}/services/connections.go | 2 +- pkg/{ => internal}/services/encryptor.go | 0 pkg/{ => internal}/services/jwt.go | 0 pkg/{ => internal}/services/livekit.go | 0 pkg/{ => internal}/services/mailer.go | 0 pkg/{ => internal}/services/messages.go | 4 +- pkg/{ => internal}/services/realms.go | 32 ++- pkg/{ => internal}/views/favicon.png | Bin pkg/{ => internal}/views/index.gohtml | 0 pkg/{ => internal}/views/open.gohtml | 0 pkg/{cmd => }/main.go | 27 +-- pkg/server/auth.go | 54 ------ pkg/server/startup.go | 122 ------------ pkg/server/well_known_api.go | 16 -- pkg/services/attachments.go | 30 --- settings.toml | 6 +- 55 files changed, 603 insertions(+), 385 deletions(-) delete mode 100644 pkg/grpc/client.go rename pkg/{ => internal}/database/migrator.go (85%) rename pkg/{ => internal}/database/source.go (100%) rename pkg/{ => internal}/embed.go (100%) create mode 100644 pkg/internal/gap/client.go create mode 100644 pkg/internal/gap/net.go create mode 100644 pkg/internal/gap/server.go create mode 100644 pkg/internal/grpc/health.go create mode 100644 pkg/internal/grpc/server.go rename pkg/{ => internal}/meta.go (100%) rename pkg/{ => internal}/models/accounts.go (100%) rename pkg/{ => internal}/models/base.go (100%) rename pkg/{ => internal}/models/calls.go (100%) rename pkg/{ => internal}/models/channels.go (100%) rename pkg/{ => internal}/models/messages.go (100%) rename pkg/{ => internal}/models/realms.go (100%) rename pkg/{ => internal}/models/unified.go (100%) rename pkg/{ => internal}/models/utils.go (100%) rename pkg/{server => internal/server/api}/calls_api.go (94%) rename pkg/{server => internal/server/api}/channel_members_api.go (94%) rename pkg/{server => internal/server/api}/channels_api.go (94%) rename pkg/{server => internal/server/api}/direct_channels_api.go (85%) create mode 100644 pkg/internal/server/api/index.go rename pkg/{server => internal/server/api}/messages_api.go (94%) rename pkg/{server => internal/server/api}/messages_ws.go (89%) rename pkg/{server => internal/server/api}/realms_api.go (86%) rename pkg/{server => internal/server/api}/users_api.go (83%) create mode 100644 pkg/internal/server/exts/auth.go rename pkg/{server => internal/server/exts}/utils.go (96%) create mode 100644 pkg/internal/server/server.go rename pkg/{ => internal}/services/accounts.go (67%) create mode 100644 pkg/internal/services/attachments.go rename pkg/{ => internal}/services/auth.go (57%) rename pkg/{ => internal}/services/calls.go (97%) rename pkg/{ => internal}/services/channel_members.go (93%) rename pkg/{ => internal}/services/channels.go (97%) rename pkg/{ => internal}/services/cleaner.go (91%) rename pkg/{ => internal}/services/connections.go (94%) rename pkg/{ => internal}/services/encryptor.go (100%) rename pkg/{ => internal}/services/jwt.go (100%) rename pkg/{ => internal}/services/livekit.go (100%) rename pkg/{ => internal}/services/mailer.go (100%) rename pkg/{ => internal}/services/messages.go (97%) rename pkg/{ => internal}/services/realms.go (63%) rename pkg/{ => internal}/views/favicon.png (100%) rename pkg/{ => internal}/views/index.gohtml (100%) rename pkg/{ => internal}/views/open.gohtml (100%) rename pkg/{cmd => }/main.go (69%) delete mode 100644 pkg/server/auth.go delete mode 100644 pkg/server/startup.go delete mode 100644 pkg/server/well_known_api.go delete mode 100644 pkg/services/attachments.go diff --git a/go.mod b/go.mod index 4b0b514..d4753be 100644 --- a/go.mod +++ b/go.mod @@ -5,13 +5,14 @@ go 1.22 toolchain go1.22.1 require ( - git.solsynth.dev/hydrogen/paperclip v0.0.0-20240520143155-2b131982b821 - git.solsynth.dev/hydrogen/passport v0.0.0-20240607130225-b76e7d41cf36 + git.solsynth.dev/hydrogen/paperclip v0.0.0-20240622051057-0f56dba45745 + git.solsynth.dev/hydrogen/passport v0.0.0-20240622050421-7007cda8f210 github.com/go-playground/validator/v10 v10.17.0 github.com/gofiber/contrib/websocket v1.3.0 github.com/gofiber/fiber/v2 v2.52.4 github.com/gofiber/template/html/v2 v2.1.1 github.com/golang-jwt/jwt/v5 v5.2.0 + github.com/hashicorp/consul/api v1.29.1 github.com/jordan-wright/email v4.0.1-0.20210109023952-943e75fe5223+incompatible github.com/json-iterator/go v1.1.12 github.com/livekit/protocol v1.14.0 @@ -29,6 +30,7 @@ require ( require ( github.com/andybalholm/brotli v1.1.0 // indirect + github.com/armon/go-metrics v0.4.1 // indirect github.com/benbjohnson/clock v1.3.5 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bep/debounce v1.2.1 // indirect @@ -38,6 +40,7 @@ require ( github.com/eapache/channels v1.1.0 // indirect github.com/eapache/queue v1.1.0 // indirect github.com/fasthttp/websocket v1.5.8 // indirect + github.com/fatih/color v1.17.0 // indirect github.com/frostbyte73/core v0.0.10 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/gabriel-vasile/mimetype v1.4.2 // indirect @@ -52,7 +55,15 @@ require ( github.com/gofiber/utils v1.1.0 // indirect github.com/google/uuid v1.6.0 // indirect github.com/gorilla/websocket v1.5.1 // indirect + github.com/hashicorp/errwrap v1.1.0 // indirect + github.com/hashicorp/go-cleanhttp v0.5.2 // indirect + github.com/hashicorp/go-hclog v1.6.3 // indirect + github.com/hashicorp/go-immutable-radix v1.3.1 // indirect + github.com/hashicorp/go-multierror v1.1.1 // indirect + github.com/hashicorp/go-rootcerts v1.0.2 // indirect + github.com/hashicorp/golang-lru v1.0.2 // indirect github.com/hashicorp/hcl v1.0.0 // indirect + github.com/hashicorp/serf v0.10.1 // indirect github.com/jackc/pgpassfile v1.0.0 // indirect github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9 // indirect github.com/jackc/pgx/v5 v5.5.1 // indirect @@ -72,6 +83,7 @@ require ( 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/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect @@ -124,13 +136,13 @@ require ( go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect go.uber.org/zap/exp v0.2.0 // indirect - golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect + golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect golang.org/x/net v0.26.0 // indirect golang.org/x/sync v0.7.0 // indirect golang.org/x/sys v0.21.0 // indirect golang.org/x/text v0.16.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117 // indirect - google.golang.org/protobuf v1.34.1 // indirect + google.golang.org/protobuf v1.34.2 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect gorm.io/driver/mysql v1.5.2 // indirect diff --git a/go.sum b/go.sum index 9b9f845..d4e2a2d 100644 --- a/go.sum +++ b/go.sum @@ -1,21 +1,38 @@ -git.solsynth.dev/hydrogen/paperclip v0.0.0-20240520143155-2b131982b821 h1:azsoKVRp239SkfLU6yg6LkMc2t39vRr6aYCEVstKnms= -git.solsynth.dev/hydrogen/paperclip v0.0.0-20240520143155-2b131982b821/go.mod h1:uTNEtJcNdgt7DhOgsewPaLQQ5kTN9H+tGNRT2CshHGs= -git.solsynth.dev/hydrogen/passport v0.0.0-20240607130225-b76e7d41cf36 h1:L/dlFeiIr3WB22y15FP8LVe/ylrJzu7+8SzejcFg7nI= -git.solsynth.dev/hydrogen/passport v0.0.0-20240607130225-b76e7d41cf36/go.mod h1:UuE3QXf2540Xs1GmViUSZ3V0ILtiYePZ5iXfZhzlSo4= +git.solsynth.dev/hydrogen/paperclip v0.0.0-20240622051057-0f56dba45745 h1:40BUsQMNXjqHyytkyF9py1HjTAWlRgO6R57YXUrHNy4= +git.solsynth.dev/hydrogen/paperclip v0.0.0-20240622051057-0f56dba45745/go.mod h1:FsQGSLTl0gvo+9Jmbot02S72suyF9tFTrzDj70Xhifo= +git.solsynth.dev/hydrogen/passport v0.0.0-20240622050421-7007cda8f210 h1:DM4AVhG/l3cOfmhA5IDFgn120BL2PEATnPQDtINIS/Q= +git.solsynth.dev/hydrogen/passport v0.0.0-20240622050421-7007cda8f210/go.mod h1:XTNEOv75sZI52sNgpum7Z/tgYmlRcHfK7VdhyV7kc0w= +github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= +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/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M= github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY= +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-metrics v0.4.1 h1:hR91U9KYmb6bLBYLQjyM+3j+rcd/UhE+G78SFnF8gJA= +github.com/armon/go-metrics v0.4.1/go.mod h1:E6amYzXo6aW1tqzoZGT755KkbgrJsSdpwZ+3JqfkOG4= +github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/benbjohnson/clock v1.3.5 h1:VvXlSJBzZpA/zum6Sj74hxwYI2DIxRWuNIoXAzHZz5o= github.com/benbjohnson/clock v1.3.5/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= +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/bep/debounce v1.2.1 h1:v67fRdBA9UQu2NhLFXrSg0Brw7CexQekrBwDMM8bzeY= github.com/bep/debounce v1.2.1/go.mod h1:H8yggRPQKLUhUoqrJC1bO2xNya7vanpDl7xR3ISbCJ0= +github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs= github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c= github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA= github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0= +github.com/cespare/xxhash/v2 v2.1.1/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/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= +github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -29,6 +46,11 @@ github.com/eapache/queue v1.1.0 h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= github.com/fasthttp/websocket v1.5.8 h1:k5DpirKkftIF/w1R8ZzjSgARJrs54Je9YJK37DL/Ah8= github.com/fasthttp/websocket v1.5.8/go.mod h1:d08g8WaT6nnyvg9uMm8K9zMYyDjfKyj3170AtPRuVU0= +github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= +github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= +github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4= +github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI= github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/frostbyte73/core v0.0.10 h1:D4DQXdPb8ICayz0n75rs4UYTXrUSdxzUfeleuNJORsU= @@ -43,6 +65,10 @@ github.com/gammazero/deque v0.2.1 h1:qSdsbG6pgp6nL7A0+K/B7s12mcCY/5l5SIUpMOl+dC0 github.com/gammazero/deque v0.2.1/go.mod h1:LFroj8x4cMYCukHJDbxFCkT+r9AndaJnFMuZDV34tuU= github.com/go-jose/go-jose/v3 v3.0.3 h1:fFKWeig/irsp7XD2zBxvnmA/XaRWp5V3CBsZXJF7G7k= github.com/go-jose/go-jose/v3 v3.0.3/go.mod h1:5b+7YgP7ZICgJDBdfjZaIt+H/9L9T/YQrVfLAMboGkQ= +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-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-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= @@ -59,6 +85,7 @@ github.com/go-playground/validator/v10 v10.17.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QX github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= 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-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= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gofiber/contrib/websocket v1.3.0 h1:XADFAGorer1VJ1bqC4UkCjqS37kwRTV0415+050NrMk= @@ -71,6 +98,7 @@ github.com/gofiber/template/html/v2 v2.1.1 h1:QEy3O3EBkvwDthy5bXVGUseOyO6ldJoiDx github.com/gofiber/template/html/v2 v2.1.1/go.mod h1:2G0GHHOUx70C1LDncoBpe4T6maQbNa4x1CVNFW0wju0= github.com/gofiber/utils v1.1.0 h1:vdEBpn7AzIUJRhe+CiTOJdUcTg4Q9RK+pEa0KPbLdrM= github.com/gofiber/utils v1.1.0/go.mod h1:poZpsnhBykfnY1Mc0KeEa6mSHrS3dV0+oBWyeQmb2e0= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/golang-jwt/jwt/v5 v5.2.0 h1:d/ix8ftRUorsN+5eMIlF4T6J8CAt9rch3My2winC1Jw= github.com/golang-jwt/jwt/v5 v5.2.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 h1:au07oEsX2xN0ktxqI+Sida1w446QrXBRJ0nee3SNZlA= @@ -78,6 +106,8 @@ github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9/go.mod h1:8vg3r2V github.com/golang-sql/sqlexp v0.1.0 h1:ZCD6MBpcuOVfGVqsEmY5/4FtYiKz6tSyUv9LPEDei6A= github.com/golang-sql/sqlexp v0.1.0/go.mod h1:J4ad9Vo8ZCWQ2GMrC4UCQy1JpCbwU9m3EOqtpKwwwHI= 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/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= @@ -86,6 +116,9 @@ github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvq github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.0.1 h1:gK4Kx5IaGY9CD5sPJ36FHiBJ6ZXl0kilRiiCj+jdYp4= +github.com/google/btree v1.0.1/go.mod h1:xXMiIv4Fb/0kKde4SpL7qlzvu5cMJDRkFDxJfI9uaxA= 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/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= @@ -100,8 +133,54 @@ 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/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= +github.com/hashicorp/consul/api v1.29.1 h1:UEwOjYJrd3lG1x5w7HxDRMGiAUPrb3f103EoeKuuEcc= +github.com/hashicorp/consul/api v1.29.1/go.mod h1:lumfRkY/coLuqMICkI7Fh3ylMG31mQSRZyef2c5YvJI= +github.com/hashicorp/consul/proto-public v0.6.1 h1:+uzH3olCrksXYWAYHKqK782CtK9scfqH+Unlw3UHhCg= +github.com/hashicorp/consul/proto-public v0.6.1/go.mod h1:cXXbOg74KBNGajC+o8RlA502Esf0R9prcoJgiOX/2Tg= +github.com/hashicorp/consul/sdk v0.16.1 h1:V8TxTnImoPD5cj0U9Spl0TUxcytjcbbJeADFF07KdHg= +github.com/hashicorp/consul/sdk v0.16.1/go.mod h1:fSXvwxB2hmh1FMZCNl6PwX0Q/1wdWtHJcZ7Ea5tns0s= +github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= +github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= +github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= +github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k= +github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= +github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= +github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc= +github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= +github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= +github.com/hashicorp/go-msgpack v0.5.5 h1:i9R9JSrqIz0QVLz3sz+i3YJdT7TTSLcfLLzJi9aZTuI= +github.com/hashicorp/go-msgpack v0.5.5/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= +github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= +github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+vmowP0z+KUhOZdA= +github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= +github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= +github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= +github.com/hashicorp/go-rootcerts v1.0.2 h1:jzhAVGtqPKbwpyCPELlgNWhE1znq+qwJtW5Oi2viEzc= +github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= +github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= +github.com/hashicorp/go-sockaddr v1.0.2 h1:ztczhD1jLxIRjVejw8gFomI1BQZOe2WoVOu0SyteCQc= +github.com/hashicorp/go-sockaddr v1.0.2/go.mod h1:rB4wwRAUzs07qva3c5SdrY/NEtAUjGlgmH/UkBUC97A= +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-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= +github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= +github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iPY6p1c= +github.com/hashicorp/golang-lru v1.0.2/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= +github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= +github.com/hashicorp/mdns v1.0.4/go.mod h1:mtBihi+LeNXGtG8L9dX59gAEa12BDtBQSp4v/YAJqrc= +github.com/hashicorp/memberlist v0.5.0 h1:EtYPN8DpAURiapus508I4n9CzHs2W+8NZGbmmR/prTM= +github.com/hashicorp/memberlist v0.5.0/go.mod h1:yvyXLpo0QaGE59Y7hDTsTzDD25JYBZ4mHgHUZ8lrOI0= +github.com/hashicorp/serf v0.10.1 h1:Z1H2J60yRKvfDYAOZLd2MU0ND4AH/WDz7xYHDWQsIPY= +github.com/hashicorp/serf v0.10.1/go.mod h1:yL2t6BqATOLGc5HF7qbFkTfXoPIY0WZdWHfEvMqbG+4= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= @@ -117,14 +196,19 @@ github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= github.com/jordan-wright/email v4.0.1-0.20210109023952-943e75fe5223+incompatible h1:jdpOPRN1zP63Td1hDQbZW73xKmzDvZHzVdNYxhnTMDA= github.com/jordan-wright/email v4.0.1-0.20210109023952-943e75fe5223+incompatible/go.mod h1:1c7szIrayyPPB/987hsnvNzLushdWf4o/79s3P08L8A= +github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/jxskiss/base62 v1.1.0 h1:A5zbF8v8WXx2xixnAKD2w+abC+sIzYJX+nxmhA6HWFw= github.com/jxskiss/base62 v1.1.0/go.mod h1:HhWAlUXvxKThfOlZbcuFzsqwtF5TcqS9ru3y5GfjWAc= github.com/klauspost/compress v1.17.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0NAMnU= github.com/klauspost/compress v1.17.8/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM= github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/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/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= @@ -150,8 +234,18 @@ github.com/magefile/mage v1.15.0 h1:BvGheCMAsG3bWUDbZ8AyXXpCNwU9u5CB6sM+HNb9HYg= github.com/magefile/mage v1.15.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= +github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= +github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= +github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= @@ -160,15 +254,26 @@ github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZ github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-sqlite3 v1.14.15 h1:vfoHhTN1af61xCRSWzFIWzx2YskyMTwHLrExkBOjvxI= github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= +github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/microsoft/go-mssqldb v0.17.0 h1:Fto83dMZPnYv1Zwx5vHHxpNraeEaUlQ/hhHLgZiaenE= github.com/microsoft/go-mssqldb v0.17.0/go.mod h1:OkoNGhGEs8EZqchVTtochlXruEhEOaO4S0d2sB5aeGQ= +github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= +github.com/miekg/dns v1.1.41 h1:WMszZWJG0XmzbK9FEmzH2TVcqYzFesusSIB41b8KHxY= +github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI= +github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI= +github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= +github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= 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/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/nats-io/nats.go v1.31.0 h1:/WFBHEc/dOKBF6qf1TZhrdEfTmOZ5JzdJ+Y3m6Y/p7E= github.com/nats-io/nats.go v1.31.0/go.mod h1:di3Bm5MLsoB4Bx61CBTsxuarI36WbhAwOm8QrW39+i8= github.com/nats-io/nkeys v0.4.6 h1:IzVe95ru2CT6ta874rt9saQRkWfe2nFj1NtvYSLqMzY= @@ -184,6 +289,9 @@ github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042 github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= +github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= +github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pelletier/go-toml/v2 v2.1.1 h1:LWAJwfNvjQZCFIDKWYQaM62NcYeYViCmWIwmOStowAI= github.com/pelletier/go-toml/v2 v2.1.1/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= github.com/philhofer/fwd v1.1.2 h1:bnDivRJ1EWPjUIRXV5KfORO897HTbpFAQddBdE8t7Gw= @@ -232,17 +340,32 @@ github.com/pion/turn/v2 v2.1.3 h1:pYxTVWG2gpC97opdRc5IGsQ1lJ9O/IlNhkzj7MMrGAA= github.com/pion/turn/v2 v2.1.3/go.mod h1:huEpByKKHix2/b9kmTAM3YoX6MKP+/D//0ClgUYR2fY= github.com/pion/webrtc/v3 v3.2.28 h1:ienStxZ6HcjtH2UlmnFpMM0loENiYjaX437uIUpQSKo= github.com/pion/webrtc/v3 v3.2.28/go.mod h1:PNRCEuQlibrmuBhOTnol9j6KkIbUG11aHLEfNpUYey0= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= +github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= +github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= +github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU= github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k= +github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= 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/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.48.0 h1:QO8U2CdOzSn1BBsmXJXduaaW+dY/5QLjfB8svtSzKKE= github.com/prometheus/common v0.48.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= +github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/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/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= github.com/puzpuzpuz/xsync/v3 v3.1.0 h1:EewKT7/LNac5SLiEblJeUu8z5eERHrmRLnMQL2d7qX4= @@ -259,6 +382,7 @@ github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUz github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.31.0 h1:FcTR3NnLWW+NnTwwhFWiJSZr4ECLpqCm6QsEnyvbV4A= github.com/rs/zerolog v1.31.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= +github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ= github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4= github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE= @@ -268,6 +392,10 @@ github.com/samber/lo v1.39.0/go.mod h1:+m/ZKRl6ClXCE2Lgf3MsQlWfh4bn1bz6CXEOxnEXn github.com/savsgio/gotils v0.0.0-20240303185622-093b76447511 h1:KanIMPX0QdEdB4R3CiimCAbxFrhB3j7h0/OvpYGVQa8= github.com/savsgio/gotils v0.0.0-20240303185622-093b76447511/go.mod h1:sM7Mt7uEoCeFSCBM+qBrqvEo+/9vdmj19wzp3yzUhmg= github.com/sclevine/agouti v3.0.0+incompatible/go.mod h1:b4WX9W9L1sfQKXeJf1mUTLZKJ48R1S7H23Ji7oFO5Bw= +github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I= +github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0= github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8= @@ -279,13 +407,18 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An github.com/spf13/viper v1.18.2 h1:LUXCnvUvSM6FXAsj6nnfc8Q2tp1dIgUfY9Kc8GsSOiQ= github.com/spf13/viper v1.18.2/go.mod h1:EKmWIqdnk5lOcmR72yw6hS+8OPYcwD0jteitLMVB+yk= 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.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +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 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.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= @@ -299,6 +432,7 @@ github.com/thoas/go-funk v0.9.3 h1:7+nAEx3kn5ZJcnDm2Bh23N2yOtweO14bi//dvRtgLpw= github.com/thoas/go-funk v0.9.3/go.mod h1:+IWnUfUmFO1+WVYQWQtIJHeRRdaIyyYglZN7xzUPe4Q= github.com/tinylib/msgp v1.1.8 h1:FCXC1xanKO4I8plpHGH2P7koL/RzZs12l/+r7vakfm0= github.com/tinylib/msgp v1.1.8/go.mod h1:qkpG+2ldGg4xRFmx+jfTvZPxfGFhi64BcnL9vkCm/Tw= +github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/twitchtv/twirp v8.1.3+incompatible h1:+F4TdErPgSUbMZMwp13Q/KgDVuI7HJXP61mNV3/7iuU= github.com/twitchtv/twirp v8.1.3+incompatible/go.mod h1:RRJoFSAmTEh2weEqWtpPE3vFK5YBhA6bqp2l1kfCC5A= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= @@ -323,7 +457,9 @@ go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= go.uber.org/zap/exp v0.2.0 h1:FtGenNNeCATRB3CmB/yEUnjEFeJWpB/pMcy7e2bKPYs= go.uber.org/zap/exp v0.2.0/go.mod h1:t0gqAIdh1MfKv9EwN/dLwfZnJxe9ITAZN78HEWPFWDQ= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/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-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= @@ -334,18 +470,22 @@ golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1m golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= -golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 h1:LfspQV/FYTatPTr/3HzIcmiUFH7PGP+OQ6mgDYo3yuQ= -golang.org/x/exp v0.0.0-20240222234643-814bf88cf225/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= +golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 h1:yixxcjnhBmY0nkL253HFVIm0JsFHwrHdT3Yh6szTnfY= +golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/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-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +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-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8= golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= @@ -359,26 +499,47 @@ golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= 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-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/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= golang.org/x/sync v0.7.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-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-20181116152217-5ac8a444bdc5/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-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-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -407,6 +568,7 @@ golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY= golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= 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/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= @@ -420,6 +582,7 @@ golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= @@ -441,8 +604,9 @@ google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzi google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= -google.golang.org/protobuf v1.34.1/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/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= @@ -451,8 +615,10 @@ gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMy gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +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.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/pkg/grpc/client.go b/pkg/grpc/client.go deleted file mode 100644 index 81d2486..0000000 --- a/pkg/grpc/client.go +++ /dev/null @@ -1,44 +0,0 @@ -package grpc - -import ( - pcpb "git.solsynth.dev/hydrogen/paperclip/pkg/grpc/proto" - idpb "git.solsynth.dev/hydrogen/passport/pkg/grpc/proto" - "google.golang.org/grpc/credentials/insecure" - - "github.com/spf13/viper" - "google.golang.org/grpc" -) - -var Attachments pcpb.AttachmentsClient - -func ConnectPaperclip() error { - addr := viper.GetString("paperclip.grpc_endpoint") - if conn, err := grpc.Dial(addr, grpc.WithTransportCredentials(insecure.NewCredentials())); err != nil { - return err - } else { - Attachments = pcpb.NewAttachmentsClient(conn) - } - - return nil -} - -var ( - Realms idpb.RealmsClient - Friendships idpb.FriendshipsClient - Notify idpb.NotifyClient - Auth idpb.AuthClient -) - -func ConnectPassport() error { - addr := viper.GetString("passport.grpc_endpoint") - if conn, err := grpc.Dial(addr, grpc.WithTransportCredentials(insecure.NewCredentials())); err != nil { - return err - } else { - Realms = idpb.NewRealmsClient(conn) - Friendships = idpb.NewFriendshipsClient(conn) - Notify = idpb.NewNotifyClient(conn) - Auth = idpb.NewAuthClient(conn) - } - - return nil -} diff --git a/pkg/database/migrator.go b/pkg/internal/database/migrator.go similarity index 85% rename from pkg/database/migrator.go rename to pkg/internal/database/migrator.go index 4903fef..48a1894 100644 --- a/pkg/database/migrator.go +++ b/pkg/internal/database/migrator.go @@ -1,7 +1,7 @@ package database import ( - "git.solsynth.dev/hydrogen/messaging/pkg/models" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/models" "gorm.io/gorm" ) diff --git a/pkg/database/source.go b/pkg/internal/database/source.go similarity index 100% rename from pkg/database/source.go rename to pkg/internal/database/source.go diff --git a/pkg/embed.go b/pkg/internal/embed.go similarity index 100% rename from pkg/embed.go rename to pkg/internal/embed.go diff --git a/pkg/internal/gap/client.go b/pkg/internal/gap/client.go new file mode 100644 index 0000000..6a6a39e --- /dev/null +++ b/pkg/internal/gap/client.go @@ -0,0 +1,12 @@ +package gap + +import ( + "git.solsynth.dev/hydrogen/passport/pkg/hyper" + "github.com/spf13/viper" +) + +var H *hyper.HyperConn + +func NewHyperClient() { + H = hyper.NewHyperConn(viper.GetString("consul.addr")) +} diff --git a/pkg/internal/gap/net.go b/pkg/internal/gap/net.go new file mode 100644 index 0000000..d618851 --- /dev/null +++ b/pkg/internal/gap/net.go @@ -0,0 +1,15 @@ +package gap + +import "net" + +func GetOutboundIP() (net.IP, error) { + conn, err := net.Dial("udp", "1.1.1.1:80") + if err != nil { + return nil, err + } else { + defer conn.Close() + } + + localAddr := conn.LocalAddr().(*net.UDPAddr) + return localAddr.IP, nil +} diff --git a/pkg/internal/gap/server.go b/pkg/internal/gap/server.go new file mode 100644 index 0000000..60a07dd --- /dev/null +++ b/pkg/internal/gap/server.go @@ -0,0 +1,40 @@ +package gap + +import ( + "fmt" + "strconv" + "strings" + + "github.com/hashicorp/consul/api" + "github.com/spf13/viper" +) + +func Register() error { + cfg := api.DefaultConfig() + cfg.Address = viper.GetString("consul.addr") + + client, err := api.NewClient(cfg) + if err != nil { + return err + } + + httpBind := strings.SplitN(viper.GetString("bind"), ":", 2) + grpcBind := strings.SplitN(viper.GetString("grpc_bind"), ":", 2) + + outboundIp, _ := GetOutboundIP() + port, _ := strconv.Atoi(httpBind[1]) + + registration := new(api.AgentServiceRegistration) + registration.ID = viper.GetString("id") + registration.Name = "Hydrogen.Messaging" + registration.Address = outboundIp.String() + registration.Port = port + registration.Check = &api.AgentServiceCheck{ + GRPC: fmt.Sprintf("%s:%s", outboundIp, grpcBind[1]), + Timeout: "5s", + Interval: "1m", + DeregisterCriticalServiceAfter: "3m", + } + + return client.Agent().ServiceRegister(registration) +} diff --git a/pkg/internal/grpc/health.go b/pkg/internal/grpc/health.go new file mode 100644 index 0000000..d71549a --- /dev/null +++ b/pkg/internal/grpc/health.go @@ -0,0 +1,26 @@ +package grpc + +import ( + "context" + health "google.golang.org/grpc/health/grpc_health_v1" + "time" +) + +func (v *Server) Check(ctx context.Context, request *health.HealthCheckRequest) (*health.HealthCheckResponse, error) { + return &health.HealthCheckResponse{ + Status: health.HealthCheckResponse_SERVING, + }, nil +} + +func (v *Server) Watch(request *health.HealthCheckRequest, server health.Health_WatchServer) error { + for { + if server.Send(&health.HealthCheckResponse{ + Status: health.HealthCheckResponse_SERVING, + }) != nil { + break + } + time.Sleep(1000 * time.Millisecond) + } + + return nil +} diff --git a/pkg/internal/grpc/server.go b/pkg/internal/grpc/server.go new file mode 100644 index 0000000..e6de4f0 --- /dev/null +++ b/pkg/internal/grpc/server.go @@ -0,0 +1,33 @@ +package grpc + +import ( + "git.solsynth.dev/hydrogen/paperclip/pkg/proto" + "github.com/spf13/viper" + "google.golang.org/grpc" + health "google.golang.org/grpc/health/grpc_health_v1" + "google.golang.org/grpc/reflection" + "net" +) + +type Server struct { + proto.UnimplementedAttachmentsServer +} + +var S *grpc.Server + +func NewGRPC() { + S = grpc.NewServer() + + health.RegisterHealthServer(S, &Server{}) + + reflection.Register(S) +} + +func ListenGRPC() error { + listener, err := net.Listen("tcp", viper.GetString("grpc_bind")) + if err != nil { + return err + } + + return S.Serve(listener) +} diff --git a/pkg/meta.go b/pkg/internal/meta.go similarity index 100% rename from pkg/meta.go rename to pkg/internal/meta.go diff --git a/pkg/models/accounts.go b/pkg/internal/models/accounts.go similarity index 100% rename from pkg/models/accounts.go rename to pkg/internal/models/accounts.go diff --git a/pkg/models/base.go b/pkg/internal/models/base.go similarity index 100% rename from pkg/models/base.go rename to pkg/internal/models/base.go diff --git a/pkg/models/calls.go b/pkg/internal/models/calls.go similarity index 100% rename from pkg/models/calls.go rename to pkg/internal/models/calls.go diff --git a/pkg/models/channels.go b/pkg/internal/models/channels.go similarity index 100% rename from pkg/models/channels.go rename to pkg/internal/models/channels.go diff --git a/pkg/models/messages.go b/pkg/internal/models/messages.go similarity index 100% rename from pkg/models/messages.go rename to pkg/internal/models/messages.go diff --git a/pkg/models/realms.go b/pkg/internal/models/realms.go similarity index 100% rename from pkg/models/realms.go rename to pkg/internal/models/realms.go diff --git a/pkg/models/unified.go b/pkg/internal/models/unified.go similarity index 100% rename from pkg/models/unified.go rename to pkg/internal/models/unified.go diff --git a/pkg/models/utils.go b/pkg/internal/models/utils.go similarity index 100% rename from pkg/models/utils.go rename to pkg/internal/models/utils.go diff --git a/pkg/server/calls_api.go b/pkg/internal/server/api/calls_api.go similarity index 94% rename from pkg/server/calls_api.go rename to pkg/internal/server/api/calls_api.go index 20b1869..793565a 100644 --- a/pkg/server/calls_api.go +++ b/pkg/internal/server/api/calls_api.go @@ -1,9 +1,9 @@ -package server +package api import ( - "git.solsynth.dev/hydrogen/messaging/pkg/database" - "git.solsynth.dev/hydrogen/messaging/pkg/models" - "git.solsynth.dev/hydrogen/messaging/pkg/services" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/database" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/models" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/services" "github.com/gofiber/fiber/v2" "github.com/spf13/viper" ) diff --git a/pkg/server/channel_members_api.go b/pkg/internal/server/api/channel_members_api.go similarity index 94% rename from pkg/server/channel_members_api.go rename to pkg/internal/server/api/channel_members_api.go index d513d0b..03fe070 100644 --- a/pkg/server/channel_members_api.go +++ b/pkg/internal/server/api/channel_members_api.go @@ -1,11 +1,12 @@ -package server +package api import ( "fmt" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/server/exts" - "git.solsynth.dev/hydrogen/messaging/pkg/database" - "git.solsynth.dev/hydrogen/messaging/pkg/models" - "git.solsynth.dev/hydrogen/messaging/pkg/services" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/database" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/models" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/services" "github.com/gofiber/fiber/v2" ) @@ -60,7 +61,7 @@ func addChannelMember(c *fiber.Ctx) error { Target string `json:"target" validate:"required"` } - if err := BindAndValidate(c, &data); err != nil { + if err := exts.BindAndValidate(c, &data); err != nil { return err } @@ -101,7 +102,7 @@ func removeChannelMember(c *fiber.Ctx) error { Target string `json:"target" validate:"required"` } - if err := BindAndValidate(c, &data); err != nil { + if err := exts.BindAndValidate(c, &data); err != nil { return err } @@ -144,7 +145,7 @@ func editMyChannelMembership(c *fiber.Ctx) error { NotifyLevel int8 `json:"notify_level"` } - if err := BindAndValidate(c, &data); err != nil { + if err := exts.BindAndValidate(c, &data); err != nil { return err } diff --git a/pkg/server/channels_api.go b/pkg/internal/server/api/channels_api.go similarity index 94% rename from pkg/server/channels_api.go rename to pkg/internal/server/api/channels_api.go index a51660a..2fbf1bf 100644 --- a/pkg/server/channels_api.go +++ b/pkg/internal/server/api/channels_api.go @@ -1,11 +1,12 @@ -package server +package api import ( "fmt" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/server/exts" - "git.solsynth.dev/hydrogen/messaging/pkg/database" - "git.solsynth.dev/hydrogen/messaging/pkg/models" - "git.solsynth.dev/hydrogen/messaging/pkg/services" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/database" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/models" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/services" "github.com/gofiber/fiber/v2" ) @@ -103,7 +104,7 @@ func createChannel(c *fiber.Ctx) error { IsEncrypted bool `json:"is_encrypted"` } - if err := BindAndValidate(c, &data); err != nil { + if err := exts.BindAndValidate(c, &data); err != nil { return err } else if err = services.GetChannelAliasAvailability(data.Alias); err != nil { return fiber.NewError(fiber.StatusBadRequest, err.Error()) @@ -155,7 +156,7 @@ func editChannel(c *fiber.Ctx) error { IsEncrypted bool `json:"is_encrypted"` } - if err := BindAndValidate(c, &data); err != nil { + if err := exts.BindAndValidate(c, &data); err != nil { return err } diff --git a/pkg/server/direct_channels_api.go b/pkg/internal/server/api/direct_channels_api.go similarity index 85% rename from pkg/server/direct_channels_api.go rename to pkg/internal/server/api/direct_channels_api.go index c3a4b66..230d376 100644 --- a/pkg/server/direct_channels_api.go +++ b/pkg/internal/server/api/direct_channels_api.go @@ -1,11 +1,12 @@ -package server +package api import ( "fmt" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/server/exts" - "git.solsynth.dev/hydrogen/messaging/pkg/database" - "git.solsynth.dev/hydrogen/messaging/pkg/models" - "git.solsynth.dev/hydrogen/messaging/pkg/services" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/database" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/models" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/services" "github.com/gofiber/fiber/v2" ) @@ -20,7 +21,7 @@ func createDirectChannel(c *fiber.Ctx) error { IsEncrypted bool `json:"is_encrypted"` } - if err := BindAndValidate(c, &data); err != nil { + if err := exts.BindAndValidate(c, &data); err != nil { return err } else if err = services.GetChannelAliasAvailability(data.Alias); err != nil { return fiber.NewError(fiber.StatusBadRequest, err.Error()) diff --git a/pkg/internal/server/api/index.go b/pkg/internal/server/api/index.go new file mode 100644 index 0000000..dd4da17 --- /dev/null +++ b/pkg/internal/server/api/index.go @@ -0,0 +1,49 @@ +package api + +import ( + "github.com/gofiber/contrib/websocket" + "github.com/gofiber/fiber/v2" +) + +func MapAPIs(app *fiber.App) { + api := app.Group("/api").Name("API") + { + api.Get("/users/me", getUserinfo) + api.Get("/users/:accountId", getOthersInfo) + + channels := api.Group("/channels/:realm").Use(realmMiddleware).Name("Channels API") + { + channels.Get("/", listChannel) + channels.Get("/me", listOwnedChannel) + channels.Get("/me/available", listAvailableChannel) + channels.Get("/:channel", getChannel) + channels.Get("/:channel/me", getChannelIdentity) + + channels.Post("/", createChannel) + channels.Post("/dm", createDirectChannel) + channels.Put("/:channelId", editChannel) + channels.Delete("/:channelId", deleteChannel) + + channels.Get("/:channel/members", listChannelMembers) + channels.Get("/:channel/members/me", getMyChannelMembership) + channels.Put("/:channel/members/me", editMyChannelMembership) + channels.Post("/:channel/members", addChannelMember) + channels.Post("/:channel/members/me", joinChannel) + channels.Delete("/:channel/members", removeChannelMember) + channels.Delete("/:channel/members/me", leaveChannel) + + channels.Get("/:channel/messages", listMessage) + channels.Post("/:channel/messages", newMessage) + channels.Put("/:channel/messages/:messageId", editMessage) + channels.Delete("/:channel/messages/:messageId", deleteMessage) + + channels.Get("/:channel/calls", listCall) + channels.Get("/:channel/calls/ongoing", getOngoingCall) + channels.Post("/:channel/calls", startCall) + channels.Delete("/:channel/calls/ongoing", endCall) + channels.Post("/:channel/calls/ongoing/token", exchangeCallToken) + } + + api.Get("/ws", websocket.New(messageGateway)) + } +} diff --git a/pkg/server/messages_api.go b/pkg/internal/server/api/messages_api.go similarity index 94% rename from pkg/server/messages_api.go rename to pkg/internal/server/api/messages_api.go index 99150a6..b6dc6dc 100644 --- a/pkg/server/messages_api.go +++ b/pkg/internal/server/api/messages_api.go @@ -1,10 +1,11 @@ -package server +package api import ( "fmt" - "git.solsynth.dev/hydrogen/messaging/pkg/database" - "git.solsynth.dev/hydrogen/messaging/pkg/models" - "git.solsynth.dev/hydrogen/messaging/pkg/services" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/database" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/models" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/server/exts" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/services" "github.com/gofiber/fiber/v2" "strings" ) @@ -52,7 +53,7 @@ func newMessage(c *fiber.Ctx) error { ReplyTo *uint `json:"reply_to"` } - if err := BindAndValidate(c, &data); err != nil { + if err := exts.BindAndValidate(c, &data); err != nil { return err } else if len(data.Uuid) < 36 { return fiber.NewError(fiber.StatusBadRequest, "message uuid was not valid") @@ -131,7 +132,7 @@ func editMessage(c *fiber.Ctx) error { ReplyTo *uint `json:"reply_to"` } - if err := BindAndValidate(c, &data); err != nil { + if err := exts.BindAndValidate(c, &data); err != nil { return err } diff --git a/pkg/server/messages_ws.go b/pkg/internal/server/api/messages_ws.go similarity index 89% rename from pkg/server/messages_ws.go rename to pkg/internal/server/api/messages_ws.go index ac66e1e..fcc2870 100644 --- a/pkg/server/messages_ws.go +++ b/pkg/internal/server/api/messages_ws.go @@ -1,8 +1,8 @@ -package server +package api import ( - "git.solsynth.dev/hydrogen/messaging/pkg/models" - "git.solsynth.dev/hydrogen/messaging/pkg/services" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/models" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/services" "github.com/gofiber/contrib/websocket" jsoniter "github.com/json-iterator/go" "github.com/rs/zerolog/log" diff --git a/pkg/server/realms_api.go b/pkg/internal/server/api/realms_api.go similarity index 86% rename from pkg/server/realms_api.go rename to pkg/internal/server/api/realms_api.go index 970bf89..b2653b4 100644 --- a/pkg/server/realms_api.go +++ b/pkg/internal/server/api/realms_api.go @@ -1,8 +1,8 @@ -package server +package api import ( "fmt" - "git.solsynth.dev/hydrogen/messaging/pkg/services" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/services" "github.com/gofiber/fiber/v2" ) diff --git a/pkg/server/users_api.go b/pkg/internal/server/api/users_api.go similarity index 83% rename from pkg/server/users_api.go rename to pkg/internal/server/api/users_api.go index 5ad9a10..4d3df2c 100644 --- a/pkg/server/users_api.go +++ b/pkg/internal/server/api/users_api.go @@ -1,8 +1,8 @@ -package server +package api import ( - "git.solsynth.dev/hydrogen/messaging/pkg/database" - "git.solsynth.dev/hydrogen/messaging/pkg/models" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/database" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/models" "github.com/gofiber/fiber/v2" ) diff --git a/pkg/internal/server/exts/auth.go b/pkg/internal/server/exts/auth.go new file mode 100644 index 0000000..fd0e0fa --- /dev/null +++ b/pkg/internal/server/exts/auth.go @@ -0,0 +1,19 @@ +package exts + +import ( + "git.solsynth.dev/hydrogen/messaging/pkg/internal/services" + "git.solsynth.dev/hydrogen/passport/pkg/proto" + "github.com/gofiber/fiber/v2" +) + +func LinkAccountMiddleware(c *fiber.Ctx) error { + if val, ok := c.Locals("p_user").(*proto.Userinfo); ok { + if account, err := services.LinkAccount(val); err != nil { + return fiber.NewError(fiber.StatusInternalServerError, err.Error()) + } else { + c.Locals("user", account) + } + } + + return c.Next() +} diff --git a/pkg/server/utils.go b/pkg/internal/server/exts/utils.go similarity index 96% rename from pkg/server/utils.go rename to pkg/internal/server/exts/utils.go index 8502c7f..f34e873 100644 --- a/pkg/server/utils.go +++ b/pkg/internal/server/exts/utils.go @@ -1,4 +1,4 @@ -package server +package exts import ( "github.com/go-playground/validator/v10" diff --git a/pkg/internal/server/server.go b/pkg/internal/server/server.go new file mode 100644 index 0000000..a35d8a1 --- /dev/null +++ b/pkg/internal/server/server.go @@ -0,0 +1,86 @@ +package server + +import ( + "git.solsynth.dev/hydrogen/messaging/pkg/internal" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/gap" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/server/api" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/server/exts" + "net/http" + "strings" + + "github.com/gofiber/fiber/v2/middleware/favicon" + + "github.com/gofiber/fiber/v2" + "github.com/gofiber/fiber/v2/middleware/cors" + "github.com/gofiber/fiber/v2/middleware/idempotency" + "github.com/gofiber/fiber/v2/middleware/logger" + "github.com/gofiber/template/html/v2" + jsoniter "github.com/json-iterator/go" + "github.com/rs/zerolog/log" + "github.com/spf13/viper" +) + +var A *fiber.App + +func NewServer() { + templates := html.NewFileSystem(http.FS(pkg.FS), ".gohtml") + + A = fiber.New(fiber.Config{ + DisableStartupMessage: true, + EnableIPValidation: true, + ServerHeader: "Hydrogen.Messaging", + AppName: "Hydrogen.Messaging", + ProxyHeader: fiber.HeaderXForwardedFor, + JSONEncoder: jsoniter.ConfigCompatibleWithStandardLibrary.Marshal, + JSONDecoder: jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal, + BodyLimit: 50 * 1024 * 1024, + EnablePrintRoutes: viper.GetBool("debug.print_routes"), + Views: templates, + ViewsLayout: "views/index", + }) + + A.Use(idempotency.New()) + A.Use(cors.New(cors.Config{ + AllowCredentials: true, + AllowMethods: strings.Join([]string{ + fiber.MethodGet, + fiber.MethodPost, + fiber.MethodHead, + fiber.MethodOptions, + fiber.MethodPut, + fiber.MethodDelete, + fiber.MethodPatch, + }, ","), + AllowOriginsFunc: func(origin string) bool { + return true + }, + })) + + A.Use(logger.New(logger.Config{ + Format: "${status} | ${latency} | ${method} ${path}\n", + Output: log.Logger, + })) + + A.Use(gap.H.AuthMiddleware) + A.Use(exts.LinkAccountMiddleware) + + A.Use(favicon.New(favicon.Config{ + FileSystem: http.FS(pkg.FS), + File: "views/favicon.png", + URL: "/favicon.png", + })) + + api.MapAPIs(A) + + A.Get("/", func(c *fiber.Ctx) error { + return c.Render("views/open", fiber.Map{ + "frontend": viper.GetString("frontend"), + }) + }) +} + +func Listen() { + if err := A.Listen(viper.GetString("bind")); err != nil { + log.Fatal().Err(err).Msg("An error occurred when starting server...") + } +} diff --git a/pkg/services/accounts.go b/pkg/internal/services/accounts.go similarity index 67% rename from pkg/services/accounts.go rename to pkg/internal/services/accounts.go index bcfa2e3..f662356 100644 --- a/pkg/services/accounts.go +++ b/pkg/internal/services/accounts.go @@ -3,12 +3,12 @@ package services import ( "context" "fmt" - "git.solsynth.dev/hydrogen/messaging/pkg/database" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/database" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/gap" "time" - "git.solsynth.dev/hydrogen/messaging/pkg/grpc" - "git.solsynth.dev/hydrogen/messaging/pkg/models" - "git.solsynth.dev/hydrogen/passport/pkg/grpc/proto" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/models" + "git.solsynth.dev/hydrogen/passport/pkg/proto" "github.com/spf13/viper" ) @@ -25,7 +25,11 @@ func GetAccountFriend(userId, relatedId uint, status int) (*proto.FriendshipResp ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) defer cancel() - return grpc.Friendships.GetFriendship(ctx, &proto.FriendshipTwoSideLookupRequest{ + pc, err := gap.H.DiscoverServiceGRPC("Hydrogen.Passport") + if err != nil { + return nil, err + } + return proto.NewFriendshipsClient(pc).GetFriendship(ctx, &proto.FriendshipTwoSideLookupRequest{ AccountId: uint64(user.ExternalID), RelatedId: uint64(related.ExternalID), Status: uint32(status), @@ -36,7 +40,11 @@ func NotifyAccountMessager(user models.Account, t, s, c string, realtime bool, f ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) defer cancel() - _, err := grpc.Notify.NotifyUser(ctx, &proto.NotifyRequest{ + pc, err := gap.H.DiscoverServiceGRPC("Hydrogen.Passport") + if err != nil { + return err + } + _, err = proto.NewNotifyClient(pc).NotifyUser(ctx, &proto.NotifyRequest{ ClientId: viper.GetString("passport.client_id"), ClientSecret: viper.GetString("passport.client_secret"), Type: fmt.Sprintf("messaging.%s", t), diff --git a/pkg/internal/services/attachments.go b/pkg/internal/services/attachments.go new file mode 100644 index 0000000..a44db6e --- /dev/null +++ b/pkg/internal/services/attachments.go @@ -0,0 +1,22 @@ +package services + +import ( + "context" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/gap" + + "git.solsynth.dev/hydrogen/paperclip/pkg/proto" + "github.com/samber/lo" +) + +func CheckAttachmentByIDExists(id uint, usage string) bool { + pc, err := gap.H.DiscoverServiceGRPC("Hydrogen.Passport") + if err != nil { + return false + } + _, err = proto.NewAttachmentsClient(pc).CheckAttachmentExists(context.Background(), &proto.AttachmentLookupRequest{ + Id: lo.ToPtr(uint64(id)), + Usage: &usage, + }) + + return err == nil +} diff --git a/pkg/services/auth.go b/pkg/internal/services/auth.go similarity index 57% rename from pkg/services/auth.go rename to pkg/internal/services/auth.go index 1620aba..7d9dcf6 100644 --- a/pkg/services/auth.go +++ b/pkg/internal/services/auth.go @@ -1,17 +1,13 @@ package services import ( - "context" "errors" "fmt" - "reflect" - "time" - - "git.solsynth.dev/hydrogen/messaging/pkg/database" - "git.solsynth.dev/hydrogen/messaging/pkg/grpc" - "git.solsynth.dev/hydrogen/messaging/pkg/models" - "git.solsynth.dev/hydrogen/passport/pkg/grpc/proto" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/database" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/models" + "git.solsynth.dev/hydrogen/passport/pkg/proto" "gorm.io/gorm" + "reflect" ) func LinkAccount(userinfo *proto.Userinfo) (models.Account, error) { @@ -53,24 +49,3 @@ func LinkAccount(userinfo *proto.Userinfo) (models.Account, error) { return account, err } - -func Authenticate(atk, rtk string) (models.Account, string, string, error) { - ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) - defer cancel() - - var err error - var user models.Account - reply, err := grpc.Auth.Authenticate(ctx, &proto.AuthRequest{ - AccessToken: atk, - RefreshToken: &rtk, - }) - if err != nil { - return user, reply.GetAccessToken(), reply.GetRefreshToken(), err - } else if !reply.IsValid { - return user, reply.GetAccessToken(), reply.GetRefreshToken(), fmt.Errorf("invalid authorization context") - } - - user, err = LinkAccount(reply.Userinfo) - - return user, reply.GetAccessToken(), reply.GetRefreshToken(), err -} diff --git a/pkg/services/calls.go b/pkg/internal/services/calls.go similarity index 97% rename from pkg/services/calls.go rename to pkg/internal/services/calls.go index 077d87c..fcdbd52 100644 --- a/pkg/services/calls.go +++ b/pkg/internal/services/calls.go @@ -4,8 +4,8 @@ import ( "context" "errors" "fmt" - "git.solsynth.dev/hydrogen/messaging/pkg/database" - "git.solsynth.dev/hydrogen/messaging/pkg/models" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/database" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/models" jsoniter "github.com/json-iterator/go" "github.com/livekit/protocol/auth" "github.com/livekit/protocol/livekit" diff --git a/pkg/services/channel_members.go b/pkg/internal/services/channel_members.go similarity index 93% rename from pkg/services/channel_members.go rename to pkg/internal/services/channel_members.go index ccf3a9c..2e5e573 100644 --- a/pkg/services/channel_members.go +++ b/pkg/internal/services/channel_members.go @@ -3,8 +3,8 @@ package services import ( "fmt" - "git.solsynth.dev/hydrogen/messaging/pkg/database" - "git.solsynth.dev/hydrogen/messaging/pkg/models" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/database" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/models" ) func ListChannelMember(channelId uint) ([]models.ChannelMember, error) { diff --git a/pkg/services/channels.go b/pkg/internal/services/channels.go similarity index 97% rename from pkg/services/channels.go rename to pkg/internal/services/channels.go index ac355e0..23a3447 100644 --- a/pkg/services/channels.go +++ b/pkg/internal/services/channels.go @@ -4,8 +4,8 @@ import ( "fmt" "regexp" - "git.solsynth.dev/hydrogen/messaging/pkg/database" - "git.solsynth.dev/hydrogen/messaging/pkg/models" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/database" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/models" "github.com/samber/lo" "github.com/spf13/viper" "gorm.io/gorm" diff --git a/pkg/services/cleaner.go b/pkg/internal/services/cleaner.go similarity index 91% rename from pkg/services/cleaner.go rename to pkg/internal/services/cleaner.go index 640140d..ebfd435 100644 --- a/pkg/services/cleaner.go +++ b/pkg/internal/services/cleaner.go @@ -3,7 +3,7 @@ package services import ( "time" - "git.solsynth.dev/hydrogen/messaging/pkg/database" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/database" "github.com/rs/zerolog/log" ) diff --git a/pkg/services/connections.go b/pkg/internal/services/connections.go similarity index 94% rename from pkg/services/connections.go rename to pkg/internal/services/connections.go index 579a19d..76efb01 100644 --- a/pkg/services/connections.go +++ b/pkg/internal/services/connections.go @@ -3,7 +3,7 @@ package services import ( "sync" - "git.solsynth.dev/hydrogen/messaging/pkg/models" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/models" "github.com/gofiber/contrib/websocket" ) diff --git a/pkg/services/encryptor.go b/pkg/internal/services/encryptor.go similarity index 100% rename from pkg/services/encryptor.go rename to pkg/internal/services/encryptor.go diff --git a/pkg/services/jwt.go b/pkg/internal/services/jwt.go similarity index 100% rename from pkg/services/jwt.go rename to pkg/internal/services/jwt.go diff --git a/pkg/services/livekit.go b/pkg/internal/services/livekit.go similarity index 100% rename from pkg/services/livekit.go rename to pkg/internal/services/livekit.go diff --git a/pkg/services/mailer.go b/pkg/internal/services/mailer.go similarity index 100% rename from pkg/services/mailer.go rename to pkg/internal/services/mailer.go diff --git a/pkg/services/messages.go b/pkg/internal/services/messages.go similarity index 97% rename from pkg/services/messages.go rename to pkg/internal/services/messages.go index b848360..744f28f 100644 --- a/pkg/services/messages.go +++ b/pkg/internal/services/messages.go @@ -3,8 +3,8 @@ package services import ( "fmt" - "git.solsynth.dev/hydrogen/messaging/pkg/database" - "git.solsynth.dev/hydrogen/messaging/pkg/models" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/database" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/models" "github.com/rs/zerolog/log" "github.com/samber/lo" ) diff --git a/pkg/services/realms.go b/pkg/internal/services/realms.go similarity index 63% rename from pkg/services/realms.go rename to pkg/internal/services/realms.go index bca84cb..bef5d35 100644 --- a/pkg/services/realms.go +++ b/pkg/internal/services/realms.go @@ -4,10 +4,10 @@ import ( "context" "errors" "fmt" - "git.solsynth.dev/hydrogen/messaging/pkg/database" - "git.solsynth.dev/hydrogen/messaging/pkg/grpc" - "git.solsynth.dev/hydrogen/messaging/pkg/models" - "git.solsynth.dev/hydrogen/passport/pkg/grpc/proto" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/database" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/gap" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/models" + "git.solsynth.dev/hydrogen/passport/pkg/proto" "github.com/samber/lo" "gorm.io/gorm" "reflect" @@ -15,7 +15,11 @@ import ( func GetRealm(id uint) (models.Realm, error) { var realm models.Realm - response, err := grpc.Realms.GetRealm(context.Background(), &proto.RealmLookupRequest{ + pc, err := gap.H.DiscoverServiceGRPC("Hydrogen.Passport") + if err != nil { + return realm, err + } + response, err := proto.NewRealmsClient(pc).GetRealm(context.Background(), &proto.RealmLookupRequest{ Id: lo.ToPtr(uint64(id)), }) if err != nil { @@ -26,7 +30,11 @@ func GetRealm(id uint) (models.Realm, error) { func GetRealmWithAlias(alias string) (models.Realm, error) { var realm models.Realm - response, err := grpc.Realms.GetRealm(context.Background(), &proto.RealmLookupRequest{ + pc, err := gap.H.DiscoverServiceGRPC("Hydrogen.Passport") + if err != nil { + return realm, err + } + response, err := proto.NewRealmsClient(pc).GetRealm(context.Background(), &proto.RealmLookupRequest{ Alias: &alias, }) if err != nil { @@ -36,7 +44,11 @@ func GetRealmWithAlias(alias string) (models.Realm, error) { } func GetRealmMember(realmId uint, userId uint) (*proto.RealmMemberResponse, error) { - response, err := grpc.Realms.GetRealmMember(context.Background(), &proto.RealmMemberLookupRequest{ + pc, err := gap.H.DiscoverServiceGRPC("Hydrogen.Passport") + if err != nil { + return nil, err + } + response, err := proto.NewRealmsClient(pc).GetRealmMember(context.Background(), &proto.RealmMemberLookupRequest{ RealmId: uint64(realmId), UserId: lo.ToPtr(uint64(userId)), }) @@ -48,7 +60,11 @@ func GetRealmMember(realmId uint, userId uint) (*proto.RealmMemberResponse, erro } func ListRealmMember(realmId uint) ([]*proto.RealmMemberResponse, error) { - response, err := grpc.Realms.ListRealmMember(context.Background(), &proto.RealmMemberLookupRequest{ + pc, err := gap.H.DiscoverServiceGRPC("Hydrogen.Passport") + if err != nil { + return nil, err + } + response, err := proto.NewRealmsClient(pc).ListRealmMember(context.Background(), &proto.RealmMemberLookupRequest{ RealmId: uint64(realmId), }) if err != nil { diff --git a/pkg/views/favicon.png b/pkg/internal/views/favicon.png similarity index 100% rename from pkg/views/favicon.png rename to pkg/internal/views/favicon.png diff --git a/pkg/views/index.gohtml b/pkg/internal/views/index.gohtml similarity index 100% rename from pkg/views/index.gohtml rename to pkg/internal/views/index.gohtml diff --git a/pkg/views/open.gohtml b/pkg/internal/views/open.gohtml similarity index 100% rename from pkg/views/open.gohtml rename to pkg/internal/views/open.gohtml diff --git a/pkg/cmd/main.go b/pkg/main.go similarity index 69% rename from pkg/cmd/main.go rename to pkg/main.go index 17b12b4..90117ec 100644 --- a/pkg/cmd/main.go +++ b/pkg/main.go @@ -1,18 +1,19 @@ package main import ( + "git.solsynth.dev/hydrogen/messaging/pkg/internal/gap" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/grpc" "os" "os/signal" "syscall" - "git.solsynth.dev/hydrogen/messaging/pkg/services" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/services" "github.com/robfig/cron/v3" - "git.solsynth.dev/hydrogen/messaging/pkg/grpc" - "git.solsynth.dev/hydrogen/messaging/pkg/server" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/server" - messaging "git.solsynth.dev/hydrogen/messaging/pkg" - "git.solsynth.dev/hydrogen/messaging/pkg/database" + "git.solsynth.dev/hydrogen/messaging/pkg/internal" + "git.solsynth.dev/hydrogen/messaging/pkg/internal/database" "github.com/rs/zerolog" "github.com/rs/zerolog/log" "github.com/spf13/viper" @@ -44,30 +45,32 @@ func main() { // Connect other services services.SetupLiveKit() - if err := grpc.ConnectPassport(); err != nil { - log.Fatal().Err(err).Msg("An error occurred when connecting to passport...") - } - if err := grpc.ConnectPaperclip(); err != nil { - log.Fatal().Err(err).Msg("An error occurred when connecting to paperclip...") + if err := gap.Register(); err != nil { + log.Fatal().Err(err).Msg("An error occurred when connecting to consul...") + } else { + gap.NewHyperClient() } // Server server.NewServer() go server.Listen() + grpc.NewGRPC() + go grpc.ListenGRPC() + // Configure timed tasks quartz := cron.New(cron.WithLogger(cron.VerbosePrintfLogger(&log.Logger))) quartz.AddFunc("@every 60m", services.DoAutoDatabaseCleanup) quartz.Start() // Messages - log.Info().Msgf("Messaging v%s is started...", messaging.AppVersion) + log.Info().Msgf("Messaging v%s is started...", pkg.AppVersion) quit := make(chan os.Signal, 1) signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM) <-quit - log.Info().Msgf("Messaging v%s is quitting...", messaging.AppVersion) + log.Info().Msgf("Messaging v%s is quitting...", pkg.AppVersion) quartz.Stop() } diff --git a/pkg/server/auth.go b/pkg/server/auth.go deleted file mode 100644 index b6597c0..0000000 --- a/pkg/server/auth.go +++ /dev/null @@ -1,54 +0,0 @@ -package server - -import ( - "strings" - - "git.solsynth.dev/hydrogen/messaging/pkg/services" - "github.com/gofiber/fiber/v2" -) - -func authMiddleware(c *fiber.Ctx) error { - var token string - if cookie := c.Cookies(services.CookieAccessKey); len(cookie) > 0 { - token = cookie - } - if header := c.Get(fiber.HeaderAuthorization); len(header) > 0 { - tk := strings.Replace(header, "Bearer", "", 1) - token = strings.TrimSpace(tk) - } - if query := c.Query("tk"); len(query) > 0 { - token = strings.TrimSpace(query) - } - - c.Locals("token", token) - - if err := authFunc(c); err != nil { - return err - } - - return c.Next() -} - -func authFunc(c *fiber.Ctx, overrides ...string) error { - var token string - if len(overrides) > 0 { - token = overrides[0] - } else { - if tk, ok := c.Locals("token").(string); !ok { - return fiber.NewError(fiber.StatusUnauthorized) - } else { - token = tk - } - } - - rtk := c.Cookies(services.CookieRefreshKey) - if user, atk, rtk, err := services.Authenticate(token, rtk); err == nil { - if atk != token { - services.SetJwtCookieSet(c, atk, rtk) - } - c.Locals("principal", user) - return nil - } else { - return fiber.NewError(fiber.StatusUnauthorized, err.Error()) - } -} diff --git a/pkg/server/startup.go b/pkg/server/startup.go deleted file mode 100644 index 9117083..0000000 --- a/pkg/server/startup.go +++ /dev/null @@ -1,122 +0,0 @@ -package server - -import ( - "net/http" - "strings" - - "git.solsynth.dev/hydrogen/messaging/pkg" - "github.com/gofiber/contrib/websocket" - "github.com/gofiber/fiber/v2/middleware/favicon" - - "github.com/gofiber/fiber/v2" - "github.com/gofiber/fiber/v2/middleware/cors" - "github.com/gofiber/fiber/v2/middleware/idempotency" - "github.com/gofiber/fiber/v2/middleware/logger" - "github.com/gofiber/template/html/v2" - jsoniter "github.com/json-iterator/go" - "github.com/rs/zerolog/log" - "github.com/spf13/viper" -) - -var A *fiber.App - -func NewServer() { - templates := html.NewFileSystem(http.FS(pkg.FS), ".gohtml") - - A = fiber.New(fiber.Config{ - DisableStartupMessage: true, - EnableIPValidation: true, - ServerHeader: "Hydrogen.Messaging", - AppName: "Hydrogen.Messaging", - ProxyHeader: fiber.HeaderXForwardedFor, - JSONEncoder: jsoniter.ConfigCompatibleWithStandardLibrary.Marshal, - JSONDecoder: jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal, - BodyLimit: 50 * 1024 * 1024, - EnablePrintRoutes: viper.GetBool("debug.print_routes"), - Views: templates, - ViewsLayout: "views/index", - }) - - A.Use(idempotency.New()) - A.Use(cors.New(cors.Config{ - AllowCredentials: true, - AllowMethods: strings.Join([]string{ - fiber.MethodGet, - fiber.MethodPost, - fiber.MethodHead, - fiber.MethodOptions, - fiber.MethodPut, - fiber.MethodDelete, - fiber.MethodPatch, - }, ","), - AllowOriginsFunc: func(origin string) bool { - return true - }, - })) - - A.Use(logger.New(logger.Config{ - Format: "${status} | ${latency} | ${method} ${path}\n", - Output: log.Logger, - })) - - A.Get("/.well-known", getMetadata) - - api := A.Group("/api").Name("API") - { - api.Get("/users/me", authMiddleware, getUserinfo) - api.Get("/users/:accountId", getOthersInfo) - - channels := api.Group("/channels/:realm").Use(realmMiddleware).Name("Channels API") - { - channels.Get("/", listChannel) - channels.Get("/me", authMiddleware, listOwnedChannel) - channels.Get("/me/available", authMiddleware, listAvailableChannel) - channels.Get("/:channel", getChannel) - channels.Get("/:channel/me", authMiddleware, getChannelIdentity) - - channels.Post("/", authMiddleware, createChannel) - channels.Post("/dm", authMiddleware, createDirectChannel) - channels.Put("/:channelId", authMiddleware, editChannel) - channels.Delete("/:channelId", authMiddleware, deleteChannel) - - channels.Get("/:channel/members", listChannelMembers) - channels.Get("/:channel/members/me", authMiddleware, getMyChannelMembership) - channels.Put("/:channel/members/me", authMiddleware, editMyChannelMembership) - channels.Post("/:channel/members", authMiddleware, addChannelMember) - channels.Post("/:channel/members/me", authMiddleware, joinChannel) - channels.Delete("/:channel/members", authMiddleware, removeChannelMember) - channels.Delete("/:channel/members/me", authMiddleware, leaveChannel) - - channels.Get("/:channel/messages", authMiddleware, listMessage) - channels.Post("/:channel/messages", authMiddleware, newMessage) - channels.Put("/:channel/messages/:messageId", authMiddleware, editMessage) - channels.Delete("/:channel/messages/:messageId", authMiddleware, deleteMessage) - - channels.Get("/:channel/calls", listCall) - channels.Get("/:channel/calls/ongoing", getOngoingCall) - channels.Post("/:channel/calls", authMiddleware, startCall) - channels.Delete("/:channel/calls/ongoing", authMiddleware, endCall) - channels.Post("/:channel/calls/ongoing/token", authMiddleware, exchangeCallToken) - } - - api.Get("/ws", authMiddleware, websocket.New(messageGateway)) - } - - A.Use(favicon.New(favicon.Config{ - FileSystem: http.FS(pkg.FS), - File: "views/favicon.png", - URL: "/favicon.png", - })) - - A.Get("/", func(c *fiber.Ctx) error { - return c.Render("views/open", fiber.Map{ - "frontend": viper.GetString("frontend"), - }) - }) -} - -func Listen() { - if err := A.Listen(viper.GetString("bind")); err != nil { - log.Fatal().Err(err).Msg("An error occurred when starting server...") - } -} diff --git a/pkg/server/well_known_api.go b/pkg/server/well_known_api.go deleted file mode 100644 index e320daa..0000000 --- a/pkg/server/well_known_api.go +++ /dev/null @@ -1,16 +0,0 @@ -package server - -import ( - "github.com/gofiber/fiber/v2" - "github.com/spf13/viper" -) - -func getMetadata(c *fiber.Ctx) error { - return c.JSON(fiber.Map{ - "name": viper.GetString("name"), - "domain": viper.GetString("domain"), - "components": fiber.Map{ - "identity": viper.GetString("identity.endpoint"), - }, - }) -} diff --git a/pkg/services/attachments.go b/pkg/services/attachments.go deleted file mode 100644 index 3a19ec5..0000000 --- a/pkg/services/attachments.go +++ /dev/null @@ -1,30 +0,0 @@ -package services - -import ( - "context" - - "git.solsynth.dev/hydrogen/messaging/pkg/grpc" - pcpb "git.solsynth.dev/hydrogen/paperclip/pkg/grpc/proto" - "github.com/samber/lo" -) - -func GetAttachmentByID(id uint) (*pcpb.Attachment, error) { - return grpc.Attachments.GetAttachment(context.Background(), &pcpb.AttachmentLookupRequest{ - Id: lo.ToPtr(uint64(id)), - }) -} - -func GetAttachmentByUUID(uuid string) (*pcpb.Attachment, error) { - return grpc.Attachments.GetAttachment(context.Background(), &pcpb.AttachmentLookupRequest{ - Uuid: &uuid, - }) -} - -func CheckAttachmentByIDExists(id uint, usage string) bool { - _, err := grpc.Attachments.CheckAttachmentExists(context.Background(), &pcpb.AttachmentLookupRequest{ - Id: lo.ToPtr(uint64(id)), - Usage: &usage, - }) - - return err == nil -} diff --git a/settings.toml b/settings.toml index cfcf6c9..661c6c4 100644 --- a/settings.toml +++ b/settings.toml @@ -1,14 +1,12 @@ -name = "Solarplaza" -maintainer = "SmartSheep Studio" +id = "messaging01" frontend = "https://lian.solsynth.dev" bind = "0.0.0.0:8447" +grpc_bind = "0.0.0.0:7447" domain = "im.solsynth.dev" secret = "LtTjzAGFLshwXhN4ZD4nG5KlMv1MWcsvfv03TSZYnT1VhiAnLIZFTnHUwR0XhGgi" -content = "uploads" - [debug] database = true print_routes = false