Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

options[:no_proxy] has no value #79

Closed
Valiron opened this issue Aug 9, 2017 · 2 comments
Closed

options[:no_proxy] has no value #79

Valiron opened this issue Aug 9, 2017 · 2 comments

Comments

@Valiron
Copy link

Valiron commented Aug 9, 2017

When I tried to use the no_proxy option to bypass the proxy, it didn't delivered it correctly.
It doesn't appear in the initialize function in the client.rb

# Initializes a new Client object
    #
    # @param options [Hash]
    # @return [ZabbixApi::Client]
def initialize(options = {})

      @options = options
      if !ENV['http_proxy'].nil? && options[:no_proxy] != true
        @proxy_uri = URI.parse(ENV['http_proxy'])
        @proxy_host = @proxy_uri.host
        @proxy_port = @proxy_uri.port
        @proxy_user, @proxy_pass = @proxy_uri.userinfo.split(/:/) if @proxy_uri.userinfo
      end
      unless api_version =~ /(2\.4|3\.[02])\.\d+/
        raise ApiError.new("Zabbix API version: #{api_version} is not support by this version of zabbixapi")
      end
      @auth_hash = auth
    end
@jrbeilke
Copy link
Collaborator

Have an example of the code you're using and the response?

no_proxy is the default so you shouldn't need to pass that param unless you're needing to deal with a proxy in front of Zabbix

@pu239ppy
Copy link

pu239ppy commented Sep 13, 2017

I am also having this isssue

Per Net::Http documentation

Net::HTTP will automatically create a proxy from the http_proxy environment variable if it is present. To disable use of http_proxy, pass nil for the proxy address.

so it seem that if condition

!ENV['http_proxy'].nil? && options[:no_proxy] != true

evaluates to false you still need to tell Net::HTTP not to use a proxy, so what you really want is

      if @proxy_uri
        http = Net::HTTP.Proxy(@proxy_host, @proxy_port, @proxy_user, @proxy_pass).new(uri.host, uri.port)
      else
        http = Net::HTTP.new(uri.host, uri.port, nil)
      end

Also as @proxy_uri is a derived value perhaps you still want :no_proxy to drive this behavior

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

No branches or pull requests

4 participants