mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-12-03 23:28:39 +00:00
merge: Merge upstream v1.14.6
This commit is contained in:
@@ -4,12 +4,13 @@ import "context"
|
||||
|
||||
type contextKeyIsExternalConnection struct{}
|
||||
|
||||
func ContextWithIsExternalConnection(ctx context.Context) context.Context {
|
||||
return context.WithValue(ctx, contextKeyIsExternalConnection{}, true)
|
||||
func ContextWithIsExternalConnection(ctx context.Context, isExternal bool) context.Context {
|
||||
return context.WithValue(ctx, contextKeyIsExternalConnection{}, isExternal)
|
||||
}
|
||||
|
||||
func IsExternalConnectionFromContext(ctx context.Context) bool {
|
||||
return ctx.Value(contextKeyIsExternalConnection{}) != nil
|
||||
isExternal, _ := ctx.Value(contextKeyIsExternalConnection{}).(bool)
|
||||
return isExternal
|
||||
}
|
||||
|
||||
type contextKeyIsProviderConnection struct{}
|
||||
|
||||
@@ -24,6 +24,17 @@ func NewGroup() *Group {
|
||||
return &Group{}
|
||||
}
|
||||
|
||||
func (g *Group) Add(closer io.Closer, isExternal bool) (remove func()) {
|
||||
g.access.Lock()
|
||||
defer g.access.Unlock()
|
||||
element := g.connections.PushBack(&groupConnItem{conn: closer, isExternal: isExternal})
|
||||
return func() {
|
||||
g.access.Lock()
|
||||
defer g.access.Unlock()
|
||||
g.connections.Remove(element)
|
||||
}
|
||||
}
|
||||
|
||||
func (g *Group) NewConn(conn net.Conn, isExternal bool, isProvider bool) net.Conn {
|
||||
g.access.Lock()
|
||||
defer g.access.Unlock()
|
||||
|
||||
Reference in New Issue
Block a user