Skip to content

sanitize transport options#2

Merged
aymanosman merged 1 commit into
masterfrom
sanitize-transport-options
Mar 25, 2022
Merged

sanitize transport options#2
aymanosman merged 1 commit into
masterfrom
sanitize-transport-options

Conversation

@aymanosman

Copy link
Copy Markdown

Problem

Some transport options are invalid when passed to the tcp transport,
but machine_gun pools are specified not for a specific host-port pair
but for a so called "pool group", this means that options set for the
ssl transport are being passed to the tcp transport and causing
failure.

Solution

Drop invalid options depending on the given transport.
Currently only verify, as that is the option that is being specified.

*Problem*

Some transport options are invalid when passed to the tcp transport,
but machine_gun pools are specified not for a specific host-port pair
but for a so called "pool group", this means that options set for the
ssl transport are being passed to the tcp transport and causing
failure.

*Solution*

Drop invalid options depending on the given transport.
Currently only `verify`, as that is the option that is being specified.
@aymanosman

Copy link
Copy Markdown
Author

Demo of the problem

First install gun

> Mix.install [:gun]
:ok

Passing invalid arguments to the tcp transport raises an error

> {:ok, port} = :gen_tcp.connect('httpbin.org', 80, [verify: :verify_none])
** (exit) :badarg
    (kernel 8.2) gen_tcp.erl:172: :gen_tcp.connect/4

gun swallows the error, the process has terminated but you only notice this once you make a request.

> {:ok, pid} = :gun.open('httpbin.org', 80, %{transport: :tcp, transport_opts: [verify: :verify_none]})
{:ok, #PID<0.220.0>}
> Process.alive? pid
false

@aymanosman aymanosman merged commit a01ba95 into master Mar 25, 2022
@aymanosman aymanosman deleted the sanitize-transport-options branch March 25, 2022 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants