mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 19:04:02 +03:00
Add documentation for timeattack
This commit is contained in:
@@ -29,6 +29,9 @@ func (d detector) Valid(then time.Time) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewDetector returns a new TimeAttackDetector which validates that
|
||||
// timestamp belongs to intervar [X-duration, X+duration], so a small
|
||||
// timeshift is acceptable.
|
||||
func NewDetector(duration time.Duration) mtglib.TimeAttackDetector {
|
||||
return detector{
|
||||
Duration: duration,
|
||||
|
||||
+6
-3
@@ -1,7 +1,10 @@
|
||||
// TimeAttack has implementation of mtglib.TimeAttackDetector>
|
||||
package timeattack
|
||||
|
||||
import "time"
|
||||
|
||||
const (
|
||||
DefaultDuration = 5 * time.Second
|
||||
)
|
||||
// DefaultDuration is a default duration when timestamps are acceptable.
|
||||
//
|
||||
// It means that all timestamps which are X-DefaultDuration <= X <=
|
||||
// X+DefaultDuration are fine.
|
||||
const DefaultDuration = 5 * time.Second
|
||||
|
||||
@@ -10,6 +10,7 @@ type noop struct{}
|
||||
|
||||
func (n noop) Valid(_ time.Time) error { return nil }
|
||||
|
||||
// NewNoop returns TimeAttackDetector which accepts all timestamps.
|
||||
func NewNoop() mtglib.TimeAttackDetector {
|
||||
return noop{}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user