mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-05-31 00:14:21 +03:00
Add admin panel, manager, node_manager, bandwidth limiter, connection limiter, bonding, failover, vless encryption, mkcp transport
This commit is contained in:
27
log/id.go
27
log/id.go
@@ -13,6 +13,8 @@ func init() {
|
||||
}
|
||||
|
||||
type idKey struct{}
|
||||
type muxIdKey struct{}
|
||||
type hwidKey struct{}
|
||||
|
||||
type ID struct {
|
||||
ID uint32
|
||||
@@ -34,3 +36,28 @@ func IDFromContext(ctx context.Context) (ID, bool) {
|
||||
id, loaded := ctx.Value((*idKey)(nil)).(ID)
|
||||
return id, loaded
|
||||
}
|
||||
|
||||
func ContextWithNewMuxID(ctx context.Context) context.Context {
|
||||
return ContextWithMuxID(ctx, ID{
|
||||
ID: rand.Uint32(),
|
||||
CreatedAt: time.Now(),
|
||||
})
|
||||
}
|
||||
|
||||
func ContextWithMuxID(ctx context.Context, id ID) context.Context {
|
||||
return context.WithValue(ctx, (*muxIdKey)(nil), id)
|
||||
}
|
||||
|
||||
func MuxIDFromContext(ctx context.Context) (ID, bool) {
|
||||
id, loaded := ctx.Value((*muxIdKey)(nil)).(ID)
|
||||
return id, loaded
|
||||
}
|
||||
|
||||
func ContextWithHWID(ctx context.Context, id ID) context.Context {
|
||||
return context.WithValue(ctx, (*hwidKey)(nil), id)
|
||||
}
|
||||
|
||||
func HWIDFromContext(ctx context.Context) (ID, bool) {
|
||||
id, loaded := ctx.Value((*hwidKey)(nil)).(ID)
|
||||
return id, loaded
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user