Skip to content

Commit

Permalink
Make sure our iOS dialer does not get overwritten
Browse files Browse the repository at this point in the history
  • Loading branch information
lixmal committed Feb 15, 2024
1 parent cf87f1e commit f714880
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion client/internal/dns/upstream_ios.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,16 @@ func (u *upstreamResolverIOS) exchange(ctx context.Context, upstream string, r *
client = u.getClientPrivate()
}

return client.ExchangeContext(ctx, r, upstream)
// Cannot use client.ExchangeContext because it overwrites our Dialer
// Instead we set the timeout from the context and restore it after the call
if deadline, ok := ctx.Deadline(); ok {
oldTimeout := client.Dialer.Timeout
client.Dialer.Timeout = time.Until(deadline)
defer func() {
client.Dialer.Timeout = oldTimeout
}()
}
return client.Exchange(r, upstream)
}

// getClientPrivate returns a new DNS client bound to the local IP address of the Netbird interface
Expand Down

0 comments on commit f714880

Please sign in to comment.