projectdiscovery / fastdialer

Dialer with DNS Cache + Dial History
MIT License
53 stars 20 forks source link

parallel first dial using singleflight #287

Closed tarunKoyalwar closed 4 months ago

tarunKoyalwar commented 4 months ago

Observed behaviour/issue

If a domain, such as hackerone.com, resolves to multiple IPs, Fastdialer previously used sequential iteration. This was inefficient because if a port on the address was closed, Fastdialer would iterate over all IPs and each failed iteration would add to the total time. This issue was exacerbated when Nuclei called this function on 1000 goroutines, creating a bottleneck and delay in execution.

Proposed Changes

After multiple investigations and experiments in #284, the issue is mitigated by the following changes:

Misc changes

[!NOTE] almost all of the new logic is implemented by abstracting net.Dialer at utils/dialwrap to keep refactor / changes minimal and easy to replace

[!TIP] Checkout Associated PR in nuclei for all benefits / improvements this PR provides

tarunKoyalwar commented 4 months ago

context https://github.com/projectdiscovery/nuclei/pull/5148