mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-30 17:38:41 +00:00
Update dependencies
This commit is contained in:
parent
90d915ea05
commit
18e5b0963f
20 changed files with 523 additions and 238 deletions
|
@ -5,6 +5,7 @@ import (
|
|||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/sagernet/sing/common/control"
|
||||
"github.com/xtls/xray-core/common/net"
|
||||
"github.com/xtls/xray-core/common/session"
|
||||
"github.com/xtls/xray-core/features/dns"
|
||||
|
@ -18,7 +19,7 @@ type SystemDialer interface {
|
|||
}
|
||||
|
||||
type DefaultSystemDialer struct {
|
||||
controllers []controller
|
||||
controllers []control.Func
|
||||
dns dns.Client
|
||||
obm outbound.Manager
|
||||
}
|
||||
|
@ -81,6 +82,11 @@ func (d *DefaultSystemDialer) Dial(ctx context.Context, src net.Address, dest ne
|
|||
|
||||
if sockopt != nil || len(d.controllers) > 0 {
|
||||
dialer.Control = func(network, address string, c syscall.RawConn) error {
|
||||
for _, ctl := range d.controllers {
|
||||
if err := ctl(network, address, c); err != nil {
|
||||
newError("failed to apply external controller").Base(err).WriteToLog(session.ExportIDToError(ctx))
|
||||
}
|
||||
}
|
||||
return c.Control(func(fd uintptr) {
|
||||
if sockopt != nil {
|
||||
if err := applyOutboundSocketOptions(network, address, fd, sockopt); err != nil {
|
||||
|
@ -92,12 +98,6 @@ func (d *DefaultSystemDialer) Dial(ctx context.Context, src net.Address, dest ne
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
for _, ctl := range d.controllers {
|
||||
if err := ctl(network, address, fd); err != nil {
|
||||
newError("failed to apply external controller").Base(err).WriteToLog(session.ExportIDToError(ctx))
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ func UseAlternativeSystemDialer(dialer SystemDialer) {
|
|||
// It only works when effective dialer is the default dialer.
|
||||
//
|
||||
// xray:api:beta
|
||||
func RegisterDialerController(ctl func(network, address string, fd uintptr) error) error {
|
||||
func RegisterDialerController(ctl control.Func) error {
|
||||
if ctl == nil {
|
||||
return newError("nil listener controller")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue