2018-03-12 16:02:30 +00:00
local net = require " luci.model.network " . init ( )
local sys = require " luci.sys "
local ifaces = sys.net : devices ( )
2018-02-28 15:05:10 +00:00
local m , s , o
2018-05-09 09:53:45 +00:00
m = Map ( " omr-tracker " , translate ( " OMR-Tracker " ) )
2018-02-28 15:05:10 +00:00
2018-07-08 14:43:10 +00:00
s = m : section ( TypedSection , " shadowsocks " , translate ( " ShadowSocks tracker Settings " ) , translate ( " Detect if ShadowSocks is down and stop traffic redirection over it. " ) )
2018-05-09 09:53:45 +00:00
s.anonymous = true
2018-05-12 06:27:58 +00:00
s.addremove = false
local sdata = m : get ( ' shadowsocks ' )
if not sdata then
m : set ( ' shadowsocks ' , nil , ' shadowsocks ' )
m : set ( ' shadowsocks ' , ' enabled ' , " 1 " )
end
2018-05-09 09:53:45 +00:00
o = s : option ( Flag , " enabled " , translate ( " Enable " ) , translate ( " When tracker is disabled, connection failover is also disabled " ) )
o.rmempty = false
o = s : option ( Value , " timeout " , translate ( " Timeout (s) " ) )
o.placeholder = " 1 "
o.default = " 1 "
o.datatype = " range(1, 100) "
o.rmempty = false
o = s : option ( Value , " tries " , translate ( " Tries " ) )
o.placeholder = " 4 "
o.default = " 4 "
o.datatype = " range(1, 10) "
o.rmempty = false
o = s : option ( Value , " interval " , translate ( " Retry interval (s) " ) )
o.placeholder = " 2 "
o.default = " 2 "
o.datatype = " range(1, 100) "
o.rmempty = false
2018-07-08 14:43:10 +00:00
o = s : option ( DynamicList , " hosts " , translate ( " Hosts " ) , translate ( " IPs or domains must be available over http " ) )
2018-05-09 09:53:45 +00:00
o.placeholder = " bing.com "
o.default = { " bing.com " , " google.com " }
o.rmempty = false
s = m : section ( TypedSection , " defaults " , translate ( " Defaults Settings " ) , translate ( " OMR-Tracker detect when a connection is down and execute needed scripts " ) )
2018-02-28 15:05:10 +00:00
s.anonymous = true
2018-03-30 09:12:14 +00:00
o = s : option ( Flag , " enabled " , translate ( " Enable " ) , translate ( " When tracker is disabled, connection failover is also disabled " ) )
o.rmempty = false
2018-02-28 16:12:20 +00:00
o = s : option ( Value , " timeout " , translate ( " Timeout (s) " ) )
2018-02-28 15:05:10 +00:00
o.placeholder = " 1 "
o.default = " 1 "
o.datatype = " range(1, 100) "
o.rmempty = false
o = s : option ( Value , " tries " , translate ( " Tries " ) )
o.placeholder = " 4 "
o.default = " 4 "
o.datatype = " range(1, 10) "
o.rmempty = false
2018-02-28 16:12:20 +00:00
o = s : option ( Value , " interval " , translate ( " Retry interval (s) " ) )
2018-02-28 15:05:10 +00:00
o.placeholder = " 2 "
o.default = " 2 "
o.datatype = " range(1, 100) "
o.rmempty = false
2018-03-21 13:01:44 +00:00
o = s : option ( ListValue , " type " , translate ( " Type " ) , translate ( " Always ping gateway, then test connection by ping, httping or dns. None mode only ping gateway. " ) )
2018-03-01 13:56:02 +00:00
o : value ( " ping " , " ping " )
2018-03-21 13:01:44 +00:00
o : value ( " httping " , " httping " )
2018-03-01 13:56:02 +00:00
o : value ( " dns " , " dns " )
2018-03-02 06:46:56 +00:00
o : value ( " none " , " none " )
2018-02-28 15:05:10 +00:00
o = s : option ( DynamicList , " hosts " , translate ( " Hosts " ) )
o.placeholder = " 4.2.2.1 "
2018-03-13 13:23:54 +00:00
o.default = { " 4.2.2.1 " , " 8.8.8.8 " }
2018-02-28 15:05:10 +00:00
o.rmempty = false
2018-03-12 16:02:30 +00:00
s = m : section ( TypedSection , " interface " , translate ( " Interfaces " ) )
s.template_addremove = " omr-tracker/cbi-select-add "
s.addremove = true
s.add_select_options = { }
2018-03-12 16:19:43 +00:00
s.add_select_options [ ' ' ] = ' '
2018-03-12 16:02:30 +00:00
for _ , iface in ipairs ( ifaces ) do
if not ( iface == " lo " or iface : match ( " ^ifb.* " ) ) then
s.add_select_options [ iface ] = iface
end
end
2018-03-30 09:12:14 +00:00
o = s : option ( Flag , " enabled " , translate ( " Enable " ) )
o.rmempty = false
2018-03-12 16:02:30 +00:00
o = s : option ( Value , " timeout " , translate ( " Timeout (s) " ) )
o.placeholder = " 1 "
o.default = " 1 "
o.datatype = " range(1, 100) "
o.rmempty = false
o = s : option ( Value , " tries " , translate ( " Tries " ) )
o.placeholder = " 4 "
o.default = " 4 "
o.datatype = " range(1, 10) "
o.rmempty = false
o = s : option ( Value , " interval " , translate ( " Retry interval (s) " ) )
o.placeholder = " 2 "
o.default = " 2 "
o.datatype = " range(1, 100) "
o.rmempty = false
2018-03-21 13:01:44 +00:00
o = s : option ( ListValue , " type " , translate ( " Type " ) , translate ( " Always ping gateway, then test connection by ping, httping or dns. None mode only ping gateway. " ) )
2018-03-12 16:02:30 +00:00
o : value ( " ping " , " ping " )
2018-03-21 13:01:44 +00:00
o : value ( " httping " , " httping " )
2018-03-12 16:02:30 +00:00
o : value ( " dns " , " dns " )
o : value ( " none " , " none " )
o = s : option ( DynamicList , " hosts " , translate ( " Hosts " ) )
o.placeholder = " 4.2.2.1 "
2018-03-13 13:23:54 +00:00
o.default = { " 4.2.2.1 " , " 8.8.8.8 " }
2018-03-12 16:02:30 +00:00
o.rmempty = false
2018-02-28 15:05:10 +00:00
return m