|
@@ -13,7 +13,7 @@ import (
|
|
|
"time"
|
|
"time"
|
|
|
|
|
|
|
|
"v2ray.com/core/common"
|
|
"v2ray.com/core/common"
|
|
|
- antiReplayWindow "v2ray.com/core/common/antireplay"
|
|
|
|
|
|
|
+ "v2ray.com/core/common/antireplay"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
var (
|
|
@@ -66,12 +66,12 @@ func (aidd *AuthIDDecoder) Decode(data [16]byte) (int64, uint32, int32, []byte)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func NewAuthIDDecoderHolder() *AuthIDDecoderHolder {
|
|
func NewAuthIDDecoderHolder() *AuthIDDecoderHolder {
|
|
|
- return &AuthIDDecoderHolder{make(map[string]*AuthIDDecoderItem), antiReplayWindow.NewAntiReplayWindow(120)}
|
|
|
|
|
|
|
+ return &AuthIDDecoderHolder{make(map[string]*AuthIDDecoderItem), antireplay.NewReplayFilter(120)}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
type AuthIDDecoderHolder struct {
|
|
type AuthIDDecoderHolder struct {
|
|
|
- aidhi map[string]*AuthIDDecoderItem
|
|
|
|
|
- apw *antiReplayWindow.AntiReplayWindow
|
|
|
|
|
|
|
+ decoders map[string]*AuthIDDecoderItem
|
|
|
|
|
+ filter *antireplay.ReplayFilter
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
type AuthIDDecoderItem struct {
|
|
type AuthIDDecoderItem struct {
|
|
@@ -87,16 +87,16 @@ func NewAuthIDDecoderItem(key [16]byte, ticket interface{}) *AuthIDDecoderItem {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (a *AuthIDDecoderHolder) AddUser(key [16]byte, ticket interface{}) {
|
|
func (a *AuthIDDecoderHolder) AddUser(key [16]byte, ticket interface{}) {
|
|
|
- a.aidhi[string(key[:])] = NewAuthIDDecoderItem(key, ticket)
|
|
|
|
|
|
|
+ a.decoders[string(key[:])] = NewAuthIDDecoderItem(key, ticket)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (a *AuthIDDecoderHolder) RemoveUser(key [16]byte) {
|
|
func (a *AuthIDDecoderHolder) RemoveUser(key [16]byte) {
|
|
|
- delete(a.aidhi, string(key[:]))
|
|
|
|
|
|
|
+ delete(a.decoders, string(key[:]))
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (a *AuthIDDecoderHolder) Match(authID [16]byte) (interface{}, error) {
|
|
func (a *AuthIDDecoderHolder) Match(authID [16]byte) (interface{}, error) {
|
|
|
- for _, v := range a.aidhi {
|
|
|
|
|
- t, z, r, d := v.dec.Decode(authID)
|
|
|
|
|
|
|
+ for _, v := range a.decoders {
|
|
|
|
|
+ t, z, _, d := v.dec.Decode(authID)
|
|
|
if z != crc32.ChecksumIEEE(d[:12]) {
|
|
if z != crc32.ChecksumIEEE(d[:12]) {
|
|
|
continue
|
|
continue
|
|
|
}
|
|
}
|
|
@@ -109,12 +109,10 @@ func (a *AuthIDDecoderHolder) Match(authID [16]byte) (interface{}, error) {
|
|
|
continue
|
|
continue
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if !a.apw.Check(authID[:]) {
|
|
|
|
|
|
|
+ if !a.filter.Check(authID[:]) {
|
|
|
return nil, ErrReplay
|
|
return nil, ErrReplay
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- _ = r
|
|
|
|
|
-
|
|
|
|
|
return v.ticket, nil
|
|
return v.ticket, nil
|
|
|
}
|
|
}
|
|
|
return nil, ErrNotFound
|
|
return nil, ErrNotFound
|