Skip to content

VPN: OpenVPN: Instances (MVC) - #6584

Merged
AdSchellevis merged 2 commits into
masterfrom
openvpn_mvc
May 31, 2023
Merged

VPN: OpenVPN: Instances (MVC)#6584
AdSchellevis merged 2 commits into
masterfrom
openvpn_mvc

Conversation

@AdSchellevis

Copy link
Copy Markdown
Member

VPN: OpenVPN: Instances - add new module using the same approach as introduced for IPsec in 23.1. Since we likely can't easily migrate the old cruft, we better focus on offering the correct options for openvpn following upstream documentation.

  • Implement a solution to keep vpnid's unique so device creation for legacy and mvc can function in similar ways. (OpenVPN->usedVPNIds())
  • Add some of the main "helper" options for clients and servers (getInstanceById, isEnabled)
  • Implement certificate logic, selecting a certificate also implies an authority (which we validate)
  • Hook CRL generation into the exising openvpn_refresh_crls() event
  • Attach already refactored authentication to new MVC as well, OpenVPN->getInstanceById() is responsible for feeding the data needed during authentication and overwrite generation.
  • When in client mode and in need for a username+password combination, flush these to file and link in "auth-user-pass"
  • Routes (remote) and push routes (local), combine IPv4 and IPv6 for ease of administration,
  • Keep alive [push] ping-[restart] defined as separate fields for validation
  • Add various "push" to client options in Miscellaneous section
  • Add "auth-gen-token" lifetime for OpenVPN auth-gen-token #6135
  • Allow selection of redirect-gateway type for OpenVPN IPv6 Redirect Gateway #6220
  • Move tls-auth/crypt into separate static keys objects (tab in instances page)
  • Hook existing events (ovpn_event.py) and make sure they locate the server using getServerById() when needed
  • Use getInstanceById in openvpn_prepare() to return both legacy as MVC device configuration
  • Add ovpn_service_control.php for service control [stop|start|restart|configure] and glue this in openvpn_services() via configd
  • Change openvpn_interfaces() to use isEnabled() method on the model to query if any (legacy/mvc) instances are enabled
  • Move openvpn_config() from openvpn.inc to widget and extend with MVC instances
  • Extend ovpn_status.py to parse "instance-" sockets as well, since the filename doesn't explain the role, we're using the status call to figure out the use. uuid's are keys in this case
  • server_id type to str in kill_session.py so we can match either legacy or mvc sockets
  • Hook ExportController to OpenVPN model using getInstanceById() to glue the Client Export utility to both components
  • Extend connection status with mvc sessions (descriptions)

Which should almost complete the new module, things still on the todo list:

  • handle CARP for client type instances (stop/start?)
  • testing
  • documentation

…ntroduced for IPsec in 23.1. Since we likely can't easily migrate the old cruft, we better focus on offering the correct options for openvpn following upstream documentation.

o add boilerplate
o implement a solution to keep vpnid's unique so device creation for legacy and mvc can function in similar ways.
o add some of the main "helper" options for clients and servers
o Implement certificate logic, selecting a certificate also implies an authority (which we validate)
o hook CRL generation into the exising openvpn_refresh_crls() event
o attach already refactored authentication to new MVC as well, OpenVPN->getInstanceById() is responsible for feeding the data needed during authentication and overwrite generation.
o when in client mode and in need for a username+password combination, flush these to file and link in "auth-user-pass"
o routes (remote) and push routes (local), combine IPv4 and IPv6 for ease of administration,
o keep alive [push] ping-[restart] defined as seperate fields for validation
o add various "push" to client options in Miscellaneous section
o add "auth-gen-token" lifetime for #6135
o allow selection of redirect-gateway type for #6220
o move tls-auth/crypt into separate static keys objects (tab in instances page)
o hook existing events (ovpn_event.py) and make sure they locate the server using getServerById() when needed
o use getInstanceById in openvpn_prepare() to return both legacy as MVC device configuration
o add ovpn_service_control.php for service control [stop|start|restart|configure] and glue this in openvpn_services() via configd
o change openvpn_interfaces() to use isEnabled() method on the model to query if any (legacy/mvc) instances are enabled
o move openvpn_config() from openvpn.inc to widget and extend with MVC instances
o extend ovpn_status.py to parse "instance-" sockets as well, since the filename doesn't explain the role, we're using the status call to figure out the use. uuid's are keys in this case
o server_id type to str in kill_session.py so we can match either legacy or mvc sockets
o hook ExportController to OpenVPN model using getInstanceById() to glue the Client Export utility to both components
o extend connection status with mvc sessions (descriptions)
@AdSchellevis AdSchellevis added the feature Adding new functionality label May 29, 2023
@AdSchellevis AdSchellevis self-assigned this May 29, 2023
Comment thread src/opnsense/mvc/app/models/OPNsense/Core/Menu/Menu.xml Outdated
<servers>
<server type="ArrayField">
<vpnid type="IntegerField">
<vpnid type="TextField">

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the idea here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mvc uses uuid's

</description>
</Instance>
</Instances>
<StaticKeys>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this feature might be removed from openvpn in the near future

Comment thread src/www/widgets/widgets/openvpn.widget.php
@@ -0,0 +1,183 @@
#!/usr/local/bin/php

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this script looks a bit convoluted (new/different start,stop,etc) but you probably meant to extract bootstrap/setup code from legacy side

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I don't want to mangle the existing hooks as this will likely lead to more noise and the "configure" action is required to cleanly apply pending changes (adding the start/[re]start doesn't increase the boilerplate)

Co-authored-by: Franco Fichtner <franco@opnsense.org>
@AdSchellevis
AdSchellevis merged commit e9edb11 into master May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Adding new functionality

Development

Successfully merging this pull request may close these issues.

2 participants