Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mDNS Repeater plugin: Enable blocklist parameter in the gui to allow blocking subnets. #4362

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

Kodehyrden
Copy link

This pull request should mitigate the problem described in this forum post:
https://forum.opnsense.org/index.php?topic=44083.0

It will allow the user to add a subnet to be blocked by the mDNS Repeater. The parameter is already available in the program itself.

This is my very first commit to this repository. Comments are very much welcome. FYI I have also mailed Franz Fabian, maintainer of the mDNS Repeater plugin for OPNsense.

@Kodehyrden Kodehyrden changed the title Enable blocklist parameter in the gui to allow blocking subnets. mDNS Repeater plugin: Enable blocklist parameter in the gui to allow blocking subnets. Nov 21, 2024
Copy link
Member

@Monviech Monviech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your first submission, I have left some general feedback.

@Monviech
Copy link
Member

https://github.com/geekman/mdns-repeater/releases/tag/1.11

It says here that it supports 16 addresses in a blocklist. Why is it limited to 1 in the PR?

<Default></Default>
<Required>N</Required>
</interfaces>
<ValidationMessage>Add entire subnets in CIDR notation, e.g. 192.168.1.0/24. Only one IPv4 subnet is allowed. <ValidationMessage>
<Mask>^((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])$<Mask>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you using regex here. The network field has validation for IP addresses, is it not enough?

Copy link
Member

@Monviech Monviech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to know why you aren't using the code examples I gave you earlier.

It would allow for multiple networks in the same input field, with the tokenizer separating them cleanly, and commas being automatically added.

Right now I think you expect the user to input their own comma separated list?

Please improve on this concept.

<Default></Default>
<Required>N</Required>
<ValidationMessage>Please enter one or more valid IPv4 networks or individual addresses in CIDR notation.<ValidationMessage>
<NetMaskRequired>Y<NetMaskRequired>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you testing what you implement here? The xml is wrong. A few / are missing.

Please test what you do.

root@opn-ce-01:/src/git/opnsense_plugins/net/mdns-repeater # make lint
/src/git/opnsense_plugins/net/mdns-repeater/src/opnsense/mvc/app/models/OPNsense/MDNSRepeater/MDNSRepeater.xml:27: parser error : Opening and ending tag mismatch: AsList line 26 and blocklist
    </blocklist>
                ^
/src/git/opnsense_plugins/net/mdns-repeater/src/opnsense/mvc/app/models/OPNsense/MDNSRepeater/MDNSRepeater.xml:28: parser error : Opening and ending tag mismatch: AsList line 26 and items
  </items>
          ^
/src/git/opnsense_plugins/net/mdns-repeater/src/opnsense/mvc/app/models/OPNsense/MDNSRepeater/MDNSRepeater.xml:29: parser error : Opening and ending tag mismatch: AddressFamily line 25 and model
</model>
        ^
/src/git/opnsense_plugins/net/mdns-repeater/src/opnsense/mvc/app/models/OPNsense/MDNSRepeater/MDNSRepeater.xml:30: parser error : Premature end of data in tag AddressFamily line 25

^
*** Error code 1

Stop.

@Kodehyrden
Copy link
Author

Monviech, first of all, please accept my apologies for the work I have push on you regarding this pull request. I honestly thought it was a lot easier than expected. I have now created a virtual dev environment on my promox. I have installed the modified plugin and it appears now to be working. I did however also realize that changes needs to be made to mens-repeater port. It needs to support black list on the command line as well. I have med the changes, and will create a PR for the ports repository anytime soon. This PR is dependent on acceptance on the ports pull request.

@Monviech
Copy link
Member

Yeah some things that seem easy can become quite complicated, we're all learning every day. :)

What do you mean you have to do a PR in ports? The ports are mostly synchronized from upstream. Can you explain what exactly you need that is not working right now?

@Kodehyrden
Copy link
Author

The command line for the mens-repeater need to support blacklists. This is the PR:
Support blacklist on the commandline #208

@Kodehyrden
Copy link
Author

You're right. Since the code is pulled from https://github.com/kennylevinsen/mdns-repeater/ I will make the pull request here instead. I have deleted my pull request to the ports repository. Oh-my...

@Monviech
Copy link
Member

Its okay, one step at a time. If you have questions don't be afraid to ask.

@Kodehyrden
Copy link
Author

It actually turns out that this particular change is not possible to make upstream. Hence the PR for the opnsense ports collection is uphold.

@Monviech
Copy link
Member

Monviech commented Nov 24, 2024

The .in file comes from a different upstream, the FreeBSD ports. They only have a copy on github, the real place to patch that file is in their bugzilla.

Before going that long hard route, I would try if you can script your way around in the jinja template to construct all parameters you need into the existing variable.

(if possible, don't take my advice here 100% serious I do not know any better, did not look at it too deeply)

@Kodehyrden
Copy link
Author

PR closed in ports collection. Jinja script mods to support blacklist using existing env variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants