refine i18n, fill in miss parts

fix resetTrust cant recover send button in UI
This commit is contained in:
2026-02-07 14:11:57 +08:00
parent 4b5d2b656b
commit 20a25e8c49
12 changed files with 140 additions and 38 deletions

View File

@@ -254,7 +254,7 @@ func (c *Config) GetWindowState() WindowState {
return c.WindowState
}
func (c *Config) AddTrustedPeer(peerID string, publicKey string) {
func (c *Config) AddTrust(peerID string, publicKey string) {
c.mu.Lock()
defer c.mu.Unlock()
if c.TrustedPeer == nil {
@@ -265,13 +265,13 @@ func (c *Config) AddTrustedPeer(peerID string, publicKey string) {
_ = c.save()
}
func (c *Config) GetTrustedPeer() map[string]string {
func (c *Config) GetTrusted() map[string]string {
c.mu.RLock()
defer c.mu.RUnlock()
return c.TrustedPeer
}
func (c *Config) RemoveTrustedPeer(peerID string) {
func (c *Config) RemoveTrust(peerID string) {
c.mu.Lock()
defer c.mu.Unlock()
delete(c.TrustedPeer, peerID)
@@ -279,7 +279,7 @@ func (c *Config) RemoveTrustedPeer(peerID string) {
_ = c.save()
}
func (c *Config) IsTrustedPeer(peerID string) bool {
func (c *Config) IsTrusted(peerID string) bool {
c.mu.RLock()
defer c.mu.RUnlock()
_, exists := c.TrustedPeer[peerID]

View File

@@ -228,7 +228,7 @@ func (s *Service) startListening() {
// 验证身份一致性 (防止 ID 欺骗)
trustMismatch := false
trustedKeys := s.config.GetTrustedPeer()
trustedKeys := s.config.GetTrusted()
if knownKey, ok := trustedKeys[packet.ID]; ok {
if knownKey != packet.PublicKey {
slog.Warn("SECURITY ALERT: Peer ID mismatch with known public key (Spoofing attempt?)", "id", packet.ID, "known_key", knownKey, "received_key", packet.PublicKey)
@@ -236,6 +236,13 @@ func (s *Service) startListening() {
// 当发现 ID 欺骗时,不更新 peer而是标记为 trustMismatch
// 用户可以手动重新添加信任
}
} else {
// 不存在于信任列表
// 存在之前在信任列表,但是不匹配被用户手动重置了,此时需要将 peer.TrustMismatch 标记为 false
// 否则在 handleHeartbeat 里会一直标记为不匹配
if peer, ok := s.peers[packet.ID]; ok {
peer.TrustMismatch = false
}
}
s.handleHeartbeat(packet, remoteAddr.IP.String(), trustMismatch)

View File

@@ -49,7 +49,7 @@ func (s *Service) handleAsk(c *gin.Context) {
task.Sender.TrustMismatch = peer.TrustMismatch
}
if s.config.GetAutoAccept() || (s.config.IsTrustedPeer(task.Sender.ID) && !task.Sender.TrustMismatch) {
if s.config.GetAutoAccept() || (s.config.IsTrusted(task.Sender.ID) && !task.Sender.TrustMismatch) {
task.DecisionChan <- Decision{
ID: task.ID,
Accepted: true,