From 21c5a3c63fc637d5373c494a470dca35d2544147 Mon Sep 17 00:00:00 2001 From: Nimlas Date: Wed, 20 Nov 2024 20:38:03 +0100 Subject: [PATCH 1/5] Enable blocklist in the gui and to be transferred to the command line. --- net/mdns-repeater/Makefile | 2 +- net/mdns-repeater/pkg-descr | 5 +++++ .../app/controllers/OPNsense/MDNSRepeater/forms/general.xml | 6 ++++++ .../mvc/app/models/OPNsense/MDNSRepeater/MDNSRepeater.xml | 4 ++++ .../service/templates/OPNsense/MDNSRepeater/mdnsrepeater | 3 +++ 5 files changed, 19 insertions(+), 1 deletion(-) diff --git a/net/mdns-repeater/Makefile b/net/mdns-repeater/Makefile index 8fc5683f4a..c2d785a2de 100644 --- a/net/mdns-repeater/Makefile +++ b/net/mdns-repeater/Makefile @@ -1,5 +1,5 @@ PLUGIN_NAME= mdns-repeater -PLUGIN_VERSION= 1.1 +PLUGIN_VERSION= 1.2 PLUGIN_REVISION= 1 PLUGIN_COMMENT= Proxy multicast DNS between networks PLUGIN_MAINTAINER= franz.fabian.94@gmail.com diff --git a/net/mdns-repeater/pkg-descr b/net/mdns-repeater/pkg-descr index a5ed7facd2..c02bb39a80 100644 --- a/net/mdns-repeater/pkg-descr +++ b/net/mdns-repeater/pkg-descr @@ -7,6 +7,11 @@ It can be used to bridge zeroconf devices to work properly across the two subnet Plugin Changelog ================ +1.2 + +* Blocklist support (contributed by Kodehyrden) + + 1.1 * CARP support (contributed by Markus Reiter) diff --git a/net/mdns-repeater/src/opnsense/mvc/app/controllers/OPNsense/MDNSRepeater/forms/general.xml b/net/mdns-repeater/src/opnsense/mvc/app/controllers/OPNsense/MDNSRepeater/forms/general.xml index 7a565757fe..b842c50c7f 100644 --- a/net/mdns-repeater/src/opnsense/mvc/app/controllers/OPNsense/MDNSRepeater/forms/general.xml +++ b/net/mdns-repeater/src/opnsense/mvc/app/controllers/OPNsense/MDNSRepeater/forms/general.xml @@ -17,4 +17,10 @@ select_multiple At least 2 interfaces must be selected. The maximum number of supported interfaces by the daemon is 5. + + mdnsrepeater.bloklist + + text + Optionally to blacklist an entire subnet, (eg. 192.168.1.1/24). + diff --git a/net/mdns-repeater/src/opnsense/mvc/app/models/OPNsense/MDNSRepeater/MDNSRepeater.xml b/net/mdns-repeater/src/opnsense/mvc/app/models/OPNsense/MDNSRepeater/MDNSRepeater.xml index 85015e3d67..3ae39f7dfa 100644 --- a/net/mdns-repeater/src/opnsense/mvc/app/models/OPNsense/MDNSRepeater/MDNSRepeater.xml +++ b/net/mdns-repeater/src/opnsense/mvc/app/models/OPNsense/MDNSRepeater/MDNSRepeater.xml @@ -16,5 +16,9 @@ Y Y + + + N + diff --git a/net/mdns-repeater/src/opnsense/service/templates/OPNsense/MDNSRepeater/mdnsrepeater b/net/mdns-repeater/src/opnsense/service/templates/OPNsense/MDNSRepeater/mdnsrepeater index 7ca779ca55..2011cdf032 100644 --- a/net/mdns-repeater/src/opnsense/service/templates/OPNsense/MDNSRepeater/mdnsrepeater +++ b/net/mdns-repeater/src/opnsense/service/templates/OPNsense/MDNSRepeater/mdnsrepeater @@ -10,6 +10,9 @@ required_files="/var/run/mdns-repeater.CARP_MASTER" {% do interface_list.append(physical_interface(i)) %} {% endfor %} mdns_repeater_interfaces="{{ interface_list | join(' ') }}" +{% if helpers.exists('OPNsense.MDNSRepeater.bloklist') and OPNsense.MDNSRepeater.bloklist != '' %} +mdns_repeater_blocklist="-b " + OPNsense.MDNSRepeater.bloklist +{% endif %} {% else %} mdns_repeater_enable="NO" {% endif %} From 17bb245fc7d202810c9c431513568240797180a0 Mon Sep 17 00:00:00 2001 From: Niels Harre Date: Thu, 21 Nov 2024 20:53:40 +0000 Subject: [PATCH 2/5] Sorry for typo's. I am bit rusty in regex, but I believe this should work. --- .../OPNsense/MDNSRepeater/forms/general.xml | 2 +- .../app/models/OPNsense/MDNSRepeater/MDNSRepeater.xml | 11 +++++++++-- .../templates/OPNsense/MDNSRepeater/mdnsrepeater | 4 ++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/net/mdns-repeater/src/opnsense/mvc/app/controllers/OPNsense/MDNSRepeater/forms/general.xml b/net/mdns-repeater/src/opnsense/mvc/app/controllers/OPNsense/MDNSRepeater/forms/general.xml index b842c50c7f..26b8207f84 100644 --- a/net/mdns-repeater/src/opnsense/mvc/app/controllers/OPNsense/MDNSRepeater/forms/general.xml +++ b/net/mdns-repeater/src/opnsense/mvc/app/controllers/OPNsense/MDNSRepeater/forms/general.xml @@ -18,7 +18,7 @@ At least 2 interfaces must be selected. The maximum number of supported interfaces by the daemon is 5. - mdnsrepeater.bloklist + mdnsrepeater.blocklist text Optionally to blacklist an entire subnet, (eg. 192.168.1.1/24). diff --git a/net/mdns-repeater/src/opnsense/mvc/app/models/OPNsense/MDNSRepeater/MDNSRepeater.xml b/net/mdns-repeater/src/opnsense/mvc/app/models/OPNsense/MDNSRepeater/MDNSRepeater.xml index 3ae39f7dfa..a52b1972f3 100644 --- a/net/mdns-repeater/src/opnsense/mvc/app/models/OPNsense/MDNSRepeater/MDNSRepeater.xml +++ b/net/mdns-repeater/src/opnsense/mvc/app/models/OPNsense/MDNSRepeater/MDNSRepeater.xml @@ -16,9 +16,16 @@ Y Y - + N - + Add entire subnets in CIDR notation, e.g. 192.168.1.0/24. Only one IPv4 subnet is allowed. + ^((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\/([0-9]|[12][0-9]|3[0-2])$ + Y + Y + ipv4 + N + Y + diff --git a/net/mdns-repeater/src/opnsense/service/templates/OPNsense/MDNSRepeater/mdnsrepeater b/net/mdns-repeater/src/opnsense/service/templates/OPNsense/MDNSRepeater/mdnsrepeater index 2011cdf032..616d4cfc0c 100644 --- a/net/mdns-repeater/src/opnsense/service/templates/OPNsense/MDNSRepeater/mdnsrepeater +++ b/net/mdns-repeater/src/opnsense/service/templates/OPNsense/MDNSRepeater/mdnsrepeater @@ -10,8 +10,8 @@ required_files="/var/run/mdns-repeater.CARP_MASTER" {% do interface_list.append(physical_interface(i)) %} {% endfor %} mdns_repeater_interfaces="{{ interface_list | join(' ') }}" -{% if helpers.exists('OPNsense.MDNSRepeater.bloklist') and OPNsense.MDNSRepeater.bloklist != '' %} -mdns_repeater_blocklist="-b " + OPNsense.MDNSRepeater.bloklist +{% if helpers.exists('OPNsense.MDNSRepeater.blocklist') and OPNsense.MDNSRepeater.blocklist != '' %} +mdns_repeater_blocklist="-b " + OPNsense.MDNSRepeater.blocklist {% endif %} {% else %} mdns_repeater_enable="NO" From 707febeee5d7540fcbe44afc999584c983461592 Mon Sep 17 00:00:00 2001 From: Niels Harre Date: Fri, 22 Nov 2024 07:54:57 +0000 Subject: [PATCH 3/5] Now supporting more subnets or individual addresses --- .../app/controllers/OPNsense/MDNSRepeater/forms/general.xml | 2 +- .../mvc/app/models/OPNsense/MDNSRepeater/MDNSRepeater.xml | 6 ++---- .../service/templates/OPNsense/MDNSRepeater/mdnsrepeater | 3 ++- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/net/mdns-repeater/src/opnsense/mvc/app/controllers/OPNsense/MDNSRepeater/forms/general.xml b/net/mdns-repeater/src/opnsense/mvc/app/controllers/OPNsense/MDNSRepeater/forms/general.xml index 26b8207f84..e4487caec0 100644 --- a/net/mdns-repeater/src/opnsense/mvc/app/controllers/OPNsense/MDNSRepeater/forms/general.xml +++ b/net/mdns-repeater/src/opnsense/mvc/app/controllers/OPNsense/MDNSRepeater/forms/general.xml @@ -21,6 +21,6 @@ mdnsrepeater.blocklist text - Optionally to blacklist an entire subnet, (eg. 192.168.1.1/24). + Optionally to blacklist an entire subnet, (eg. 192.168.1.0/24) or individual addresses. Up to 16 subnets are supported and IPv4 subnets only. diff --git a/net/mdns-repeater/src/opnsense/mvc/app/models/OPNsense/MDNSRepeater/MDNSRepeater.xml b/net/mdns-repeater/src/opnsense/mvc/app/models/OPNsense/MDNSRepeater/MDNSRepeater.xml index a52b1972f3..9bc393fe6a 100644 --- a/net/mdns-repeater/src/opnsense/mvc/app/models/OPNsense/MDNSRepeater/MDNSRepeater.xml +++ b/net/mdns-repeater/src/opnsense/mvc/app/models/OPNsense/MDNSRepeater/MDNSRepeater.xml @@ -19,13 +19,11 @@ N - Add entire subnets in CIDR notation, e.g. 192.168.1.0/24. Only one IPv4 subnet is allowed. - ^((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\/([0-9]|[12][0-9]|3[0-2])$ + Please enter one or more valid IPv4 networks or individual addresses in CIDR notation. Y Y ipv4 - N - Y + Y diff --git a/net/mdns-repeater/src/opnsense/service/templates/OPNsense/MDNSRepeater/mdnsrepeater b/net/mdns-repeater/src/opnsense/service/templates/OPNsense/MDNSRepeater/mdnsrepeater index 616d4cfc0c..dbb4f67762 100644 --- a/net/mdns-repeater/src/opnsense/service/templates/OPNsense/MDNSRepeater/mdnsrepeater +++ b/net/mdns-repeater/src/opnsense/service/templates/OPNsense/MDNSRepeater/mdnsrepeater @@ -11,7 +11,8 @@ required_files="/var/run/mdns-repeater.CARP_MASTER" {% endfor %} mdns_repeater_interfaces="{{ interface_list | join(' ') }}" {% if helpers.exists('OPNsense.MDNSRepeater.blocklist') and OPNsense.MDNSRepeater.blocklist != '' %} -mdns_repeater_blocklist="-b " + OPNsense.MDNSRepeater.blocklist +{% set networkstobeblocked = "-b " + OPNsense.MDNSRepeater.blocklist.split(',') | join(' -b ') %} +mdns_repeater_blocklist="{{ networkstobeblocked }}" {% endif %} {% else %} mdns_repeater_enable="NO" From fe06b3beef6e26c73999e40d3ccfa5b46ffda7a0 Mon Sep 17 00:00:00 2001 From: Kodehyrden Date: Fri, 22 Nov 2024 17:44:17 +0100 Subject: [PATCH 4/5] Update end tag - embarrasing --- .../app/models/OPNsense/MDNSRepeater/MDNSRepeater.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/net/mdns-repeater/src/opnsense/mvc/app/models/OPNsense/MDNSRepeater/MDNSRepeater.xml b/net/mdns-repeater/src/opnsense/mvc/app/models/OPNsense/MDNSRepeater/MDNSRepeater.xml index 9bc393fe6a..791bd0c8ac 100644 --- a/net/mdns-repeater/src/opnsense/mvc/app/models/OPNsense/MDNSRepeater/MDNSRepeater.xml +++ b/net/mdns-repeater/src/opnsense/mvc/app/models/OPNsense/MDNSRepeater/MDNSRepeater.xml @@ -19,11 +19,11 @@ N - Please enter one or more valid IPv4 networks or individual addresses in CIDR notation. - Y - Y - ipv4 - Y + Please enter one or more valid IPv4 networks or individual addresses in CIDR notation. + Y + Y + ipv4 + Y From 3a24c8e953b5f3351a484adf172d49b0f09e33f8 Mon Sep 17 00:00:00 2001 From: Kodehyrden Date: Fri, 22 Nov 2024 18:09:30 +0100 Subject: [PATCH 5/5] Added a field separator --- .../mvc/app/models/OPNsense/MDNSRepeater/MDNSRepeater.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/mdns-repeater/src/opnsense/mvc/app/models/OPNsense/MDNSRepeater/MDNSRepeater.xml b/net/mdns-repeater/src/opnsense/mvc/app/models/OPNsense/MDNSRepeater/MDNSRepeater.xml index 791bd0c8ac..954db6d1a9 100644 --- a/net/mdns-repeater/src/opnsense/mvc/app/models/OPNsense/MDNSRepeater/MDNSRepeater.xml +++ b/net/mdns-repeater/src/opnsense/mvc/app/models/OPNsense/MDNSRepeater/MDNSRepeater.xml @@ -19,7 +19,8 @@ N - Please enter one or more valid IPv4 networks or individual addresses in CIDR notation. + Please enter one or more valid IPv4 networks or individual addresses in CIDR notation. + , Y Y ipv4