Explorar o código

Allow direct outbounds without `domain_resolver`

世界 hai 6 meses
pai
achega
ac7bc587cb
Modificáronse 2 ficheiros con 8 adicións e 2 borrados
  1. 2 1
      common/dialer/dialer.go
  2. 6 1
      protocol/direct/outbound.go

+ 2 - 1
common/dialer/dialer.go

@@ -24,6 +24,7 @@ type Options struct {
 	ResolverOnDetour bool
 	NewDialer        bool
 	LegacyDNSDialer  bool
+	DirectOutbound   bool
 }
 
 // TODO: merge with NewWithOptions
@@ -108,7 +109,7 @@ func NewWithOptions(options Options) (N.Dialer, error) {
 				dnsQueryOptions.Transport = dnsTransport.Default()
 			} else if options.NewDialer {
 				return nil, E.New("missing domain resolver for domain server address")
-			} else {
+			} else if !options.DirectOutbound {
 				deprecated.Report(options.Context, deprecated.OptionMissingDomainResolver)
 			}
 		}

+ 6 - 1
protocol/direct/outbound.go

@@ -48,7 +48,12 @@ func NewOutbound(ctx context.Context, router adapter.Router, logger log.ContextL
 	if options.Detour != "" {
 		return nil, E.New("`detour` is not supported in direct context")
 	}
-	outboundDialer, err := dialer.New(ctx, options.DialerOptions, true)
+	outboundDialer, err := dialer.NewWithOptions(dialer.Options{
+		Context:        ctx,
+		Options:        options.DialerOptions,
+		RemoteIsDomain: true,
+		DirectOutbound: true,
+	})
 	if err != nil {
 		return nil, err
 	}