网关重启时恢复权限与分配数据
This commit is contained in:
@@ -8,3 +8,8 @@ type Permit struct {
|
|||||||
Username *string `json:"username"`
|
Username *string `json:"username"`
|
||||||
Password *string `json:"password"`
|
Password *string `json:"password"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type PermitDef struct {
|
||||||
|
Id int32 `json:"id"`
|
||||||
|
Permit
|
||||||
|
}
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ func processCtrlConn(_ctx context.Context, conn net.Conn) (err error) {
|
|||||||
|
|
||||||
// 读取命令
|
// 读取命令
|
||||||
cmd, err := reader.ReadByte()
|
cmd, err := reader.ReadByte()
|
||||||
if errors.Is(err, syscall.WSAECONNRESET) {
|
if errors.Is(err, syscall.ECONNRESET) || errors.Is(err, syscall.WSAECONNRESET) {
|
||||||
slog.Debug("节点重置了控制通道连接(WSAECONNRESET)")
|
slog.Debug("节点重置了控制通道连接(WSAECONNRESET)")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,8 +23,9 @@ func Online(name string) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var body struct {
|
var body struct {
|
||||||
Id int32 `json:"id"`
|
Id int32 `json:"id"`
|
||||||
Secret string `json:"secret"`
|
Secret string `json:"secret"`
|
||||||
|
Permits []core.PermitDef `json:"permits"`
|
||||||
}
|
}
|
||||||
err = json.Unmarshal([]byte(resp), &body)
|
err = json.Unmarshal([]byte(resp), &body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -33,6 +34,9 @@ func Online(name string) (err error) {
|
|||||||
|
|
||||||
app.Id = body.Id
|
app.Id = body.Id
|
||||||
app.PlatformSecret = body.Secret
|
app.PlatformSecret = body.Secret
|
||||||
|
for _, def := range body.Permits {
|
||||||
|
app.Permits.Store(def.Id, &def.Permit)
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,10 +6,7 @@ import (
|
|||||||
"proxy-server/gateway/core"
|
"proxy-server/gateway/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
type PermitReq struct {
|
type PermitReq []core.PermitDef
|
||||||
Id int32 `json:"id"`
|
|
||||||
core.Permit
|
|
||||||
}
|
|
||||||
|
|
||||||
func Permit(ctx *fiber.Ctx) (err error) {
|
func Permit(ctx *fiber.Ctx) (err error) {
|
||||||
|
|
||||||
@@ -20,7 +17,7 @@ func Permit(ctx *fiber.Ctx) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 获取请求参数
|
// 获取请求参数
|
||||||
req, err := core.Decrypt[[]PermitReq](&sec, app.PlatformSecret)
|
req, err := core.Decrypt[PermitReq](&sec, app.PlatformSecret)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user