1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-01-03 07:56:42 -05:00
This commit is contained in:
Darien Raymond 2017-04-25 23:41:07 +02:00
parent 0d92dce5eb
commit 96d544e047
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

View File

@ -13,33 +13,33 @@ type ValidationStrategy interface {
Invalidate() Invalidate()
} }
type AlwaysValidStrategy struct{} type alwaysValidStrategy struct{}
func AlwaysValid() ValidationStrategy { func AlwaysValid() ValidationStrategy {
return AlwaysValidStrategy{} return alwaysValidStrategy{}
} }
func (AlwaysValidStrategy) IsValid() bool { func (alwaysValidStrategy) IsValid() bool {
return true return true
} }
func (AlwaysValidStrategy) Invalidate() {} func (alwaysValidStrategy) Invalidate() {}
type TimeoutValidStrategy struct { type timeoutValidStrategy struct {
until time.Time until time.Time
} }
func BeforeTime(t time.Time) ValidationStrategy { func BeforeTime(t time.Time) ValidationStrategy {
return &TimeoutValidStrategy{ return &timeoutValidStrategy{
until: t, until: t,
} }
} }
func (v *TimeoutValidStrategy) IsValid() bool { func (v *timeoutValidStrategy) IsValid() bool {
return v.until.After(time.Now()) return v.until.After(time.Now())
} }
func (v *TimeoutValidStrategy) Invalidate() { func (v *timeoutValidStrategy) Invalidate() {
v.until = time.Time{} v.until = time.Time{}
} }