接入本机人工处置协议和终端并记录Linux回归进度
This commit is contained in:
1 parent
bf4caebaae
commit
0f2e6bfcce
24 files changed
+1534
-48
No files matched your search
@@ -0,0 +1,89 @@
|
||||
package httpapi
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.pcux.cn/xuans/Scert/backend/internal/deployment"
|
||||
"git.pcux.cn/xuans/Scert/backend/internal/localreset"
|
||||
)
|
||||
|
||||
type localRecoveryExecutor interface {
|
||||
PrepareRecoveryConfirmation(context.Context, string, string, deployment.RecoveryAction, func(context.Context, string) (deployment.Server, error)) (deployment.RecoveryConfirmation, string, error)
|
||||
ExecuteRecoveryDisposition(context.Context, deployment.RecoveryConfirmation, string, string, func(context.Context, string) (deployment.Server, error)) (deployment.RecoveryDisposition, error)
|
||||
GetRecoveryDisposition(context.Context, string) (deployment.RecoveryDispositionSummary, error)
|
||||
}
|
||||
|
||||
func (r *localResetSession) DispositionAvailable() bool {
|
||||
_, ok := r.server.recoveryInspection.(localRecoveryExecutor)
|
||||
return ok && r.RecoveryAvailable()
|
||||
}
|
||||
|
||||
func (r *localResetSession) recoveryServer(ctx context.Context, id string) (deployment.Server, error) {
|
||||
if !r.current(ctx) {
|
||||
return deployment.Server{}, localreset.ErrUnavailable
|
||||
}
|
||||
return r.server.servers.GetServerByID(ctx, id)
|
||||
}
|
||||
|
||||
func (r *localResetSession) PrepareRecovery(ctx context.Context, id string, action deployment.RecoveryAction) (localreset.RecoveryPreparation, error) {
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
// 新准备替换旧准备;任何失败也不能继续使用上次的确认对象。
|
||||
r.recoveryConfirmation = deployment.RecoveryConfirmation{}
|
||||
executor, ok := r.server.recoveryInspection.(localRecoveryExecutor)
|
||||
if !r.enterRecovery(ctx) || !ok {
|
||||
return localreset.RecoveryPreparation{}, localreset.ErrProtocol
|
||||
}
|
||||
confirmation, token, err := executor.PrepareRecoveryConfirmation(ctx, id, r.peer.Identity, action, r.recoveryServer)
|
||||
if err != nil || !r.current(ctx) {
|
||||
r.stage = -1
|
||||
return localreset.RecoveryPreparation{}, localreset.ErrUnavailable
|
||||
}
|
||||
r.recoveryConfirmation = confirmation
|
||||
return localreset.RecoveryPreparation{DispositionID: confirmation.DispositionID(), Token: token, Summary: confirmation.Summary()}, nil
|
||||
}
|
||||
|
||||
func (r *localResetSession) ExecuteRecovery(ctx context.Context, id, token string) (deployment.RecoveryDispositionSummary, error) {
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
confirmation := r.recoveryConfirmation
|
||||
r.recoveryConfirmation = deployment.RecoveryConfirmation{}
|
||||
executor, ok := r.server.recoveryInspection.(localRecoveryExecutor)
|
||||
if !r.enterRecovery(ctx) || !ok || id == "" || id != confirmation.DispositionID() {
|
||||
r.stage = -1
|
||||
return deployment.RecoveryDispositionSummary{}, localreset.ErrProtocol
|
||||
}
|
||||
item, err := executor.ExecuteRecoveryDisposition(ctx, confirmation, r.peer.Identity, token, r.recoveryServer)
|
||||
if !r.current(ctx) {
|
||||
r.stage = -1
|
||||
return deployment.RecoveryDispositionSummary{}, localreset.ErrUnavailable
|
||||
}
|
||||
// 执行失败但意图已落库时,返回明确的拒绝、不确定或运行中状态;不将错误伪装成成功,也不自动重试。
|
||||
summary := item.Summary()
|
||||
if summary.ID != id || summary.Validate() != nil {
|
||||
r.stage = -1
|
||||
return deployment.RecoveryDispositionSummary{}, localreset.ErrUnavailable
|
||||
}
|
||||
if err != nil && summary.Status == "succeeded" {
|
||||
r.stage = -1
|
||||
return deployment.RecoveryDispositionSummary{}, localreset.ErrUnavailable
|
||||
}
|
||||
return summary, nil
|
||||
}
|
||||
|
||||
func (r *localResetSession) GetRecoveryDisposition(ctx context.Context, id string) (deployment.RecoveryDispositionSummary, error) {
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
executor, ok := r.server.recoveryInspection.(localRecoveryExecutor)
|
||||
if !r.enterRecovery(ctx) || !ok {
|
||||
return deployment.RecoveryDispositionSummary{}, localreset.ErrProtocol
|
||||
}
|
||||
result, err := executor.GetRecoveryDisposition(ctx, id)
|
||||
if err != nil || !r.current(ctx) || result.ID != id || result.Validate() != nil {
|
||||
r.stage = -1
|
||||
return deployment.RecoveryDispositionSummary{}, localreset.ErrUnavailable
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
var _ localreset.RecoveryDispositionSession = (*localResetSession)(nil)
|
||||
@@ -0,0 +1,125 @@
|
||||
//go:build linux
|
||||
|
||||
package httpapi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.pcux.cn/xuans/Scert/backend/internal/deployment"
|
||||
"git.pcux.cn/xuans/Scert/backend/internal/localreset"
|
||||
)
|
||||
|
||||
func TestLocalDispositionUnixIdentityAndLostResponse(t *testing.T) {
|
||||
for _, mode := range []string{"normal", "lost-response", "foreign-session"} {
|
||||
t.Run(mode, func(t *testing.T) {
|
||||
server, _, journal := localDispositionFixture(t)
|
||||
path := filepath.Join(t.TempDir(), "control.sock")
|
||||
listener, err := localreset.Listen(path)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
info, err := os.Lstat(path)
|
||||
if err != nil || info.Mode().Perm() != 0600 {
|
||||
t.Fatal("socket is not protected")
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(t.Context(), 5*time.Second)
|
||||
done := make(chan error, 1)
|
||||
go func() {
|
||||
done <- listener.Serve(ctx, server.localResetFactory(func(context.Context, string, string) error { return nil }))
|
||||
}()
|
||||
defer func() {
|
||||
cancel()
|
||||
_ = listener.Close()
|
||||
if err := <-done; err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}()
|
||||
conn, err := localreset.Dial(ctx, path, uint32(os.Geteuid()))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer conn.Close()
|
||||
reader, writer := json.NewDecoder(conn), json.NewEncoder(conn)
|
||||
var challenge localreset.Response
|
||||
if err := reader.Decode(&challenge); err != nil || !challenge.DispositionAvailable {
|
||||
t.Fatalf("challenge: %v", err)
|
||||
}
|
||||
if err := writer.Encode(localreset.Request{Version: localreset.Version, Nonce: challenge.Nonce, Action: "recovery_prepare", TransactionID: "tx-1", RecoveryAction: deployment.RecoveryActionRecord}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var preparation localreset.Response
|
||||
if err := reader.Decode(&preparation); err != nil || preparation.Preparation == nil {
|
||||
t.Fatalf("prepare: %+v %v", preparation, err)
|
||||
}
|
||||
prepared := preparation.Preparation
|
||||
if mode == "foreign-session" {
|
||||
_ = conn.Close()
|
||||
other, err := localreset.Dial(ctx, path, uint32(os.Geteuid()))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
client, err := localreset.Begin(ctx, other)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer client.Close()
|
||||
if _, err := client.ExecuteRecovery(prepared.DispositionID, prepared.Token); err == nil {
|
||||
t.Fatal("confirmation escaped original session")
|
||||
}
|
||||
journal.mu.Lock()
|
||||
defer journal.mu.Unlock()
|
||||
if journal.begins != 0 {
|
||||
t.Fatal("foreign session wrote intent")
|
||||
}
|
||||
return
|
||||
}
|
||||
if err := writer.Encode(localreset.Request{Version: localreset.Version, Nonce: preparation.Nonce, Action: "recovery_execute", DispositionID: prepared.DispositionID, ConfirmationToken: prepared.Token}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if mode == "normal" {
|
||||
var result localreset.Response
|
||||
if err := reader.Decode(&result); err != nil || result.Disposition == nil || result.Disposition.ResultCode != "observed" {
|
||||
t.Fatalf("execute: %+v %v", result, err)
|
||||
}
|
||||
}
|
||||
_ = conn.Close()
|
||||
for {
|
||||
journal.mu.Lock()
|
||||
finished := journal.finishes == 1
|
||||
journal.mu.Unlock()
|
||||
if finished {
|
||||
break
|
||||
}
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
t.Fatal("execution never reached durable result")
|
||||
case <-time.After(5 * time.Millisecond):
|
||||
}
|
||||
}
|
||||
other, err := localreset.Dial(ctx, path, uint32(os.Geteuid()))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
client, err := localreset.Begin(ctx, other)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer client.Close()
|
||||
result, err := client.GetRecoveryDisposition(prepared.DispositionID)
|
||||
if err != nil || result.Status != "succeeded" || result.ResultCode != "observed" {
|
||||
t.Fatalf("reconnect query: %+v %v", result, err)
|
||||
}
|
||||
journal.mu.Lock()
|
||||
defer journal.mu.Unlock()
|
||||
if journal.begins != 1 || journal.finishes != 1 || journal.queries != 1 || journal.item.Intent.Operator != fmt.Sprintf("uid:%d", os.Geteuid()) {
|
||||
t.Fatal("identity not from socket or query replayed")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,250 @@
|
||||
package httpapi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.pcux.cn/xuans/Scert/backend/internal/deployment"
|
||||
"git.pcux.cn/xuans/Scert/backend/internal/localreset"
|
||||
"git.pcux.cn/xuans/Scert/backend/internal/repository"
|
||||
)
|
||||
|
||||
type localDispositionJournal struct {
|
||||
deployment.TransactionJournal
|
||||
mu sync.Mutex
|
||||
record deployment.TransactionRecord
|
||||
item deployment.RecoveryDisposition
|
||||
begins int
|
||||
finishes int
|
||||
queries int
|
||||
failFinish bool
|
||||
}
|
||||
|
||||
func (j *localDispositionJournal) ListPendingDeploymentTransactions(context.Context) ([]deployment.TransactionRecord, error) {
|
||||
return []deployment.TransactionRecord{j.record}, nil
|
||||
}
|
||||
func (j *localDispositionJournal) BeginRecoveryDisposition(_ context.Context, intent deployment.RecoveryDispositionIntent) (deployment.RecoveryDisposition, bool, error) {
|
||||
j.mu.Lock()
|
||||
defer j.mu.Unlock()
|
||||
j.begins++
|
||||
if j.item.Intent.ID != "" {
|
||||
return j.item, false, nil
|
||||
}
|
||||
now := time.Now().UTC()
|
||||
j.item = deployment.RecoveryDisposition{Intent: intent, Status: "running", CreatedAt: now, UpdatedAt: now}
|
||||
return j.item, true, nil
|
||||
}
|
||||
func (j *localDispositionJournal) FinishRecoveryDisposition(_ context.Context, id, result string) (deployment.RecoveryDisposition, error) {
|
||||
j.mu.Lock()
|
||||
defer j.mu.Unlock()
|
||||
j.finishes++
|
||||
if j.failFinish {
|
||||
return deployment.RecoveryDisposition{}, errors.New("secret-audit-error")
|
||||
}
|
||||
j.item.Status, j.item.ResultCode, j.item.UpdatedAt = "succeeded", result, time.Now().UTC()
|
||||
if result == "rejected" || result == "uncertain" {
|
||||
j.item.Status = result
|
||||
}
|
||||
return j.item, nil
|
||||
}
|
||||
func (j *localDispositionJournal) GetRecoveryDisposition(context.Context, string) (deployment.RecoveryDisposition, error) {
|
||||
j.mu.Lock()
|
||||
defer j.mu.Unlock()
|
||||
j.queries++
|
||||
return j.item, nil
|
||||
}
|
||||
func (*localDispositionJournal) HasRecoveryClaim(context.Context, string) (bool, error) {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
type localDispositionRemote struct{ deployment.Client }
|
||||
|
||||
func (localDispositionRemote) Exists(context.Context, string) (bool, error) { return false, nil }
|
||||
func (localDispositionRemote) Close() error { return nil }
|
||||
func (localDispositionRemote) CreateOwnedLock(context.Context, string, string) error {
|
||||
return errors.New("unexpected mutation")
|
||||
}
|
||||
func (localDispositionRemote) ReadLockOwner(context.Context, string) (string, error) {
|
||||
return "", errors.New("absent")
|
||||
}
|
||||
func (localDispositionRemote) FileDigest(context.Context, string) (string, error) {
|
||||
return "", errors.New("absent")
|
||||
}
|
||||
|
||||
type localDispositionFactory struct{}
|
||||
|
||||
func (localDispositionFactory) Connect(context.Context, deployment.Server) (deployment.Client, error) {
|
||||
return localDispositionRemote{}, nil
|
||||
}
|
||||
|
||||
type localDispositionServerRepo struct {
|
||||
repository.ServerRepository
|
||||
server deployment.Server
|
||||
}
|
||||
|
||||
func (r localDispositionServerRepo) GetServerByID(context.Context, string) (deployment.Server, error) {
|
||||
return r.server, nil
|
||||
}
|
||||
|
||||
func localDispositionFixture(t *testing.T) (*Server, *localResetSession, *localDispositionJournal) {
|
||||
t.Helper()
|
||||
server := newLocalResetTestServer(t)
|
||||
target := deployment.Server{ID: "server-1", Name: "server-1", Address: "192.0.2.1", Port: 22, Username: "deploy", AuthMethod: deployment.SSHAuthPassword,
|
||||
PasswordRef: "secret://ssh/password/test", HostKeyFingerprint: "SHA256:test", CertificatePath: "/cert.pem", CertificateChainPath: "/chain.pem", PrivateKeyPath: "/key.pem", WebServer: deployment.WebServerNginx}.Normalize()
|
||||
journal := &localDispositionJournal{record: deployment.TransactionRecord{ID: "tx-1", ServerID: target.ID, Phase: "locked", Status: deployment.TransactionStatusRecoveryRequired,
|
||||
Paths: []string{target.CertificatePath, target.CertificateChainPath, target.PrivateKeyPath}}}
|
||||
server.recoveryInspection = deployment.NewServiceWithJournal(localDispositionFactory{}, journal)
|
||||
server.servers = localDispositionServerRepo{server: target}
|
||||
session := localDispositionNewSession(t, server)
|
||||
return server, session, journal
|
||||
}
|
||||
func localDispositionNewSession(t *testing.T, server *Server) *localResetSession {
|
||||
t.Helper()
|
||||
session, err := server.localResetFactory(func(context.Context, string, string) error { t.Error("unexpected mail"); return nil })(t.Context(), localreset.Peer{Identity: "uid:0"})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(session.Close)
|
||||
return session.(*localResetSession)
|
||||
}
|
||||
|
||||
func TestLocalDispositionRecordAndReconnectQuery(t *testing.T) {
|
||||
server, session, journal := localDispositionFixture(t)
|
||||
if !session.DispositionAvailable() {
|
||||
t.Fatal("missing capability")
|
||||
}
|
||||
prepared, err := session.PrepareRecovery(t.Context(), "tx-1", deployment.RecoveryActionRecord)
|
||||
if err != nil || len(prepared.Token) != 64 {
|
||||
t.Fatalf("prepare: %+v %v", prepared, err)
|
||||
}
|
||||
result, err := session.ExecuteRecovery(t.Context(), prepared.DispositionID, prepared.Token)
|
||||
if err != nil || result.Status != "succeeded" || result.ResultCode != "observed" {
|
||||
t.Fatalf("execute: %+v %v", result, err)
|
||||
}
|
||||
if journal.item.Intent.Operator != "uid:0" || journal.record.Status != deployment.TransactionStatusRecoveryRequired || journal.record.Evidence != nil {
|
||||
t.Fatal("identity or original transaction changed")
|
||||
}
|
||||
if _, err := session.ExecuteRecovery(t.Context(), prepared.DispositionID, prepared.Token); err == nil {
|
||||
t.Fatal("confirmation replayed")
|
||||
}
|
||||
next := localDispositionNewSession(t, server)
|
||||
queried, err := next.GetRecoveryDisposition(t.Context(), prepared.DispositionID)
|
||||
if err != nil || queried != result {
|
||||
t.Fatalf("query: %+v %v", queried, err)
|
||||
}
|
||||
if journal.begins != 1 || journal.finishes != 1 || journal.queries != 1 {
|
||||
t.Fatal("query replayed execution")
|
||||
}
|
||||
if err := next.Select(t.Context(), "email"); err == nil {
|
||||
t.Fatal("query switched to password reset")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLocalDispositionInvalidSessionAndConfirmationNeverBegin(t *testing.T) {
|
||||
for _, mode := range []string{"expired", "cancelled", "changed-admin", "closed", "reset-stage", "wrong-id", "wrong-token", "changed-peer", "replaced-confirmation"} {
|
||||
t.Run(mode, func(t *testing.T) {
|
||||
server, session, journal := localDispositionFixture(t)
|
||||
prepared, err := session.PrepareRecovery(t.Context(), "tx-1", deployment.RecoveryActionRecord)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ctx, cancel := context.WithCancel(t.Context())
|
||||
defer cancel()
|
||||
switch mode {
|
||||
case "expired":
|
||||
session.expires = time.Time{}
|
||||
case "cancelled":
|
||||
cancel()
|
||||
case "changed-admin":
|
||||
server.config.Admin.Email = "changed@example.test"
|
||||
case "closed":
|
||||
session.Close()
|
||||
case "reset-stage":
|
||||
session.stage = 1
|
||||
case "wrong-id":
|
||||
prepared.DispositionID = strings.Repeat("a", 64)
|
||||
case "wrong-token":
|
||||
prepared.Token = strings.Repeat("a", 64)
|
||||
case "changed-peer":
|
||||
session.peer.Identity = "uid:123"
|
||||
case "replaced-confirmation":
|
||||
if _, err := session.PrepareRecovery(ctx, "tx-1", deployment.RecoveryActionRecord); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
if _, err := session.ExecuteRecovery(ctx, prepared.DispositionID, prepared.Token); err == nil {
|
||||
t.Fatal("invalid execution accepted")
|
||||
}
|
||||
if _, err := session.ExecuteRecovery(t.Context(), prepared.DispositionID, prepared.Token); err == nil {
|
||||
t.Fatal("failed confirmation reusable")
|
||||
}
|
||||
if journal.begins != 0 || journal.finishes != 0 {
|
||||
t.Fatal("invalid request wrote intent")
|
||||
}
|
||||
if session.recoveryConfirmation.DispositionID() != "" {
|
||||
t.Fatal("confirmation retained")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestLocalDispositionConcurrentExecuteOnce(t *testing.T) {
|
||||
_, session, journal := localDispositionFixture(t)
|
||||
prepared, err := session.PrepareRecovery(t.Context(), "tx-1", deployment.RecoveryActionRecord)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var wg sync.WaitGroup
|
||||
for i := 0; i < 16; i++ {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
_, _ = session.ExecuteRecovery(t.Context(), prepared.DispositionID, prepared.Token)
|
||||
}()
|
||||
}
|
||||
wg.Wait()
|
||||
if journal.begins != 1 || journal.finishes != 1 {
|
||||
t.Fatal("concurrent execution duplicated")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLocalDispositionAuditFailureReturnsRunning(t *testing.T) {
|
||||
server, session, journal := localDispositionFixture(t)
|
||||
journal.failFinish = true
|
||||
prepared, err := session.PrepareRecovery(t.Context(), "tx-1", deployment.RecoveryActionRecord)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
result, err := session.ExecuteRecovery(t.Context(), prepared.DispositionID, prepared.Token)
|
||||
if err != nil || result.Status != "running" || result.ResultCode != "" {
|
||||
t.Fatalf("false success: %+v %v", result, err)
|
||||
}
|
||||
next := localDispositionNewSession(t, server)
|
||||
if result, err := next.GetRecoveryDisposition(t.Context(), prepared.DispositionID); err != nil || result.Status != "running" {
|
||||
t.Fatalf("query: %+v %v", result, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLocalDispositionMissingEvidenceAndReaderOnly(t *testing.T) {
|
||||
for _, action := range []deployment.RecoveryAction{deployment.RecoveryActionCommit, deployment.RecoveryActionRollback} {
|
||||
_, session, journal := localDispositionFixture(t)
|
||||
if _, err := session.PrepareRecovery(t.Context(), "tx-1", action); err == nil {
|
||||
t.Fatal("missing evidence authorized mutation")
|
||||
}
|
||||
if journal.begins != 0 || session.recoveryConfirmation.DispositionID() != "" {
|
||||
t.Fatal("invalid confirmation retained")
|
||||
}
|
||||
}
|
||||
server := newLocalResetTestServer(t)
|
||||
session := newLocalRecoverySession(t, server, &testLocalRecoveryReader{})
|
||||
if session.DispositionAvailable() {
|
||||
t.Fatal("reader advertised writes")
|
||||
}
|
||||
if _, err := session.PrepareRecovery(t.Context(), "tx-1", deployment.RecoveryActionRecord); err == nil {
|
||||
t.Fatal("reader accepted action")
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
"time"
|
||||
|
||||
"git.pcux.cn/xuans/Scert/backend/internal/config"
|
||||
"git.pcux.cn/xuans/Scert/backend/internal/deployment"
|
||||
"git.pcux.cn/xuans/Scert/backend/internal/localreset"
|
||||
"git.pcux.cn/xuans/Scert/backend/internal/notification"
|
||||
"git.pcux.cn/xuans/Scert/backend/internal/passwordpolicy"
|
||||
@@ -23,15 +24,16 @@ import (
|
||||
type resetCodeSender func(context.Context, string, string) error
|
||||
|
||||
type localResetSession struct {
|
||||
server *Server
|
||||
send resetCodeSender
|
||||
reserve func() bool
|
||||
admin config.AdminConfig
|
||||
expires time.Time
|
||||
peer localreset.Peer
|
||||
mu sync.Mutex
|
||||
stage int
|
||||
codeHash [32]byte
|
||||
server *Server
|
||||
send resetCodeSender
|
||||
reserve func() bool
|
||||
admin config.AdminConfig
|
||||
expires time.Time
|
||||
peer localreset.Peer
|
||||
mu sync.Mutex
|
||||
stage int
|
||||
codeHash [32]byte
|
||||
recoveryConfirmation deployment.RecoveryConfirmation
|
||||
}
|
||||
|
||||
// LocalResetFactory 只交给受保护的本机通道,不注册到普通 HTTP 路由。
|
||||
@@ -187,6 +189,7 @@ func (r *localResetSession) Close() {
|
||||
defer r.mu.Unlock()
|
||||
r.stage = -1
|
||||
r.codeHash = [32]byte{}
|
||||
r.recoveryConfirmation = deployment.RecoveryConfirmation{}
|
||||
}
|
||||
|
||||
func (r *localResetSession) audit(status, message string) {
|
||||
|
||||
Reference in new issue
Block a user