First beta, without arguments checking (install and web admin)
This commit is contained in:
Binary file not shown.
@@ -1,32 +1,71 @@
|
||||
<?php
|
||||
|
||||
function moulinette_get($var) {
|
||||
return htmlspecialchars(exec("sudo yunohost app setting vpnclient ".escapeshellarg($var)));
|
||||
}
|
||||
|
||||
function moulinette_set($var, $value) {
|
||||
return exec("sudo yunohost app setting vpnclient ".escapeshellarg($var)." -v ".escapeshellarg($value));
|
||||
}
|
||||
|
||||
function restart_service() {
|
||||
exec('sudo service ynh-vpnclient stop');
|
||||
exec('sudo service ynh-vpnclient start', $output, $retcode);
|
||||
|
||||
return $retcode;
|
||||
}
|
||||
|
||||
dispatch('/', function() {
|
||||
set('title', T_('Configure your VPN client'));
|
||||
return render('settings.html.php');
|
||||
set('title', T_('VPN client'));
|
||||
|
||||
set('server_name', moulinette_get('server_name'));
|
||||
set('server_port', moulinette_get('server_port'));
|
||||
set('server_proto', moulinette_get('server_proto'));
|
||||
|
||||
return render('settings.html.php');
|
||||
});
|
||||
|
||||
dispatch_put('/settings', function() {
|
||||
$success_message = "";
|
||||
foreach ($_POST as $key => $value) {
|
||||
$success_message = $success_message.T_("Parameter ").$key.": ".$value."<br>";
|
||||
}
|
||||
flash('success', $success_message);
|
||||
redirect_to('/');
|
||||
moulinette_set('server_name', $_POST['server_name']);
|
||||
moulinette_set('server_port', $_POST['server_port']);
|
||||
moulinette_set('server_proto', $_POST['server_proto']);
|
||||
|
||||
if($_FILES['crt_client']['error'] == UPLOAD_ERR_OK) {
|
||||
move_uploaded_file($_FILES['crt_client']['tmp_name'], '/etc/openvpn/keys/user.crt');
|
||||
}
|
||||
|
||||
if($_FILES['crt_client_key']['error'] == UPLOAD_ERR_OK) {
|
||||
move_uploaded_file($_FILES['crt_client_key']['tmp_name'], '/etc/openvpn/keys/user.key');
|
||||
}
|
||||
|
||||
if($_FILES['crt_server_ca']['error'] == UPLOAD_ERR_OK) {
|
||||
move_uploaded_file($_FILES['crt_server_ca']['tmp_name'], '/etc/openvpn/keys/ca-server.crt');
|
||||
}
|
||||
|
||||
$retcode = restart_service();
|
||||
|
||||
if($retcode == 0) {
|
||||
flash('success', T_('Configuration updated and service successfully reloaded'));
|
||||
} else {
|
||||
flash('error', T_('Configuration updated but service reload failed'));
|
||||
}
|
||||
|
||||
redirect_to('/');
|
||||
});
|
||||
|
||||
dispatch('/lang/:locale', function($locale = 'en') {
|
||||
switch ($locale) {
|
||||
case 'fr':
|
||||
$_SESSION['locale'] = 'fr';
|
||||
break;
|
||||
default:
|
||||
$_SESSION['locale'] = 'en';
|
||||
break;
|
||||
}
|
||||
if(!empty($_GET['redirect_to']))
|
||||
redirect_to($_GET['redirect_to']);
|
||||
else
|
||||
redirect_to('/');
|
||||
});
|
||||
switch ($locale) {
|
||||
case 'fr':
|
||||
$_SESSION['locale'] = 'fr';
|
||||
break;
|
||||
|
||||
default:
|
||||
$_SESSION['locale'] = 'en';
|
||||
}
|
||||
|
||||
if(!empty($_GET['redirect_to'])) {
|
||||
redirect_to($_GET['redirect_to']);
|
||||
} else {
|
||||
redirect_to('/');
|
||||
}
|
||||
});
|
||||
|
@@ -1,5 +1,14 @@
|
||||
$(document).ready(function() {
|
||||
$('.btn-group').button();
|
||||
$('[data-toggle="tooltip"]').tooltip();
|
||||
});
|
||||
|
||||
$('.fileinput').click(function() {
|
||||
var realinputid = '#' + $(this).attr('id').replace(/_chooser.*/, '');
|
||||
$(realinputid).click();
|
||||
});
|
||||
|
||||
$('input[type="file"]').change(function() {
|
||||
var choosertxtid = '#' + $(this).attr('id') + '_choosertxt';
|
||||
$(choosertxtid).val($(this).val());
|
||||
});
|
||||
});
|
||||
|
@@ -4,37 +4,36 @@
|
||||
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
|
||||
<!--[if gt IE 8]><!--> <html class="no-js" lang="<?= $locale ?>"> <!--<![endif]-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<title>VPN Client <? echo (isset($title)) ? "| ".$title : "" ?></title>
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<link media="all" type="text/css" href="<?= PUBLIC_DIR ?>/bootstrap/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link media="all" type="text/css" href="<?= PUBLIC_DIR ?>/bootstrap/css/bootstrap-theme.min.css" rel="stylesheet">
|
||||
<link media="all" type="text/css" href="<?= PUBLIC_DIR ?>/css/style.css" rel="stylesheet">
|
||||
<script src="<?= PUBLIC_DIR ?>/jquery/jquery-2.1.1.min.js"></script>
|
||||
<script src="<?= PUBLIC_DIR ?>/bootstrap/js/bootstrap.min.js"></script>
|
||||
<script src="<?= PUBLIC_DIR ?>/js/custom.js"></script>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<title>VPN Client <? echo (isset($title)) ? "| ".$title : "" ?></title>
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<link media="all" type="text/css" href="<?= PUBLIC_DIR ?>/bootstrap/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link media="all" type="text/css" href="<?= PUBLIC_DIR ?>/bootstrap/css/bootstrap-theme.min.css" rel="stylesheet">
|
||||
<link media="all" type="text/css" href="<?= PUBLIC_DIR ?>/css/style.css" rel="stylesheet">
|
||||
<script src="<?= PUBLIC_DIR ?>/jquery/jquery-2.1.1.min.js"></script>
|
||||
<script src="<?= PUBLIC_DIR ?>/bootstrap/js/bootstrap.min.js"></script>
|
||||
<script src="<?= PUBLIC_DIR ?>/js/custom.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<? if (isset($flash['error'])) { ?>
|
||||
<div class="alert alert-dismissible alert-error fade in" role="alert">
|
||||
<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
|
||||
<strong><?= T_('Error') ?>:</strong> <?= $flash['error'] ?>
|
||||
</div>
|
||||
<? } elseif (isset($flash['notice'])) { ?>
|
||||
<div class="alert alert-dismissible alert-info fade in" role="alert">
|
||||
<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
|
||||
<strong><?= T_('Notice') ?>:</strong> <?= $flash['notice'] ?>
|
||||
</div>
|
||||
<? } elseif (isset($flash['success'])) { ?>
|
||||
<div class="alert alert-dismissible alert-success fade in" role="alert">
|
||||
<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
|
||||
<?= $flash['success'] ?>
|
||||
</div>
|
||||
<? } ?>
|
||||
|
||||
<?= $content?>
|
||||
<div class="container">
|
||||
<? if (isset($flash['error'])) { ?>
|
||||
<div class="alert alert-dismissible alert-danger fade in" style="margin-top: 20px" role="alert">
|
||||
<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
|
||||
<strong><?= T_('Error') ?>:</strong> <?= $flash['error'] ?>
|
||||
</div>
|
||||
<? } elseif (isset($flash['notice'])) { ?>
|
||||
<div class="alert alert-dismissible alert-info fade in" style="margin-top: 20px" role="alert">
|
||||
<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
|
||||
<strong><?= T_('Notice') ?>:</strong> <?= $flash['notice'] ?>
|
||||
</div>
|
||||
<? } elseif (isset($flash['success'])) { ?>
|
||||
<div class="alert alert-dismissible alert-success fade in" style="margin-top: 20px" role="alert">
|
||||
<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
|
||||
<?= $flash['success'] ?>
|
||||
</div>
|
||||
<? } ?>
|
||||
|
||||
<?= $content?>
|
||||
</body>
|
||||
</html>
|
||||
|
@@ -1,57 +1,71 @@
|
||||
<h2><?= T_("VPN Client Configuration") ?></h2>
|
||||
<hr>
|
||||
|
||||
<hr />
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-offset-2 col-sm-8">
|
||||
<form method="post" action="settings" class="form-horizontal" role="form">
|
||||
<input type="hidden" name="_method" value="put" />
|
||||
<div class="form-group">
|
||||
<label for="server_name" class="col-sm-3 control-label"><?= T_('Server Address') ?></label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" class="form-control" name="server_name" id="server_name" placeholder="access.ldn-fai.net">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="server_port" class="col-sm-3 control-label"><?= T_('Server Port') ?></label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" data-toggle="tooltip" data-title="<?= T_('With restricted access, you should use 443 (TCP) or 53 (UDP)') ?>" class="form-control" name="server_port" id="server_port" placeholder="1194">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="server_port" class="col-sm-3 control-label"><?= T_('Protocol') ?></label>
|
||||
<div class="btn-group col-sm-9" data-toggle="buttons">
|
||||
<label class="btn btn-default active">
|
||||
<input type="radio" name="server_proto" value="udp"> <?= T_('UDP') ?>
|
||||
</label>
|
||||
<div class="col-sm-offset-2 col-sm-8">
|
||||
<form method="post" enctype="multipart/form-data" action="?/settings" class="form-horizontal" role="form">
|
||||
<input type="hidden" name="_method" value="put" />
|
||||
|
||||
<label class="btn btn-default" data-toggle="tooltip" data-title="<?= T_('UDP is more efficient than TCP (but more filtered in case of restrictive access)') ?>">
|
||||
<input type="radio" name="server_proto" value="tcp"> <?= T_('TCP') ?>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="crt_client" class="col-sm-3 control-label"><?= T_('Client Certificate') ?></label>
|
||||
<div class="btn-group col-sm-9">
|
||||
<textarea class="form-control" name="crt_client" id="crt_client" placeholder="-----BEGIN CERTIFICATE-----"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="crt_client_key" class="col-sm-3 control-label"><?= T_('Client Certificate Key') ?></label>
|
||||
<div class="btn-group col-sm-9">
|
||||
<textarea class="form-control" name="crt_client_key" id="crt_client_key" placeholder="-----BEGIN PRIVATE KEY-----"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="crt_server_ca" class="col-sm-3 control-label"><?= T_('Server Certificate Authority') ?></label>
|
||||
<div class="btn-group col-sm-9">
|
||||
<textarea class="form-control" name="crt_server_ca" id="crt_server_ca" placeholder="-----BEGIN CERTIFICATE-----"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="server_name" class="col-sm-3 control-label"><?= T_('Server Address') ?></label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" class="form-control" name="server_name" id="server_name" placeholder="access.ldn-fai.net" value="<?= $server_name ?>" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-xs-offset-3 col-sm-9">
|
||||
<button type="submit" class="btn btn-default"><?= T_('Save and reload') ?></button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="server_port" class="col-sm-3 control-label"><?= T_('Server Port') ?></label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" data-toggle="tooltip" data-title="<?= T_('With restricted access, you should use 443 (TCP) or 53 (UDP)') ?>" class="form-control" name="server_port" id="server_port" placeholder="1194" value="<?= $server_port ?>" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="server_port" class="col-sm-3 control-label"><?= T_('Protocol') ?></label>
|
||||
<div class="btn-group col-sm-9" data-toggle="buttons">
|
||||
<label class="btn btn-default <?= $server_proto == 'udp' ? 'active' : '' ?>">
|
||||
<input type="radio" name="server_proto" value="udp" <?= $server_proto == 'udp' ? 'checked="cheked"' : '' ?> /> <?= T_('UDP') ?>
|
||||
</label>
|
||||
|
||||
<label class="btn btn-default <?= $server_proto == 'tcp' ? 'active' : '' ?>" data-toggle="tooltip" data-title="<?= T_('UDP is more efficient than TCP (but more filtered in case of restrictive access)') ?>">
|
||||
<input type="radio" name="server_proto" value="tcp" <?= $server_proto == 'tcp' ? 'checked="cheked"' : '' ?> /> <?= T_('TCP') ?>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="crt_client" class="col-sm-3 control-label"><?= T_('Update Client Cert.') ?></label>
|
||||
<div class="input-group col-sm-9" style="padding: 0 15px">
|
||||
<input id="crt_client" name="crt_client" type="file" style="display: none" />
|
||||
<input type="text" class="form-control fileinput" id="crt_client_choosertxt" placeholder="-----BEGIN CERTIFICATE-----" readonly="readonly" />
|
||||
<a class="btn input-group-addon fileinput" id="crt_client_chooserbtn"><?= T_('Browse') ?></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="crt_client_key" class="col-sm-3 control-label"><?= T_('Update Client Cert. Key') ?></label>
|
||||
<div class="input-group col-sm-9" style="padding: 0 15px">
|
||||
<input id="crt_client_key" name="crt_client_key" type="file" style="display: none" />
|
||||
<input type="text" class="form-control fileinput" id="crt_client_key_choosertxt" placeholder="-----BEGIN PRIVATE KEY-----" readonly="readonly" />
|
||||
<a class="btn input-group-addon fileinput" id="crt_client_key_chooserbtn"><?= T_('Browse') ?></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="crt_server_ca" class="col-sm-3 control-label"><?= T_('Update Server CA') ?></label>
|
||||
<div class="input-group col-sm-9" style="padding: 0 15px">
|
||||
<input id="crt_server_ca" name="crt_server_ca" type="file" style="display: none" />
|
||||
<input type="text" class="form-control fileinput" id="crt_server_ca_choosertxt" placeholder="-----BEGIN CERTIFICATE-----" readonly="readonly" />
|
||||
<a class="btn input-group-addon fileinput" id="crt_server_ca_chooserbtn"><?= T_('Browse') ?></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-xs-offset-3 col-sm-9">
|
||||
<button type="submit" class="btn btn-default" data-toggle="tooltip" data-title="<?= T_('Reloading may take a few minutes. Be patient.') ?>"><?= T_('Save and reload') ?></button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user