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

OMR-ByPass rules can be enabled or disabled

This commit is contained in:
Ycarus (Yannick Chabanois) 2020-09-23 09:49:55 +02:00
parent 58196720a1
commit d0e3a051f0
2 changed files with 52 additions and 0 deletions

View file

@ -28,6 +28,9 @@ return L.view.extend({
s.anonymous = true; s.anonymous = true;
s.nodescriptions = true; s.nodescriptions = true;
o = s.option(form.Flag, 'enabled', _('Enabled'));
o.default = o.enabled;
o = s.option(form.Value, 'name', _('Domain')); o = s.option(form.Value, 'name', _('Domain'));
o.rmempty = false; o.rmempty = false;
@ -44,6 +47,9 @@ return L.view.extend({
s.anonymous = true; s.anonymous = true;
s.nodescriptions = true; s.nodescriptions = true;
o = s.option(form.Flag, 'enabled', _('Enabled'));
o.default = o.enabled;
o = s.option(form.Value, 'ip', _('IP')); o = s.option(form.Value, 'ip', _('IP'));
o.rmempty = false; o.rmempty = false;
@ -60,6 +66,9 @@ return L.view.extend({
s.anonymous = true; s.anonymous = true;
s.nodescriptions = true; s.nodescriptions = true;
o = s.option(form.Flag, 'enabled', _('Enabled'));
o.default = o.enabled;
o = s.option(form.Value, 'dport', _('port')); o = s.option(form.Value, 'dport', _('port'));
o.rmempty = false; o.rmempty = false;
@ -83,6 +92,9 @@ return L.view.extend({
s.anonymous = true; s.anonymous = true;
s.nodescriptions = true; s.nodescriptions = true;
o = s.option(form.Flag, 'enabled', _('Enabled'));
o.default = o.enabled;
o = s.option(form.Value, 'sport', _('port')); o = s.option(form.Value, 'sport', _('port'));
o.rmempty = false; o.rmempty = false;
@ -106,6 +118,9 @@ return L.view.extend({
s.anonymous = true; s.anonymous = true;
s.nodescriptions = true; s.nodescriptions = true;
o = s.option(form.Flag, 'enabled', _('Enabled'));
o.default = o.enabled;
o = s.option(form.Value, 'mac', _('source MAC-Address')); o = s.option(form.Value, 'mac', _('source MAC-Address'));
o.datatype = 'list(unique(macaddr))'; o.datatype = 'list(unique(macaddr))';
o.rmempty = false; o.rmempty = false;
@ -127,6 +142,9 @@ return L.view.extend({
s.anonymous = true; s.anonymous = true;
s.nodescriptions = true; s.nodescriptions = true;
o = s.option(form.Flag, 'enabled', _('Enabled'));
o.default = o.enabled;
o = s.option(form.Value, 'ip', _('IP Address')); o = s.option(form.Value, 'ip', _('IP Address'));
o.datatype = 'or(ip4addr,ip6addr)'; o.datatype = 'or(ip4addr,ip6addr)';
o.rmempty = false; o.rmempty = false;
@ -150,6 +168,9 @@ return L.view.extend({
s.anonymous = true; s.anonymous = true;
s.nodescriptions = true; s.nodescriptions = true;
o = s.option(form.Flag, 'enabled', _('Enabled'));
o.default = o.enabled;
o = s.option(form.Value, 'asn', _('ASN')); o = s.option(form.Value, 'asn', _('ASN'));
o.rmempty = false; o.rmempty = false;
@ -166,6 +187,9 @@ return L.view.extend({
s.anonymous = true; s.anonymous = true;
s.nodescriptions = true; s.nodescriptions = true;
o = s.option(form.Flag, 'enabled', _('Enabled'));
o.default = o.enabled;
o = s.option(form.Value, 'proto', _('Protocol/Service')); o = s.option(form.Value, 'proto', _('Protocol/Service'));
o.rmempty = false; o.rmempty = false;
o.load = function(section_id) { o.load = function(section_id) {

View file

@ -39,8 +39,11 @@ _bypass_ip() {
_bypass_domains() { _bypass_domains() {
local domain local domain
local intf local intf
local enabled
config_get domain $1 name config_get domain $1 name
config_get intf $1 interface config_get intf $1 interface
config_get enabled $1 enabled
[ "$enabled" = "0" ] && return
_bypass_domain $domain $intf _bypass_domain $domain $intf
} }
@ -82,8 +85,11 @@ _bypass_domain() {
_bypass_mac() { _bypass_mac() {
local mac local mac
local intf local intf
local enabled
config_get mac $1 mac config_get mac $1 mac
config_get intf $1 interface config_get intf $1 interface
config_get enabled $1 enabled
[ "$enabled" = "0" ] && return
local intfid="$(uci -q get omr-bypass.$intf.id)" local intfid="$(uci -q get omr-bypass.$intf.id)"
[ -z "$intf" ] && intf="all" [ -z "$intf" ] && intf="all"
@ -120,8 +126,11 @@ _bypass_mac() {
_bypass_lan_ip() { _bypass_lan_ip() {
local ip local ip
local intf local intf
local enabled
config_get ip $1 ip config_get ip $1 ip
config_get intf $1 interface config_get intf $1 interface
config_get enabled $1 enabled
[ "$enabled" = "0" ] && return
local intfid="$(uci -q get omr-bypass.$intf.id)" local intfid="$(uci -q get omr-bypass.$intf.id)"
[ -z "$intf" ] && intf="all" [ -z "$intf" ] && intf="all"
@ -171,9 +180,14 @@ _bypass_lan_ip() {
_bypass_dest_port() { _bypass_dest_port() {
local intf local intf
local enabled
local dport
local proto
config_get dport $1 dport config_get dport $1 dport
config_get proto $1 proto config_get proto $1 proto
config_get intf $1 interface config_get intf $1 interface
config_get enabled $1 enabled
[ "$enabled" = "0" ] && return
local intfid="$(uci -q get omr-bypass.$intf.id)" local intfid="$(uci -q get omr-bypass.$intf.id)"
[ -z "$intf" ] && intf="all" [ -z "$intf" ] && intf="all"
@ -221,9 +235,14 @@ _bypass_dest_port() {
_bypass_src_port() { _bypass_src_port() {
local intf local intf
local enabled
local sport
local proto
config_get sport $1 sport config_get sport $1 sport
config_get proto $1 proto config_get proto $1 proto
config_get intf $1 interface config_get intf $1 interface
config_get enabled $1 enabled
[ "$enabled" = "0" ] && return
local intfid="$(uci -q get omr-bypass.$intf.id)" local intfid="$(uci -q get omr-bypass.$intf.id)"
[ -z "$intf" ] && intf="all" [ -z "$intf" ] && intf="all"
@ -272,8 +291,11 @@ _bypass_src_port() {
_bypass_proto() { _bypass_proto() {
local proto local proto
local intf local intf
local enabled
config_get proto $1 proto config_get proto $1 proto
config_get intf $1 interface config_get intf $1 interface
config_get enabled $1 enabled
[ "$enabled" = "0" ] && return
local intfid="$(uci -q get omr-bypass.$intf.id)" local intfid="$(uci -q get omr-bypass.$intf.id)"
[ -z "$intf" ] && intf="all" [ -z "$intf" ] && intf="all"
@ -411,16 +433,22 @@ _intf_rule() {
_bypass_ip_set() { _bypass_ip_set() {
local ip local ip
local interface local interface
local enabled
config_get ip $1 ip config_get ip $1 ip
config_get interface $1 interface config_get interface $1 interface
config_get enabled $1 enabled
[ "$enabled" = "0" ] && return
_bypass_ip $ip $interface _bypass_ip $ip $interface
} }
_bypass_asn() { _bypass_asn() {
local asn local asn
local interface local interface
local enabled
config_get asn $1 asn config_get asn $1 asn
config_get interface $1 interface config_get interface $1 interface
config_get enabled $1 enabled
[ "$enabled" = "0" ] && return
local asnips local asnips
asnips=`curl --max-time 4 -s -k https://stat.ripe.net/data/announced-prefixes/data.json?resource=${asn} | jsonfilter -q -e '@.data.prefixes.*.prefix'` asnips=`curl --max-time 4 -s -k https://stat.ripe.net/data/announced-prefixes/data.json?resource=${asn} | jsonfilter -q -e '@.data.prefixes.*.prefix'`
for ip in $asnips; do for ip in $asnips; do