From 5c05ed81fe0242d541da15239217335294c8864a Mon Sep 17 00:00:00 2001 From: WendelHime <6754291+WendelHime@users.noreply.github.com> Date: Mon, 3 Mar 2025 18:38:08 -0300 Subject: [PATCH] fix: renaming structs --- option/outline.go | 4 ++-- protocol/outline/outbound.go | 25 +++++++++++-------------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/option/outline.go b/option/outline.go index d65f7b2f..5571a02d 100644 --- a/option/outline.go +++ b/option/outline.go @@ -2,11 +2,11 @@ package option 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 // 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 -type OutlineOutboundOptions struct { +type OutboundOutlineOptions struct { DialerOptions DNSResolvers []DNSEntryConfig `json:"dns,omitempty" yaml:"dns,omitempty"` TLS []string `json:"tls,omitempty" yaml:"tls,omitempty"` diff --git a/protocol/outline/outbound.go b/protocol/outline/outbound.go index 83519b1e..388c01c0 100644 --- a/protocol/outline/outbound.go +++ b/protocol/outline/outbound.go @@ -23,8 +23,8 @@ import ( "gopkg.in/yaml.v3" ) -// OutlineOutbound implements the smart dialer outbound -type OutlineOutbound struct { +// Outbound implements the smart dialer outbound from outline sdk +type Outbound struct { outbound.Adapter logger logger.ContextLogger dialer otransport.StreamDialer @@ -32,14 +32,13 @@ type OutlineOutbound struct { // RegisterOutbound registers the outline outbound to the 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 -func NewOutlineOutbound(ctx context.Context, router adapter.Router, logger log.ContextLogger, tag string, options option.OutlineOutboundOptions) (adapter.Outbound, error) { - logger.DebugContext(ctx, "creating outline smart dialer outbound") - outboundDialer, err := dialer.New(ctx, options.DialerOptions, true) +func NewOutbound(ctx context.Context, router adapter.Router, log log.ContextLogger, tag string, options option.OutboundOutlineOptions) (adapter.Outbound, error) { + outboundDialer, err := dialer.New(ctx, options.DialerOptions) if err != nil { return nil, err } @@ -51,7 +50,7 @@ func NewOutlineOutbound(ctx context.Context, router adapter.Router, logger log.C outboundStreamDialer := &outboundStreamDialer{ dialer: outboundDialer, - logger: logger, + logger: log, } strategyFinder := &smart.StrategyFinder{ @@ -72,16 +71,16 @@ func NewOutlineOutbound(ctx context.Context, router adapter.Router, logger log.C return nil, err } - return &OutlineOutbound{ + return &Outbound{ Adapter: outbound.NewAdapterWithDialerOptions("outline", tag, []string{network.NetworkTCP}, options.DialerOptions), - logger: logger, + logger: log, dialer: dialer, }, nil } // DialContext extracts the metadata domain, add the destination to the context // 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) metadata.Outbound = o.Tag() metadata.Destination = destination @@ -90,7 +89,7 @@ func (o *OutlineOutbound) DialContext(ctx context.Context, network string, desti } // 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 } @@ -105,7 +104,6 @@ func (s *outboundStreamDialer) DialStream(ctx context.Context, addr string) (otr destination := metadata.ParseSocksaddr(addr) conn, err := s.dialer.DialContext(ctx, network.NetworkTCP, destination) if err != nil { - s.logger.ErrorContext(ctx, "error dialing %s: %v", addr, err) return nil, err } return conn.(*net.TCPConn), nil @@ -115,7 +113,6 @@ func (s *outboundStreamDialer) DialPacket(ctx context.Context, addr string) (net destination := metadata.ParseSocksaddr(addr) conn, err := s.dialer.ListenPacket(ctx, destination) if err != nil { - s.logger.ErrorContext(ctx, "error listening packet %s: %v", addr, err) return nil, err } return conn.(*net.UDPConn), nil