From ef17fec2bc80c6ec4ad537e74748762d18e92606 Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 23 Apr 2021 22:52:16 +0800 Subject: improve proxy to support mirror url --- xmake/modules/net/proxy.lua | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'xmake/modules/net/proxy.lua') 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 -- cgit v1.3.1