Ethon - Valid resolve option format

242 views Asked by At

Curl has an option which allows me to specify to which IP a domain should be resolved

e.g. curl --resolve example.com:443:1.2.3.4 https://example.com/foo

to make sure that a very specific server is called (e.g. when multiple servers have the same vhost with a load balancer usually in front of it and there are multiple applications running on the same port with different vhosts)

How do I set this value when using Ethon? https://github.com/typhoeus/ethon

This is how I'd expect it to work

Ethon::Easy.new(url: "https://example.com/foo", :resolve => "example.com:443:1.2.3.4")

but I'm getting an invalid value exception (I have tried multiple different formats that came to mind)

Ethon::Errors::InvalidValue: The value: example.com:443:1.2.3.4 is invalid for option: resolve.

I took a look at the code but couldn't figure out how I'd have to provide the value - and the documentation on this is a bit scarce

Thanks in advance for any reply that might point me in the right direction

1

There are 1 answers

0
Tobias Schoknecht On

Thanks to i0rek on Github I got the answer I was looking for:

resolve = nil
Ethon::Curl.slist_append(resolve, "example.com:443:1.2.3.4")
e = Ethon::Easy.new(url: "https://example.com/foo", :resolve => resolve)
#=> #<Ethon::Easy:0x007faca2574f30 @url="https://example.com/foo", ...>

Further information can be found here: https://github.com/typhoeus/ethon/issues/95#event-199961240