mirror of
https://github.com/wyx2685/V2bX.git
synced 2026-02-04 04:30:08 +00:00
测试:增加hysteria2内核
This commit is contained in:
26
core/hy2/hook.go
Normal file
26
core/hy2/hook.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package hy2
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/InazumaV/V2bX/common/counter"
|
||||
)
|
||||
|
||||
type HookServer struct {
|
||||
Tag string
|
||||
Counter sync.Map
|
||||
}
|
||||
|
||||
func (h *HookServer) Log(id string, tx, rx uint64) (ok bool) {
|
||||
if c, ok := h.Counter.Load(h.Tag); ok {
|
||||
c.(*counter.TrafficCounter).Rx(id, int(rx))
|
||||
c.(*counter.TrafficCounter).Tx(id, int(rx))
|
||||
return true
|
||||
} else {
|
||||
c := counter.NewTrafficCounter()
|
||||
h.Counter.Store(h.Tag, c)
|
||||
c.Rx(id, int(rx))
|
||||
c.Tx(id, int(rx))
|
||||
return true
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user