2022-02-12 16:05:03 +08:00
-- Copyright 2008 Yanira <forum-2008@email.de>
-- Licensed to the public under the Apache License 2.0.
local uci = luci.model . uci.cursor ( )
local m , o , s
require ( " nixio.fs " )
2022-03-01 16:53:24 +08:00
local v2raya_bin = " /usr/bin/v2raya "
2022-03-08 09:14:59 +08:00
v2raya_version = " <b><font style= \" color:red \" > " .. luci.sys . exec ( v2raya_bin .. " --version 2>/dev/null " ) .. " </font></b> "
2022-03-01 16:53:24 +08:00
2022-02-12 16:05:03 +08:00
m = Map ( " v2raya " )
2022-03-01 16:53:24 +08:00
m.title = translate ( " v2rayA Client " )
2022-02-12 16:05:03 +08:00
m.description = translate ( " v2rayA is a V2Ray Linux client supporting global transparent proxy, compatible with SS, SSR, Trojan(trojan-go), PingTunnel protocols. " )
m : section ( SimpleSection ) . template = " v2raya/v2raya_status "
s = m : section ( TypedSection , " v2raya " )
2022-09-11 23:44:21 +08:00
s : tab ( " settings " , translate ( " Basic Setting " ) )
s : tab ( " log " , translate ( " Logs " ) )
2022-02-12 16:05:03 +08:00
s.addremove = false
2022-09-11 19:15:54 +08:00
s.anonymous = true
2022-02-12 16:05:03 +08:00
2022-09-11 23:44:21 +08:00
o = s : taboption ( " settings " , Flag , " enabled " , translate ( " Enabled " ) )
o.default = o.disabled
2022-02-12 16:05:03 +08:00
o.rmempty = false
2022-09-11 23:44:21 +08:00
o = s : taboption ( " settings " , DummyValue , " v2raya_version " , translate ( " v2rayA Version " ) )
2022-03-01 16:53:24 +08:00
o.rawhtml = true
o.value = v2raya_version
2022-09-11 23:44:21 +08:00
o = s : taboption ( " settings " , Value , " address " , translate ( " GUI access address " ) )
2022-02-12 16:05:03 +08:00
o.description = translate ( " Use 0.0.0.0:2017 to monitor all access. " )
2022-09-11 23:44:21 +08:00
--[[o.datatype = 'ipaddrport(1)']] --
2022-02-12 16:05:03 +08:00
o.default = " http://0.0.0.0:2017 "
o.rmempty = false
2022-09-11 23:44:21 +08:00
o = s : taboption ( " settings " , Value , " config " , translate ( " v2rayA configuration directory " ) )
2022-02-12 16:05:03 +08:00
o.rmempty = ' /etc/v2raya '
2022-09-11 23:44:21 +08:00
o.rmempty = false ;
2022-02-12 16:05:03 +08:00
2022-09-11 23:44:21 +08:00
o = s : taboption ( " settings " , ListValue , " ipv6_support " , translate ( " Ipv6 Support " ) )
2022-02-12 16:05:03 +08:00
o.description = translate ( " Make sure your IPv6 network works fine before you turn it on. " )
o : value ( " auto " , translate ( " AUTO " ) )
o : value ( " on " , translate ( " ON " ) )
o : value ( " off " , translate ( " OFF " ) )
o.default = auto
2022-09-11 23:44:21 +08:00
o.rmempty = false
2022-02-12 16:05:03 +08:00
2022-09-11 23:44:21 +08:00
o = s : taboption ( " settings " , Value , " log_file " , translate ( " Log file " ) )
2022-04-21 22:15:25 +08:00
o.default = " /var/log/v2raya/v2raya.log "
2022-09-11 23:44:21 +08:00
o.rmempty = false
o.readonly = true
2022-02-12 16:05:03 +08:00
2022-09-11 23:44:21 +08:00
o = s : taboption ( " settings " , ListValue , " log_level " , translate ( " Log Level " ) )
2022-02-12 16:05:03 +08:00
o : value ( " trace " , translate ( " Trace " ) )
o : value ( " debug " , translate ( " Debug " ) )
o : value ( " info " , translate ( " Info " ) )
o : value ( " warn " , translate ( " Warning " ) )
o : value ( " error " , translate ( " Error " ) )
o.default = " Info "
2022-09-11 23:44:21 +08:00
o.rmempty = false
2022-02-12 16:05:03 +08:00
2022-09-11 23:44:21 +08:00
o = s : taboption ( " settings " , ListValue , " log_max_days " , translate ( " Log Keepd Max Days " ) )
2022-02-12 16:05:03 +08:00
o.description = translate ( " Maximum number of days to keep log files is 3 day. " )
o.datatype = " uinteger "
o : value ( " 1 " , translate ( " 1 " ) )
o : value ( " 2 " , translate ( " 2 " ) )
o : value ( " 3 " , translate ( " 3 " ) )
o.default = 3
o.rmempty = false
2022-09-11 23:44:21 +08:00
o = s : taboption ( " settings " , Flag , " log_disable_color " , translate ( " Disable log color " ) )
o.default = o.enabled
2022-02-12 16:05:03 +08:00
o.rmempty = false
2022-09-11 23:44:21 +08:00
o = s : taboption ( " settings " , Flag , " log_disable_timestamp " , translate ( " Log disable timestamp " ) )
o.default = o.disabled
2022-02-12 16:05:03 +08:00
o.rmempty = false
2022-09-11 23:44:21 +08:00
o = s : taboption ( " settings " , Value , " v2ray_bin " , translate ( " v2ray binary path " ) )
o.description = translate ( " Executable v2ray binary path. Auto-detect if put it empty (recommended). " )
o.datatype = ' path '
o = s : taboption ( " settings " , Value , " v2ray_confdir " , translate ( " Extra config directory " ) )
o.description = translate ( " Additional v2ray config directory, files in it will be combined with config generated by v2rayA. " )
o.datatype = ' path '
o = s : taboption ( " settings " , Value , " vless_grpc_inbound_cert_key " , translate ( " Upload certificate " ) )
2022-02-12 16:05:03 +08:00
o.description = translate ( " Specify the certification path instead of automatically generating a self-signed certificate. " )
o.template = " v2raya/v2raya_certupload "
cert_dir = " /etc/v2raya/ "
local path
luci.http . setfilehandler ( function ( meta , chunk , eof )
if not fd then
if ( not meta ) or ( not meta.name ) or ( not meta.file ) then
return
end
fd = nixio.open ( cert_dir .. meta.file , " w " )
if not fd then
path = translate ( " Create upload file error. " )
return
end
end
if chunk and fd then
fd : write ( chunk )
end
if eof and fd then
fd : close ( )
fd = nil
path = ' /etc/v2raya/ ' .. meta.file .. ' '
end
end )
if luci.http . formvalue ( " upload " ) then
local f = luci.http . formvalue ( " ulfile " )
if # f <= 0 then
path = translate ( " No specify upload file. " )
end
end
2022-09-11 23:44:21 +08:00
o = s : taboption ( " settings " , Value , " vless_grpc_inbound_cert_key " , translate ( " Upload Certificate Path " ) )
2022-02-12 16:05:03 +08:00
o.description = translate ( " This is the path where the certificate resides after the certificate is uploaded. " )
o.default = " /etc/v2raya/cert.crt,/etc/v2raya/cert.key "
2022-09-11 23:44:21 +08:00
o = s : taboption ( " log " , Value , " log " , translate ( " Logs " ) )
o.template = " v2raya/v2raya_log "
--[[o.rows = 50]] --
2022-02-12 16:05:03 +08:00
o.inputstyle = " reload "
luci.sys . exec ( " /etc/init.d/v2raya start >/dev/null 2>&1 & " )
return m