OPNsense Forum

English Forums => 24.7, 24.10 Legacy Series => Topic started by: TotalGriffLock on August 14, 2024, 09:53:36 PM

Title: Plugin Development Questions & Some Bugs?
Post by: TotalGriffLock on August 14, 2024, 09:53:36 PM
Hi,

I am porting the scan agent for phpIPAM into OPNSense so you can perform subnet scans directly from the firewall/gateway/DHCP server/whatever role OPNSense has in your network. The agent itself is a threaded (using prctl) CLI PHP application from https://github.com/phpipam/phpipam-agent

I have written a plugin to perform GUI configuration of the agent and add scanning tasks as cron jobs in the web gui which all works fine and as expected. However there are some packaging questions I have:

Then, some possible bugs! I think there may be a couple of mistakes in the documentation regarding building. Several times in the build documentation the package vim-console is referenced, but this does not appear to be installable anymore. 

I believe there is a line of code in the example for the settingscontroller jquery which is incorrect. By this I mean the code shown in the documentation at https://docs.opnsense.org/development/examples/helloworld.html - the file in the github repo is correct. There is a line:

$result["validations"]["general.".$msg->getField()] = $msg->getMessage();
Which I think should be:
$result["validations"]["helloworld.".$msg->getField()] = $msg->getMessage();

The original code results in an object being returned called general.general.fieldname when I think it should be helloworld.general.fieldname?

Additionally it does not appear possible to have an entry in the menu.xml file for a plugin where the tag name starts with php

This did not work in my testing:
<menu>
    <Services>
        <PhpIpamAgent visibleName="phpIPAM Agent" cssClass="fa fa-list-ol fa-fw">
            <Settings url="/ui/phpipamagent" />
        </PhpIpamAgent>
    </Services>
</menu>


This does work:
<menu>
    <Services>
        <ipamAgent visibleName="phpIPAM Agent" cssClass="fa fa-list-ol fa-fw">
            <Settings url="/ui/phpipamagent" />
        </ipamAgent>
    </Services>
</menu>


Thanks!
Title: Re: Plugin Development Questions & Some Bugs?
Post by: TotalGriffLock on August 14, 2024, 11:37:42 PM
Ah, I am an idiot. The answer to question 1 is obvious - put it in /usr/local/opnsense/scripts