summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2021-05-31 23:10:40 +0800
committerruki <[email protected]>2021-05-31 23:10:40 +0800
commit0e7407de833067b88721bceb934999fe7fa0da8f (patch)
treec0823f6c26b05ccf909a6c7a33956d128beaa27d
parent3ca55fb8685393bf461ab71d61436e1b5f34c4e6 (diff)
improve proxy
-rw-r--r--xmake/modules/net/proxy.lua14
1 files changed, 13 insertions, 1 deletions
diff --git a/xmake/modules/net/proxy.lua b/xmake/modules/net/proxy.lua
index 0d6b6805b..8259a07c9 100644
--- a/xmake/modules/net/proxy.lua
+++ b/xmake/modules/net/proxy.lua
@@ -78,6 +78,18 @@ function _host_pattern(pattern)
return pattern
end
+-- has main entry? it will be callable directly
+function _is_callable(func)
+ if type(func) == "function" then
+ return true
+ elseif type(func) == "table" then
+ local meta = debug.getmetatable(func)
+ if meta and meta.__call then
+ return true
+ end
+ end
+end
+
-- get proxy mirror url
function mirror(url)
local proxy_pac = _proxy_pac()
@@ -111,7 +123,7 @@ function config(url)
-- get proxy from the pac file
local proxy_pac = _proxy_pac()
- if proxy_pac and proxy_pac(url, host) then
+ if proxy_pac and _is_callable(proxy_pac) and proxy_pac(url, host) then
return global.get("proxy")
end
if not proxy_pac and not proxy_hosts then