#!/usr/bin/perl

use Net::OpenVPN::Manager;
use AnyEvent; # AnyEvent import to be sure plackup launch a twiggy server

my $m = Net::OpenVPN::Manager->new_with_config(configfile => '/etc/openvpn-manager.conf');
$m->start();

$m->run_if_script;

__END__

=head1 NAME

openvpn-manager - Start OpenVPN Manager and return PSGI handler

=head1 SYNOPSIS

  plackup --host 127.0.0.1 --port 5000 /usr/bin/openvpn-manager

Configuration has to be defined int /etc/openvpn-manager.conf file. This file
is in YAML format. It looks like :

  address: 127.0.0.1
  port: 8000
  dbconnect: DBI:MariaDB:database=vpn;host=db.my.domain
  apikeys:
    - abcdefgh0123456789
  plugins_config:
    TOTP:
      trust_delay: 86400
      sliding_window: 1
    LDAP:
      servers:
        - address: ldap.my.domain
          port: 389
      binddn: cn=admin,dc=my,dc=domain
      bindpw: adminpass
      basedn: ou=people,dc=my,dc=domain
      filter: (&(objectClass=inetOrgPerson)(uid=%USERNAME%))

OpenVPN server must be configure to use his management interface, for example :

  management 127.0.0.1 8000

=head1 Plugins

=over

=item *

L<Net::OpenVPN::Manager::Plugin::ClientProfile>

=item *

L<Net::OpenVPN::Manager::Plugin::FixMSS>

=item *

L<Net::OpenVPN::Manager::Plugin::InternalToken>

=item *

L<Net::OpenVPN::Manager::Plugin::Iptables>

=item *

L<Net::OpenVPN::Manager::Plugin::LDAP>

=item *

L<Net::OpenVPN::Manager::Plugin::Prometheus>

=item *

L<Net::OpenVPN::Manager::Plugin::TOTP>

=back

=head1 SEE ALSO

L<Net::OpenVPN::Manager>, L<Net::OpenVPN::Manager::Plugin>

=cut
