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(+) (limited to 'src') 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