1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-02-15 03:51:51 +00:00

New version of OMR-Tracker

This commit is contained in:
Ycarus (Yannick Chabanois) 2024-01-12 17:28:40 +01:00
parent bb64827a1e
commit f5b3aa6831
15 changed files with 831 additions and 318 deletions

View file

@ -1,5 +1,5 @@
# #
# Copyright (C) 2018-2019 Ycarus (Yannick Chabanois) <ycarus@zugaina.org> # Copyright (C) 2018-2023 Ycarus (Yannick Chabanois) <ycarus@zugaina.org>
# #
# #

View file

@ -0,0 +1,289 @@
'use strict';
'require form';
'require fs';
'require view';
'require uci';
var cfgtypes = ['defaults','interface'];
return view.extend({
load: function() {
return Promise.all([
L.resolveDefault(fs.stat('/usr/bin/httping'), {}),
L.resolveDefault(fs.stat('/usr/bin/dig'), {}),
// L.resolveDefault(fs.stat('/usr/bin/nping'), {}),
// L.resolveDefault(fs.stat('/usr/bin/arping'), {}),
uci.load('network')
]);
},
render: function (stats) {
var m, s, o;
m = new form.Map('omr-tracker', _('OMR-Tracker - Interfaces'),
_('Names must match the interface name found in /etc/config/network.') + '<br />' +
_('Names may contain characters A-Z, a-z, 0-9, _ and no spaces-'));
//s = m.section(form.GridSection, 'defaults');
s = m.section(form.GridSection);
s.addremove = true;
s.anonymous = false;
s.nodescriptions = true;
s.cfgsections = function() {
return this.map.data.sections(this.map.config)
.filter(function(s) { return cfgtypes.indexOf(s['.type']) !== -1; })
.map(function(s) { return s['.name']; });
};
o = s.option(form.Flag, 'enabled', _('Enabled'));
o.default = false;
o = s.option(form.ListValue, 'initial_state', _('Initial state'),
_('Expect interface state on up event'));
o.default = 'online';
o.value('online', _('Online'));
o.value('offline', _('Offline'));
o.modalonly = true;
o = s.option(form.ListValue, 'family', _('Internet Protocol'));
o.default = 'ipv4';
o.value('ipv4', _('IPv4'));
o.value('ipv6', _('IPv6'));
o.value('ipv4ipv6', _('IPv4 & IPv6'));
o.modalonly = true;
o = s.option(form.DynamicList, 'hosts', _('Tracking hostname or IP address'),
_('This hostname or IP address will be pinged to determine if the link is up or down. Leave blank to use defaults settings.'));
o.datatype = 'hosts';
o.modalonly = true;
o.rmempty = false;
o = s.option(form.DynamicList, 'hosts6', _('Tracking hostname or IP address for IPv6'),
_('This hostname or IP address will be pinged to determine if the link is up or down. Leave blank to use defaults settings.'));
o.datatype = 'hosts';
o.modalonly = true;
o.depends('family', 'ipv4ipv6');
o.depends('family', 'ipv6');
o.rmempty = false;
o = s.option(form.ListValue, 'type', _('Tracking method'));
o.default = 'ping';
o.value('none');
o.value('ping');
if (stats[0].type === 'file') {
o.value('httping');
}
if (stats[1].type === 'file') {
o.value('dns');
}
/*
if (stats[2].type === 'file') {
o.value('nping-tcp');
o.value('nping-udp');
o.value('nping-icmp');
o.value('nping-arp');
}
if (stats[3].type === 'file') {
o.value('arping');
}
*/
o = s.option(form.Flag, 'server_http_test', _('Server http test'),
_('Check if connection work with http by sending a request to server'));
o.rmempty = false;
o.modalonly = true;
o = s.option(form.Flag, 'mail_alert', _('Mail alert'),
_('Send a mail when connection status change. You need to configure e-mail settings here.'));
o.rmempty = false;
o.modalonly = true;
/*
o = s.option(form.Flag, 'httping_ssl', _('Enable ssl tracking'),
_('Enables https tracking on ssl port 443'));
o.depends('type', 'httping');
o.rmempty = false;
o.modalonly = true;
*/
o = s.option(form.Value, 'reliability', _('Tracking reliability'),
_('Acceptable values: 1-100. This many Tracking IP addresses must respond for the link to be deemed up'));
o.datatype = 'range(1, 100)';
o.default = '1';
o = s.option(form.ListValue, 'count', _('Ping count'));
o.default = '1';
o.value('1');
o.value('2');
o.value('3');
o.value('4');
o.value('5');
o.modalonly = true;
o = s.option(form.Value, 'size', _('Ping size'));
o.default = '56';
o.depends('type', 'ping');
o.value('8');
o.value('24');
o.value('56');
o.value('120');
o.value('248');
o.value('504');
o.value('1016');
o.value('1472');
o.value('2040');
o.datatype = 'range(1, 65507)';
o.modalonly = true;
o =s.option(form.Value, 'max_ttl', _('Max TTL'));
o.default = '60';
o.depends('type', 'ping');
o.value('10');
o.value('20');
o.value('30');
o.value('40');
o.value('50');
o.value('60');
o.value('70');
o.datatype = 'range(1, 255)';
o.modalonly = true;
o = s.option(form.Flag, 'check_quality', _('Check link quality'));
o.depends('type', 'ping');
o.default = false;
o.modalonly = true;
o = s.option(form.Value, 'failure_latency', _('Failure latency [ms]'));
o.depends('check_quality', '1');
o.default = '1000';
o.value('25');
o.value('50');
o.value('75');
o.value('100');
o.value('150');
o.value('200');
o.value('250');
o.value('300');
o.modalonly = true;
o = s.option(form.Value, 'failure_loss', _('Failure packet loss [%]'));
o.depends('check_quality', '1');
o.default = '40';
o.value('2');
o.value('5');
o.value('10');
o.value('20');
o.value('25');
o.modalonly = true;
o = s.option(form.Value, 'recovery_latency', _('Recovery latency [ms]'));
o.depends('check_quality', '1');
o.default = '500';
o.value('25');
o.value('50');
o.value('75');
o.value('100');
o.value('150');
o.value('200');
o.value('250');
o.value('300');
o.modalonly = true;
o = s.option(form.Value, 'recovery_loss', _('Recovery packet loss [%]'));
o.depends('check_quality', '1');
o.default = '10';
o.value('2');
o.value('5');
o.value('10');
o.value('20');
o.value('25');
o.modalonly = true;
o = s.option(form.ListValue, "timeout", _("Ping timeout"));
o.default = '4';
o.value('1', _('%d second').format('1'));
for (var i = 2; i <= 10; i++)
o.value(String(i), _('%d seconds').format(i));
o.modalonly = true;
o = s.option(form.ListValue, 'interval', _('Ping interval'));
o.default = '10';
o.value('1', _('%d second').format('1'));
o.value('3', _('%d seconds').format('3'));
o.value('5', _('%d seconds').format('5'));
o.value('10', _('%d seconds').format('10'));
o.value('20', _('%d seconds').format('20'));
o.value('30', _('%d seconds').format('30'));
o.value('60', _('%d minute').format('1'));
o.value('300', _('%d minutes').format('5'));
o.value('600', _('%d minutes').format('10'));
o.value('900', _('%d minutes').format('15'));
o.value('1800', _('%d minutes').format('30'));
o.value('3600', _('%d hour').format('1'));
o = s.option(form.Value, 'failure_interval', _('Failure interval'),
_('Ping interval during failure detection'));
o.default = '5';
o.value('1', _('%d second').format('1'));
o.value('3', _('%d seconds').format('3'));
o.value('5', _('%d seconds').format('5'));
o.value('10', _('%d seconds').format('10'));
o.value('20', _('%d seconds').format('20'));
o.value('30', _('%d seconds').format('30'));
o.value('60', _('%d minute').format('1'));
o.value('300', _('%d minutes').format('5'));
o.value('600', _('%d minutes').format('10'));
o.value('900', _('%d minutes').format('15'));
o.value('1800', _('%d minutes').format('30'));
o.value('3600', _('%d hour').format('1'));
o.modalonly = true;
o = s.option(form.Flag, 'keep_failure_interval', _('Keep failure interval'),
_('Keep ping failure interval during failure state'));
o.default = false;
o.modalonly = true;
o = s.option(form.ListValue, 'tries', _('Interface down'),
_('Interface will be deemed down after this many failed ping tests'));
o.default = '5';
o.value('1');
o.value('2');
o.value('3');
o.value('4');
o.value('5');
o.value('6');
o.value('7');
o.value('8');
o.value('9');
o.value('10');
o = s.option(form.ListValue, 'tries_up', _('Interface up'),
_('Downed interface will be deemed up after this many successful ping tests'));
o.default = "5";
o.value('1');
o.value('2');
o.value('3');
o.value('4');
o.value('5');
o.value('6');
o.value('7');
o.value('8');
o.value('9');
o.value('10');
o = s.option(form.Flag, 'restart_down', _('Restart if down'),
_('Restart interface if detected as down.'));
o.rmempty = false;
o.modalonly = true;
/*
o = s.option(form.DynamicList, 'flush_conntrack', _('Flush conntrack table'),
_('Flush global firewall conntrack table on interface events'));
o.value('ifup', _('ifup (netifd)'));
o.value('ifdown', _('ifdown (netifd)'));
o.modalonly = true;
*/
return m.render();
}
})

