mirror of
https://github.com/SagerNet/sing-box.git
synced 2025-06-13 21:54:13 +08:00
fix: renaming structs
This commit is contained in:
parent
c4701022fa
commit
5c05ed81fe
@ -2,11 +2,11 @@ package option
|
|||||||
|
|
||||||
import "time"
|
import "time"
|
||||||
|
|
||||||
// OutlineOutboundOptions set the outbound options used by the outline-sdk
|
// OutboundOutlineOptions set the outbound options used by the outline-sdk
|
||||||
// smart dialer. You can find more details about the parameters by looking
|
// smart dialer. You can find more details about the parameters by looking
|
||||||
// through the implementation: https://github.com/Jigsaw-Code/outline-sdk/blob/v0.0.18/x/smart/stream_dialer.go#L65-L100
|
// through the implementation: https://github.com/Jigsaw-Code/outline-sdk/blob/v0.0.18/x/smart/stream_dialer.go#L65-L100
|
||||||
// Or check the documentation README: https://github.com/Jigsaw-Code/outline-sdk/tree/v0.0.18/x/smart
|
// Or check the documentation README: https://github.com/Jigsaw-Code/outline-sdk/tree/v0.0.18/x/smart
|
||||||
type OutlineOutboundOptions struct {
|
type OutboundOutlineOptions struct {
|
||||||
DialerOptions
|
DialerOptions
|
||||||
DNSResolvers []DNSEntryConfig `json:"dns,omitempty" yaml:"dns,omitempty"`
|
DNSResolvers []DNSEntryConfig `json:"dns,omitempty" yaml:"dns,omitempty"`
|
||||||
TLS []string `json:"tls,omitempty" yaml:"tls,omitempty"`
|
TLS []string `json:"tls,omitempty" yaml:"tls,omitempty"`
|
||||||
|
@ -23,8 +23,8 @@ import (
|
|||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
// OutlineOutbound implements the smart dialer outbound
|
// Outbound implements the smart dialer outbound from outline sdk
|
||||||
type OutlineOutbound struct {
|
type Outbound struct {
|
||||||
outbound.Adapter
|
outbound.Adapter
|
||||||
logger logger.ContextLogger
|
logger logger.ContextLogger
|
||||||
dialer otransport.StreamDialer
|
dialer otransport.StreamDialer
|
||||||
@ -32,14 +32,13 @@ type OutlineOutbound struct {
|
|||||||
|
|
||||||
// RegisterOutbound registers the outline outbound to the registry
|
// RegisterOutbound registers the outline outbound to the registry
|
||||||
func RegisterOutbound(registry *outbound.Registry) {
|
func RegisterOutbound(registry *outbound.Registry) {
|
||||||
outbound.Register[option.OutlineOutboundOptions](registry, C.TypeOutline, NewOutlineOutbound)
|
outbound.Register[option.OutboundOutlineOptions](registry, C.TypeOutline, NewOutbound)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewOutlineOutbound creates a proxyless outbond that uses the proxyless transport
|
// NewOutbound creates a proxyless outbond that uses the proxyless transport
|
||||||
// for dialing
|
// for dialing
|
||||||
func NewOutlineOutbound(ctx context.Context, router adapter.Router, logger log.ContextLogger, tag string, options option.OutlineOutboundOptions) (adapter.Outbound, error) {
|
func NewOutbound(ctx context.Context, router adapter.Router, log log.ContextLogger, tag string, options option.OutboundOutlineOptions) (adapter.Outbound, error) {
|
||||||
logger.DebugContext(ctx, "creating outline smart dialer outbound")
|
outboundDialer, err := dialer.New(ctx, options.DialerOptions)
|
||||||
outboundDialer, err := dialer.New(ctx, options.DialerOptions, true)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -51,7 +50,7 @@ func NewOutlineOutbound(ctx context.Context, router adapter.Router, logger log.C
|
|||||||
|
|
||||||
outboundStreamDialer := &outboundStreamDialer{
|
outboundStreamDialer := &outboundStreamDialer{
|
||||||
dialer: outboundDialer,
|
dialer: outboundDialer,
|
||||||
logger: logger,
|
logger: log,
|
||||||
}
|
}
|
||||||
|
|
||||||
strategyFinder := &smart.StrategyFinder{
|
strategyFinder := &smart.StrategyFinder{
|
||||||
@ -72,16 +71,16 @@ func NewOutlineOutbound(ctx context.Context, router adapter.Router, logger log.C
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &OutlineOutbound{
|
return &Outbound{
|
||||||
Adapter: outbound.NewAdapterWithDialerOptions("outline", tag, []string{network.NetworkTCP}, options.DialerOptions),
|
Adapter: outbound.NewAdapterWithDialerOptions("outline", tag, []string{network.NetworkTCP}, options.DialerOptions),
|
||||||
logger: logger,
|
logger: log,
|
||||||
dialer: dialer,
|
dialer: dialer,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DialContext extracts the metadata domain, add the destination to the context
|
// DialContext extracts the metadata domain, add the destination to the context
|
||||||
// and use the proxyless dialer for sending the request
|
// and use the proxyless dialer for sending the request
|
||||||
func (o *OutlineOutbound) DialContext(ctx context.Context, network string, destination metadata.Socksaddr) (net.Conn, error) {
|
func (o *Outbound) DialContext(ctx context.Context, network string, destination metadata.Socksaddr) (net.Conn, error) {
|
||||||
ctx, metadata := adapter.ExtendContext(ctx)
|
ctx, metadata := adapter.ExtendContext(ctx)
|
||||||
metadata.Outbound = o.Tag()
|
metadata.Outbound = o.Tag()
|
||||||
metadata.Destination = destination
|
metadata.Destination = destination
|
||||||
@ -90,7 +89,7 @@ func (o *OutlineOutbound) DialContext(ctx context.Context, network string, desti
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ListenPacket isn't implemented
|
// ListenPacket isn't implemented
|
||||||
func (o *OutlineOutbound) ListenPacket(ctx context.Context, destination metadata.Socksaddr) (net.PacketConn, error) {
|
func (o *Outbound) ListenPacket(ctx context.Context, destination metadata.Socksaddr) (net.PacketConn, error) {
|
||||||
return nil, os.ErrInvalid
|
return nil, os.ErrInvalid
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,7 +104,6 @@ func (s *outboundStreamDialer) DialStream(ctx context.Context, addr string) (otr
|
|||||||
destination := metadata.ParseSocksaddr(addr)
|
destination := metadata.ParseSocksaddr(addr)
|
||||||
conn, err := s.dialer.DialContext(ctx, network.NetworkTCP, destination)
|
conn, err := s.dialer.DialContext(ctx, network.NetworkTCP, destination)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.logger.ErrorContext(ctx, "error dialing %s: %v", addr, err)
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return conn.(*net.TCPConn), nil
|
return conn.(*net.TCPConn), nil
|
||||||
@ -115,7 +113,6 @@ func (s *outboundStreamDialer) DialPacket(ctx context.Context, addr string) (net
|
|||||||
destination := metadata.ParseSocksaddr(addr)
|
destination := metadata.ParseSocksaddr(addr)
|
||||||
conn, err := s.dialer.ListenPacket(ctx, destination)
|
conn, err := s.dialer.ListenPacket(ctx, destination)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.logger.ErrorContext(ctx, "error listening packet %s: %v", addr, err)
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return conn.(*net.UDPConn), nil
|
return conn.(*net.UDPConn), nil
|
||||||
|
Loading…
x
Reference in New Issue
Block a user