diff --git a/package/lienol/luci-app-passwall/Makefile b/package/lienol/luci-app-passwall/Makefile
index 85b442c049..f15062610b 100644
--- a/package/lienol/luci-app-passwall/Makefile
+++ b/package/lienol/luci-app-passwall/Makefile
@@ -7,8 +7,8 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-passwall
PKG_VERSION:=3.6
-PKG_RELEASE:=13
-PKG_DATE:=20200305
+PKG_RELEASE:=16
+PKG_DATE:=20200306
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_trojan_client_config.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_trojan.lua
similarity index 100%
rename from package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_trojan_client_config.lua
rename to package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_trojan.lua
diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_v2ray_client_config.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_v2ray.lua
similarity index 75%
rename from package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_v2ray_client_config.lua
rename to package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_v2ray.lua
index 81e347443a..03d20c2690 100755
--- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_v2ray_client_config.lua
+++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_v2ray.lua
@@ -141,61 +141,6 @@ if node.type == "V2ray_balancing" and node.v2ray_balancing_node then
{type = "field", network = "tcp,udp", balancerTag = "balancer"}
}
}
-elseif node.type == "V2ray_shunt" then
- local rules = {}
-
- local youtube_node = node.youtube_node or nil
- if youtube_node and youtube_node ~= "nil" then
- local node = ucursor:get_all("passwall", youtube_node)
- local youtube_outbound = gen_outbound(node, "youtube")
- if youtube_outbound then
- table.insert(outbounds, youtube_outbound)
- local rule = {
- type = "field",
- domain = {
- "youtube", "youtube.com", "youtu.be", "googlevideo.com",
- "ytimg.com","gvt2.com"
- },
- outboundTag = "youtube"
- }
- table.insert(rules, rule)
- end
- end
-
- local netflix_node = node.netflix_node or nil
- if netflix_node and netflix_node ~= "nil" then
- local node = ucursor:get_all("passwall", netflix_node)
- local netflix_outbound = gen_outbound(node, "netflix")
- if netflix_outbound then
- table.insert(outbounds, netflix_outbound)
- local rule = {
- type = "field",
- domain = {
- "netflix", "netflix.com", "nflxso.net", "nflxext.com",
- "nflximg.com", "nflximg.net", "nflxvideo.net"
- },
- outboundTag = "netflix"
- }
- table.insert(rules, rule)
- end
- end
-
- local default_node = node.default_node or nil
- if default_node and default_node ~= "nil" then
- local node = ucursor:get_all("passwall", default_node)
- local default_outbound = gen_outbound(node, "default")
- if default_outbound then
- table.insert(outbounds, default_outbound)
- local rule = {
- type = "field",
- outboundTag = "default",
- network = network
- }
- table.insert(rules, rule)
- end
- end
-
- routing = {domainStrategy = "IPOnDemand", rules = rules}
else
local outbound = gen_outbound(node)
if outbound then table.insert(outbounds, outbound) end
diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_v2ray_shunt.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_v2ray_shunt.lua
new file mode 100755
index 0000000000..ba9d6a315b
--- /dev/null
+++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_v2ray_shunt.lua
@@ -0,0 +1,242 @@
+local ucursor = require"luci.model.uci".cursor()
+local sys = require "luci.sys"
+local json = require "luci.jsonc"
+local node_section = arg[1]
+local proto = arg[2]
+local redir_port = arg[3]
+local socks5_proxy_port = arg[4]
+local node = ucursor:get_all("passwall", node_section)
+local inbounds = {}
+local outbounds = {}
+local network = proto
+local routing = nil
+
+local function gen_outbound(node, tag)
+ local result = nil
+ if node then
+ local cbi_id = node[".name"]
+ if node.type ~= "V2ray" then
+ if node.type == "Socks5" then
+ node.v2ray_protocol = "socks"
+ node.v2ray_transport = "tcp"
+ else
+ local node_type = (proto and proto ~= "nil") and proto or
+ "socks"
+ local new_port = sys.exec(
+ "echo -n $(/usr/share/passwall/app.sh get_new_port auto tcp)")
+ node.port = new_port
+ sys.call(string.format(
+ "/usr/share/passwall/app.sh gen_start_config %s %s %s %s %s %s",
+ cbi_id, new_port, "SOCKS5",
+ "/var/etc/passwall/v2_shunt_" .. node_type .. "_" ..
+ cbi_id .. ".json", "4", "127.0.0.1"))
+ node.v2ray_protocol = "socks"
+ node.v2ray_transport = "tcp"
+ node.address = "127.0.0.1"
+ end
+ end
+ result = {
+ tag = tag,
+ cbi_id = cbi_id,
+ protocol = node.v2ray_protocol or "vmess",
+ mux = {
+ enabled = (node.v2ray_mux == "1") and true or false,
+ concurrency = (node.v2ray_mux_concurrency) and
+ tonumber(node.v2ray_mux_concurrency) or 8
+ },
+ -- 底层传输配置
+ streamSettings = {
+ network = node.v2ray_transport,
+ security = node.v2ray_stream_security,
+ tlsSettings = (node.v2ray_stream_security == "tls") and {
+ serverName = node.tls_serverName,
+ allowInsecure = (node.tls_allowInsecure == "1") and true or
+ false
+ } or nil,
+ tcpSettings = (node.v2ray_transport == "tcp" and
+ node.v2ray_protocol ~= "socks") and {
+ header = {
+ type = node.v2ray_tcp_guise,
+ request = {
+ path = node.v2ray_tcp_guise_http_path or {"/"},
+ headers = {
+ Host = node.v2ray_tcp_guise_http_host or {}
+ }
+ } or {}
+ }
+ } or nil,
+ kcpSettings = (node.v2ray_transport == "mkcp") and {
+ mtu = tonumber(node.v2ray_mkcp_mtu),
+ tti = tonumber(node.v2ray_mkcp_tti),
+ uplinkCapacity = tonumber(node.v2ray_mkcp_uplinkCapacity),
+ downlinkCapacity = tonumber(node.v2ray_mkcp_downlinkCapacity),
+ congestion = (node.v2ray_mkcp_congestion == "1") and true or
+ false,
+ readBufferSize = tonumber(node.v2ray_mkcp_readBufferSize),
+ writeBufferSize = tonumber(node.v2ray_mkcp_writeBufferSize),
+ header = {type = node.v2ray_mkcp_guise}
+ } or nil,
+ wsSettings = (node.v2ray_transport == "ws") and {
+ path = node.v2ray_ws_path or "",
+ headers = (node.v2ray_ws_host ~= nil) and
+ {Host = node.v2ray_ws_host} or nil
+ } or nil,
+ httpSettings = (node.v2ray_transport == "h2") and
+ {path = node.v2ray_h2_path, host = node.v2ray_h2_host} or
+ nil,
+ dsSettings = (node.v2ray_transport == "ds") and
+ {path = node.v2ray_ds_path} or nil,
+ quicSettings = (node.v2ray_transport == "quic") and {
+ security = node.v2ray_quic_security,
+ key = node.v2ray_quic_key,
+ header = {type = node.v2ray_quic_guise}
+ } or nil
+ },
+ settings = {
+ vnext = (node.v2ray_protocol == "vmess") and {
+ {
+ address = node.address,
+ port = tonumber(node.port),
+ users = {
+ {
+ id = node.v2ray_VMess_id,
+ alterId = tonumber(node.v2ray_VMess_alterId),
+ level = tonumber(node.v2ray_VMess_level),
+ security = node.v2ray_security
+ }
+ }
+ }
+ } or nil,
+ servers = (node.v2ray_protocol == "socks") and {
+ {
+ address = node.address,
+ port = tonumber(node.port),
+ users = (node.username and node.password) and
+ {{user = node.username, pass = node.password}} or
+ nil
+ }
+ } or (node.v2ray_protocol == "ss") and {
+ {
+ email = nil,
+ address = node.address,
+ method = nil,
+ ota = nil,
+ password = node.password or nil,
+ port = tonumber(node.port),
+ level = 1
+ }
+ } or nil
+ }
+ }
+ end
+ return result
+end
+
+if socks5_proxy_port ~= "nil" then
+ table.insert(inbounds, {
+ listen = "0.0.0.0",
+ port = socks5_proxy_port,
+ protocol = "socks",
+ settings = {auth = "noauth", udp = true, ip = "127.0.0.1"}
+ })
+ network = "tcp,udp"
+end
+
+if redir_port ~= "nil" then
+ table.insert(inbounds, {
+ port = redir_port,
+ protocol = "dokodemo-door",
+ settings = {network = proto, followRedirect = true},
+ sniffing = {enabled = true, destOverride = {"http", "tls"}}
+ })
+ if proto == "tcp" and node.v2ray_tcp_socks == "1" then
+ table.insert(inbounds, {
+ listen = "0.0.0.0",
+ port = tonumber(node.v2ray_tcp_socks_port),
+ protocol = "socks",
+ settings = {
+ auth = node.v2ray_tcp_socks_auth,
+ accounts = (node.v2ray_tcp_socks_auth == "password") and {
+ {
+ user = node.v2ray_tcp_socks_auth_username,
+ pass = node.v2ray_tcp_socks_auth_password
+ }
+ } or nil,
+ udp = true
+ }
+ })
+ end
+end
+
+local rules = {}
+
+local youtube_node = node.youtube_node or nil
+if youtube_node and youtube_node ~= "nil" then
+ local node = ucursor:get_all("passwall", youtube_node)
+ local youtube_outbound = gen_outbound(node, "youtube")
+ if youtube_outbound then
+ table.insert(outbounds, youtube_outbound)
+ local rule = {
+ type = "field",
+ domain = {
+ "youtube", "youtube.com", "youtu.be", "googlevideo.com",
+ "ytimg.com", "gvt2.com"
+ },
+ outboundTag = "youtube"
+ }
+ table.insert(rules, rule)
+ end
+end
+
+local netflix_node = node.netflix_node or nil
+if netflix_node and netflix_node ~= "nil" then
+ local node = ucursor:get_all("passwall", netflix_node)
+ local netflix_outbound = gen_outbound(node, "netflix")
+ if netflix_outbound then
+ table.insert(outbounds, netflix_outbound)
+ local rule = {
+ type = "field",
+ domain = {
+ "netflix", "netflix.com", "nflxso.net", "nflxext.com",
+ "nflximg.com", "nflximg.net", "nflxvideo.net"
+ },
+ outboundTag = "netflix"
+ }
+ table.insert(rules, rule)
+ end
+end
+
+local default_node = node.default_node or nil
+if default_node and default_node ~= "nil" then
+ local node = ucursor:get_all("passwall", default_node)
+ local default_outbound = gen_outbound(node, "default")
+ if default_outbound then
+ table.insert(outbounds, default_outbound)
+ local rule = {
+ type = "field",
+ outboundTag = "default",
+ network = network
+ }
+ table.insert(rules, rule)
+ end
+end
+
+routing = {domainStrategy = "IPOnDemand", rules = rules}
+
+-- 额外传出连接
+table.insert(outbounds,
+ {protocol = "freedom", tag = "direct", settings = {keep = ""}})
+
+local v2ray = {
+ log = {
+ -- error = "/var/log/v2ray.log",
+ loglevel = "warning"
+ },
+ -- 传入连接
+ inbounds = inbounds,
+ -- 传出连接
+ outbounds = outbounds,
+ -- 路由
+ routing = routing
+}
+print(json.stringify(v2ray, 1))
diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/node_config.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/node_config.lua
index 9346ae1dea..15365aa48f 100644
--- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/node_config.lua
+++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/node_config.lua
@@ -96,9 +96,9 @@ brook_tls:depends("brook_protocol", "wsclient")
local n = {}
uci:foreach(appname, "nodes", function(e)
- if e.type and e.type == "V2ray" and e.remarks and e.port then
+ if e.type and e.remarks and e.port then
if e.address:match("[\u4e00-\u9fa5]") and e.address:find("%.") and e.address:sub(#e.address) ~= "." then
- n[e[".name"]] = "[%s] %s:%s" % {e.remarks, e.address, e.port}
+ n[e[".name"]] = "%s:[%s] %s:%s" % {e.type, e.remarks, e.address, e.port}
end
end
end)
diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/node_list.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/node_list.lua
index 9641f4b5f0..38a3fb9fdb 100644
--- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/node_list.lua
+++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/node_list.lua
@@ -76,8 +76,7 @@ if api.uci_get_type("global_other", "compact_display_nodes", "0") == "1" then
local type = api.uci_get_type_id(n, "type") or ""
local address = api.uci_get_type_id(n, "address") or ""
local port = api.uci_get_type_id(n, "port") or ""
- if is_sub == "" and group == "" then str = str .. translate(type) .. ":" end
- str = str .. remarks
+ str = str .. translate(type) .. ":" .. remarks
if address ~= "" and port ~= "" then
local s = " (" .. address .. ":" .. port .. ")"
str = str .. s
@@ -98,23 +97,28 @@ else
return str
end
end
- ---- Remarks
- o = s:option(DummyValue, "remarks", translate("Remarks"))
---- Type
o = s:option(DummyValue, "type", translate("Type"))
o.cfgvalue = function(t, n)
local v = Value.cfgvalue(t, n)
- if v then
- return translate(v)
- end
+ if v then return translate(v) end
end
+ ---- Remarks
+ o = s:option(DummyValue, "remarks", translate("Remarks"))
+
---- Address
o = s:option(DummyValue, "address", translate("Address"))
+ o.cfgvalue = function(t, n)
+ return Value.cfgvalue(t, n) or "---"
+ end
---- Port
o = s:option(DummyValue, "port", translate("Port"))
+ o.cfgvalue = function(t, n)
+ return Value.cfgvalue(t, n) or "---"
+ end
---- Encrypt Method
--[[ o = s:option(DummyValue, "encrypt_method", translate("Encrypt Method"))
diff --git a/package/lienol/luci-app-passwall/luasrc/view/passwall/node_list/auto_ping.htm b/package/lienol/luci-app-passwall/luasrc/view/passwall/node_list/auto_ping.htm
index d964e6e0d8..c54774e34c 100644
--- a/package/lienol/luci-app-passwall/luasrc/view/passwall/node_list/auto_ping.htm
+++ b/package/lienol/luci-app-passwall/luasrc/view/passwall/node_list/auto_ping.htm
@@ -1,3 +1,3 @@
<%+cbi/valueheader%>
-
+---
<%+cbi/valuefooter%>
\ No newline at end of file
diff --git a/package/lienol/luci-app-passwall/root/etc/config/passwall b/package/lienol/luci-app-passwall/root/etc/config/passwall
index 1e3cff01eb..a0bb67f5ca 100644
--- a/package/lienol/luci-app-passwall/root/etc/config/passwall
+++ b/package/lienol/luci-app-passwall/root/etc/config/passwall
@@ -22,7 +22,7 @@ config global_delay
config global_forwarding
option process '1'
option tcp_no_redir_ports 'disable'
- option udp_no_redir_ports 'disable'
+ option udp_no_redir_ports '80,443'
option tcp_redir_ports '22,25,53,143,465,587,993,995,80,443'
option udp_redir_ports '1:65535'
option socks5_proxy_port '1081'
diff --git a/package/lienol/luci-app-passwall/root/usr/share/passwall/app.sh b/package/lienol/luci-app-passwall/root/usr/share/passwall/app.sh
index ff01c90b7f..997b45960b 100755
--- a/package/lienol/luci-app-passwall/root/usr/share/passwall/app.sh
+++ b/package/lienol/luci-app-passwall/root/usr/share/passwall/app.sh
@@ -18,8 +18,9 @@ DNSMASQ_PATH=/etc/dnsmasq.d
RESOLVFILE=/tmp/resolv.conf.d/resolv.conf.auto
DNS_PORT=7913
LUA_API_PATH=/usr/lib/lua/luci/model/cbi/$CONFIG/api
-API_GEN_V2RAY=$LUA_API_PATH/gen_v2ray_client_config.lua
-API_GEN_TROJAN=$LUA_API_PATH/gen_trojan_client_config.lua
+API_GEN_TROJAN=$LUA_API_PATH/gen_trojan.lua
+API_GEN_V2RAY=$LUA_API_PATH/gen_v2ray.lua
+API_GEN_V2RAY_SHUNT=$LUA_API_PATH/gen_v2ray_shunt.lua
FWI=$(uci get firewall.passwall.path 2>/dev/null)
echolog() {
@@ -100,8 +101,9 @@ check_port_exists() {
fi
}
-get_not_exists_port_after() {
+get_new_port() {
port=$1
+ [ "$port" == "auto" ] && port=$SOCKS5_PROXY_PORT3
protocol=$2
result=$(check_port_exists $port $protocol)
if [ "$result" = 1 ]; then
@@ -111,7 +113,7 @@ get_not_exists_port_after() {
elif [ "$port" -gt 1 ]; then
temp=$(expr $port - 1)
fi
- get_not_exists_port_after $temp $protocol
+ get_new_port $temp $protocol
else
echo $port
fi
@@ -259,11 +261,13 @@ gen_ss_ssr_config_file() {
}
gen_start_config() {
- local node local_port redir_type config_file server_host port type
+ local node local_port redir_type config_file bind server_host port type
node=$1
local_port=$2
redir_type=$3
config_file=$4
+ bind="0.0.0.0"
+ [ -n "$6" ] && bind="$6"
type=$(echo $(config_n_get $node type) | tr 'A-Z' 'a-z')
remarks=$(config_n_get $node remarks)
server_host=$(config_n_get $node address)
@@ -277,18 +281,21 @@ gen_start_config() {
echolog "$redir_type节点,非法的服务器地址,无法启动!"
return 1
}
- echolog "$redir_type节点:$remarks,节点:${server_host}:${port},监听端口:$local_port"
+ [ "$bind" == "0.0.0.0" ] && echolog "$redir_type节点:$remarks,节点:${server_host}:${port},监听端口:$local_port"
}
if [ "$redir_type" == "SOCKS5" ]; then
eval SOCKS5_NODE${5}_PORT=$port
if [ "$type" == "socks5" ]; then
echolog "Socks5节点不能使用Socks5代理节点!"
- elif [ "$type" == "v2ray" -o "$type" == "v2ray_balancing" -o "$type" == "v2ray_shunt" ]; then
+ elif [ "$type" == "v2ray" -o "$type" == "v2ray_balancing" ]; then
lua $API_GEN_V2RAY $node nil nil $local_port >$config_file
ln_start_bin $(config_t_get global_app v2ray_file $(find_bin v2ray))/v2ray v2ray_socks_$5 "-config=$config_file"
+ elif [ "$type" == "v2ray_shunt" ]; then
+ lua $API_GEN_V2RAY_SHUNT $node nil nil $local_port >$config_file
+ ln_start_bin $(config_t_get global_app v2ray_file $(find_bin v2ray))/v2ray v2ray_socks_$5 "-config=$config_file"
elif [ "$type" == "trojan" ]; then
- lua $API_GEN_TROJAN $node client "0.0.0.0" $local_port >$config_file
+ lua $API_GEN_TROJAN $node client $bind $local_port >$config_file
ln_start_bin $(find_bin trojan) trojan_socks_$5 "-c $config_file"
elif [ "$type" == "brook" ]; then
local protocol=$(config_n_get $node brook_protocol client)
@@ -296,10 +303,10 @@ gen_start_config() {
[ "$protocol" == "wsclient" ] && {
[ "$brook_tls" == "1" ] && server_host="wss://${server_host}" || server_host="ws://${server_host}"
}
- ln_start_bin $(config_t_get global_app brook_file $(find_bin brook)) brook_socks_$5 "$protocol -l 0.0.0.0:$local_port -i 0.0.0.0 -s $server_host:$port -p $(config_n_get $node password)"
+ ln_start_bin $(config_t_get global_app brook_file $(find_bin brook)) brook_socks_$5 "$protocol -l $bind:$local_port -i $$bind -s $server_host:$port -p $(config_n_get $node password)"
elif [ "$type" == "ssr" ]; then
gen_ss_ssr_config_file ssr $local_port 0 $node $config_file
- ln_start_bin $(find_bin ssr-local) ssr-local_socks_$5 "-c $config_file -b 0.0.0.0 -u"
+ ln_start_bin $(find_bin ssr-local) ssr-local_socks_$5 "-c $config_file -b $bind -u"
elif [ "$type" == "ss" ]; then
gen_ss_ssr_config_file ss $local_port 0 $node $config_file
local plugin_params=""
@@ -310,7 +317,7 @@ gen_start_config() {
plugin_params="--plugin $plugin --plugin-opts $opts"
}
fi
- ln_start_bin $(find_bin ss-local) ss-local_socks_$5 "-c $config_file -b 0.0.0.0 -u $plugin_params"
+ ln_start_bin $(find_bin ss-local) ss-local_socks_$5 "-c $config_file -b $bind -u $plugin_params"
fi
fi
@@ -324,12 +331,15 @@ gen_start_config() {
local server_password=$(config_n_get $node password)
eval port=\$UDP_REDIR_PORT$5
ln_start_bin $(find_bin ipt2socks) ipt2socks_udp_$5 "-U -l $port -b 0.0.0.0 -s $node_address -p $node_port -R"
- elif [ "$type" == "v2ray" -o "$type" == "v2ray_balancing" -o "$type" == "v2ray_shunt" ]; then
+ elif [ "$type" == "v2ray" -o "$type" == "v2ray_balancing" ]; then
lua $API_GEN_V2RAY $node udp $local_port nil >$config_file
ln_start_bin $(config_t_get global_app v2ray_file $(find_bin v2ray))/v2ray v2ray_udp_$5 "-config=$config_file"
+ elif [ "$type" == "v2ray_shunt" ]; then
+ lua $API_GEN_V2RAY_SHUNT $node udp $local_port nil >$config_file
+ ln_start_bin $(config_t_get global_app v2ray_file $(find_bin v2ray))/v2ray v2ray_udp_$5 "-config=$config_file"
elif [ "$type" == "trojan" ]; then
SOCKS5_PROXY_PORT4=$(expr $SOCKS5_PROXY_PORT3 + 1)
- local_port=$(get_not_exists_port_after $SOCKS5_PROXY_PORT4 tcp)
+ local_port=$(get_new_port $SOCKS5_PROXY_PORT4 tcp)
socks5_port=$local_port
lua $API_GEN_TROJAN $node client "127.0.0.1" $socks5_port >$config_file
ln_start_bin $(find_bin trojan) trojan_udp_$5 "-c $config_file"
@@ -374,9 +384,12 @@ gen_start_config() {
local server_password=$(config_n_get $node password)
eval port=\$TCP_REDIR_PORT$5
ln_start_bin $(find_bin ipt2socks) ipt2socks_tcp_$5 "-T -l $port -b 0.0.0.0 -s $node_address -p $node_port -R"
- elif [ "$type" == "v2ray" -o "$type" == "v2ray_balancing" -o "$type" == "v2ray_shunt" ]; then
+ elif [ "$type" == "v2ray" -o "$type" == "v2ray_balancing" ]; then
lua $API_GEN_V2RAY $node tcp $local_port nil >$config_file
ln_start_bin $(config_t_get global_app v2ray_file $(find_bin v2ray))/v2ray v2ray_tcp_$5 "-config=$config_file"
+ elif [ "$type" == "v2ray_shunt" ]; then
+ lua $API_GEN_V2RAY_SHUNT $node tcp $local_port nil >$config_file
+ ln_start_bin $(config_t_get global_app v2ray_file $(find_bin v2ray))/v2ray v2ray_tcp_$5 "-config=$config_file"
elif [ "$type" == "trojan" ]; then
lua $API_GEN_TROJAN $node nat "0.0.0.0" $local_port >$config_file
for k in $(seq 1 $process); do
@@ -395,7 +408,7 @@ gen_start_config() {
if [ -n "$kcptun_port" -a -n "$kcptun_config" ]; then
local run_kcptun_ip=$server_host
[ -n "$kcptun_server_host" ] && run_kcptun_ip=$(get_host_ip $network_type $kcptun_server_host)
- KCPTUN_REDIR_PORT=$(get_not_exists_port_after $KCPTUN_REDIR_PORT tcp)
+ KCPTUN_REDIR_PORT=$(get_new_port $KCPTUN_REDIR_PORT tcp)
ln_start_bin $(config_t_get global_app kcptun_client_file $(find_bin kcptun-client)) kcptun_tcp_$5 "-l 0.0.0.0:$KCPTUN_REDIR_PORT -r $run_kcptun_ip:$kcptun_port $kcptun_config"
fi
fi
@@ -423,7 +436,7 @@ gen_start_config() {
local brook_tls=$(config_n_get $node brook_tls 0)
if [ "$protocol" == "wsclient" ]; then
[ "$brook_tls" == "1" ] && server_ip="wss://${server_ip}" || server_ip="ws://${server_ip}"
- socks5_port=$(get_not_exists_port_after $(expr $SOCKS5_PROXY_PORT3 + 3) tcp)
+ socks5_port=$(get_new_port $(expr $SOCKS5_PROXY_PORT3 + 3) tcp)
ln_start_bin $(config_t_get global_app brook_file $(find_bin brook)) brook_tcp_$5 "wsclient -l 127.0.0.1:$socks5_port -i 127.0.0.1 -s $server_ip:$port -p $(config_n_get $node password)"
eval port=\$TCP_REDIR_PORT$5
ln_start_bin $(find_bin ipt2socks) ipt2socks_tcp_$5 "-T -l $port -b 0.0.0.0 -s 127.0.0.1 -p $socks5_port -R"
@@ -466,7 +479,7 @@ start_redir() {
TYPE=$(echo $(config_n_get $node type) | tr 'A-Z' 'a-z')
local config_file=$TMP_PATH/${1}_${i}.json
eval current_port=\$${1}_${2}_PORT$i
- local port=$(echo $(get_not_exists_port_after $current_port $3))
+ local port=$(echo $(get_new_port $current_port $3))
eval ${1}_${2}$i=$port
gen_start_config $node $port $1 $config_file $i
#eval ip=\$${1}_NODE${i}_IP
@@ -949,6 +962,12 @@ stop() {
}
case $1 in
+get_new_port)
+ get_new_port $2 $3
+ ;;
+gen_start_config)
+ gen_start_config $2 $3 $4 $5 $6 $7
+ ;;
node_switch)
node_switch $2 $3 $4 $5 $6
;;
@@ -962,7 +981,4 @@ start)
boot)
boot
;;
-*)
- echo "Usage: $0 (start|stop|restart)"
- ;;
esac
diff --git a/package/lienol/luci-app-passwall/root/usr/share/passwall/config.default b/package/lienol/luci-app-passwall/root/usr/share/passwall/config.default
index e10e8ce332..14cca8fc9f 100644
--- a/package/lienol/luci-app-passwall/root/usr/share/passwall/config.default
+++ b/package/lienol/luci-app-passwall/root/usr/share/passwall/config.default
@@ -22,7 +22,7 @@ config global_delay
config global_forwarding
option process '1'
option tcp_no_redir_ports 'disable'
- option udp_no_redir_ports 'disable'
+ option udp_no_redir_ports '80,443'
option tcp_redir_ports '22,25,53,143,465,587,993,995,80,443'
option udp_redir_ports '1:65535'
option socks5_proxy_port '1081'
diff --git a/package/lienol/luci-app-passwall/root/usr/share/passwall/iptables.sh b/package/lienol/luci-app-passwall/root/usr/share/passwall/iptables.sh
index 2aeb5e0aaa..300c1b5dfd 100755
--- a/package/lienol/luci-app-passwall/root/usr/share/passwall/iptables.sh
+++ b/package/lienol/luci-app-passwall/root/usr/share/passwall/iptables.sh
@@ -273,8 +273,8 @@ add_firewall_rule() {
ipset -! create $IPSET_VPSIPLIST nethash
ipset -! create $IPSET_GFW nethash
ipset -! create $IPSET_CHN nethash
- ipset -! create $IPSET_BLACKLIST nethash && ipset flush $IPSET_BLACKLIST
- ipset -! create $IPSET_WHITELIST nethash && ipset flush $IPSET_WHITELIST
+ ipset -! create $IPSET_BLACKLIST nethash
+ ipset -! create $IPSET_WHITELIST nethash
cat $RULES_PATH/chnroute | sed -e "/^$/d" | sed -e "s/^/add $IPSET_CHN &/g" | awk '{print $0} END{print "COMMIT"}' | ipset -! -R
cat $RULES_PATH/blacklist_ip | sed -e "/^$/d" | sed -e "s/^/add $IPSET_BLACKLIST &/g" | awk '{print $0} END{print "COMMIT"}' | ipset -! -R
@@ -643,10 +643,10 @@ del_firewall_rule() {
ipset -F $IPSET_LANIPLIST >/dev/null 2>&1 && ipset -X $IPSET_LANIPLIST >/dev/null 2>&1 &
ipset -F $IPSET_VPSIPLIST >/dev/null 2>&1 && ipset -X $IPSET_VPSIPLIST >/dev/null 2>&1 &
- ipset -F $IPSET_GFW >/dev/null 2>&1 && ipset -X $IPSET_GFW >/dev/null 2>&1 &
+ #ipset -F $IPSET_GFW >/dev/null 2>&1 && ipset -X $IPSET_GFW >/dev/null 2>&1 &
#ipset -F $IPSET_CHN >/dev/null 2>&1 && ipset -X $IPSET_CHN >/dev/null 2>&1 &
- ipset -F $IPSET_BLACKLIST >/dev/null 2>&1 && ipset -X $IPSET_BLACKLIST >/dev/null 2>&1 &
- ipset -F $IPSET_WHITELIST >/dev/null 2>&1 && ipset -X $IPSET_WHITELIST >/dev/null 2>&1 &
+ #ipset -F $IPSET_BLACKLIST >/dev/null 2>&1 && ipset -X $IPSET_BLACKLIST >/dev/null 2>&1 &
+ #ipset -F $IPSET_WHITELIST >/dev/null 2>&1 && ipset -X $IPSET_WHITELIST >/dev/null 2>&1 &
}
flush_ipset() {