View file

@ -0,0 +1,186 @@
'use strict';
'require form';
'require fs';
'require view';
'require uci';
var cfgtypes = ['proxy'];
return view.extend({
load: function() {
return Promise.all([
L.resolveDefault(fs.stat('/usr/bin/httping'), {}),
L.resolveDefault(fs.stat('/usr/bin/dig'), {}),
// L.resolveDefault(fs.stat('/usr/bin/nping'), {}),
// L.resolveDefault(fs.stat('/usr/bin/arping'), {}),
uci.load('network')
]);
},
render: function (stats) {
var m, s, o;
m = new form.Map('omr-tracker', _('OMR-Tracker - Proxy'),
_('Detect if proxy is down and stop redirection over it.'));
//s = m.section(form.GridSection, 'defaults');
s = m.section(form.GridSection);
//s.addremove = true;
s.anonymous = false;
s.nodescriptions = true;
s.cfgsections = function() {
return this.map.data.sections(this.map.config)
.filter(function(s) { return cfgtypes.indexOf(s['.type']) !== -1; })
.map(function(s) { return s['.name']; });
};
o = s.option(form.Flag, 'enabled', _('Enabled'));
o.default = false;
o = s.option(form.ListValue, 'initial_state', _('Initial state'),
_('Expect interface state on up event'));
o.default = 'online';
o.value('online', _('Online'));
o.value('offline', _('Offline'));
o.modalonly = true;
o = s.option(form.ListValue, 'family', _('Internet Protocol'));
o.default = 'ipv4ipv6';
//o.value('ipv4', _('IPv4'));
//o.value('ipv6', _('IPv6'));
o.value('ipv4ipv6', _('IPv4 & IPv6'));
o.modalonly = true;
o = s.option(form.DynamicList, 'hosts', _('Tracking hostname or IP address'),
_('This hostname or IP address will be pinged to determine if the link is up or down. Leave blank to assume interface is always online'));
o.datatype = 'hosts';
o.modalonly = true;
o = s.option(form.DynamicList, 'hosts6', _('Tracking hostname or IP address for IPv6'),
_('This hostname or IP address will be pinged to determine if the link is up or down. Leave blank to assume interface is always online'));
o.datatype = 'hosts';
o.modalonly = true;
o.depends('family', 'ipv4ipv6');
o.depends('family', 'ipv6');
/*
o = s.option(form.Flag, 'httping_ssl', _('Enable ssl tracking'),
_('Enables https tracking on ssl port 443'));
o.depends('track_method', 'httping');
o.rmempty = false;
o.modalonly = true;
*/
o = s.option(form.Flag, 'mail_alert', _('Mail alert'),
_('Send a mail when connection status change. You need to configure e-mail settings here.'));
o.rmempty = false;
o.modalonly = true;
/*
o = s.option(form.Value, 'reliability', _('Tracking reliability'),
_('Acceptable values: 1-100. This many Tracking IP addresses must respond for the link to be deemed up'));
o.datatype = 'range(1, 100)';
o.default = '1';
*/
o = s.option(form.ListValue, 'tries', _('Test count'));
o.default = '1';
o.value('1');
o.value('2');
o.value('3');
o.value('4');
o.value('5');
o.modalonly = true;
o = s.option(form.ListValue, "timeout", _("Test timeout"));
o.default = '4';
o.value('1', _('%d second').format('1'));
for (var i = 2; i <= 10; i++)
o.value(String(i), _('%d seconds').format(i));
o.modalonly = true;
o = s.option(form.ListValue, 'interval', _('Test interval'));
o.default = '10';
o.value('1', _('%d second').format('1'));
o.value('3', _('%d seconds').format('3'));
o.value('5', _('%d seconds').format('5'));
o.value('10', _('%d seconds').format('10'));
o.value('20', _('%d seconds').format('20'));
o.value('30', _('%d seconds').format('30'));
o.value('60', _('%d minute').format('1'));
o.value('300', _('%d minutes').format('5'));
o.value('600', _('%d minutes').format('10'));
o.value('900', _('%d minutes').format('15'));
o.value('1800', _('%d minutes').format('30'));
o.value('3600', _('%d hour').format('1'));
/*
o = s.option(form.Value, 'failure_interval', _('Failure interval'),
_('Ping interval during failure detection'));
o.default = '5';
o.value('1', _('%d second').format('1'));
o.value('3', _('%d seconds').format('3'));
o.value('5', _('%d seconds').format('5'));
o.value('10', _('%d seconds').format('10'));
o.value('20', _('%d seconds').format('20'));
o.value('30', _('%d seconds').format('30'));
o.value('60', _('%d minute').format('1'));
o.value('300', _('%d minutes').format('5'));
o.value('600', _('%d minutes').format('10'));
o.value('900', _('%d minutes').format('15'));
o.value('1800', _('%d minutes').format('30'));
o.value('3600', _('%d hour').format('1'));
o.modalonly = true;
o = s.option(form.Flag, 'keep_failure_interval', _('Keep failure interval'),
_('Keep ping failure interval during failure state'));
o.default = false;
o.modalonly = true;
o = s.option(form.Value, 'recovery_interval', _('Recovery interval'),
_('Ping interval during failure recovering'));
o.default = '5';
o.value('1', _('%d second').format('1'));
o.value('3', _('%d seconds').format('3'));
o.value('5', _('%d seconds').format('5'));
o.value('10', _('%d seconds').format('10'));
o.value('20', _('%d seconds').format('20'));
o.value('30', _('%d seconds').format('30'));
o.value('60', _('%d minute').format('1'));
o.value('300', _('%d minutes').format('5'));
o.value('600', _('%d minutes').format('10'));
o.value('900', _('%d minutes').format('15'));
o.value('1800', _('%d minutes').format('30'));
o.value('3600', _('%d hour').format('1'));
o.modalonly = true;
o = s.option(form.ListValue, 'tries', _('Proxy down'),
_('Proxy will be deemed down after this many failed tests'));
o.default = '5';
o.value('1');
o.value('2');
o.value('3');
o.value('4');
o.value('5');
o.value('6');
o.value('7');
o.value('8');
o.value('9');
o.value('10');
o = s.option(form.ListValue, 'tries_up', _('Interface up'),
_('Downed interface will be deemed up after this many successful ping tests'));
o.default = "5";
o.value('1');
o.value('2');
o.value('3');
o.value('4');
o.value('5');
o.value('6');
o.value('7');
o.value('8');
o.value('9');
o.value('10');
*/
return m.render();
}
})

