From e2ef7d83a17bf3fd93995e16eb67dcde3a6fbba4 Mon Sep 17 00:00:00 2001 From: Sergei Maklagin Date: Sat, 2 May 2026 14:54:26 +0300 Subject: [PATCH] Fix creating config for WARP --- protocol/warp/endpoint.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/protocol/warp/endpoint.go b/protocol/warp/endpoint.go index 8b417813..2ec1a24d 100644 --- a/protocol/warp/endpoint.go +++ b/protocol/warp/endpoint.go @@ -68,7 +68,7 @@ func NewEndpoint(ctx context.Context, router adapter.Router, logger log.ContextL } } if config == nil { - config, err := endpoint.createConfig() + config, err = endpoint.createConfig() if err != nil { logger.ErrorContext(ctx, err) return @@ -183,6 +183,16 @@ func (w *Endpoint) isEndpointInitialized(ctx context.Context) error { } func (w *Endpoint) createConfig() (*Config, error) { + opts := make([]cloudflare.CloudflareApiOption, 0, 1) + if w.options.Profile.Detour != "" { + detour, ok := service.FromContext[adapter.OutboundManager](w.ctx).Outbound(w.options.Profile.Detour) + if !ok { + return nil, E.New("outbound detour not found: ", w.options.Profile.Detour) + } + opts = append(opts, cloudflare.WithDialContext(func(ctx context.Context, network, addr string) (net.Conn, error) { + return detour.DialContext(ctx, network, M.ParseSocksaddr(addr)) + })) + } var privateKey wgtypes.Key var err error if w.options.Profile.PrivateKey != "" { @@ -196,16 +206,6 @@ func (w *Endpoint) createConfig() (*Config, error) { return nil, err } } - opts := make([]cloudflare.CloudflareApiOption, 0, 1) - if w.options.Profile.Detour != "" { - detour, ok := service.FromContext[adapter.OutboundManager](w.ctx).Outbound(w.options.Profile.Detour) - if !ok { - return nil, E.New("outbound detour not found: ", w.options.Profile.Detour) - } - opts = append(opts, cloudflare.WithDialContext(func(ctx context.Context, network, addr string) (net.Conn, error) { - return detour.DialContext(ctx, network, M.ParseSocksaddr(addr)) - })) - } api := cloudflare.NewCloudflareApi(opts...) var profile *cloudflare.CloudflareProfile if w.options.Profile.AuthToken != "" && w.options.Profile.ID != "" {