fix(server): encode ServerKey in base64 and update last reported time for nodes
This commit is contained in:
parent
10757612f5
commit
7ecf955eb7
@ -1,6 +1,7 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
@ -102,7 +103,7 @@ func (l *GetServerConfigLogic) compatible(config node.Protocol) map[string]inter
|
||||
result = ShadowsocksNode{
|
||||
Port: config.Port,
|
||||
Cipher: config.Cipher,
|
||||
ServerKey: config.ServerKey,
|
||||
ServerKey: base64.StdEncoding.EncodeToString([]byte(config.ServerKey)),
|
||||
}
|
||||
case Vless:
|
||||
result = VlessNode{
|
||||
|
||||
@ -3,6 +3,7 @@ package server
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"github.com/perfect-panel/server/internal/model/node"
|
||||
"github.com/perfect-panel/server/internal/svc"
|
||||
@ -42,5 +43,14 @@ func (l *ServerPushStatusLogic) ServerPushStatus(req *types.ServerPushStatusRequ
|
||||
l.Errorw("[ServerPushStatus] UpdateNodeStatus error", logger.Field("error", err))
|
||||
return errors.New("update node status failed")
|
||||
}
|
||||
now := time.Now()
|
||||
serverInfo.LastReportedAt = &now
|
||||
|
||||
err = l.svcCtx.NodeModel.UpdateServer(l.ctx, serverInfo)
|
||||
if err != nil {
|
||||
l.Errorw("[ServerPushStatus] UpdateServer error", logger.Field("error", err))
|
||||
return nil
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ package server
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"time"
|
||||
|
||||
"github.com/hibiken/asynq"
|
||||
"github.com/perfect-panel/server/internal/svc"
|
||||
@ -51,5 +52,15 @@ func (l *ServerPushUserTrafficLogic) ServerPushUserTraffic(req *types.ServerPush
|
||||
} else {
|
||||
l.Infow("[ServerPushUserTraffic] Push traffic task success", logger.Field("task", t), logger.Field("info", info))
|
||||
}
|
||||
|
||||
// Update server last reported time
|
||||
now := time.Now()
|
||||
serverInfo.LastReportedAt = &now
|
||||
|
||||
err = l.svcCtx.NodeModel.UpdateServer(l.ctx, serverInfo)
|
||||
if err != nil {
|
||||
l.Errorw("[ServerPushUserTraffic] UpdateServer error", logger.Field("error", err))
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user