2022-07-09 09:26:50 +08:00
|
|
|
package dialer
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"net"
|
|
|
|
|
|
|
|
"github.com/sagernet/sing-box/adapter"
|
|
|
|
M "github.com/sagernet/sing/common/metadata"
|
|
|
|
N "github.com/sagernet/sing/common/network"
|
|
|
|
)
|
|
|
|
|
2024-11-09 21:16:11 +08:00
|
|
|
type DefaultOutboundDialer struct {
|
|
|
|
outboundManager adapter.OutboundManager
|
2022-07-09 09:26:50 +08:00
|
|
|
}
|
|
|
|
|
2024-11-09 21:16:11 +08:00
|
|
|
func NewDefaultOutbound(outboundManager adapter.OutboundManager) N.Dialer {
|
|
|
|
return &DefaultOutboundDialer{outboundManager: outboundManager}
|
2022-07-09 09:26:50 +08:00
|
|
|
}
|
|
|
|
|
2024-11-09 21:16:11 +08:00
|
|
|
func (d *DefaultOutboundDialer) DialContext(ctx context.Context, network string, destination M.Socksaddr) (net.Conn, error) {
|
|
|
|
return d.outboundManager.Default().DialContext(ctx, network, destination)
|
2022-07-09 09:26:50 +08:00
|
|
|
}
|
|
|
|
|
2024-11-09 21:16:11 +08:00
|
|
|
func (d *DefaultOutboundDialer) ListenPacket(ctx context.Context, destination M.Socksaddr) (net.PacketConn, error) {
|
|
|
|
return d.outboundManager.Default().ListenPacket(ctx, destination)
|
2022-07-09 09:26:50 +08:00
|
|
|
}
|
|
|
|
|
2024-11-09 21:16:11 +08:00
|
|
|
func (d *DefaultOutboundDialer) Upstream() any {
|
|
|
|
return d.outboundManager.Default()
|
2022-07-09 09:26:50 +08:00
|
|
|
}
|