perara / wg-manager

A easy to use WireGuard dashboard and management tool
MIT License
599 stars 72 forks source link

Hotfix for being unable to disable IPv6 support #131

Closed Shigbeard closed 2 years ago

Shigbeard commented 2 years ago

IPv6 Support is an optional feature, in that when you create an interface, you can disable IPv6 support with a checkbox. This greys out the ipv6 options, which means when the form is submitted on the front-end, it only hands IPv4 information to the back-end. This is a problem, as the database was created with the v6_subnet column set to NOT NULL

A more elegant fix would be to have the front-end submit dummy data for the IPv6 subnet, this way existing users would not be required to manually modify their database (as SQLite does not support altering tables to remove the NOT NULL property) to either recreate the table and all of its triggers/keys, or (and this is more reasonable) have the backend make a new database and then have the existing user manually import data from their old database.

(EDIT: Should note, however, that I've tested this fix and have found no issues with EDITING an existing configuration using this change. I've not tested if you can CREATE a new configuration with the change, however I believe it wouldn't make a difference.)

Unfortunately, I'm unfamiliar with Angular, however if I were a betting man I'd say you could probably insert something into the following spot to override the value submitted despite the field being disabled.

https://github.com/perara/wg-manager/blob/e70ba4bdc288318bc164fe696750a0c40ed1fac6/wg-manager-frontend/src/app/page/dashboard/add-server/add-server.component.ts#L84-L94

Shigbeard commented 2 years ago

Whoops, forgot to select dev branch, my B.

perara commented 2 years ago

Looks good! Perhaps the dummy data could be inserted at the backend side as well (is frontend does not submit and v6 info)

Thanks for your work!