return $rc;
}
+sub read_pids($) {
+ my $pidfile = shift;
+
+ # Open the PID file
+ open(PIDFILE, "<${pidfile}");
+
+ # Store all PIDs here
+ my @pids = ();
+
+ # Read all PIDs
+ while (<PIDFILE>) {
+ chomp $_;
+
+ if (-d "/proc/$_") {
+ push(@pids, $_);
+ }
+ }
+
+ # Close the PID file
+ close(PIDFILE);
+
+ return @pids;
+}
+
+sub find_pids($) {
+ my $process = shift;
+
+ # Store all PIDs here
+ my @pids = ();
+
+ foreach my $status (</proc/*/status>) {
+ # Open the status file
+ open(STATUS, "<${status}");
+
+ # Read the status file
+ while (<STATUS>) {
+ # If the name does not match, we break the loop immediately
+ if ($_ =~ m/^Name:\s+(.*)$/) {
+ last if ($process ne $1);
+
+ # Push the PID onto the list
+ } elsif ($_ =~ m/^Pid:\s+(\d+)$/) {
+ push(@pids, $1);
+
+ # Once we got here, we are done
+ last;
+ }
+ }
+
+ # Close the status file
+ close(STATUS);
+ }
+
+ return @pids;
+}
+
+sub get_memory_consumption() {
+ my $memory = 0;
+
+ foreach my $pid (@_) {
+ # Open the status file or skip on error
+ open(STATUS, "/proc/${pid}/status") or next;
+
+ while (<STATUS>) {
+ if ($_ =~ m/^VmRSS:\s+(\d+) kB/) {
+ $memory += $1 * 1024;
+ last;
+ }
+ }
+
+ close(STATUS);
+ }
+
+ return $memory;
+}
+
# Function to remove duplicates from an array
sub uniq { my %seen; grep !$seen{$_}++, @_ }
close($file);
}
+sub ServiceStatus() {
+ my $services = shift;
+ my %services = %{ $services };
+
+ # Write the table header
+ print <<EOF;
+ <table class="tbl">
+ <!-- <thead>
+ <tr>
+ <th>
+ $Lang::tr{'service'}
+ </th>
+
+ <th>
+ $Lang::tr{'status'}
+ </th>
+
+ <th>
+ $Lang::tr{'memory'}
+ </th>
+ </tr>
+ </thead> -->
+
+ <tbody>
+EOF
+
+ foreach my $service (sort keys %services) {
+ my %config = %{ $services{$service} };
+
+ my $pidfile = $config{"pidfile"};
+ my $process = $config{"process"};
+
+ # Collect all pids
+ my @pids = ();
+
+ # Read the PID file or go search...
+ if (defined $pidfile) {
+ @pids = &General::read_pids("${pidfile}");
+ } else {
+ @pids = &General::find_pids("${process}");
+ }
+
+ # Get memory consumption
+ my $mem = &General::get_memory_consumption(@pids);
+
+ print <<EOF;
+ <tr>
+ <th scope="row">
+ $service
+ </th>
+EOF
+
+ # Running?
+ if (scalar @pids) {
+ # Format memory
+ $mem = &General::formatBytes($mem);
+
+ print <<EOF;
+ <td class="status is-running">
+ $Lang::tr{'running'}
+ </td>
+
+ <td class="text-right">
+ ${mem}
+ </td>
+EOF
+
+ # Not Running
+ } else {
+ print <<EOF;
+ <td class="status is-stopped" colspan="2">
+ $Lang::tr{'stopped'}
+ </td>
+EOF
+ }
+
+ print <<EOF;
+ </tr>
+EOF
+
+ }
+
+ print <<EOF;
+ </tbody>
+ </table>
+EOF
+}
+
1; # End of package "Header"
WARNING: untranslated string: ovpn fallback cipher = Fallback Cipher
WARNING: untranslated string: ovpn fallback cipher help = This cipher is being used by clients that do not support cipher negotiation.
WARNING: untranslated string: ovpn no cipher selected = No cipher selected
+WARNING: untranslated string: ovpn roadwarrior server = OpenVPN Roadwarrior Server
WARNING: untranslated string: ovpn roadwarrior settings = Roadwarrior Settings
WARNING: untranslated string: ovpn unsupported cipher selected = Unknown cipher selected
WARNING: untranslated string: pakfire invalid tree = Invalid repository selected
WARNING: untranslated string: ovpn no cipher selected = No cipher selected
WARNING: untranslated string: ovpn no connections = No active OpenVPN connections
WARNING: untranslated string: ovpn port in root range = A port number of 1024 or higher is required.
+WARNING: untranslated string: ovpn roadwarrior server = OpenVPN Roadwarrior Server
WARNING: untranslated string: ovpn roadwarrior settings = Roadwarrior Settings
WARNING: untranslated string: ovpn routes push = Routes (one per line) e.g. 192.168.10.0/255.255.255.0 192.168.20.0/24
WARNING: untranslated string: ovpn routes push options = Route push options
WARNING: untranslated string: ovpn fallback cipher = Fallback Cipher
WARNING: untranslated string: ovpn fallback cipher help = This cipher is being used by clients that do not support cipher negotiation.
WARNING: untranslated string: ovpn no cipher selected = No cipher selected
+WARNING: untranslated string: ovpn roadwarrior server = OpenVPN Roadwarrior Server
WARNING: untranslated string: ovpn roadwarrior settings = Roadwarrior Settings
WARNING: untranslated string: ovpn unsupported cipher selected = Unknown cipher selected
WARNING: untranslated string: pakfire ago = ago.
WARNING: untranslated string: ovpn fallback cipher = Fallback Cipher
WARNING: untranslated string: ovpn fallback cipher help = This cipher is being used by clients that do not support cipher negotiation.
WARNING: untranslated string: ovpn no cipher selected = No cipher selected
+WARNING: untranslated string: ovpn roadwarrior server = OpenVPN Roadwarrior Server
WARNING: untranslated string: ovpn roadwarrior settings = Roadwarrior Settings
WARNING: untranslated string: ovpn unsupported cipher selected = Unknown cipher selected
WARNING: untranslated string: pakfire ago = ago.
WARNING: untranslated string: ovpn fallback cipher = Fallback Cipher
WARNING: untranslated string: ovpn fallback cipher help = This cipher is being used by clients that do not support cipher negotiation.
WARNING: untranslated string: ovpn no cipher selected = No cipher selected
+WARNING: untranslated string: ovpn roadwarrior server = OpenVPN Roadwarrior Server
WARNING: untranslated string: ovpn roadwarrior settings = Roadwarrior Settings
WARNING: untranslated string: ovpn rw connection log = OpenVPN Roadwarrior Connections Log
WARNING: untranslated string: ovpn tls auth = TLS Channel Protection:
WARNING: untranslated string: ovpn fallback cipher help = This cipher is being used by clients that do not support cipher negotiation.
WARNING: untranslated string: ovpn ha = Hash algorithm
WARNING: untranslated string: ovpn no cipher selected = No cipher selected
+WARNING: untranslated string: ovpn roadwarrior server = OpenVPN Roadwarrior Server
WARNING: untranslated string: ovpn roadwarrior settings = Roadwarrior Settings
WARNING: untranslated string: ovpn rw connection log = OpenVPN Roadwarrior Connections Log
WARNING: untranslated string: ovpn tls auth = TLS Channel Protection:
WARNING: untranslated string: ovpn no cipher selected = No cipher selected
WARNING: untranslated string: ovpn no connections = No active OpenVPN connections
WARNING: untranslated string: ovpn port in root range = A port number of 1024 or higher is required.
+WARNING: untranslated string: ovpn roadwarrior server = OpenVPN Roadwarrior Server
WARNING: untranslated string: ovpn roadwarrior settings = Roadwarrior Settings
WARNING: untranslated string: ovpn routes push = Routes (one per line) e.g. 192.168.10.0/255.255.255.0 192.168.20.0/24
WARNING: untranslated string: ovpn routes push options = Route push options
WARNING: untranslated string: ovpn no cipher selected = No cipher selected
WARNING: untranslated string: ovpn no connections = No active OpenVPN connections
WARNING: untranslated string: ovpn port in root range = A port number of 1024 or higher is required.
+WARNING: untranslated string: ovpn roadwarrior server = OpenVPN Roadwarrior Server
WARNING: untranslated string: ovpn roadwarrior settings = Roadwarrior Settings
WARNING: untranslated string: ovpn rw connection log = OpenVPN Roadwarrior Connections Log
WARNING: untranslated string: ovpn tls auth = TLS Channel Protection:
WARNING: untranslated string: ovpn fallback cipher = Fallback Cipher
WARNING: untranslated string: ovpn fallback cipher help = This cipher is being used by clients that do not support cipher negotiation.
WARNING: untranslated string: ovpn no cipher selected = No cipher selected
+WARNING: untranslated string: ovpn roadwarrior server = OpenVPN Roadwarrior Server
WARNING: untranslated string: ovpn roadwarrior settings = Roadwarrior Settings
WARNING: untranslated string: ovpn rw connection log = OpenVPN Roadwarrior Connections Log
WARNING: untranslated string: ovpn tls auth = TLS Channel Protection:
< ovpn fallback cipher
< ovpn fallback cipher help
< ovpn no cipher selected
+< ovpn roadwarrior server
< ovpn roadwarrior settings
< ovpn unsupported cipher selected
< quick control
< ovpn fallback cipher
< ovpn fallback cipher help
< ovpn no cipher selected
+< ovpn roadwarrior server
< ovpn roadwarrior settings
< ovpn unsupported cipher selected
< regenerate host certificate
< ovpn fallback cipher
< ovpn fallback cipher help
< ovpn no cipher selected
+< ovpn roadwarrior server
< ovpn roadwarrior settings
< ovpn unsupported cipher selected
< system time
< ovpn fallback cipher
< ovpn fallback cipher help
< ovpn no cipher selected
+< ovpn roadwarrior server
< ovpn roadwarrior settings
< ovpn rw connection log
< ovpn tls auth
< ovpn ha
< ovpn no cipher selected
< ovpn reneg sec
+< ovpn roadwarrior server
< ovpn roadwarrior settings
< ovpn rw connection log
< ovpn tls auth
< ovpn no connections
< ovpn port in root range
< ovpn reneg sec
+< ovpn roadwarrior server
< ovpn roadwarrior settings
< ovpn routes push
< ovpn routes push options
< ovpn no connections
< ovpn port in root range
< ovpn reneg sec
+< ovpn roadwarrior server
< ovpn roadwarrior settings
< ovpn rw connection log
< ovpn tls auth
< ovpn fallback cipher
< ovpn fallback cipher help
< ovpn no cipher selected
+< ovpn roadwarrior server
< ovpn roadwarrior settings
< ovpn rw connection log
< ovpn tls auth
$activeonrun = "disabled='disabled'";
}
&Header::openbox('100%', 'LEFT', $Lang::tr{'ovpn roadwarrior settings'});
+
+ # Show the service status
+ &Header::ServiceStatus({
+ $Lang::tr{'ovpn roadwarrior server'} => {
+ "process" => "openvpn",
+ "pidfile" => "/var/run/openvpn.pid",
+ }
+ });
+
print <<END;
<table width='100%' border='0'>
<form method='post'>
+:root {
+ --color-green : #339933;
+ --color-green-invert : #ffffff;
+ --color-red : #993333;
+ --color-red-invert : #ffffff;
+}
/* This controls the width of the fixed width layouts */
float: right !important;
}
+/*
+ Text Alignment
+*/
+
+.text-left {
+ text-align: left;
+}
+
+.text-center {
+ text-align: center;
+}
+
+.text-right {
+ text-align: right;
+}
+
/* Header */
#header {
border-spacing: 0;
}
+.tbl {
+ width: 100%;
+}
+
.tbl th {
color: #ffffff;
border-top: 1px solid #363636;
padding-right: 0.5em;
}
+.tbl th[scope=row] {
+ text-align: left;
+}
+
.tbl th:first-child {
border-left: 1px solid #363636;
border-top: 1px solid #363636;
border-bottom: 1px solid #363636;
}
+.tbl .status {
+ text-align: center;
+ font-weight: bold;
+}
+
+.tbl .status.is-running {
+ background-color: var(--color-green);
+ color: var(--color-green-invert);
+}
+
+.tbl .status.is-stopped {
+ background-color: var(--color-red);
+ color: var(--color-red-invert);
+
+ width: 33%;
+}
+
table.fw-nat tbody tr td {
height: 2.25em;
}
'ovpn on red' => 'OpenVPN on RED:',
'ovpn port in root range' => 'A port number of 1024 or higher is required.',
'ovpn reneg sec' => 'Session key lifetime:',
+'ovpn roadwarrior server' => 'OpenVPN Roadwarrior Server',
'ovpn roadwarrior settings' => 'Roadwarrior Settings',
'ovpn routes push' => 'Routes (one per line) e.g. 192.168.10.0/255.255.255.0 192.168.20.0/24',
'ovpn routes push options' => 'Route push options',