maintenance 링크를 잘못 만들던 문제 수정
This commit is contained in:
10
core/api.go
10
core/api.go
@ -18,7 +18,7 @@ import (
|
||||
"time"
|
||||
"unsafe"
|
||||
|
||||
common "repositories.action2quare.com/ayo/gocommon"
|
||||
"repositories.action2quare.com/ayo/gocommon"
|
||||
"repositories.action2quare.com/ayo/gocommon/logger"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
@ -66,9 +66,9 @@ func (fd *FileDocumentDesc) Save() error {
|
||||
if fd.Extract {
|
||||
switch path.Ext(destFile) {
|
||||
case ".zip":
|
||||
err = common.Unzip(destFile)
|
||||
err = gocommon.Unzip(destFile)
|
||||
case ".tar":
|
||||
err = common.Untar(destFile)
|
||||
err = gocommon.Untar(destFile)
|
||||
}
|
||||
}
|
||||
return err
|
||||
@ -431,9 +431,9 @@ func (mg *Maingate) api(w http.ResponseWriter, r *http.Request) {
|
||||
ptr := atomic.LoadPointer(&mg.admins)
|
||||
adminsptr := (*globalAdmins)(ptr)
|
||||
|
||||
if adminsptr.modtime != common.ConfigModTime() {
|
||||
if adminsptr.modtime != gocommon.ConfigModTime() {
|
||||
var config globalAdmins
|
||||
if err := common.LoadConfig(&config); err == nil {
|
||||
if err := gocommon.LoadConfig(&config); err == nil {
|
||||
config.parse()
|
||||
adminsptr = &config
|
||||
atomic.StorePointer(&mg.admins, unsafe.Pointer(adminsptr))
|
||||
|
||||
@ -2,20 +2,18 @@ package core
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"path"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
"unsafe"
|
||||
|
||||
common "repositories.action2quare.com/ayo/gocommon"
|
||||
"repositories.action2quare.com/ayo/gocommon"
|
||||
"repositories.action2quare.com/ayo/gocommon/logger"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
@ -139,9 +137,9 @@ type serviceDescription struct {
|
||||
ServerApiTokens []primitive.ObjectID `bson:"api_tokens" json:"api_tokens"`
|
||||
Admins []string `bson:"admins" json:"admins"`
|
||||
|
||||
auths *common.AuthCollection
|
||||
auths *gocommon.AuthCollection
|
||||
wl *whitelist
|
||||
mongoClient common.MongoClient
|
||||
mongoClient gocommon.MongoClient
|
||||
sessionTTL time.Duration
|
||||
MaximumNumLinkAccount int64
|
||||
|
||||
@ -238,11 +236,16 @@ func (sh *serviceDescription) prepare(mg *Maingate) error {
|
||||
} else if strings.HasPrefix(div.Maintenance.Notice, "http") {
|
||||
div.Maintenance.link = div.Maintenance.Notice
|
||||
} else {
|
||||
hasher := md5.New()
|
||||
hasher.Write(sh.Id[:])
|
||||
subfolder := hex.EncodeToString(hasher.Sum(nil))[:8]
|
||||
var fd FileDocumentDesc
|
||||
if err := sh.mongoClient.FindOneAs(CollectionFile, bson.M{
|
||||
"key": div.Maintenance.Notice,
|
||||
}, &fd, options.FindOne().SetProjection(bson.M{"link": 1})); err != nil {
|
||||
logger.Println(err)
|
||||
return err
|
||||
}
|
||||
|
||||
div.Maintenance.link = path.Join("static", subfolder, div.Maintenance.Notice)
|
||||
div.Maintenance.link = fd.Link
|
||||
logger.Println("div.Maintenance.link :", fd.Link)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -687,7 +690,7 @@ func (sh *serviceDescription) authorize(w http.ResponseWriter, r *http.Request)
|
||||
|
||||
newsession := primitive.NewObjectID()
|
||||
expired := primitive.NewDateTimeFromTime(time.Now().UTC().Add(sh.sessionTTL))
|
||||
newauth := common.Authinfo{
|
||||
newauth := gocommon.Authinfo{
|
||||
Accid: accid,
|
||||
ServiceCode: sh.ServiceCode,
|
||||
Platform: authtype,
|
||||
|
||||
@ -10,7 +10,7 @@ import (
|
||||
"time"
|
||||
"unsafe"
|
||||
|
||||
common "repositories.action2quare.com/ayo/gocommon"
|
||||
"repositories.action2quare.com/ayo/gocommon"
|
||||
"repositories.action2quare.com/ayo/gocommon/logger"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
@ -24,7 +24,7 @@ type authPipelineDocument struct {
|
||||
DocumentKey struct {
|
||||
Id primitive.ObjectID `bson:"_id"`
|
||||
} `bson:"documentKey"`
|
||||
Authinfo *common.Authinfo `bson:"fullDocument"`
|
||||
Authinfo *gocommon.Authinfo `bson:"fullDocument"`
|
||||
}
|
||||
|
||||
type servicePipelineDocument struct {
|
||||
@ -289,7 +289,7 @@ func (mg *Maingate) watchServiceCollection(parentctx context.Context, serveMux *
|
||||
logger.Println("service is on the board! :", data.Service)
|
||||
atomic.StorePointer(&mg.serviceptr, unsafe.Pointer(data.Service))
|
||||
if !already {
|
||||
serveMux.Handle(common.MakeHttpHandlerPattern(prefix, data.Service.ServiceCode, "/"), mg.service())
|
||||
serveMux.Handle(gocommon.MakeHttpHandlerPattern(prefix, data.Service.ServiceCode, "/"), mg.service())
|
||||
}
|
||||
}
|
||||
|
||||
@ -321,7 +321,7 @@ func (mg *Maingate) watchServiceCollection(parentctx context.Context, serveMux *
|
||||
}
|
||||
}
|
||||
|
||||
func watchAuthCollection(parentctx context.Context, ac *common.AuthCollection, mongoClient common.MongoClient) {
|
||||
func watchAuthCollection(parentctx context.Context, ac *gocommon.AuthCollection, mongoClient gocommon.MongoClient) {
|
||||
defer func() {
|
||||
s := recover()
|
||||
if s != nil {
|
||||
|
||||
Reference in New Issue
Block a user