From f022fe08167e67ae854120d472d273bed47ff3ff Mon Sep 17 00:00:00 2001 From: Ignacio Burgueño Date: Fri, 17 Apr 2015 12:22:54 -0300 Subject: Drop use of config.proxy Alwways fallback to defined downloader if https_proxy env var is set. --- src/luarocks/cfg.lua | 3 +++ src/luarocks/fs/lua.lua | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index ba8c7f22..b7e76535 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua @@ -595,6 +595,9 @@ end cfg.user_agent = "LuaRocks/"..cfg.program_version.." "..cfg.arch +cfg.http_proxy = os.getenv("http_proxy") +cfg.https_proxy = os.getenv("https_proxy") + --- Check if platform was detected -- @param query string: The platform name to check. -- @return boolean: true if LuaRocks is currently running on queried platform. diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index 48db4a0d..1a2ec888 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua @@ -545,7 +545,7 @@ local redirect_protocols = { local function request(url, method, http, loop_control) local result = {} - local proxy = cfg.proxy + local proxy = cfg.http_proxy if type(proxy) ~= "string" then proxy = nil end -- LuaSocket's http.request crashes when given URLs missing the scheme part. if proxy and not proxy:find("://") then @@ -660,7 +660,7 @@ function fs_lua.download(url, filename, cache) elseif util.starts_with(url, "ftp:") then content, err = ftp.get(url) elseif util.starts_with(url, "https:") then - if luasec_ok then + if luasec_ok and not cfg.https_proxy then content, err = http_request(url, https, cache and filename) else https_err = true -- cgit v1.2.3-55-g6feb From 2c536b4bdd07b6f8983876a01296a1e8c752d2be Mon Sep 17 00:00:00 2001 From: Ignacio Burgueño Date: Fri, 17 Apr 2015 15:58:10 -0300 Subject: Deal with 'no_proxy' env var If the 'no_proxy' environment variable, delegate to the downloader to deal with it. --- src/luarocks/cfg.lua | 6 ++++++ src/luarocks/fs/lua.lua | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index b7e76535..f6993ba5 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua @@ -597,6 +597,12 @@ cfg.user_agent = "LuaRocks/"..cfg.program_version.." "..cfg.arch cfg.http_proxy = os.getenv("http_proxy") cfg.https_proxy = os.getenv("https_proxy") +cfg.no_proxy = os.getenv("no_proxy") + +-- make sure that no_proxy is not 'alone' +if cfg.no_proxy and not (cfg.https_proxy or cfg.http_proxy) then + cfg.no_proxy = nil +end --- Check if platform was detected -- @param query string: The platform name to check. diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index 1a2ec888..c0f6c1c6 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua @@ -653,6 +653,11 @@ function fs_lua.download(url, filename, cache) assert(type(filename) == "string" or not filename) filename = fs.absolute_name(filename or dir.base_name(url)) + + -- delegate to the configured downloader so we don't have to deal with whitelists + if cfg.no_proxy then + return fs.use_downloader(url, filename, cache) + end local content, err, https_err if util.starts_with(url, "http:") then @@ -660,6 +665,7 @@ function fs_lua.download(url, filename, cache) elseif util.starts_with(url, "ftp:") then content, err = ftp.get(url) elseif util.starts_with(url, "https:") then + -- skip LuaSec when proxy is enabled since it is not supported if luasec_ok and not cfg.https_proxy then content, err = http_request(url, https, cache and filename) else -- cgit v1.2.3-55-g6feb From 7b6efb92c092aa00affa8fe63b6226476864c6e3 Mon Sep 17 00:00:00 2001 From: Ignacio Burgueño Date: Fri, 17 Apr 2015 16:17:34 -0300 Subject: Trust the user :) --- src/luarocks/cfg.lua | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index f6993ba5..49ce5188 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua @@ -599,11 +599,6 @@ cfg.http_proxy = os.getenv("http_proxy") cfg.https_proxy = os.getenv("https_proxy") cfg.no_proxy = os.getenv("no_proxy") --- make sure that no_proxy is not 'alone' -if cfg.no_proxy and not (cfg.https_proxy or cfg.http_proxy) then - cfg.no_proxy = nil -end - --- Check if platform was detected -- @param query string: The platform name to check. -- @return boolean: true if LuaRocks is currently running on queried platform. -- cgit v1.2.3-55-g6feb