|
@@ -4,6 +4,7 @@ import (
|
|
"context"
|
|
"context"
|
|
"net"
|
|
"net"
|
|
"net/netip"
|
|
"net/netip"
|
|
|
|
+ "reflect"
|
|
"time"
|
|
"time"
|
|
|
|
|
|
"github.com/sagernet/sing-box/adapter"
|
|
"github.com/sagernet/sing-box/adapter"
|
|
@@ -27,6 +28,7 @@ func RegisterOutbound(registry *outbound.Registry) {
|
|
var (
|
|
var (
|
|
_ N.ParallelDialer = (*Outbound)(nil)
|
|
_ N.ParallelDialer = (*Outbound)(nil)
|
|
_ dialer.ParallelNetworkDialer = (*Outbound)(nil)
|
|
_ dialer.ParallelNetworkDialer = (*Outbound)(nil)
|
|
|
|
+ _ dialer.DirectDialer = (*Outbound)(nil)
|
|
)
|
|
)
|
|
|
|
|
|
type Outbound struct {
|
|
type Outbound struct {
|
|
@@ -37,6 +39,7 @@ type Outbound struct {
|
|
fallbackDelay time.Duration
|
|
fallbackDelay time.Duration
|
|
overrideOption int
|
|
overrideOption int
|
|
overrideDestination M.Socksaddr
|
|
overrideDestination M.Socksaddr
|
|
|
|
+ isEmpty bool
|
|
// loopBack *loopBackDetector
|
|
// loopBack *loopBackDetector
|
|
}
|
|
}
|
|
|
|
|
|
@@ -56,6 +59,8 @@ func NewOutbound(ctx context.Context, router adapter.Router, logger log.ContextL
|
|
domainStrategy: C.DomainStrategy(options.DomainStrategy),
|
|
domainStrategy: C.DomainStrategy(options.DomainStrategy),
|
|
fallbackDelay: time.Duration(options.FallbackDelay),
|
|
fallbackDelay: time.Duration(options.FallbackDelay),
|
|
dialer: outboundDialer.(dialer.ParallelInterfaceDialer),
|
|
dialer: outboundDialer.(dialer.ParallelInterfaceDialer),
|
|
|
|
+ //nolint:staticcheck
|
|
|
|
+ isEmpty: reflect.DeepEqual(options.DialerOptions, option.DialerOptions{UDPFragmentDefault: true}) && options.OverrideAddress == "" && options.OverridePort == 0,
|
|
// loopBack: newLoopBackDetector(router),
|
|
// loopBack: newLoopBackDetector(router),
|
|
}
|
|
}
|
|
//nolint:staticcheck
|
|
//nolint:staticcheck
|
|
@@ -242,6 +247,10 @@ func (h *Outbound) ListenSerialNetworkPacket(ctx context.Context, destination M.
|
|
return conn, newDestination, nil
|
|
return conn, newDestination, nil
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+func (h *Outbound) IsEmpty() bool {
|
|
|
|
+ return h.isEmpty
|
|
|
|
+}
|
|
|
|
+
|
|
/*func (h *Outbound) NewConnection(ctx context.Context, conn net.Conn, metadata adapter.InboundContext) error {
|
|
/*func (h *Outbound) NewConnection(ctx context.Context, conn net.Conn, metadata adapter.InboundContext) error {
|
|
if h.loopBack.CheckConn(metadata.Source.AddrPort(), M.AddrPortFromNet(conn.LocalAddr())) {
|
|
if h.loopBack.CheckConn(metadata.Source.AddrPort(), M.AddrPortFromNet(conn.LocalAddr())) {
|
|
return E.New("reject loopback connection to ", metadata.Destination)
|
|
return E.New("reject loopback connection to ", metadata.Destination)
|