View file

@ -0,0 +1,163 @@
'use strict';
'require form';
'require fs';
'require view';
'require uci';
var cfgtypes = ['server'];
return view.extend({
load: function() {
return Promise.all([
L.resolveDefault(fs.stat('/usr/bin/httping'), {}),
L.resolveDefault(fs.stat('/usr/bin/dig'), {}),
// L.resolveDefault(fs.stat('/usr/bin/nping'), {}),
// L.resolveDefault(fs.stat('/usr/bin/arping'), {}),
uci.load('network')
]);
},
render: function (stats) {
var m, s, o;
m = new form.Map('omr-tracker', _('OMR-Tracker - Server'),
_('Detect if server is down and use defined backup server in this case.'));
//s = m.section(form.GridSection, 'defaults');
s = m.section(form.GridSection);
//s.addremove = true;
s.anonymous = false;
s.nodescriptions = true;
s.cfgsections = function() {
return this.map.data.sections(this.map.config)
.filter(function(s) { return cfgtypes.indexOf(s['.type']) !== -1; })
.map(function(s) { return s['.name']; });
};
o = s.option(form.Flag, 'enabled', _('Enabled'));
o.default = false;
o = s.option(form.ListValue, 'initial_state', _('Initial state'),
_('Expect interface state on up event'));
o.default = 'online';
o.value('online', _('Online'));
o.value('offline', _('Offline'));
o.modalonly = true;
o = s.option(form.Flag, 'mail_alert', _('Mail alert'),
_('Send a mail when connection status change. You need to configure e-mail settings here.'));
o.rmempty = false;
o.modalonly = true;
/*
o = s.option(form.Value, 'reliability', _('Tracking reliability'),
_('Acceptable values: 1-100. This many Tracking IP addresses must respond for the link to be deemed up'));
o.datatype = 'range(1, 100)';
o.default = '1';
*/
o = s.option(form.ListValue, 'tries', _('Test count'));
o.default = '1';
o.value('1');
o.value('2');
o.value('3');
o.value('4');
o.value('5');
o.modalonly = true;
/*
o = s.option(form.Flag, 'check_quality', _('Check link quality'));
o.depends('track_method', 'ping');
o.default = false;
o.modalonly = true;
*/
o = s.option(form.ListValue, "timeout", _("Test timeout"));
o.default = '4';
o.value('1', _('%d second').format('1'));
for (var i = 2; i <= 10; i++)
o.value(String(i), _('%d seconds').format(i));
o.modalonly = true;
o = s.option(form.ListValue, 'interval', _('Test interval'));
o.default = '10';
o.value('1', _('%d second').format('1'));
o.value('3', _('%d seconds').format('3'));
o.value('5', _('%d seconds').format('5'));
o.value('10', _('%d seconds').format('10'));
o.value('20', _('%d seconds').format('20'));
o.value('30', _('%d seconds').format('30'));
o.value('60', _('%d minute').format('1'));
o.value('300', _('%d minutes').format('5'));
o.value('600', _('%d minutes').format('10'));
o.value('900', _('%d minutes').format('15'));
o.value('1800', _('%d minutes').format('30'));
o.value('3600', _('%d hour').format('1'));
/*
o = s.option(form.Value, 'failure_interval', _('Failure interval'),
_('Ping interval during failure detection'));
o.default = '5';
o.value('1', _('%d second').format('1'));
o.value('3', _('%d seconds').format('3'));
o.value('5', _('%d seconds').format('5'));
o.value('10', _('%d seconds').format('10'));
o.value('20', _('%d seconds').format('20'));
o.value('30', _('%d seconds').format('30'));
o.value('60', _('%d minute').format('1'));
o.value('300', _('%d minutes').format('5'));
o.value('600', _('%d minutes').format('10'));
o.value('900', _('%d minutes').format('15'));
o.value('1800', _('%d minutes').format('30'));
o.value('3600', _('%d hour').format('1'));
o.modalonly = true;
o = s.option(form.Flag, 'keep_failure_interval', _('Keep failure interval'),
_('Keep ping failure interval during failure state'));
o.default = false;
o.modalonly = true;
o = s.option(form.Value, 'recovery_interval', _('Recovery interval'),
_('Ping interval during failure recovering'));
o.default = '5';
o.value('1', _('%d second').format('1'));
o.value('3', _('%d seconds').format('3'));
o.value('5', _('%d seconds').format('5'));
o.value('10', _('%d seconds').format('10'));
o.value('20', _('%d seconds').format('20'));
o.value('30', _('%d seconds').format('30'));
o.value('60', _('%d minute').format('1'));
o.value('300', _('%d minutes').format('5'));
o.value('600', _('%d minutes').format('10'));
o.value('900', _('%d minutes').format('15'));
o.value('1800', _('%d minutes').format('30'));
o.value('3600', _('%d hour').format('1'));
o.modalonly = true;
o = s.option(form.ListValue, 'down', _('Interface down'),
_('Interface will be deemed down after this many failed ping tests'));
o.default = '5';
o.value('1');
o.value('2');
o.value('3');
o.value('4');
o.value('5');
o.value('6');
o.value('7');
o.value('8');
o.value('9');
o.value('10');
o = s.option(form.ListValue, 'up', _('Interface up'),
_('Downed interface will be deemed up after this many successful ping tests'));
o.default = "5";
o.value('1');
o.value('2');
o.value('3');
o.value('4');
o.value('5');
o.value('6');
o.value('7');
o.value('8');
o.value('9');
o.value('10');
*/
return m.render();
}
})

View file

@ -1,6 +0,0 @@
module("luci.controller.omr-tracker", package.seeall)
function index()
--entry({"admin", "openmptcprouter", "omr-tracker"}, cbi("omr-tracker"), _("OMR-Tracker"))
entry({"admin", "services", "omr-tracker"}, cbi("omr-tracker"), _("OMR-Tracker"))
end

View file

