mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-03 07:56:42 -05:00
refactor
This commit is contained in:
parent
0d92dce5eb
commit
96d544e047
@ -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{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user