OPNsense Forum

English Forums => Development and Code Review => Topic started by: hdholm on November 30, 2021, 03:18:49 PM

Title: A couple of "How To" Questions
Post by: hdholm on November 30, 2021, 03:18:49 PM
I'm new to OPNsense development.  I'm trying to add a plug-in for tang (see https://github.com/latchset/tang for more info.)  The tang server and its dependencies are in the FreeBSD package repositories.  Work-in-progress for the plug-in is at https://github.com/hdholm/plugins/tree/tang/security/tang and of course all constructive comments are welcome.  But the reason for this post is a couple of things I haven't quite figured out.

First, selecting interfaces.  While the development manual has a section on fields that includes an InterfaceField there's not much more information.  Although I think the right form selection is select_multiple (although I couldn't find any mappings from Fields to forms) I can't for the life of me figure out how to correctly populate a selection.  All the examples I found seem to be pure PHP pages not using the forms system at all.

Second, I'm hoping there's an easy way to display a log file.  Looking at the Unbound plug-in it looks like it uses a diagnostics/log/core/resolver page to produce a nice log display, but I can't figure out how it was all tied together to the specific log.  e.g., How would I tie something like that to /var/log/tang?

Thanks.

Title: Re: A couple of "How To" Questions
Post by: 8191 on December 12, 2021, 09:29:05 AM
Hi,
the IDS plugin (part of core) uses an interface selection (ids.general.interfaces).

For the logging part, unfortunately the diagnostics/log view requires an extension of the LogController (which is part of core). You need to create a new view + LogController in your project. I'd have a look at the security/acme-client plugin - there's also logging implemented using diagnostics/log. The API controller can be re-used (as done in acme-client).

BR
Manuel