WireGuard / wireguard-vyatta-ubnt

WireGuard for Ubiquiti Devices
https://www.wireguard.com/
GNU General Public License v3.0
1.46k stars 69 forks source link

Rewrite of template logic #20

Closed Lochnair closed 3 years ago

Lochnair commented 4 years ago

Copying this from the old issue.

IMO it's about time for a rewrite of all the logic in the templates. Or rather ripping all the logic out of the templates (except syntax validation etc.).

As things currently stand the templates are becoming harder and harder to maintain every time we try to add features or fix bugs, because more logic are added to an already convoluted template system.

Personally I'd like to see everything moved out to an external script in much the same way the VyOS guys have done, avoiding a mess in the templates.

VyOS' Python wrapper for cli-shell-api partly works on EdgeOS, because the cli_shell_api version on EdgeOS doesn't include isMulti, isTag and the likes.

I have managed to get it completely working by building a patched cli_shell_api binary that includes them. I guess we could ship that, and let it live side-by-side with the stock one.

This would also be a good opportunity to do breaking changes such as #92.

I'd love to hear what people think about this and any suggestions you might have.

FossoresLP commented 4 years ago

I think this is a good idea but I do not have enough experience with Vyatta so it would be great if someone could create a PR. @jollyjinx If you get started on this (as you mentioned in #14) please let us know here. Anyone else is also welcome to help out so marking this help-wanted.

acejacek commented 4 years ago

I know very little about this, but having extra free time due to current circumstances, I'd love to learn new stuff. Just help me to kick start.

jollyjinx commented 4 years ago

I haven't started yet as I wanted to understand the template system a bit more. What helped me was to add print statements to the node.def files so I could see what is happening when. As I don't know how to get the template system into debug mode. I've created a branch for just switching over to get debug messages. I then have a crude command line that does install the current local version to the router: scp -r wireguard router:/tmp/wireguard; ssh router 'cd /opt/vyatta/share/vyatta-cfg/templates/interfaces;sudo mv -f wireguard /tmp/wg.old.$(date +'%H%M%S') ; sudo mv /tmp/wireguard /opt/vyatta/share/vyatta-cfg/templates/interfaces/wireguard and do my commands on the router console then while looking at the output of /tmp/wg.log

If someone knows a way to get the whole template system into debug mode - that would help a lot.

whiskerz007 commented 3 years ago

I just submitted a pull request to address this concern.

FossoresLP commented 3 years ago

Fixed by #55