Skip to content

Commit 3b4aab3

Browse files
committed
Add local address support for CLI
1 parent 7c7b3e6 commit 3b4aab3

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

exe/wreq

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ parser = OptionParser.new do |o|
101101

102102
o.on("-x", "--proxy URL", "Proxy URL (e.g. http://host:port)") { |p| cfg[:proxy] = p }
103103

104+
o.on("--local-address IP", "Bind outgoing connections to this source IP address") do |ip|
105+
cfg[:local_address] = ip
106+
end
107+
104108
o.on("--timeout SECS", Float, "Total timeout in seconds") { |t| cfg[:timeout] = t }
105109
o.on("--connect-timeout SECS", Float, "Connection timeout in seconds") { |t| cfg[:connect_timeout] = t }
106110

@@ -154,7 +158,7 @@ end
154158
cfg[:method] ||= "GET"
155159

156160
# Build Wreq::Client options (connection/emulation settings only)
157-
CLIENT_KEYS = %i[emulation emulation_os user_agent proxy timeout connect_timeout
161+
CLIENT_KEYS = %i[emulation emulation_os user_agent proxy local_address timeout connect_timeout
158162
http1_only http2_only cookie_store https_only].freeze
159163
client_opts = cfg.slice(*CLIENT_KEYS).reject { |_, v| v.nil? }
160164
client_opts[:redirect] = cfg[:redirect]

0 commit comments

Comments
 (0)