1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 10:08:15 -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()
}
type AlwaysValidStrategy struct{}
type alwaysValidStrategy struct{}
func AlwaysValid() ValidationStrategy {
return AlwaysValidStrategy{}
return alwaysValidStrategy{}
}
func (AlwaysValidStrategy) IsValid() bool {
func (alwaysValidStrategy) IsValid() bool {
return true
}
func (AlwaysValidStrategy) Invalidate() {}
func (alwaysValidStrategy) Invalidate() {}
type TimeoutValidStrategy struct {
type timeoutValidStrategy struct {
until time.Time
}
func BeforeTime(t time.Time) ValidationStrategy {
return &TimeoutValidStrategy{
return &timeoutValidStrategy{
until: t,
}
}
func (v *TimeoutValidStrategy) IsValid() bool {
func (v *timeoutValidStrategy) IsValid() bool {
return v.until.After(time.Now())
}
func (v *TimeoutValidStrategy) Invalidate() {
func (v *timeoutValidStrategy) Invalidate() {
v.until = time.Time{}
}