luci: use v2fly version 5

This commit is contained in:
xiaorouji 2022-04-14 16:42:40 +08:00 committed by sbwml
parent 8302d0ed49
commit a1ba938881
4 changed files with 11 additions and 7 deletions

View File

@ -336,8 +336,10 @@ function get_bin_version_cache(file, cmd)
return sys.exec("echo -n $(cat /tmp/etc/passwall_tmp/%s)" % md5) return sys.exec("echo -n $(cat /tmp/etc/passwall_tmp/%s)" % md5)
else else
local version = sys.exec(string.format("echo -n $(%s %s)", file, cmd)) local version = sys.exec(string.format("echo -n $(%s %s)", file, cmd))
sys.call("echo '" .. version .. "' > " .. "/tmp/etc/passwall_tmp/" .. md5) if version and version ~= "" then
return version sys.call("echo '" .. version .. "' > " .. "/tmp/etc/passwall_tmp/" .. md5)
return version
end
end end
end end
return "" return ""
@ -350,7 +352,7 @@ end
function get_v2ray_version(file) function get_v2ray_version(file)
if file == nil then file = get_v2ray_path() end if file == nil then file = get_v2ray_path() end
local cmd = "-version | awk '{print $2}' | sed -n 1P" local cmd = "version | awk '{print $2}' | sed -n 1P"
return get_bin_version_cache(file, cmd) return get_bin_version_cache(file, cmd)
end end

View File

@ -7,7 +7,7 @@ local i18n = api.i18n
local pre_release_url = "https://api.github.com/repos/v2fly/v2ray-core/releases?per_page=1" local pre_release_url = "https://api.github.com/repos/v2fly/v2ray-core/releases?per_page=1"
local release_url = "https://api.github.com/repos/v2fly/v2ray-core/releases/latest" local release_url = "https://api.github.com/repos/v2fly/v2ray-core/releases/latest"
local api_url = release_url local api_url = pre_release_url
local app_path = api.get_v2ray_path() or "" local app_path = api.get_v2ray_path() or ""
function check_path() function check_path()

View File

@ -123,7 +123,7 @@ local function start()
bin = ln_run("/usr/bin/" .. type .. "-server", type .. "-server", "-c " .. config_file .. " " .. udp_param, log_path) bin = ln_run("/usr/bin/" .. type .. "-server", type .. "-server", "-c " .. config_file .. " " .. udp_param, log_path)
elseif type == "V2ray" then elseif type == "V2ray" then
config = require(require_dir .. "v2ray").gen_config(user) config = require(require_dir .. "v2ray").gen_config(user)
bin = ln_run(api.get_v2ray_path(), "v2ray", "-config=" .. config_file, log_path) bin = ln_run(api.get_v2ray_path(), "v2ray", "run -config=" .. config_file, log_path)
elseif type == "Xray" then elseif type == "Xray" then
config = require(require_dir .. "v2ray").gen_config(user) config = require(require_dir .. "v2ray").gen_config(user)
bin = ln_run(api.get_xray_path(), "xray", "-config=" .. config_file, log_path) bin = ln_run(api.get_xray_path(), "xray", "-config=" .. config_file, log_path)

View File

@ -353,7 +353,8 @@ run_v2ray() {
_extra_param="${_extra_param} -tcp_proxy_way $tcp_proxy_way" _extra_param="${_extra_param} -tcp_proxy_way $tcp_proxy_way"
_extra_param="${_extra_param} -loglevel $loglevel" _extra_param="${_extra_param} -loglevel $loglevel"
lua $API_GEN_V2RAY ${_extra_param} > $config_file lua $API_GEN_V2RAY ${_extra_param} > $config_file
ln_run "$(first_type $(config_t_get global_app ${type}_file) ${type})" ${type} $log_file -config="$config_file" [ "$type" = "xray" ] && ln_run "$(first_type $(config_t_get global_app ${type}_file) ${type})" ${type} $log_file -config="$config_file"
[ "$type" = "v2ray" ] && ln_run "$(first_type $(config_t_get global_app ${type}_file) ${type})" ${type} $log_file run -config="$config_file"
} }
run_dns2socks() { run_dns2socks() {
@ -436,7 +437,8 @@ run_socks() {
local _extra_param="-local_http_port $http_port" local _extra_param="-local_http_port $http_port"
} }
lua $API_GEN_V2RAY_PROTO -local_socks_port $socks_port ${_extra_param} -server_proto socks -server_address ${_socks_address} -server_port ${_socks_port} -server_username ${_socks_username} -server_password ${_socks_password} > $config_file lua $API_GEN_V2RAY_PROTO -local_socks_port $socks_port ${_extra_param} -server_proto socks -server_address ${_socks_address} -server_port ${_socks_port} -server_username ${_socks_username} -server_password ${_socks_password} > $config_file
ln_run "$bin" $type $log_file -config="$config_file" [ "$type" = "xray" ] && ln_run "$bin" $type $log_file -config="$config_file"
[ "$type" = "v2ray" ] && ln_run "$bin" $type $log_file run -config="$config_file"
;; ;;
v2ray|\ v2ray|\
xray) xray)