Skip to content

Commit

Permalink
Refactoring: made the no-proxy setting a method pair.
Browse files Browse the repository at this point in the history
  • Loading branch information
mvidner committed May 4, 2018
1 parent df3bc49 commit 9da500c
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions src/modules/Proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@ def main
@pass = ""
end

# no-proxy domains; reader
# @return [String]
def no
@no
end

# no-proxy domains; writer
# @param value [String]
def no=(value)
@no = value
end
# Display popup at the end of the proxy configuration
# @param [Boolean] modified true if proxy settings have been modified
def ProxyFinishPopup(modified)
Expand Down Expand Up @@ -71,8 +82,7 @@ def Read
@https = "" if @https == nil
@ftp = Convert.to_string(SCR.Read(path(".sysconfig.proxy.FTP_PROXY")))
@ftp = "" if @ftp == nil
@no = Convert.to_string(SCR.Read(path(".sysconfig.proxy.NO_PROXY")))
@no = "" if @no == nil
self.no = SCR.Read(path(".sysconfig.proxy.NO_PROXY")) || ""
@enabled = Convert.to_string(
SCR.Read(path(".sysconfig.proxy.PROXY_ENABLED"))
) == "yes"
Expand Down Expand Up @@ -108,7 +118,7 @@ def WriteSysconfig
SCR.Write(path(".sysconfig.proxy.HTTP_PROXY"), @http)
SCR.Write(path(".sysconfig.proxy.HTTPS_PROXY"), @https)
SCR.Write(path(".sysconfig.proxy.FTP_PROXY"), @ftp)
SCR.Write(path(".sysconfig.proxy.NO_PROXY"), @no)
SCR.Write(path(".sysconfig.proxy.NO_PROXY"), no)
SCR.Write(path(".sysconfig.proxy"), nil)
end

Expand All @@ -132,7 +142,7 @@ def WriteCurlrc
# bnc#305163
"--proxy" => @http,
# bsc#923788
"--noproxy" => @no
"--noproxy" => no
}

# proxy is used, write /root/.curlrc
Expand Down Expand Up @@ -210,7 +220,7 @@ def Import(settings)
@http = Ops.get_string(settings, "http_proxy", "")
@https = Ops.get_string(settings, "https_proxy", "")
@ftp = Ops.get_string(settings, "ftp_proxy", "")
@no = Ops.get_string(settings, "no_proxy", "localhost")
self.no = Ops.get_string(settings, "no_proxy", "localhost")
@user = Ops.get_string(settings, "proxy_user", "")
@pass = Ops.get_string(settings, "proxy_password", "")

Expand Down Expand Up @@ -401,7 +411,7 @@ def Export
"http_proxy" => @http,
"https_proxy" => @https,
"ftp_proxy" => @ftp,
"no_proxy" => @no,
"no_proxy" => no,
"proxy_user" => @user,
"proxy_password" => @pass
}
Expand Down Expand Up @@ -480,7 +490,7 @@ def GetEnvironment
"http_proxy" => @http,
"HTTPS_PROXY" => @https,
"FTP_PROXY" => @ftp,
"NO_PROXY" => @no
"NO_PROXY" => no
}
end

Expand All @@ -491,7 +501,6 @@ def GetEnvironment
publish :variable => :http, :type => "string"
publish :variable => :https, :type => "string"
publish :variable => :ftp, :type => "string"
publish :variable => :no, :type => "string"
publish :variable => :user, :type => "string"
publish :variable => :pass, :type => "string"
publish :function => :Read, :type => "boolean ()"
Expand Down

0 comments on commit 9da500c

Please sign in to comment.