diff options
Diffstat (limited to 'xmake/modules')
| -rw-r--r-- | xmake/modules/devel/git/clone.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/devel/git/ls_remote.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/devel/git/pull.lua | 4 | ||||
| -rw-r--r-- | xmake/modules/net/http/download.lua | 4 | ||||
| -rw-r--r-- | xmake/modules/net/proxy.lua | 14 | ||||
| -rw-r--r-- | xmake/modules/private/action/require/impl/actions/download.lua | 7 | ||||
| -rw-r--r-- | xmake/modules/private/action/require/impl/actions/download_resources.lua | 3 |
7 files changed, 25 insertions, 11 deletions
diff --git a/xmake/modules/devel/git/clone.lua b/xmake/modules/devel/git/clone.lua index da42e33e5..534ae8ac3 100644 --- a/xmake/modules/devel/git/clone.lua +++ b/xmake/modules/devel/git/clone.lua @@ -84,7 +84,7 @@ function main(url, opt) -- use proxy? local envs - local proxy_conf = proxy.get(url) + local proxy_conf = proxy.config(url) if proxy_conf then envs = {ALL_PROXY = proxy_conf} end diff --git a/xmake/modules/devel/git/ls_remote.lua b/xmake/modules/devel/git/ls_remote.lua index c736c85d9..78ee36197 100644 --- a/xmake/modules/devel/git/ls_remote.lua +++ b/xmake/modules/devel/git/ls_remote.lua @@ -58,7 +58,7 @@ function main(reftype, url) -- use proxy? local envs - local proxy_conf = proxy.get(url) + local proxy_conf = proxy.config(url) if proxy_conf then envs = {ALL_PROXY = proxy_conf} end diff --git a/xmake/modules/devel/git/pull.lua b/xmake/modules/devel/git/pull.lua index e40707e4e..9970f8dbc 100644 --- a/xmake/modules/devel/git/pull.lua +++ b/xmake/modules/devel/git/pull.lua @@ -66,7 +66,7 @@ function main(opt) -- use proxy? local envs - local proxy_conf = proxy.get() + local proxy_conf = proxy.config() if proxy_conf then -- get proxy configuration from the current remote url local remoteinfo = try { function() return os.iorunv(git.program, {"remote", "-v"}) end } @@ -76,7 +76,7 @@ function main(opt) if #splitinfo > 1 and splitinfo[1] == (opt.remote or "origin") then local url = splitinfo[2] if url then - proxy_conf = proxy.get(url) + proxy_conf = proxy.config(url) end break end diff --git a/xmake/modules/net/http/download.lua b/xmake/modules/net/http/download.lua index aad644416..7a90ac8bc 100644 --- a/xmake/modules/net/http/download.lua +++ b/xmake/modules/net/http/download.lua @@ -64,7 +64,7 @@ function _curl_download(tool, url, outputfile, opt) end -- use proxy? - local proxy_conf = proxy.get(url) + local proxy_conf = proxy.config(url) if proxy_conf then table.insert(argv, "-x") table.insert(argv, proxy_conf) @@ -114,7 +114,7 @@ function _wget_download(tool, url, outputfile, opt) end -- use proxy? - local proxy_conf = proxy.get(url) + local proxy_conf = proxy.config(url) if proxy_conf then table.insert(argv, "-e") table.insert(argv, "use_proxy=yes") diff --git a/xmake/modules/net/proxy.lua b/xmake/modules/net/proxy.lua index e216931dd..0d6b6805b 100644 --- a/xmake/modules/net/proxy.lua +++ b/xmake/modules/net/proxy.lua @@ -39,6 +39,9 @@ end -- pac.lua -- -- @code +-- function mirror(url) +-- return url:gsub("github.com", "hub.fastgit.org") +-- end -- function main(url, host) -- if host:find("bintray.com") then -- return true @@ -75,11 +78,20 @@ function _host_pattern(pattern) return pattern end +-- get proxy mirror url +function mirror(url) + local proxy_pac = _proxy_pac() + if proxy_pac and proxy_pac.mirror then + return proxy_pac.mirror(url) + end + return url +end + -- get proxy configuration from the given url, [protocol://]host[:port] -- -- @see https://github.com/xmake-io/xmake/issues/854 -- -function get(url) +function config(url) -- enable proxy for the given url and configuration pattern if url then diff --git a/xmake/modules/private/action/require/impl/actions/download.lua b/xmake/modules/private/action/require/impl/actions/download.lua index 019b01ae8..ba742aeb3 100644 --- a/xmake/modules/private/action/require/impl/actions/download.lua +++ b/xmake/modules/private/action/require/impl/actions/download.lua @@ -29,6 +29,7 @@ import("lib.detect.find_directory") import("private.action.require.impl.utils.filter") import("private.action.require.impl..utils.url_filename") import("net.http") +import("net.proxy") import("devel.git") import("utils.archive") @@ -67,13 +68,13 @@ function _checkout(package, url, sourcedir, url_alias) if package:branch() then -- only shadow clone this branch - git.clone(url, {depth = 1, recursive = true, longpaths = longpaths, branch = package:branch(), outputdir = packagedir}) + git.clone(proxy.mirror(url), {depth = 1, recursive = true, longpaths = longpaths, branch = package:branch(), outputdir = packagedir}) -- download package from revision or tag? else -- clone whole history and tags - git.clone(url, {longpaths = longpaths, outputdir = packagedir}) + git.clone(proxy.mirror(url), {longpaths = longpaths, outputdir = packagedir}) -- attempt to checkout the given version local revision = package:revision(url_alias) or package:tag() or package:version_str() @@ -134,7 +135,7 @@ function _download(package, url, sourcedir, url_alias, url_excludes) -- we can use local package from the search directories directly if network is too slow os.cp(localfile, packagefile) else - http.download(url, packagefile) + http.download(proxy.mirror(url), packagefile) end end diff --git a/xmake/modules/private/action/require/impl/actions/download_resources.lua b/xmake/modules/private/action/require/impl/actions/download_resources.lua index 9c40b0b81..5a85c7c35 100644 --- a/xmake/modules/private/action/require/impl/actions/download_resources.lua +++ b/xmake/modules/private/action/require/impl/actions/download_resources.lua @@ -23,6 +23,7 @@ import("core.base.option") import("core.package.package", {alias = "core_package"}) import("lib.detect.find_file") import("net.http") +import("net.proxy") import("utils.archive") -- download resources @@ -55,7 +56,7 @@ function _download(package, resource_name, resource_url, resource_hash) -- we can use local resource from the search directories directly if network is too slow os.cp(localfile, resource_file) elseif resource_url:find(string.ipattern("https-://")) or resource_url:find(string.ipattern("ftps-://")) then - http.download(resource_url, resource_file) + http.download(proxy.mirror(resource_url), resource_file) else raise("invalid resource url(%s)", resource_url) end |
