diff --git a/go.mod b/go.mod index f2c881c..68dc55d 100644 --- a/go.mod +++ b/go.mod @@ -41,7 +41,6 @@ require ( github.com/minio/md5-simd v1.1.2 // indirect github.com/rivo/uniseg v0.4.7 // indirect github.com/stretchr/testify v1.10.0 // indirect - github.com/tealeg/xlsx v1.0.5 // indirect github.com/themakers/hlog v0.0.0-20191205140925-235e0e4baddf // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasthttp v1.59.0 // indirect diff --git a/go.sum b/go.sum index 8f66f54..6cddcb6 100644 --- a/go.sum +++ b/go.sum @@ -61,12 +61,6 @@ github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYW github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.2.9 h1:66ze0taIn2H33fBvCkXuv9BmCwDfafmiIVpKV9kKGuY= github.com/klauspost/cpuid/v2 v2.2.9/go.mod h1:rqkxqrZ1EhYM9G+hXH7YdowN5R5RGN6NK4QwQ3WMXF8= -github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= @@ -108,8 +102,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/tealeg/xlsx v1.0.5 h1:+f8oFmvY8Gw1iUXzPk+kz+4GpbDZPK1FhPiQRd+ypgE= -github.com/tealeg/xlsx v1.0.5/go.mod h1:btRS8dz54TDnvKNosuAqxrM1QgN1udgk9O34bDCnORM= github.com/themakers/bdd v0.0.0-20210316111417-6b1dfe326f33 h1:N9f/Q+2Ssa+yDcbfaoLTYvXmdeyUUxsJKdPUVsjSmiA= github.com/themakers/bdd v0.0.0-20210316111417-6b1dfe326f33/go.mod h1:rpcH99JknBh8seZmlOlUg51gasZH6QH34oXNsIwYT6E= github.com/themakers/hlog v0.0.0-20191205140925-235e0e4baddf h1:TJJm6KcBssmbWzplF5lzixXl1RBAi/ViPs1GaSOkhwo= @@ -155,8 +147,6 @@ google.golang.org/grpc v1.70.0 h1:pWFv03aZoHzlRKHWicjsZytKAiYCtNS0dHbXnIdq7jQ= google.golang.org/grpc v1.70.0/go.mod h1:ofIJqVKDXx/JiXrwr2IG4/zwdH9txy3IlF40RmcJSQw= google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM= google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/tucnak/telebot.v2 v2.5.0 h1:i+NynLo443Vp+Zn3Gv9JBjh3Z/PaiKAQwcnhNI7y6Po= diff --git a/internal/app/app.go b/internal/app/app.go index 219ee76..2393740 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -11,7 +11,6 @@ import ( "gitea.pena/SQuiz/answerer/internal/server/http" "gitea.pena/SQuiz/answerer/pkg/closer" "gitea.pena/SQuiz/common/model" - "gitea.pena/SQuiz/common/utils" "github.com/gofiber/fiber/v2/log" "go.uber.org/zap" "go.uber.org/zap/zapcore" @@ -97,8 +96,6 @@ func New(ctx context.Context, cfg initialize.Config, build Build) error { return err } - encrypt := utils.NewEncrypt(cfg.PubKey, cfg.PrivKey) - workerSendClientCh := make(chan model.Answer, 50) workerRespondentCh := make(chan []model.Answer, 50) @@ -123,7 +120,7 @@ func New(ctx context.Context, cfg initialize.Config, build Build) error { RedisClient: redisClient, WorkerSendClientCh: workerSendClientCh, WorkerRespondentCh: workerRespondentCh, - Encrypt: encrypt, + Encrypt: &cfg.ExternalCfg.EncryptCommon, }) srv := http.NewServer(http.ServerConfig{ diff --git a/internal/controllers/http_controllers/common/common.go b/internal/controllers/http_controllers/common/common.go index f6a47b9..d2055be 100644 --- a/internal/controllers/http_controllers/common/common.go +++ b/internal/controllers/http_controllers/common/common.go @@ -3,13 +3,13 @@ package common import ( "encoding/json" "fmt" + "gitea.pena/PenaSide/common/encrypt" "gitea.pena/PenaSide/common/log_mw" "gitea.pena/SQuiz/answerer/internal/dal" "gitea.pena/SQuiz/answerer/internal/models" quizdal "gitea.pena/SQuiz/common/dal" "gitea.pena/SQuiz/common/middleware" "gitea.pena/SQuiz/common/model" - "gitea.pena/SQuiz/common/utils" "github.com/gofiber/fiber/v2" "github.com/rs/xid" "net/url" @@ -24,7 +24,7 @@ type Deps struct { Dal *quizdal.DAL WorkerRespondentCh chan<- []model.Answer WorkerSendClientCh chan<- model.Answer - Encrypt *utils.Encrypt + Encrypt *encrypt.Encrypt RedirectURl string } @@ -35,7 +35,7 @@ type Common struct { m sync.Mutex workerRespondentCh chan<- []model.Answer workerSendClientCh chan<- model.Answer - encrypt *utils.Encrypt + encrypt *encrypt.Encrypt redirectURl string } diff --git a/internal/initialize/config.go b/internal/initialize/config.go index c878a04..c8c867e 100644 --- a/internal/initialize/config.go +++ b/internal/initialize/config.go @@ -1,6 +1,7 @@ package initialize import ( + "gitea.pena/PenaSide/common/encrypt" "github.com/caarlos0/env/v8" "github.com/joho/godotenv" "log" @@ -20,9 +21,12 @@ type Config struct { RedisPassword string `env:"REDIS_PASSWORD"` RedisDB uint64 `env:"REDIS_DB"` RedirectURL string `env:"REDIRECT_URL" envDefault:"https://squiz.pena.digital"` - PubKey string `env:"ENCRYPT_PUBLIC_KEY"` - PrivKey string `env:"ENCRYPT_PRIVATE_KEY"` TrashLogHost string `env:"TRASH_LOG_HOST" envDefault:"localhost:7113"` + ExternalCfg ExternalCfg +} + +type ExternalCfg struct { + EncryptCommon encrypt.Encrypt } func LoadConfig() (*Config, error) { diff --git a/internal/initialize/controllers.go b/internal/initialize/controllers.go index 747974a..751c469 100644 --- a/internal/initialize/controllers.go +++ b/internal/initialize/controllers.go @@ -1,9 +1,9 @@ package initialize import ( + "gitea.pena/PenaSide/common/encrypt" "gitea.pena/SQuiz/answerer/internal/controllers/http_controllers/common" "gitea.pena/SQuiz/common/model" - "gitea.pena/SQuiz/common/utils" "github.com/go-redis/redis/v8" ) @@ -13,7 +13,7 @@ type ControllerDeps struct { RedisClient *redis.Client WorkerRespondentCh chan<- []model.Answer WorkerSendClientCh chan<- model.Answer - Encrypt *utils.Encrypt + Encrypt *encrypt.Encrypt } type Controller struct {