OPNsense Forum

English Forums => General Discussion => Topic started by: cyanmask on March 16, 2021, 09:26:15 am

Title: Modify config.xml at build time
Post by: cyanmask on March 16, 2021, 09:26:15 am
Hi,

I'd like to find a way to define a default wireguard's server tag to config.xml.
I've already read the Hello world module & plugin.
I think I need to edit the Server.php file, but I don't know how to do it.

Code: [Select]
<OPNsense>
    <wireguard>
      <general version="0.0.1">
        <enabled>0</enabled>
      </general>
      <client version="0.0.4">
        <clients/>
      </client>
      <server version="0.0.2">
        <servers>
          <server uuid="148cd40d-46d3-0000-1111-463edfe3641a">
            <enabled>1</enabled>
            <name>wgtest</name>
            <instance>0</instance>
            <pubkey>1111111111111111111111111111111111111111111=</pubkey>
            <privkey>2222222222222222222222222222222222222222222=</privkey>
            <port>51820</port>
            <mtu/>
            <dns/>
            <tunneladdress>10.10.0.1/24</tunneladdress>
            <disableroutes>0</disableroutes>
            <gateway/>
            <peers/>
          </server>
        </servers>
      </server>
    </wireguard>
</OPNsense>

I look forward to your response.
Title: Re: Modify config.xml at build time
Post by: mihak on March 19, 2021, 06:53:54 pm
You would like to write to config.xml from... Where? Are you building a new back-end logic (in usr/local/opnsense/scripts), or just changing the behavior of the front-end? Did you change the model in  mvc/app/models/OPNsense/Wireguard/Server.xml yet?


Tell us more so we can help you better... :-)