auth.blade.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. @extends('admin.layouts')
  2. @section('css')
  3. <link href="/assets/global/vendor/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
  4. @endsection
  5. @section('content')
  6. <div class="page-content container-fluid">
  7. <div class="panel">
  8. <div class="panel-heading">
  9. <h2 class="panel-title">{!! trans('admin.node.auth.title') !!}</h2>
  10. @can('admin.node.auth.store')
  11. <div class="panel-actions">
  12. <button class="btn btn-primary" onclick="addAuth()">
  13. <i class="icon wb-plus" aria-hidden="true"></i> {{ trans('common.add') }}
  14. </button>
  15. </div>
  16. @endcan
  17. </div>
  18. <div class="panel-body">
  19. <table class="text-md-center" data-toggle="table" data-mobile-responsive="true">
  20. <thead class="thead-default">
  21. <tr>
  22. <th> {{ trans('model.node.id') }}</th>
  23. <th> {{ trans('model.common.type') }}</th>
  24. <th> {{ trans('model.node.name') }}</th>
  25. <th> {{ trans('model.node.domain') }}</th>
  26. <th> {{ trans('model.node.ipv4') }}</th>
  27. <th> {!! trans('model.node_auth.key') !!}</th>
  28. <th> {{ trans('model.node_auth.secret') }}</th>
  29. <th> {{trans('common.action')}}</th>
  30. </tr>
  31. </thead>
  32. <tbody>
  33. @foreach ($authorizations as $auth)
  34. <tr>
  35. <td> {{$auth->node_id}} </td>
  36. <td> {{$auth->node->type_label}} </td>
  37. <td> {{Str::limit($auth->node->name, 20) ?? ''}} </td>
  38. <td> {{$auth->node->server ?? ''}} </td>
  39. <td> {{$auth->node->ip ?? ''}} </td>
  40. <td><span class="badge badge-lg badge-info"> {{$auth->key}} </span></td>
  41. <td><span class="badge badge-lg badge-info"> {{$auth->secret}} </span></td>
  42. <td>
  43. <div class="btn-group">
  44. <button data-target="#install_{{$auth->node->type}}_{{$auth->id}}" data-toggle="modal" class="btn btn-primary">
  45. <i class="icon wb-code" aria-hidden="true"></i> {{ trans('admin.node.auth.deploy.attribute') }}
  46. </button>
  47. @can('admin.node.auth.update')
  48. <button onclick="refreshAuth('{{$auth->id}}')" class="btn btn-danger">
  49. <i class="icon wb-reload" aria-hidden="true"></i> {{ trans('admin.node.auth.reset_auth') }}
  50. </button>
  51. @endcan
  52. @can('admin.node.auth.destroy')
  53. <button onclick="deleteAuth('{{$auth->id}}')" class="btn btn-primary">
  54. <i class="icon wb-trash" aria-hidden="true"></i> {{ trans('common.delete') }}
  55. </button>
  56. @endcan
  57. </div>
  58. </td>
  59. </tr>
  60. @endforeach
  61. </tbody>
  62. </table>
  63. </div>
  64. <div class="panel-footer">
  65. <div class="row">
  66. <div class="col-sm-4">
  67. {!! trans('admin.node.auth.counts', ['num' => $authorizations->total()]) !!}
  68. </div>
  69. <div class="col-sm-8">
  70. <nav class="Page navigation float-right">
  71. {{ $authorizations->links() }}
  72. </nav>
  73. </div>
  74. </div>
  75. </div>
  76. </div>
  77. </div>
  78. @foreach($authorizations as $auth)
  79. <div id="install_{{$auth->node->type}}_{{$auth->id}}" class="modal fade" tabindex="-1" data-focus-on="input:first" data-keyboard="false">
  80. <div class="modal-dialog modal-simple modal-center modal-lg">
  81. <div class="modal-content">
  82. <div class="modal-header">
  83. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  84. <span aria-hidden="true">×</span>
  85. </button>
  86. <h4 class="modal-title">
  87. {{ trans('admin.node.auth.deploy.title', ['type_label' => $auth->node->type_label]) }}
  88. </h4>
  89. </div>
  90. <div class="modal-body">
  91. @if($auth->node->type === 2)
  92. <div class="alert alert-info text-break">
  93. <div class="text-center red-700 mb-5">VNET-V2Ray</div>
  94. (yum install curl 2> /dev/null || apt install curl 2> /dev/null) \<br>
  95. && curl -L -s https://bit.ly/3oO3HZy \<br>
  96. | WEB_API="{{sysConfig('web_api_url') ?: sysConfig('website_url')}}" \<br>
  97. NODE_ID={{$auth->node->id}} \<br>
  98. NODE_KEY={{$auth->key}} \<br>
  99. bash
  100. <br>
  101. <br>
  102. <div class="text-center red-700 mb-5">{{ trans('admin.node.auth.deploy.command') }}</div>
  103. {{ trans('admin.node.auth.deploy.update') }}{{ trans('admin.node.auth.deploy.same') }}
  104. <br>
  105. {{ trans('admin.node.auth.deploy.uninstall') }}curl -L -s https://bit.ly/3oO3HZy | bash -s -- --remove
  106. <br>
  107. {{ trans('admin.node.auth.deploy.start') }}systemctl start vnet-v2ray
  108. <br>
  109. {{ trans('admin.node.auth.deploy.stop') }}systemctl stop vnet-v2ray
  110. <br>
  111. {{ trans('admin.node.auth.deploy.status') }}systemctl status vnet-v2ray
  112. <br>
  113. {{ trans('admin.node.auth.deploy.recent_logs') }}journalctl -x -n 300 --no-pager -u vnet-v2ray
  114. <br>
  115. {{ trans('admin.node.auth.deploy.real_time_logs') }}journalctl -u vnet-v2ray -f
  116. </div>
  117. <div class="alert alert-info text-break">
  118. <div class="text-center red-700 mb-5">V2Ray-Poseidon</div>
  119. (yum install curl 2> /dev/null || apt install curl 2> /dev/null) \<br>
  120. && curl -L -s https://bit.ly/2HswWko \<br>
  121. | WEB_API="{{sysConfig('web_api_url') ?: sysConfig('website_url')}}" \<br>
  122. NODE_ID={{$auth->node->id}} \<br>
  123. NODE_KEY={{$auth->key}} \<br>
  124. bash
  125. <br>
  126. <br>
  127. <div class="text-center red-700 mb-5">{{ trans('admin.node.auth.deploy.command') }}</div>
  128. {{ trans('admin.node.auth.deploy.update') }}curl -L -s https://bit.ly/2HswWko | bash
  129. <br>
  130. {{ trans('admin.node.auth.deploy.uninstall') }}curl -L -s http://mrw.so/5IHPR4 | bash
  131. <br>
  132. {{ trans('admin.node.auth.deploy.start') }}systemctl start v2ray
  133. <br>
  134. {{ trans('admin.node.auth.deploy.stop') }}systemctl stop v2ray
  135. <br>
  136. {{ trans('admin.node.auth.deploy.status') }}systemctl status v2ray
  137. <br>
  138. {{ trans('admin.node.auth.deploy.recent_logs') }}journalctl -x -n 300 --no-pager -u v2ray
  139. <br>
  140. {{ trans('admin.node.auth.deploy.real_time_logs') }}journalctl -u v2ray -f
  141. </div>
  142. @elseif($auth->node->type === 3)
  143. @if(!$auth->node->server)
  144. <h3>
  145. {!! trans('admin.node.auth.deploy.trojan_hint', ['url' => route('admin.node.edit', $auth->node)]) !!}
  146. </h3>
  147. @else
  148. <div class="alert alert-info text-break">
  149. <div class="text-center red-700 mb-5">Trojan-Poseidon</div>
  150. (yum install curl 2> /dev/null || apt install curl 2> /dev/null) \<br>
  151. && curl -L -s http://mrw.so/6cMfGy \<br>
  152. | WEB_API="{{sysConfig('web_api_url') ?: sysConfig('website_url')}}" \<br>
  153. NODE_ID={{$auth->node->id}} \<br>
  154. NODE_KEY={{$auth->key}} \<br>
  155. NODE_HOST={{$auth->node->server}} \<br>
  156. bash
  157. <br>
  158. <br>
  159. <div class="text-center red-700 mb-5">{{ trans('admin.node.auth.deploy.command') }}</div>
  160. {{ trans('admin.node.auth.deploy.update') }}curl -L -s http://mrw.so/6cMfGy | bash
  161. <br>
  162. {{ trans('admin.node.auth.deploy.uninstall') }}curl -L -s http://mrw.so/5ulpvu | bash
  163. <br>
  164. {{ trans('admin.node.auth.deploy.start') }}systemctl start trojanp
  165. <br>
  166. {{ trans('admin.node.auth.deploy.stop') }}systemctl stop trojanp
  167. <br>
  168. {{ trans('admin.node.auth.deploy.status') }}systemctl status trojanp
  169. <br>
  170. {{ trans('admin.node.auth.deploy.recent_logs') }}journalctl -x -n 300 --no-pager -u trojanp
  171. <br>
  172. {{ trans('admin.node.auth.deploy.real_time_logs') }}journalctl -u trojanp -f
  173. </div>
  174. @endif
  175. @else
  176. <div class="alert alert-info text-break">
  177. <div class="text-center red-700 mb-5">VNET</div>
  178. (yum install curl 2> /dev/null || apt install curl 2> /dev/null) \<br>
  179. && curl -L -s https://bit.ly/3828OP1 \<br>
  180. | WEB_API="{{sysConfig('web_api_url') ?: sysConfig('website_url')}}" \<br>
  181. NODE_ID={{$auth->node->id}} \<br>
  182. NODE_KEY={{$auth->key}} \<br>
  183. bash
  184. <br>
  185. <br>
  186. <div class="text-center red-700 mb-5">{{ trans('admin.node.auth.deploy.command') }}</div>
  187. {{ trans('admin.node.auth.deploy.update') }}{{ trans('admin.node.auth.deploy.same') }}
  188. <br>
  189. {{ trans('admin.node.auth.deploy.uninstall') }}curl -L -s https://bit.ly/3828OP1 | bash -s -- --remove
  190. <br>
  191. {{ trans('admin.node.auth.deploy.start') }}systemctl start vnet
  192. <br>
  193. {{ trans('admin.node.auth.deploy.stop') }}systemctl stop vnet
  194. <br>
  195. {{ trans('admin.node.auth.deploy.restart') }}systemctl restart vnet
  196. <br>
  197. {{ trans('admin.node.auth.deploy.status') }}systemctl status vnet
  198. <br>
  199. {{ trans('admin.node.auth.deploy.recent_logs') }}journalctl -x -n 300 --no-pager -u vnet
  200. <br>
  201. {{ trans('admin.node.auth.deploy.real_time_logs') }}journalctl -u vnet -f
  202. </div>
  203. @endif
  204. </div>
  205. </div>
  206. </div>
  207. </div>
  208. @endforeach
  209. @endsection
  210. @section('javascript')
  211. <script src="/assets/global/vendor/bootstrap-table/bootstrap-table.min.js"></script>
  212. <script src="/assets/global/vendor/bootstrap-table/extensions/mobile/bootstrap-table-mobile.min.js"></script>
  213. <script>
  214. // 生成授权KEY
  215. @can('admin.node.auth.store')
  216. function addAuth() {
  217. swal.fire({
  218. title: '{{ trans('admin.hint') }}',
  219. text: '{{ trans('admin.node.auth.generating_all') }}',
  220. icon: 'info',
  221. showCancelButton: true,
  222. cancelButtonText: '{{ trans('common.close') }}',
  223. confirmButtonText: '{{ trans('common.confirm') }}',
  224. }).then((result) => {
  225. if (result.value) {
  226. $.post('{{route('admin.node.auth.store')}}', {_token: '{{csrf_token()}}'}, function(ret) {
  227. if (ret.status === 'success') {
  228. swal.fire({title: ret.message, icon: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  229. } else {
  230. swal.fire({title: ret.message, icon: 'error'}).then(() => window.location.reload());
  231. }
  232. });
  233. }
  234. });
  235. }
  236. @endcan
  237. @can('admin.node.auth.destroy')
  238. // 删除授权
  239. function deleteAuth(id) {
  240. swal.fire({
  241. title: '{{ trans('admin.hint') }}',
  242. text: '{{ trans('admin.confirm.delete.0', ['attribute' => trans('model.node_auth.attribute')]) }}' + id + '{{ trans('admin.confirm.delete.1') }}',
  243. icon: 'info',
  244. showCancelButton: true,
  245. cancelButtonText: '{{trans('common.close')}}',
  246. confirmButtonText: '{{trans('common.confirm')}}',
  247. }).then((result) => {
  248. if (result.value) {
  249. $.ajax({
  250. method: 'DELETE',
  251. url: '{{route('admin.node.auth.destroy', '')}}/' + id,
  252. data: {_token: '{{csrf_token()}}'},
  253. dataType: 'json',
  254. success: function(ret) {
  255. if (ret.status === 'success') {
  256. swal.fire({title: ret.message, icon: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  257. } else {
  258. swal.fire({title: ret.message, icon: 'error'}).then(() => window.location.reload());
  259. }
  260. },
  261. });
  262. }
  263. });
  264. }
  265. @endcan
  266. @can('admin.node.auth.update')
  267. // 重置授权认证KEY
  268. function refreshAuth(id) {
  269. swal.fire({
  270. title: '{{ trans('admin.hint') }}',
  271. text: '{{ trans('admin.confirm.continues') }}',
  272. icon: 'info',
  273. showCancelButton: true,
  274. cancelButtonText: '{{trans('common.close')}}',
  275. confirmButtonText: '{{trans('common.confirm')}}',
  276. }).then((result) => {
  277. if (result.value) {
  278. $.ajax({
  279. method: 'PUT',
  280. url: '{{route('admin.node.auth.update', '')}}/' + id,
  281. data: {_token: '{{csrf_token()}}'},
  282. dataType: 'json',
  283. success: function(ret) {
  284. if (ret.status === 'success') {
  285. swal.fire({title: ret.message, icon: 'success', timer: 1000, showConfirmButton: false}).then(() => window.location.reload());
  286. } else {
  287. swal.fire({title: ret.message, icon: 'error'}).then(() => window.location.reload());
  288. }
  289. },
  290. });
  291. }
  292. });
  293. }
  294. @endcan
  295. </script>
  296. @endsection