Enhance relay testing and event handling
- Updated TestRelay to include a wait mechanism for relay readiness, improving test reliability. - Refactored startTestRelay to return the assigned port, allowing dynamic port assignment. - Added timestamp validation in HandleEvent to reject events with timestamps more than one hour in the future. - Introduced channels for handling OK and COUNT messages in the Client struct, improving message processing. - Updated tests to reflect changes in event timestamp handling and increased wait times for event processing. - Bumped version to v0.20.6 to reflect these enhancements.
This commit is contained in:
@@ -176,6 +176,18 @@ func (l *Listener) HandleEvent(msg []byte) (err error) {
|
||||
}
|
||||
return
|
||||
}
|
||||
// validate timestamp - reject events too far in the future (more than 1 hour)
|
||||
now := time.Now().Unix()
|
||||
if env.E.CreatedAt > now+3600 {
|
||||
if err = Ok.Invalid(
|
||||
l, env,
|
||||
"timestamp too far in the future",
|
||||
); chk.E(err) {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// verify the signature
|
||||
var ok bool
|
||||
if ok, err = env.Verify(); chk.T(err) {
|
||||
|
||||
Reference in New Issue
Block a user