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
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
@ -102,7 +103,7 @@ func (l *GetServerConfigLogic) compatible(config node.Protocol) map[string]inter
|
|||||||
result = ShadowsocksNode{
|
result = ShadowsocksNode{
|
||||||
Port: config.Port,
|
Port: config.Port,
|
||||||
Cipher: config.Cipher,
|
Cipher: config.Cipher,
|
||||||
ServerKey: config.ServerKey,
|
ServerKey: base64.StdEncoding.EncodeToString([]byte(config.ServerKey)),
|
||||||
}
|
}
|
||||||
case Vless:
|
case Vless:
|
||||||
result = VlessNode{
|
result = VlessNode{
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package server
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/perfect-panel/server/internal/model/node"
|
"github.com/perfect-panel/server/internal/model/node"
|
||||||
"github.com/perfect-panel/server/internal/svc"
|
"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))
|
l.Errorw("[ServerPushStatus] UpdateNodeStatus error", logger.Field("error", err))
|
||||||
return errors.New("update node status failed")
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package server
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/hibiken/asynq"
|
"github.com/hibiken/asynq"
|
||||||
"github.com/perfect-panel/server/internal/svc"
|
"github.com/perfect-panel/server/internal/svc"
|
||||||
@ -51,5 +52,15 @@ func (l *ServerPushUserTrafficLogic) ServerPushUserTraffic(req *types.ServerPush
|
|||||||
} else {
|
} else {
|
||||||
l.Infow("[ServerPushUserTraffic] Push traffic task success", logger.Field("task", t), logger.Field("info", info))
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user