测试:增加hysteria2内核

This commit is contained in:
wyx2685
2024-02-06 10:59:37 +09:00
parent 77ec03016c
commit 0d274bcf61
15 changed files with 933 additions and 28 deletions

26
core/hy2/hook.go Normal file
View 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
}
}