fix
This commit is contained in:
@@ -1 +1,3 @@
|
|||||||
# The extended (may be experimental) features outside the main gost tree.
|
# The extended (may be experimental) features outside the main gost tree.
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
||||||
"github.com/go-gost/core/logger"
|
"github.com/go-gost/core/logger"
|
||||||
"github.com/go-gost/core/metadata"
|
"github.com/go-gost/core/metadata"
|
||||||
@@ -102,6 +103,15 @@ func (s *hashStrategy[T]) Apply(ctx context.Context, vs ...T) (v T) {
|
|||||||
if len(vs) == 0 {
|
if len(vs) == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 打印 基于用户 id 进行 hash 选择最终出口
|
||||||
|
if clientID := xctx.ClientIDFromContext(ctx); clientID != "" {
|
||||||
|
idStr := string(clientID)
|
||||||
|
value := uint64(crc32.ChecksumIEEE([]byte(idStr)))
|
||||||
|
logger.Default().Infof("【命中】从 xctx 拿到 ID: %s, Hash: %d", idStr, value)
|
||||||
|
return vs[value%uint64(len(vs))]
|
||||||
|
}
|
||||||
|
|
||||||
if h := xctx.HashFromContext(ctx); h != nil {
|
if h := xctx.HashFromContext(ctx); h != nil {
|
||||||
value := uint64(crc32.ChecksumIEEE([]byte(h.Source)))
|
value := uint64(crc32.ChecksumIEEE([]byte(h.Source)))
|
||||||
logger.Default().Tracef("hash %s %d", h.Source, value)
|
logger.Default().Tracef("hash %s %d", h.Source, value)
|
||||||
|
|||||||
Reference in New Issue
Block a user