fix workflow to fetch libsecp256k1.so
Some checks failed
Go / build-and-release (push) Has been cancelled
Some checks failed
Go / build-and-release (push) Has been cancelled
This commit is contained in:
@@ -131,7 +131,8 @@
|
|||||||
"Bash(systemctl:*)",
|
"Bash(systemctl:*)",
|
||||||
"Bash(systemctl show:*)",
|
"Bash(systemctl show:*)",
|
||||||
"Bash(ssh relay1:*)",
|
"Bash(ssh relay1:*)",
|
||||||
"Bash(done)"
|
"Bash(done)",
|
||||||
|
"Bash(go run:*)"
|
||||||
],
|
],
|
||||||
"deny": [],
|
"deny": [],
|
||||||
"ask": []
|
"ask": []
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package app
|
package app
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -38,6 +39,7 @@ type Listener struct {
|
|||||||
messageQueue chan messageRequest // Buffered channel for message processing
|
messageQueue chan messageRequest // Buffered channel for message processing
|
||||||
processingDone chan struct{} // Closed when message processor exits
|
processingDone chan struct{} // Closed when message processor exits
|
||||||
handlerWg sync.WaitGroup // Tracks spawned message handler goroutines
|
handlerWg sync.WaitGroup // Tracks spawned message handler goroutines
|
||||||
|
authProcessing sync.RWMutex // Ensures AUTH completes before other messages check authentication
|
||||||
// Flow control counters (atomic for concurrent access)
|
// Flow control counters (atomic for concurrent access)
|
||||||
droppedMessages atomic.Int64 // Messages dropped due to full queue
|
droppedMessages atomic.Int64 // Messages dropped due to full queue
|
||||||
// Diagnostics: per-connection counters
|
// Diagnostics: per-connection counters
|
||||||
@@ -218,14 +220,32 @@ func (l *Listener) messageProcessor() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process the message in a separate goroutine to avoid blocking
|
// Lock immediately to ensure AUTH is processed before subsequent messages
|
||||||
// This allows multiple messages to be processed concurrently (like khatru does)
|
// are dequeued. This prevents race conditions where EVENT checks authentication
|
||||||
// Track the goroutine so we can wait for it during cleanup
|
// before AUTH completes.
|
||||||
l.handlerWg.Add(1)
|
l.authProcessing.Lock()
|
||||||
go func(data []byte, remote string) {
|
|
||||||
defer l.handlerWg.Done()
|
// Check if this is an AUTH message by looking for the ["AUTH" prefix
|
||||||
l.HandleMessage(data, remote)
|
isAuthMessage := len(req.data) > 7 && bytes.HasPrefix(req.data, []byte(`["AUTH"`))
|
||||||
}(req.data, req.remote)
|
|
||||||
|
if isAuthMessage {
|
||||||
|
// Process AUTH message synchronously while holding lock
|
||||||
|
// This blocks the messageProcessor from dequeuing the next message
|
||||||
|
// until authentication is complete and authedPubkey is set
|
||||||
|
log.D.F("ws->%s processing AUTH synchronously with lock", req.remote)
|
||||||
|
l.HandleMessage(req.data, req.remote)
|
||||||
|
// Unlock after AUTH completes so subsequent messages see updated authedPubkey
|
||||||
|
l.authProcessing.Unlock()
|
||||||
|
} else {
|
||||||
|
// Not AUTH - unlock immediately and process concurrently
|
||||||
|
// The next message can now be dequeued (possibly another non-AUTH to process concurrently)
|
||||||
|
l.authProcessing.Unlock()
|
||||||
|
l.handlerWg.Add(1)
|
||||||
|
go func(data []byte, remote string) {
|
||||||
|
defer l.handlerWg.Done()
|
||||||
|
l.HandleMessage(data, remote)
|
||||||
|
}(req.data, req.remote)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
v0.29.16
|
v0.29.17
|
||||||
Reference in New Issue
Block a user