settings.html.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <!--
  2. VPN Client app for YunoHost
  3. Copyright (C) 2015 Julien Vaubourg <julien@vaubourg.com>
  4. Contribute at https://github.com/labriqueinternet/vpnclient_ynh
  5. This program is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU Affero General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU Affero General Public License for more details.
  13. You should have received a copy of the GNU Affero General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. -->
  16. <h2><?= _("VPN Client Configuration") ?></h2>
  17. <?php if($faststatus): ?>
  18. <span class="label label-success" data-toggle="tooltip" data-title="<?= _('This is a fast status. Click on More details to show the complete status.') ?>"><?= _('Running') ?></span>
  19. <?php else: ?>
  20. <span class="label label-danger" data-toggle="tooltip" data-title="<?= _('This is a fast status. Click on More details to show the complete status.') ?>"><?= _('Not Running') ?></span>
  21. <?php endif; ?>
  22. &nbsp; <img src="public/img/loading.gif" id="status-loading" alt="Loading..." /><a href="#" id="statusbtn" data-toggle="tooltip" data-title="<?= _('Loading complete status may take a few minutes. Be patient.') ?>"><?= _('More details') ?></a>
  23. <div id="status" class="alert alert-dismissible alert-info fade in" style="margin-top: 10px" role="alert">
  24. <button type="button" class="close"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
  25. <div id="status-text"></div>
  26. </div>
  27. <hr />
  28. <div class="row">
  29. <div class="col-sm-offset-2 col-sm-8">
  30. <form method="post" enctype="multipart/form-data" action="?/settings" class="form-horizontal" role="form" id="form">
  31. <input type="hidden" name="_method" value="put" />
  32. <div class="panel panel-default">
  33. <div class="panel-heading">
  34. <h3 class="panel-title"><?= _("Service") ?></h3>
  35. </div>
  36. <div style="padding: 14px 14px 0 10px">
  37. <div class="form-group">
  38. <label for="service_enabled" class="col-sm-3 control-label"><?= _('VPN Enabled') ?></label>
  39. <div class="col-sm-9 input-group-btn">
  40. <div class="input-group">
  41. <input type="checkbox" class="form-control switch" name="service_enabled" id="service_enabled" value="1" <?= $service_enabled == 1 ? 'checked="checked"' : '' ?> />
  42. </div>
  43. </div>
  44. </div>
  45. </div>
  46. </div>
  47. <div class="panel panel-default enabled" <?= $service_enabled == 0 ? 'style="display: none"' : '' ?>>
  48. <div class="panel-heading">
  49. <h3 class="panel-title"><?= _("VPN") ?></h3>
  50. </div>
  51. <div style="padding: 14px 14px 0 10px">
  52. <div class="form-group">
  53. <label for="server_name" class="col-sm-3 control-label"><?= _('Server Address') ?></label>
  54. <div class="col-sm-9">
  55. <input type="text" class="form-control" name="server_name" id="server_name" placeholder="access.ldn-fai.net" value="<?= $server_name ?>" />
  56. </div>
  57. </div>
  58. <div class="form-group">
  59. <label for="server_port" class="col-sm-3 control-label"><?= _('Server Port') ?></label>
  60. <div class="col-sm-9">
  61. <input type="text" data-toggle="tooltip" data-title="<?= _('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 ?>" />
  62. </div>
  63. </div>
  64. <div class="form-group">
  65. <label for="server_proto" class="col-sm-3 control-label"><?= _('Protocol') ?></label>
  66. <div class="btn-group col-sm-9" data-toggle="buttons">
  67. <label class="btn btn-default <?= $server_proto == 'udp' ? 'active' : '' ?>">
  68. <input type="radio" name="server_proto" value="udp" <?= $server_proto == 'udp' ? 'checked="cheked"' : '' ?> /> <?= _('UDP') ?>
  69. </label>
  70. <label class="btn btn-default <?= $server_proto == 'tcp' ? 'active' : '' ?>" data-toggle="tooltip" data-title="<?= _('UDP is more efficient than TCP (but more filtered in case of restrictive access)') ?>">
  71. <input type="radio" name="server_proto" value="tcp" <?= $server_proto == 'tcp' ? 'checked="cheked"' : '' ?> /> <?= _('TCP') ?>
  72. </label>
  73. </div>
  74. </div>
  75. <div class="form-group" id="raw_openvpn_btnpanel">
  76. <label class="col-sm-3 control-label"></label>
  77. <div class="col-sm-9">
  78. <span class="glyphicon glyphicon-cog"></span> <a href="#" id="raw_openvpn_btn" data-toggle="tooltip" data-title="<?= _('Edit the raw configuration only if you know what you do!') ?>"><?= _('Advanced') ?></a>
  79. </div>
  80. </div>
  81. <div class="form-group" id="raw_openvpn_panel">
  82. <label for="raw_openvpn" class="col-sm-3 control-label"><?= _('Advanced') ?></label>
  83. <div class="col-sm-9">
  84. <pre><textarea class="form-control" name="raw_openvpn" id="raw_openvpn"><?= $raw_openvpn ?></textarea></pre>
  85. </div>
  86. </div>
  87. </div>
  88. </div>
  89. <div class="panel panel-default enabled" <?= $service_enabled == 0 ? 'style="display: none"' : '' ?>>
  90. <div class="panel-heading">
  91. <h3 class="panel-title"><?= _("IPv6") ?></h3>
  92. </div>
  93. <div style="padding: 14px 14px 0 10px">
  94. <div class="form-group">
  95. <label for="ip6_net" class="col-sm-3 control-label"><?= _('Delegated prefix') ?></label>
  96. <div class="col-sm-9">
  97. <input type="text" data-toggle="tooltip" data-title="<?= _('Leave empty if your Internet Service Provider does not give you a delegated prefix') ?>" class="form-control" name="ip6_net" id="ip6_net" placeholder="2001:db8:42::" value="<?= $ip6_net ?>" />
  98. </div>
  99. </div>
  100. </div>
  101. </div>
  102. <?php if(!$crt_client_key_exists && empty($login_user)): ?>
  103. <div class="alert alert-dismissible alert-warning fade in enabled" <?= $service_enabled == 0 ? 'style="display: none"' : '' ?> style="margin: 2px 0px 17px" role="alert">
  104. <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
  105. <strong><?= _('Notice') ?>:</strong> <?= _("You need to upload a Client Certificate, or define a Username (or both) for starting your VPN Client.") ?>
  106. </div>
  107. <?php endif; ?>
  108. <div class="panel panel-default enabled" <?= $service_enabled == 0 ? 'style="display: none"' : '' ?>>
  109. <div class="panel-heading">
  110. <h3 class="panel-title"><?= _("Certificates") ?></h3>
  111. </div>
  112. <div style="padding: 14px 14px 0 10px">
  113. <div class="form-group">
  114. <label for="crt_client" class="col-sm-3 control-label"><?= $crt_client_exists ? _('Update Client Cert.') : _('Upload Client Cert.') ?></label>
  115. <div class="input-group col-sm-9" style="padding: 0 15px">
  116. <?php if($crt_client_exists): ?>
  117. <a class="btn btn-danger input-group-addon deletefile" id="crt_client_deletebtn" data-toggle="tooltip" data-title="<?= _('Delete this certificate') ?>"><span class="glyphicon glyphicon-remove"></span></a>
  118. <input id="crt_client_delete" name="crt_client_delete" type="checkbox" value="1" style="display: none" />
  119. <?php endif; ?>
  120. <input type="text" class="form-control fileinput" id="crt_client_choosertxt" placeholder="-----BEGIN CERTIFICATE-----" readonly="readonly" />
  121. <input id="crt_client" name="crt_client" type="file" style="display: none" />
  122. <a class="btn input-group-addon fileinput" id="crt_client_chooserbtn" data-toggle="tooltip" data-title="<?= _('Browse') ?>"><span class="glyphicon glyphicon-search"></span></a>
  123. </div>
  124. </div>
  125. <div class="form-group">
  126. <label for="crt_client_key" class="col-sm-3 control-label"><?= $crt_client_key_exists ? _('Update Client Key') : _('Upload Client Key') ?></label>
  127. <div class="input-group col-sm-9" style="padding: 0 15px">
  128. <?php if($crt_client_key_exists): ?>
  129. <a class="btn btn-danger input-group-addon deletefile" id="crt_client_key_deletebtn" data-toggle="tooltip" data-title="<?= _('Delete this certificate') ?>"><span class="glyphicon glyphicon-remove"></span></a>
  130. <input id="crt_client_key_delete" name="crt_client_key_delete" type="checkbox" value="1" style="display: none" />
  131. <?php endif; ?>
  132. <input type="text" class="form-control fileinput" id="crt_client_key_choosertxt" data-toggle="tooltip" data-title="<?= _('Make sure your browser is able to read the key file before uploading') ?>" placeholder="-----BEGIN PRIVATE KEY-----" readonly="readonly" />
  133. <input id="crt_client_key" name="crt_client_key" type="file" style="display: none" />
  134. <a class="btn input-group-addon fileinput" id="crt_client_key_chooserbtn" data-toggle="tooltip" data-title="<?= _('Browse') ?> (<?= _('make sure your browser is able to read the key file before uploading') ?>)"><span class="glyphicon glyphicon-search"></span></a>
  135. </div>
  136. </div>
  137. <div class="form-group">
  138. <?php if(!$crt_server_ca_exists): ?>
  139. <div class="alert alert-dismissible alert-warning fade in" style="margin: 2px 16px 17px" role="alert">
  140. <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
  141. <strong><?= _('Notice') ?>:</strong> <?= _("You need to upload a Server CA for starting your VPN Client.") ?>
  142. </div>
  143. <?php endif; ?>
  144. <label for="crt_server_ca" class="col-sm-3 control-label"><?= $crt_server_ca_exists ? _('Update Server CA') : _('Upload Server CA') ?></label>
  145. <div class="input-group col-sm-9" style="padding: 0 15px">
  146. <?php if($crt_server_ca_exists): ?>
  147. <a class="btn btn-danger not-allowed btn-disabled input-group-addon" id="crt_server_ca_deletebtn" data-toggle="tooltip" data-title="<?= _('You cannot have no server CA') ?>"><span class="glyphicon glyphicon-remove"></span></a>
  148. <input id="crt_server_ca_delete" name="crt_server_ca_delete" type="checkbox" value="1" style="display: none" />
  149. <?php endif; ?>
  150. <input type="text" class="form-control fileinput" id="crt_server_ca_choosertxt" placeholder="-----BEGIN CERTIFICATE-----" readonly="readonly" />
  151. <input id="crt_server_ca" name="crt_server_ca" type="file" style="display: none" />
  152. <a class="btn input-group-addon fileinput" id="crt_server_ca_chooserbtn" data-toggle="tooltip" data-title="<?= _('Browse') ?>"><span class="glyphicon glyphicon-search"></span></a>
  153. </div>
  154. </div>
  155. </div>
  156. </div>
  157. <div class="panel panel-default enabled" <?= $service_enabled == 0 ? 'style="display: none"' : '' ?>>
  158. <div class="panel-heading">
  159. <h3 class="panel-title"><?= _("Login") ?></h3>
  160. </div>
  161. <div style="padding: 14px 14px 0 10px">
  162. <div class="form-group">
  163. <label for="login_user" class="col-sm-3 control-label"><?= _('Username') ?></label>
  164. <div class="col-sm-9">
  165. <input type="text" data-toggle="tooltip" data-title="<?= _('Leave empty if not necessary') ?>" class="form-control" name="login_user" id="login_user" placeholder="michu" value="<?= $login_user ?>" />
  166. </div>
  167. </div>
  168. <div class="form-group">
  169. <label for="login_passphrase" class="col-sm-3 control-label"><?= _('Password') ?></label>
  170. <div class="col-sm-9">
  171. <input type="text" data-toggle="tooltip" data-title="<?= _('Leave empty if not necessary') ?>" class="form-control" name="login_passphrase" id="login_passphrase" placeholder="XVCwSbDkxnqQ" value="<?= $login_passphrase ?>" />
  172. </div>
  173. </div>
  174. </div>
  175. </div>
  176. <div class="form-group">
  177. <div style="text-align: center">
  178. <button type="submit" class="btn btn-default" data-toggle="tooltip" id="save" data-title="<?= _('Reloading may take a few minutes. Be patient.') ?>"><?= _('Save and reload') ?></button> <img src="public/img/loading.gif" id="save-loading" alt="Loading..." />
  179. </div>
  180. </div>
  181. </form>
  182. </div>
  183. </div>