chore: Generate UUID from fastrand

This commit is contained in:
H1JK
2023-03-05 11:00:14 +08:00
parent 3b037acb01
commit ae966833a4
11 changed files with 34 additions and 19 deletions

View File

@ -8,10 +8,9 @@ import (
"strings"
N "github.com/Dreamacro/clash/common/net"
"github.com/Dreamacro/clash/common/utils"
"github.com/Dreamacro/clash/component/dialer"
C "github.com/Dreamacro/clash/constant"
"github.com/gofrs/uuid"
)
type Base struct {
@ -35,7 +34,7 @@ func (b *Base) Name() string {
// Id implements C.ProxyAdapter
func (b *Base) Id() string {
if b.id == "" {
id, err := uuid.NewV6()
id, err := utils.UnsafeUUIDGenerator.NewV6()
if err != nil {
b.id = b.name
} else {

View File

@ -6,10 +6,10 @@ import (
"github.com/Dreamacro/clash/common/batch"
"github.com/Dreamacro/clash/common/singledo"
"github.com/Dreamacro/clash/common/utils"
C "github.com/Dreamacro/clash/constant"
"github.com/Dreamacro/clash/log"
"github.com/gofrs/uuid"
"go.uber.org/atomic"
)
@ -77,7 +77,7 @@ func (hc *HealthCheck) touch() {
func (hc *HealthCheck) check() {
_, _, _ = hc.singleDo.Do(func() (struct{}, error) {
id := ""
if uid, err := uuid.NewV4(); err == nil {
if uid, err := utils.UnsafeUUIDGenerator.NewV4(); err == nil {
id = uid.String()
}
log.Debugln("Start New Health Checking {%s}", id)