ninenines / gun

HTTP/1.1, HTTP/2, Websocket client (and more) for Erlang/OTP.
ISC License
891 stars 232 forks source link

Fix infinite loop when connecting from a source in another subnet #290

Closed juantascon closed 2 years ago

juantascon commented 2 years ago

There's an infinite loop when trying to connect to an ip if you provide a source ip address in another subnet, this can be reproduced like this: :gun_pool.start_pool({20.20.20.1}, 8888, %{conn_opts: %{protocols: [:http2],tcp_opts: [ip: {127, 0, 0, 1}]}})

essen commented 2 years ago

Thanks I will take a look soon.

juantascon commented 2 years ago

@essen please do not forget to review

essen commented 2 years ago

Please don't bump I will review when time allows.

essen commented 2 years ago

OK I can reproduce. The fix is invalid because it only "fixes" gun_pool and not plain Gun usage. The right fix would be to do what this todo talks about: https://github.com/ninenines/gun/blob/master/src/gun_pools_sup.erl#L33

I have opened #292 to track this. Thanks!

essen commented 1 year ago

This is fixed in the most recent commit. The pool will be left in a degraded state when this happens, but it will no longer try to open new Gun connections infinitely.