diff --git a/luci-app-passwall/Makefile b/luci-app-passwall/Makefile index 722e5820d..d9ef4471d 100644 --- a/luci-app-passwall/Makefile +++ b/luci-app-passwall/Makefile @@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-passwall PKG_VERSION:=4.62 -PKG_RELEASE:=3 +PKG_RELEASE:=4 PKG_CONFIG_DEPENDS:= \ CONFIG_PACKAGE_$(PKG_NAME)_Iptables_Transparent_Proxy \ diff --git a/luci-app-passwall/root/usr/share/passwall/app.sh b/luci-app-passwall/root/usr/share/passwall/app.sh index 7ce63a8c8..a5a19ae02 100755 --- a/luci-app-passwall/root/usr/share/passwall/app.sh +++ b/luci-app-passwall/root/usr/share/passwall/app.sh @@ -1224,7 +1224,7 @@ start_haproxy() { [ "$(config_t_get global_haproxy balancing_enable 0)" != "1" ] && return haproxy_path=${TMP_PATH}/haproxy haproxy_conf="config.cfg" - lua $APP_PATH/haproxy.lua -path ${haproxy_path} -conf ${haproxy_conf} + lua $APP_PATH/haproxy.lua -path ${haproxy_path} -conf ${haproxy_conf} -dns ${LOCAL_DNS} ln_run "$(first_type haproxy)" haproxy "/dev/null" -f "${haproxy_path}/${haproxy_conf}" } diff --git a/luci-app-passwall/root/usr/share/passwall/haproxy.lua b/luci-app-passwall/root/usr/share/passwall/haproxy.lua index 3dd63d1d2..42f12c7b9 100644 --- a/luci-app-passwall/root/usr/share/passwall/haproxy.lua +++ b/luci-app-passwall/root/usr/share/passwall/haproxy.lua @@ -30,6 +30,7 @@ end local var = api.get_args(arg) local haproxy_path = var["-path"] local haproxy_conf = var["-conf"] +local haproxy_dns = var["-dns"] or "119.29.29.29" local health_check_type = uci:get(appname, "@global_haproxy[0]", "health_check_type") or "tcp" local health_check_inter = uci:get(appname, "@global_haproxy[0]", "health_check_inter") or "10" @@ -43,11 +44,11 @@ local f_out = io.open(haproxy_file, "a") local haproxy_config = [[ global + daemon log 127.0.0.1 local2 maxconn 60000 stats socket %s/haproxy.sock %s - daemon defaults mode tcp @@ -68,17 +69,17 @@ defaults maxconn 3000 resolvers mydns - nameserver dns1 127.0.0.1:53 + nameserver dns1 %s:53 resolve_retries 3 timeout retry 3s - hold valid 30s + hold valid 600s ]] f_out:write(string.format(haproxy_config, haproxy_path, health_check_type == "passwall_logic" and string.format([[ external-check insecure-fork-wanted -]]) or "" +]]) or "", haproxy_dns )) local listens = {} @@ -95,6 +96,8 @@ uci:foreach(appname, "haproxy_config", function(t) server_remark = server_node.address .. ":" .. server_node.port server_address = server_node.address server_port = server_node.port + t.origin_address = server_address + t.origin_port = server_port if health_check_type == "passwall_logic" then if server_node.type ~= "Socks" then local relay_port = server_node.port @@ -118,6 +121,8 @@ uci:foreach(appname, "haproxy_config", function(t) else server_address, server_port = get_ip_port_from(lbss) server_remark = server_address .. ":" .. server_port + t.origin_address = server_address + t.origin_port = server_port end if server_address and server_port and listen_port > 0 then if not listens[listen_port] then @@ -166,10 +171,10 @@ listen %s ]], remark, server, o.lbweight, health_check_inter, o.backup == "1" and "backup" or "")) if o.export ~= "0" then - sys.call(string.format("/usr/share/passwall/app.sh add_ip2route %s %s", o.server_address, o.export)) + sys.call(string.format("/usr/share/passwall/app.sh add_ip2route %s %s", o.origin_address, o.export)) end - log(string.format(" | - 出口节点:%s:%s,权重:%s", o.server_address, o.server_port, o.lbweight)) + log(string.format(" | - 出口节点:%s:%s,权重:%s", o.origin_address, o.origin_port, o.lbweight)) end end