@ -1,254 +0,0 @@
local net = require "luci.model.network".init()
local sys = require "luci.sys"
local m, s, o
m = Map("omr-tracker", translate("OMR-Tracker"))
s = m:section(TypedSection, "proxy", translate("Proxy tracker Settings"), translate("Detect if Proxy is down and stop traffic redirection over it."))
s.anonymous = true
s.addremove = false
local sdata = m:get('proxy')
if not sdata then
m:set('proxy', nil, 'proxy')
m:set('proxy', 'enabled', "1")
end
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
o = s:option(Value, "wait_test", translate("Wait after a failed test (s)"))
o.placeholder = "0"
o.default = "0"
o.datatype = "range(0, 100)"
o.rmempty = false
o = s:option(Flag, "mail_alert", translate("Mail alert"), translate("Send a mail when connection state change"))
o.optional = false
o.rmempty = false
o.default = false
o.disabled = 0
o.enabled = 1
o = s:option(DynamicList, "hosts", translate("Hosts"), translate("IPs or domains must be available over http"))
o.placeholder = "bing.com"
o.default = { "bing.com", "google.com" }
o.rmempty = false
s = m:section(TypedSection, "server", translate("Server tracker Settings"), translate("Detect if Server is down and use defined backup server in this case."))
s.anonymous = true
s.addremove = false
local sdata = m:get('server')
if not sdata then
m:set('server', nil, 'server')
m:set('server', 'enabled', "1")
end
o = s:option(Flag, "enabled", translate("Enable"), translate("When tracker is disabled, server 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
o = s:option(Value, "wait_test", translate("Wait after a failed test (s)"))
o.placeholder = "0"
o.default = "0"
o.datatype = "range(0, 100)"
o.rmempty = false
o = s:option(Flag, "mail_alert", translate("Mail alert"), translate("Send a mail when connection state change"))
o.optional = false
o.rmempty = false
o.default = false
o.disabled = 0
o.enabled = 1
s = m:section(TypedSection, "defaults", translate("Defaults Settings"), translate("OMR-Tracker create needed routes and detect when a connection is down or up"))
s.anonymous = true
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"), translate("How many times repeat test"))
o.placeholder = "4"
o.default = "4"
o.datatype = "range(1, 10)"
o.rmempty = false
o = s:option(Value, "count", translate("Count"), translate("How many packets send on each test"))
o.placeholder = "2"
o.default = "2"
o.datatype = "range(1, 100)"
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
o = s:option(Value, "wait_test", translate("Wait after a failed test (s)"))
o.placeholder = "0"
o.default = "0"
o.datatype = "range(0, 100)"
o.rmempty = false
o = s:option(ListValue, "type", translate("Type"), translate("Always ping gateway, then test connection by ping, httping or dns. None mode only ping gateway."))
o:value("ping","ping")
o:value("httping","httping")
o:value("dns","dns")
o:value("none","none")
o = s:option(Flag, "server_http_test", translate("Server http test"), translate("Check if connection work with http by sending a request to server"))
o.optional = false
o.rmempty = false
o.default = true
o.disabled = 0
o.enabled = 1
o = s:option(Flag, "mail_alert", translate("Mail alert"), translate("Send a mail when connection state change"))
o.optional = false
o.rmempty = false
o.default = false
o.disabled = 0
o.enabled = 1
o = s:option(Flag, "restart_down", translate("Restart if down"), translate("Restart interface if detected as down"))
o.optional = false
o.rmempty = false
o.default = false
o.disabled = 0
o.enabled = 1
o = s:option(DynamicList, "hosts", translate("Hosts"), translate("Must be IPs and not domains"))
o.placeholder = "4.2.2.1"
o.default = { "4.2.2.1", "8.8.8.8" }
o.rmempty = false
o = s:option(DynamicList, "hosts6", translate("Hosts IPv6"), translate("Must be IPs and not domains"))
o.placeholder = "2001:4860:4860::8844"
o.default = { "2001:4860:4860::8888", "2001:4860:4860::8844" }
o.rmempty = false
s = m:section(TypedSection, "interface", translate("Interfaces"))
s.template_addremove = "omr-tracker/cbi-select-add"
s.addremove = true
s.add_select_options = { }
s.add_select_options[''] = ''
for _, iface in ipairs(net:get_networks()) do
if not (iface:name() == "loopback") then
s.add_select_options[iface:name()] = iface:name()
end
end
o = s:option(Flag, "enabled", translate("Enable"))
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, "count", translate("Count"), translate("How many packets send on each test, one wrong make test fail, one wrong make tail fail"))
o.placeholder = "2"
o.default = "2"
o.datatype = "range(1, 100)"
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
o = s:option(Value, "wait_test", translate("Wait after a failed test (s)"))
o.placeholder = "0"
o.default = "0"
o.datatype = "range(0, 100)"
o.rmempty = false
o = s:option(ListValue, "type", translate("Type"), translate("Always ping gateway, then test connection by ping, httping or dns. None mode only ping gateway."))
o:value("ping","ping")
o:value("httping","httping")
o:value("dns","dns")
o:value("none","none")
o = s:option(Flag, "server_http_test", translate("Server http test"), translate("Check if connection work with http by sending a request to server"))
o.optional = false
o.rmempty = false
o.default = true
o.disabled = 0
o.enabled = 1
o = s:option(Flag, "mail_alert", translate("Mail alert"), translate("Send a mail when connection status change. You need to configure e-mail settings <a href=\"/cgi-bin/luci/admin/services/mail\">here</a>."))
o.optional = false
o.rmempty = false
o.default = false
o.disabled = 0
o.enabled = 1
o = s:option(Flag, "restart_down", translate("Restart if down"), translate("Restart interface if detected as down"))
o.optional = false
o.rmempty = false
o.default = false
o.disabled = 0
o.enabled = 1
o = s:option(DynamicList, "hosts", translate("Hosts"), translate("Must be IPs and not domains"))
o.placeholder = "4.2.2.1"
o.default = { "4.2.2.1", "8.8.8.8" }
o.rmempty = false
o = s:option(DynamicList, "hosts6", translate("Hosts IPv6"), translate("Must be IPs and not domains"))
o.placeholder = "2001:4860:4860::8844"
o.rmempty = false
return m

View file

@ -1,10 +0,0 @@
<div class="cbi-section-create">
<% if self.invalid_cts then -%><div class="cbi-section-error"><% end %>
<select class="cbi-section-create-name" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.select">
<%- for k, v in luci.util.kspairs(self.add_select_options) do %>
<option value="<%=k%>"><%=luci.xml.pcdata(v)%></option>
<% end -%>
</select>
<input class="cbi-button cbi-button-add" type="submit" value="<%:Add%>" title="<%:Add%>" />
<% if self.invalid_cts then %><br /><%:Invalid%></div><% end %>
</div>

View file

@ -1,13 +1,36 @@
{ {
"admin/services/omr-tracker": { "admin/services/omr-tracker": {
"title": "OMR-Tracker", "title": "OMR-Tracker Manager",
"order": 10, "order": 60,
"action": { "action": {
"type": "cbi", "type": "firstchild"
"path": "omr-tracker"
}, },
"depends": { "depends": {
"acl": [ "luci-app-omr-tracker" ] "acl": [ "luci-app-omr-tracker" ]
} }
},
"admin/services/omr-tracker/interface": {
"title": "Interface",
"order": 10,
"action": {
"type": "view",
"path": "omr-tracker/network/interface"
}
},
"admin/services/omr-tracker/proxy": {
"title": "Proxy",
"order": 20,
"action": {
"type": "view",
"path": "omr-tracker/network/proxy"
}
},
"admin/services/omr-tracker/server": {
"title": "Server",
"order": 30,
"action": {
"type": "view",
"path": "omr-tracker/network/server"
}
} }
} }

View file

@ -2,7 +2,13 @@
"luci-app-omr-tracker": { "luci-app-omr-tracker": {
"description": "Grant UCI access for luci-app-omr-tracker", "description": "Grant UCI access for luci-app-omr-tracker",
"read": { "read": {
"uci": [ "omr-tracker" ] "uci": [ "omr-tracker" ],
"file": {
"/usr/bin/httping": [ "list" ],
"/usr/bin/dig": [ "list" ],
"/usr/bin/nping": [ "list" ],
"/usr/bin/arping": [ "list" ]
}
}, },
"write": { "write": {
"uci": [ "omr-tracker" ] "uci": [ "omr-tracker" ]

View file

@ -1,6 +1,6 @@
# #
# OpenMPTCProuter tracker is a modified version of OverTheBox tracker from OVH # OpenMPTCProuter tracker is a modified version of OverTheBox tracker from OVH
# Copyright (C) 2017-2019 Ycarus (Yannick Chabanois) <ycarus@zugaina.org> # Copyright (C) 2017-2023 Ycarus (Yannick Chabanois) <ycarus@zugaina.org>
# #
# This is free software, licensed under the GNU General Public License v3. # This is free software, licensed under the GNU General Public License v3.
# See /LICENSE for more information. # See /LICENSE for more information.
@ -9,7 +9,7 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=omr-tracker PKG_NAME:=omr-tracker
PKG_VERSION:=1.7 PKG_VERSION:=2.0
PKG_RELEASE:=1 PKG_RELEASE:=1
include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/package.mk

View file

@ -17,6 +17,9 @@ export OMR_TRACKER_INTERFACE
export OMR_TRACKER_HOST export OMR_TRACKER_HOST
export OMR_TRACKER_HOST6 export OMR_TRACKER_HOST6
export OMR_TRACKER_TIMEOUT export OMR_TRACKER_TIMEOUT
export OMR_TRACKER_SIZE
export OMR_TRACKER_MAX_TTL
export OMR_TRACKER_LOSS
export OMR_TRACKER_STATUS export OMR_TRACKER_STATUS
export OMR_TRACKER_STATUS_MSG export OMR_TRACKER_STATUS_MSG
export OMR_TRACKER_PREV_STATUS export OMR_TRACKER_PREV_STATUS
@ -150,6 +153,8 @@ _ping() {
ret=$(ping -I "${device}" \ ret=$(ping -I "${device}" \
-w "$OMR_TRACKER_TIMEOUT" \ -w "$OMR_TRACKER_TIMEOUT" \
-c "$OMR_TRACKER_COUNT" \ -c "$OMR_TRACKER_COUNT" \
-s "$OMR_TRACKER_SIZE" \
-t "$OMR_TRACKER_MAX_TTL" \
-Q 184 \ -Q 184 \
"${host}" 2>&1 "${host}" 2>&1
) && echo "$ret" | grep -sq " 0% packet loss" && { ) && echo "$ret" | grep -sq " 0% packet loss" && {
@ -163,15 +168,20 @@ _ping() {
ret=$(ping -B -I "${device}" \ ret=$(ping -B -I "${device}" \
-w "$OMR_TRACKER_TIMEOUT" \ -w "$OMR_TRACKER_TIMEOUT" \
-c "$OMR_TRACKER_COUNT" \ -c "$OMR_TRACKER_COUNT" \
-s "$OMR_TRACKER_SIZE" \
-t "$OMR_TRACKER_MAX_TTL" \
-Q 184 \ -Q 184 \
"${host}" 2>&1 "${host}" 2>&1
) && echo "$ret" | grep -sq " 0% packet loss" && { )
loss=$(echo "$ret" | grep 'packet loss' | sed -ne 's/.*\([0-9]\+\)% packet loss.*/\1/p')
if [ -n "$loss" ] && [ "$loss" -ne 100 ]; then
if [ "$localip" = "yes" ]; then if [ "$localip" = "yes" ]; then
OMR_TRACKER_LATENCY=$(echo "$ret" | cut -d "/" -s -f5 | cut -d "." -f1 | tr -d '\n') OMR_TRACKER_LATENCY=$(echo "$ret" | cut -d "/" -s -f5 | cut -d "." -f1 | tr -d '\n')
OMR_TRACKER_LOSS="$loss"
_update_rto "$OMR_TRACKER_LATENCY" _update_rto "$OMR_TRACKER_LATENCY"
fi fi
return return
} fi
#) && echo "$ret" | grep -sq "bytes from" && { #) && echo "$ret" | grep -sq "bytes from" && {
fi fi
false false
@ -242,6 +252,7 @@ while true; do
OMR_TRACKER_STATUS="ERROR" OMR_TRACKER_STATUS="ERROR"
OMR_TRACKER_STATUS_MSG="" OMR_TRACKER_STATUS_MSG=""
OMR_TRACKER_LATENCY= OMR_TRACKER_LATENCY=
OMR_TRACKER_LOSS=
#OMR_TRACKER_TIMEOUT=$((rto / 1000 + (rto % 1000 ? 1 : 0))) #OMR_TRACKER_TIMEOUT=$((rto / 1000 + (rto % 1000 ? 1 : 0)))
OMR_TRACKER_LIST_HOSTS="" OMR_TRACKER_LIST_HOSTS=""
OMR_TRACKER_DEVICE_GATEWAY= OMR_TRACKER_DEVICE_GATEWAY=
@ -259,7 +270,7 @@ while true; do
if [ -n "$OMR_TRACKER_DEVICE" ] && [ -d "/sys/class/net/$OMR_TRACKER_DEVICE" ]; then if [ -n "$OMR_TRACKER_DEVICE" ] && [ -d "/sys/class/net/$OMR_TRACKER_DEVICE" ]; then
if [ -n "$(ip link show $OMR_TRACKER_DEVICE | grep UP)" ]; then if [ -n "$(ip link show $OMR_TRACKER_DEVICE | grep UP)" ]; then
# retrieve iface ip and gateway # retrieve iface ip and gateway
if [ "$OMR_TRACKER_INTERFACE_PROTO" != "dhcpv6" ]; then if ([ "$OMR_TRACKER_FAMILY" = "ipv4" ] || [ "$OMR_TRACKER_FAMILY" = "ipv4ipv6" ]) && [ "$OMR_TRACKER_INTERFACE_PROTO" != "dhcpv6" ]; then
OMR_TRACKER_DEVICE_IP=$(ip -4 -br addr ls dev "$OMR_TRACKER_DEVICE" | awk -F'[ /]+' '{print $3}') OMR_TRACKER_DEVICE_IP=$(ip -4 -br addr ls dev "$OMR_TRACKER_DEVICE" | awk -F'[ /]+' '{print $3}')
if [ -z "$OMR_TRACKER_DEVICE_IP" ]; then if [ -z "$OMR_TRACKER_DEVICE_IP" ]; then
OMR_TRACKER_DEVICE_IP=$(ip -4 addr show dev "$OMR_TRACKER_DEVICE" | grep -m 1 inet | awk '{print $2}' | cut -d'/' -s -f1) OMR_TRACKER_DEVICE_IP=$(ip -4 addr show dev "$OMR_TRACKER_DEVICE" | grep -m 1 inet | awk '{print $2}' | cut -d'/' -s -f1)
@ -305,7 +316,7 @@ while true; do
OMR_TRACKER_DEVICE_GATEWAY=$(ip -4 r list dev "$OMR_TRACKER_DEVICE" | awk '/via/ {print $3}' | tr -d "\n") OMR_TRACKER_DEVICE_GATEWAY=$(ip -4 r list dev "$OMR_TRACKER_DEVICE" | awk '/via/ {print $3}' | tr -d "\n")
fi fi
fi fi
if [ "$OMR_TRACKER_IPV6" = "1" ] || [ "$OMR_TRACKER_IPV6" = "auto" ]; then if ([ "$OMR_TRACKER_IPV6" = "1" ] || [ "$OMR_TRACKER_IPV6" = "auto" ] || [ -z "$OMR_TRACKER_IPV6" ]) && ([ "$OMR_TRACKER_FAMILY" = "ipv6" ] || [ "$OMR_TRACKER_FAMILY" = "ipv4ipv6" ]); then
#OMR_TRACKER_DEVICE_IP6=$(ip -6 -br addr ls dev "$OMR_TRACKER_DEVICE" | awk -F'[ /]+' '{print $3}') #OMR_TRACKER_DEVICE_IP6=$(ip -6 -br addr ls dev "$OMR_TRACKER_DEVICE" | awk -F'[ /]+' '{print $3}')
#if [ -z "$OMR_TRACKER_DEVICE_IP6" ]; then #if [ -z "$OMR_TRACKER_DEVICE_IP6" ]; then
OMR_TRACKER_DEVICE_IP6=$(ip -6 addr show dev "$OMR_TRACKER_DEVICE" | sort -r | grep -m 1 inet6 | awk '{print $2}' | cut -d'/' -s -f1) OMR_TRACKER_DEVICE_IP6=$(ip -6 addr show dev "$OMR_TRACKER_DEVICE" | sort -r | grep -m 1 inet6 | awk '{print $2}' | cut -d'/' -s -f1)
@ -331,9 +342,13 @@ while true; do
fi fi
# execute specific tracker # execute specific tracker
if [ -n "$OMR_TRACKER_DEVICE_IP" ] && [ -n "$OMR_TRACKER_DEVICE_GATEWAY" ]; then if ([ "$OMR_TRACKER_FAMILY" = "ipv4" ] || [ "$OMR_TRACKER_FAMILY" = "ipv4ipv6" ]) && [ -n "$OMR_TRACKER_DEVICE_IP" ] && [ -n "$OMR_TRACKER_DEVICE_GATEWAY" ]; then
# setup loop variable # setup loop variable
if [ "$OMR_TRACKER_PREV_STATUS" = "ERROR" ]; then
tries="$OMR_TRACKER_TRIES" tries="$OMR_TRACKER_TRIES"
else
tries="$OMR_TRACKER_TRIES_UP"
fi
# loop until tries attempts have been reached # loop until tries attempts have been reached
while [ "$tries" -gt 0 ]; do while [ "$tries" -gt 0 ]; do
if [ -n "$OMR_TRACKER_DEVICE_ROUTE" ]; then if [ -n "$OMR_TRACKER_DEVICE_ROUTE" ]; then
@ -430,9 +445,14 @@ while true; do
sleep "$OMR_TRACKER_INTERVAL_TRIES" sleep "$OMR_TRACKER_INTERVAL_TRIES"
done done
fi fi
if [ "$(uci -q get openmptcprouter.settings.disable_ipv6)" = "0" ] && [ -n "$OMR_TRACKER_DEVICE_IP6" ] && [ -n "$OMR_TRACKER_DEVICE_GATEWAY6" ]; then #if [ "$(uci -q get openmptcprouter.settings.disable_ipv6)" = "0" ] && [ -n "$OMR_TRACKER_DEVICE_IP6" ] && [ -n "$OMR_TRACKER_DEVICE_GATEWAY6" ]; then
if ([ "$OMR_TRACKER_FAMILY" = "ipv6" ] || [ "$OMR_TRACKER_FAMILY" = "ipv4ipv6" ]) && [ "$(uci -q get openmptcprouter.settings.disable_ipv6)" = "0" ] && [ -n "$OMR_TRACKER_DEVICE_IP6" ] && [ -n "$OMR_TRACKER_DEVICE_GATEWAY6" ]; then
# setup loop variable # setup loop variable
if [ "$OMR_TRACKER_PREV_STATUS" = "ERROR" ]; then
tries="$OMR_TRACKER_TRIES" tries="$OMR_TRACKER_TRIES"
else
tries="$OMR_TRACKER_TRIES_UP"
fi
# loop until tries attempts have been reached # loop until tries attempts have been reached
while [ "$tries" -gt 0 ]; do while [ "$tries" -gt 0 ]; do
#if [ -n "$OMR_TRACKER_DEVICE_ROUTE" ]; then #if [ -n "$OMR_TRACKER_DEVICE_ROUTE" ]; then
@ -534,7 +554,7 @@ while true; do
[ -z "$OMR_TRACKER_STATUS_MSG" ] && OMR_TRACKER_STATUS_MSG="$OMR_TRACKER_INTERFACE may have ip issues" [ -z "$OMR_TRACKER_STATUS_MSG" ] && OMR_TRACKER_STATUS_MSG="$OMR_TRACKER_INTERFACE may have ip issues"
[ -z "$OMR_TRACKER_DEVICE_IP" ] && OMR_TRACKER_STATUS_MSG="$OMR_TRACKER_STATUS_MSG, interface have no IPv4" [ -z "$OMR_TRACKER_DEVICE_IP" ] && OMR_TRACKER_STATUS_MSG="$OMR_TRACKER_STATUS_MSG, interface have no IPv4"
[ -z "$OMR_TRACKER_DEVICE_GATEWAY" ] && OMR_TRACKER_STATUS_MSG="$OMR_TRACKER_STATUS_MSG, interface have no IPv4 gateway" [ -z "$OMR_TRACKER_DEVICE_GATEWAY" ] && OMR_TRACKER_STATUS_MSG="$OMR_TRACKER_STATUS_MSG, interface have no IPv4 gateway"
if [ "$(uci -q get openmptcprouter.settings.disable_ipv6)" = "0" ]; then if ([ "$OMR_TRACKER_IPV6" = "1" ] || [ "$OMR_TRACKER_IPV6" = "auto" ] || [ -z "$OMR_TRACKER_IPV6" ]) && ([ "$OMR_TRACKER_FAMILY" = "ipv6" ] || [ "$OMR_TRACKER_FAMILY" = "ipv4ipv6" ]); then
[ -z "$OMR_TRACKER_DEVICE_IP6" ] && OMR_TRACKER_STATUS_MSG="$OMR_TRACKER_STATUS_MSG, interface have no IPv6" [ -z "$OMR_TRACKER_DEVICE_IP6" ] && OMR_TRACKER_STATUS_MSG="$OMR_TRACKER_STATUS_MSG, interface have no IPv6"
[ -z "$OMR_TRACKER_DEVICE_GATEWAY6" ] && OMR_TRACKER_STATUS_MSG="$OMR_TRACKER_STATUS_MSG, interface have no IPv6 gateway" [ -z "$OMR_TRACKER_DEVICE_GATEWAY6" ] && OMR_TRACKER_STATUS_MSG="$OMR_TRACKER_STATUS_MSG, interface have no IPv6 gateway"
fi fi
@ -558,6 +578,26 @@ while true; do
OMR_TRACKER_STATUS_MSG="$OMR_TRACKER_STATUS_MSG and $OMR_TRACKER_TYPE from $OMR_TRACKER_DEVICE_IP error ($OMR_TRACKER_LIST_HOSTS6)" OMR_TRACKER_STATUS_MSG="$OMR_TRACKER_STATUS_MSG and $OMR_TRACKER_TYPE from $OMR_TRACKER_DEVICE_IP error ($OMR_TRACKER_LIST_HOSTS6)"
fi fi
fi fi
if [ "$OMR_TRACKER_CHECK_QUALITY" = "1" ]; then
if [ "$OMR_TRACKER_PREV_STATUS" = "OK" ]; then
if [ -n "$OMR_TRACKER_LOSS" ] && [ "$OMR_TRACKER_LOSS" -ge "$OMR_TRACKER_LOSS_FAILURE" ] && [ "$OMR_TRACKER_STATUS" = "OK" ]; then
OMR_TRACKER_STATUS="ERROR"
OMR_TRACKER_STATUS_MSG="Packet loss is $OMR_TRACKER_LOSS this is more than limit defined at $OMR_TRACKER_LOSS_FAILURE"
fi
if [ -n "$OMR_TRACKER_LATENCY" ] && [ "$OMR_TRACKER_LATENCY" -ge "$OMR_TRACKER_LATENCY_FAILURE" ] && [ "$OMR_TRACKER_STATUS" = "OK" ]; then
OMR_TRACKER_STATUS="ERROR"
OMR_TRACKER_STATUS_MSG="Latency is $OMR_TRACKER_LATENCY this is more than limit defined at $OMR_TRACKER_LATENCY_FAILURE"
fi
elif [ "$OMR_TRACKER_PREV_STATUS" = "ERROR" ]; then
OMR_TRACKER_STATUS="ERROR"
if [ -n "$OMR_TRACKER_LOSS" ] && [ "$OMR_TRACKER_LOSS" -le "$OMR_TRACKER_LOSS_RECOVERY" ] && [ "$OMR_TRACKER_STATUS" = "OK" ]; then
OMR_TRACKER_STATUS="OK"
fi
if [ -n "$OMR_TRACKER_LATENCY" ] && [ "$OMR_TRACKER_LATENCY" -ge "$OMR_TRACKER_LATENCY_RECOVERY" ] && [ "$OMR_TRACKER_STATUS" = "OK" ]; then
OMR_TRACKER_STATUS="OK"
fi
fi
fi
#[ "$OMR_TRACKER_HOSTS" = "$initial_hosts" ] || [ "$OMR_TRACKER_STATUS" = "OK" ] && _post_tracking #[ "$OMR_TRACKER_HOSTS" = "$initial_hosts" ] || [ "$OMR_TRACKER_STATUS" = "OK" ] && _post_tracking
#[ "$OMR_TRACKER_STATUS" = "ERROR" ] && _restart #[ "$OMR_TRACKER_STATUS" = "ERROR" ] && _restart
@ -567,5 +607,9 @@ while true; do
OMR_TRACKER_PREV_STATUS="$OMR_TRACKER_STATUS" OMR_TRACKER_PREV_STATUS="$OMR_TRACKER_STATUS"
_restart _restart
if [ "$OMR_TRACKER_STATUS" = "ERROR" ]; then
sleep "$OMR_TRACKER_FAILURE_INTERVAL"
else
sleep "$OMR_TRACKER_INTERVAL" sleep "$OMR_TRACKER_INTERVAL"
fi
done done

View file

@ -27,6 +27,12 @@ config defaults 'defaults'
option server_http_test '0' option server_http_test '0'
option restart_down '0' option restart_down '0'
option mail_alert '0' option mail_alert '0'
option initial_state 'online'
option family 'ipv4'
option reliability '1'
option count '2'
option failure_interval '5'
option tries_up '5'
config proxy 'proxy' config proxy 'proxy'
option enabled '1' option enabled '1'
@ -43,6 +49,8 @@ config proxy 'proxy'
option interval_tries '1' option interval_tries '1'
option interval '10' option interval '10'
option mail_alert '0' option mail_alert '0'
option initial_state 'online'
option family 'ipv4ipv6'
config server 'server' config server 'server'
option enabled '1' option enabled '1'
@ -51,3 +59,4 @@ config server 'server'
option wait_test '0' option wait_test '0'
option interval '5' option interval '5'
option mail_alert '0' option mail_alert '0'
option initial_state 'online'

View file

@ -16,34 +16,54 @@
. /lib/functions/network.sh . /lib/functions/network.sh
_validate_section() { _validate_section() {
local tmp_hosts=$hosts tmp_hosts6=$hosts6 tmp_timeout=$timeout tmp_count=$count tmp_tries=$tries local tmp_hosts=$hosts tmp_hosts6=$hosts6 tmp_timeout=$timeout tmp_count=$count tmp_tries=$tries tmp_size=$size tmp_max_ttl=$max_ttl tmp_failure_loss=$failure_loss tmp_failure_latency=$failure_latency tmp_recovery_loss=$recovery_loss tmp_recovery_latency=$recovery_latency
local tmp_interval=$interval tmp_interval_tries=$interval_tries tmp_options=$options tmp_type=$type tmp_enabled=$enabled tmp_wait_test=$wait_test tmp_server_http_test=$server_http_test local tmp_interval=$interval tmp_interval_tries=$interval_tries tmp_options=$options tmp_type=$type tmp_enabled=$enabled tmp_wait_test=$wait_test tmp_server_http_test=$server_http_test tmp_check_quality=$check_quality tmp_failure_interval=$failure_interval tmp_tries_up=$tries_up tmp_family=$family
uci_validate_section omr-tracker "$1" "$2" \ uci_validate_section omr-tracker "$1" "$2" \
'hosts:list(host)' \ 'hosts:list(host)' \
'hosts6:list(host)' \ 'hosts6:list(host)' \
'timeout:uinteger' \ 'timeout:uinteger' \
'size:uinteger' \
'max_ttl:uinteger' \
'failure_loss:uinteger' \
'failure_latency:uinteger' \
'recovery_loss:uinteger' \
'recovery_latency:uinteger' \
'check_quality:bool:0' \
'count:uinteger' \ 'count:uinteger' \
'tries:uinteger' \ 'tries:uinteger' \
'tries_up:uinteger' \
'interval:uinteger' \ 'interval:uinteger' \
'interval_tries:uinteger' \ 'interval_tries:uinteger' \
'failure_interval:uinteger' \
'wait_test:uinteger' \ 'wait_test:uinteger' \
'type:string:undef' \ 'type:string:undef' \
'enabled:bool:1' \ 'enabled:bool:1' \
'server_http_test:bool:0' \ 'server_http_test:bool:0' \
'family:string' \
'options:string' 'options:string'
[ -z "$hosts" ] && hosts=$tmp_hosts [ -z "$hosts" ] && hosts=$tmp_hosts
[ -z "$hosts6" ] && hosts6=$tmp_hosts6 [ -z "$hosts6" ] && hosts6=$tmp_hosts6
[ -z "$timeout" ] && timeout=$tmp_timeout [ -z "$timeout" ] && timeout=$tmp_timeout
[ -z "$count" ] && count=$tmp_count [ -z "$count" ] && count=$tmp_count
[ -z "$size" ] && size=$tmp_size
[ -z "$failure_loss" ] && failure_loss=$tmp_failure_loss
[ -z "$failure_latency" ] && failure_latency=$tmp_failure_latency
[ -z "$failure_interval" ] && failure_interval=$tmp_failure_interval
[ -z "$recovery_loss" ] && recovery_loss=$tmp_recovery_loss
[ -z "$recovery_latency" ] && recovery_latency=$tmp_recovery_latency
[ -z "$check_quality" ] && check_quality=$tmp_check_quality
[ -z "$max_ttl" ] && max_ttl=$tmp_max_ttl
[ -z "$tries" ] && tries=$tmp_tries [ -z "$tries" ] && tries=$tmp_tries
[ -z "$tries_up" ] && tries_up=$tmp_tries_up
[ -z "$interval" ] && interval=$tmp_interval [ -z "$interval" ] && interval=$tmp_interval
[ -z "$interval_tries" ] && interval_tries=$tmp_interval_tries [ -z "$interval_tries" ] && interval_tries=$tmp_interval_tries
[ -z "$wait_test" ] && wait_test=$tmp_wait_test [ -z "$wait_test" ] && wait_test=$tmp_wait_test
[ -z "$options" ] && options=$tmp_options [ -z "$options" ] && options=$tmp_options
[ "$type" = "undef" ] && type=${tmp_type:-ping} [ "$type" = "undef" ] && type=${tmp_type:-ping}
[ -z "$server_http_test" ] && server_http_test=$tmp_server_http_test [ -z "$server_http_test" ] && server_http_test=$tmp_server_http_test
[ -z "$family" ] && family=$tmp_family
[ -z "$enabled" ] && enabled=$tmp_enabled [ -z "$enabled" ] && enabled=$tmp_enabled
} }
@ -52,7 +72,7 @@ _launch_tracker() {
loopback|lan*|if0*) return;; loopback|lan*|if0*) return;;
esac esac
[ -z "$1" ] && return [ -z "$1" ] && return
local hosts hosts6 timeout count tries interval interval_tries options type enabled wait_test ipv6 proto server_http_test local hosts hosts6 timeout count tries tries_up interval interval_tries options type enabled wait_test ipv6 proto server_http_test size max_ttl failure_loss failure_interval failure_latency recovery_loss recovery_latency family
_validate_section "defaults" "defaults" _validate_section "defaults" "defaults"
_validate_section "interface" "$1" _validate_section "interface" "$1"
@ -80,6 +100,11 @@ _launch_tracker() {
#[ "${ifstatus}" = "false" ] && [ -z "${ifdevice}" ] && return #[ "${ifstatus}" = "false" ] && [ -z "${ifdevice}" ] && return
[ -z "${interval_tries}" ] && interval_tries=1 [ -z "${interval_tries}" ] && interval_tries=1
[ -z "${count}" ] && count=2 [ -z "${count}" ] && count=2
[ -z "${max_ttl}" ] && max_ttl=60
[ -z "${size}" ] && size=56
[ -z "${check_quality}" ] && check_quality=0
[ -z "${tries}" ] && tries=5
[ -z "${tries_up}" ] && tries_up=${tries}
procd_open_instance procd_open_instance
# shellcheck disable=SC2086 # shellcheck disable=SC2086
@ -87,14 +112,24 @@ _launch_tracker() {
procd_append_param env "OMR_TRACKER_HOSTS=$hosts" procd_append_param env "OMR_TRACKER_HOSTS=$hosts"
procd_append_param env "OMR_TRACKER_HOSTS6=$hosts6" procd_append_param env "OMR_TRACKER_HOSTS6=$hosts6"
procd_append_param env "OMR_TRACKER_TIMEOUT=$timeout" procd_append_param env "OMR_TRACKER_TIMEOUT=$timeout"
procd_append_param env "OMR_TRACKER_SIZE=$size"
procd_append_param env "OMR_TRACKER_CHECK_QUALITY=$check_quality"
procd_append_param env "OMR_TRACKER_MAX_TTL=$max_ttl"
procd_append_param env "OMR_TRACKER_FAILURE_LOSS=$failure_loss"
procd_append_param env "OMR_TRACKER_FAILURE_LATENCY=$failure_latency"
procd_append_param env "OMR_TRACKER_RECOVERY_LOSS=$recovery_loss"
procd_append_param env "OMR_TRACKER_RECOVERY_LATENCY=$recovery_latency"
procd_append_param env "OMR_TRACKER_COUNT=$count" procd_append_param env "OMR_TRACKER_COUNT=$count"
procd_append_param env "OMR_TRACKER_TRIES=$tries" procd_append_param env "OMR_TRACKER_TRIES=$tries"
procd_append_param env "OMR_TRACKER_TRIES_UP=$tries_up"
procd_append_param env "OMR_TRACKER_INTERVAL=$interval" procd_append_param env "OMR_TRACKER_INTERVAL=$interval"
procd_append_param env "OMR_TRACKER_FAILURE_INTERVAL=$failure_interval"
procd_append_param env "OMR_TRACKER_INTERVAL_TRIES=$interval_tries" procd_append_param env "OMR_TRACKER_INTERVAL_TRIES=$interval_tries"
procd_append_param env "OMR_TRACKER_TABLE=$ip4table" procd_append_param env "OMR_TRACKER_TABLE=$ip4table"
procd_append_param env "OMR_TRACKER_DEVICE=$ifname" procd_append_param env "OMR_TRACKER_DEVICE=$ifname"
procd_append_param env "OMR_TRACKER_DEVICE_GATEWAY=$gateway" procd_append_param env "OMR_TRACKER_DEVICE_GATEWAY=$gateway"
procd_append_param env "OMR_TRACKER_TYPE=$type" procd_append_param env "OMR_TRACKER_TYPE=$type"
procd_append_param env "OMR_TRACKER_FAMILY=$family"
procd_append_param env "OMR_TRACKER_IPV6=$ipv6" procd_append_param env "OMR_TRACKER_IPV6=$ipv6"
procd_append_param env "OMR_TRACKER_PROTO=$proto" procd_append_param env "OMR_TRACKER_PROTO=$proto"
procd_append_param env "OMR_TRACKER_WAIT_TEST=$wait_test" procd_append_param env "OMR_TRACKER_WAIT_TEST=$wait_test"

View file

@ -106,4 +106,26 @@ if [ "$(uci -q get omr-tracker.defaults.server_http_test)" = "" ]; then
EOF EOF
fi fi
if [ "$(uci -q get omr-tracker.defaults.family)" = "" ]; then
uci -q batch <<-EOF >/dev/null
set omr-tracker.defaults.initial_state='online'
set omr-tracker.defaults.family='ipv4ipv6'
set omr-tracker.defaults.reliability='1'
set omr-tracker.defaults.interval='1'
set omr-tracker.defaults.failure_interval='5'
set omr-tracker.defaults.count='1'
set omr-tracker.defaults.tries_up='5'
set omr-tracker.omrvpn.initial_state='online'
set omr-tracker.omrvpn.family='ipv4'
set omr-tracker.omrvpn.reliability='1'
set omr-tracker.omrvpn.failure_interval='5'
set omr-tracker.omrvpn.tries_up='5'
set omr-tracker.omrvpn.count='1'
set omr-tracker.proxy.initial_state='online'
set omr-tracker.proxy.family='ipv4ipv6'
set omr-tracker.server.initial_state='online'
commit omr-tracker
EOF
fi
exit 0 exit 0

View file

@ -15,6 +15,12 @@ if [ "$(uci -q get omr-tracker.omrvpn)" = "" ]; then
set omr-tracker.omrvpn.restart_down=0 set omr-tracker.omrvpn.restart_down=0
add_list omr-tracker.omrvpn.hosts='4.2.2.1' add_list omr-tracker.omrvpn.hosts='4.2.2.1'
add_list omr-tracker.omrvpn.hosts='8.8.8.8' add_list omr-tracker.omrvpn.hosts='8.8.8.8'
set omr-tracker.omrvpn.initial_state='online'
set omr-tracker.omrvpn.family='ipv4'
set omr-tracker.omrvpn.reliability='1'
set omr-tracker.omrvpn.count='1'
set omr-tracker.omrvpn.failure_interval='5'
set omr-tracker.omrvpn.tries_up='5
commit omr-tracker commit omr-tracker
EOF EOF
fi fi