mirror of
https://github.com/v2fly/v2ray-core.git
synced 2026-05-30 15:59:08 -04:00
optimize udp hub
This commit is contained in:
@@ -95,6 +95,7 @@ func (this *DokodemoDoor) ListenUDP() error {
|
||||
this.meta.Address, this.meta.Port, udp.ListenOption{
|
||||
Callback: this.handleUDPPackets,
|
||||
ReceiveOriginalDest: this.config.FollowRedirect,
|
||||
Concurrency: 2,
|
||||
})
|
||||
if err != nil {
|
||||
log.Error("Dokodemo failed to listen on ", this.meta.Address, ":", this.meta.Port, ": ", err)
|
||||
|
||||
@@ -59,7 +59,7 @@ func (this *TimedUserValidator) Release() {
|
||||
}
|
||||
|
||||
this.cancel.Cancel()
|
||||
<-this.cancel.WaitForDone()
|
||||
this.cancel.WaitForDone()
|
||||
|
||||
this.Lock()
|
||||
defer this.Unlock()
|
||||
@@ -100,7 +100,9 @@ func (this *TimedUserValidator) generateNewHashes(nowSec protocol.Timestamp, idx
|
||||
}
|
||||
|
||||
func (this *TimedUserValidator) updateUserHash(interval time.Duration) {
|
||||
L:
|
||||
this.cancel.WaitThread()
|
||||
defer this.cancel.FinishThread()
|
||||
|
||||
for {
|
||||
select {
|
||||
case now := <-time.After(interval):
|
||||
@@ -109,10 +111,9 @@ L:
|
||||
this.generateNewHashes(nowSec, entry.userIdx, entry)
|
||||
}
|
||||
case <-this.cancel.WaitForCancel():
|
||||
break L
|
||||
return
|
||||
}
|
||||
}
|
||||
this.cancel.Done()
|
||||
}
|
||||
|
||||
func (this *TimedUserValidator) Add(user *protocol.User) error {
|
||||
|
||||
Reference in New Issue
Block a user