mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-30 17:38:41 +00:00
Core: Fix memory leaks with RequireFeatures() (#4095)
Fixes https://github.com/XTLS/Xray-core/issues/4054 Fixes https://github.com/XTLS/Xray-core/issues/3338 Fixes https://github.com/XTLS/Xray-core/issues/3221
This commit is contained in:
parent
a2b773135a
commit
0e2304c403
15 changed files with 98 additions and 59 deletions
|
@ -4,8 +4,9 @@ import (
|
|||
"context"
|
||||
|
||||
"github.com/xtls/xray-core/common/net"
|
||||
"github.com/xtls/xray-core/features/routing"
|
||||
)
|
||||
|
||||
type DialFunc func(ctx context.Context, dest net.Destination, tag string) (net.Conn, error)
|
||||
type DialFunc func(ctx context.Context, dispatcher routing.Dispatcher, dest net.Destination, tag string) (net.Conn, error)
|
||||
|
||||
var Dialer DialFunc
|
||||
|
|
|
@ -12,17 +12,10 @@ import (
|
|||
"github.com/xtls/xray-core/transport/internet/tagged"
|
||||
)
|
||||
|
||||
func DialTaggedOutbound(ctx context.Context, dest net.Destination, tag string) (net.Conn, error) {
|
||||
var dispatcher routing.Dispatcher
|
||||
func DialTaggedOutbound(ctx context.Context, dispatcher routing.Dispatcher, dest net.Destination, tag string) (net.Conn, error) {
|
||||
if core.FromContext(ctx) == nil {
|
||||
return nil, errors.New("Instance context variable is not in context, dial denied. ")
|
||||
}
|
||||
if err := core.RequireFeatures(ctx, func(dispatcherInstance routing.Dispatcher) {
|
||||
dispatcher = dispatcherInstance
|
||||
}); err != nil {
|
||||
return nil, errors.New("Required Feature dispatcher not resolved").Base(err)
|
||||
}
|
||||
|
||||
content := new(session.Content)
|
||||
content.SkipDNSResolve = true
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue