auth.blade.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. @extends('admin.table_layouts')
  2. @section('content')
  3. <div class="page-content container-fluid">
  4. <x-admin.table-panel :title="trans('admin.menu.node.auth')" :theads="[
  5. trans('model.node.id'),
  6. trans('model.common.type'),
  7. trans('model.node.name'),
  8. trans('model.node.domain'),
  9. trans('model.node_auth.key'),
  10. trans('model.node_auth.secret'),
  11. trans('common.action'),
  12. ]" :count="trans('admin.node.auth.counts', ['num' => $authorizations->total()])" :pagination="$authorizations->links()" :delete-config="['url' => route('admin.node.auth.destroy', 'PLACEHOLDER'), 'attribute' => trans('model.node_auth.attribute'), 'nameColumn' => 2]">
  13. @can('admin.node.auth.store')
  14. <x-slot:actions>
  15. <button class="btn btn-primary" onclick="addAuth()">
  16. <i class="icon wb-plus" aria-hidden="true"></i> {{ trans('common.add') }}
  17. </button>
  18. </x-slot:actions>
  19. @endcan
  20. <x-slot:tbody>
  21. @foreach ($authorizations as $auth)
  22. <tr>
  23. <td> {{ $auth->node_id }} </td>
  24. <td> {{ $auth->node->type_label }} </td>
  25. <td> {{ Str::limit($auth->node->name, 20) }} </td>
  26. <td> {{ $auth->node->host }} </td>
  27. <td><span class="badge badge-lg badge-info"> {{ $auth->key }} </span></td>
  28. <td><span class="badge badge-lg badge-info"> {{ $auth->secret }} </span></td>
  29. <td>
  30. <div class="btn-group">
  31. <button class="btn btn-primary"
  32. onclick="showDeployModal({{ $auth->node->id }}, {{ $auth->node->type }}, '{{ $auth->key }}', '{{ $auth->node->type_label }}', '{{ $auth->node->host }}')">
  33. <i class="icon wb-code" aria-hidden="true"></i> {{ trans('admin.node.auth.deploy.attribute') }}
  34. </button>
  35. @can('admin.node.auth.update')
  36. <button class="btn btn-danger" onclick="refreshAuth('{{ $auth->id }}')">
  37. <i class="icon wb-reload" aria-hidden="true"></i> {{ trans('admin.node.auth.reset_auth') }}
  38. </button>
  39. @endcan
  40. @can('admin.node.auth.destroy')
  41. <button class="btn btn-primary" data-action="delete">
  42. <i class="icon wb-trash" aria-hidden="true"></i> {{ trans('common.delete') }}
  43. </button>
  44. @endcan
  45. </div>
  46. </td>
  47. </tr>
  48. @endforeach
  49. </x-slot:tbody>
  50. </x-admin.table-panel>
  51. </div>
  52. <!-- 部署教程模态框模板 -->
  53. <x-ui.modal id="deployModal" tabindex="-1" size="simple" position="center" :keyboard="false" focus="input:first">
  54. <x-slot:title>
  55. <span id="deployModalTitle"></span>
  56. </x-slot:title>
  57. <div id="deployModalBody"></div>
  58. </x-ui.modal>
  59. @endsection
  60. @push('javascript')
  61. <script>
  62. // 生成授权KEY
  63. @can('admin.node.auth.store')
  64. function addAuth() {
  65. showConfirm({
  66. title: '{{ trans('admin.hint') }}',
  67. text: '{{ trans('admin.node.auth.generating_all') }}',
  68. icon: 'info',
  69. onConfirm: function() {
  70. ajaxPost('{{ route('admin.node.auth.store') }}');
  71. }
  72. });
  73. }
  74. @endcan
  75. @can('admin.node.auth.update')
  76. // 重置授权认证KEY
  77. function refreshAuth(id) {
  78. showConfirm({
  79. title: '{{ trans('admin.hint') }}',
  80. text: '{{ trans('admin.confirm.continues') }}',
  81. icon: 'info',
  82. onConfirm: function() {
  83. ajaxPut(jsRoute('{{ route('admin.node.auth.update', 'PLACEHOLDER') }}', id));
  84. }
  85. });
  86. }
  87. @endcan
  88. // 显示部署教程模态框
  89. function showDeployModal(nodeId, nodeType, nodeKey, typeLabel, nodeHost) {
  90. // 设置模态框标题
  91. $('#deployModalTitle').text(`{{ trans('admin.node.auth.deploy.title', ['type_label' => '${typeLabel}']) }}`);
  92. const webApi = '{{ sysConfig('web_api_url') ?: sysConfig('website_url') }}';
  93. // 定义节点配置
  94. const nodeConfigs = {
  95. 1: { // 默认节点 (VNET)
  96. name: 'VNET',
  97. scriptUrl: 'https://bit.ly/3828OP1',
  98. commands: {
  99. update: '{{ trans('admin.node.auth.deploy.same') }}',
  100. uninstall: 'curl -L -s https://bit.ly/3828OP1 | bash -s -- --remove',
  101. start: 'systemctl start vnet',
  102. stop: 'systemctl stop vnet',
  103. restart: 'systemctl restart vnet',
  104. status: 'systemctl status vnet',
  105. recent_logs: 'journalctl -x -n 300 --no-pager -u vnet',
  106. real_time_logs: 'journalctl -u vnet -f'
  107. }
  108. },
  109. 2: { // V2Ray 节点
  110. scripts: [{
  111. name: 'VNET-V2Ray',
  112. scriptUrl: 'https://bit.ly/3oO3HZy',
  113. commands: {
  114. update: '{{ trans('admin.node.auth.deploy.same') }}',
  115. uninstall: 'curl -L -s https://bit.ly/3oO3HZy | bash -s -- --remove',
  116. start: 'systemctl start vnet-v2ray',
  117. stop: 'systemctl stop vnet-v2ray',
  118. status: 'systemctl status vnet-v2ray',
  119. recent_logs: 'journalctl -x -n 300 --no-pager -u vnet-v2ray',
  120. real_time_logs: 'journalctl -u vnet-v2ray -f'
  121. }
  122. },
  123. {
  124. name: 'V2Ray-Poseidon',
  125. scriptUrl: 'https://bit.ly/2HswWko',
  126. commands: {
  127. update: 'curl -L -s https://bit.ly/2HswWko | bash',
  128. uninstall: 'curl -L -s https://mrw.so/5IHPR4 | bash',
  129. start: 'systemctl start v2ray',
  130. stop: 'systemctl stop v2ray',
  131. status: 'systemctl status v2ray',
  132. recent_logs: 'journalctl -x -n 300 --no-pager -u v2ray',
  133. real_time_logs: 'journalctl -u v2ray -f'
  134. }
  135. }
  136. ]
  137. },
  138. 3: { // Trojan 节点
  139. name: 'Trojan-Poseidon',
  140. scriptUrl: 'https://mrw.so/6cMfGy',
  141. requireHost: true,
  142. commands: {
  143. update: 'curl -L -s https://mrw.so/6cMfGy | bash',
  144. uninstall: 'curl -L -s https://mrw.so/5ulpvu | bash',
  145. start: 'systemctl start trojanp',
  146. stop: 'systemctl stop trojanp',
  147. status: 'systemctl status trojanp',
  148. recent_logs: 'journalctl -x -n 300 --no-pager -u trojanp',
  149. real_time_logs: 'journalctl -u trojanp -f'
  150. }
  151. }
  152. };
  153. let content = '';
  154. if (nodeType === 2) {
  155. // V2Ray 节点(特殊处理,有两个脚本)
  156. const config = nodeConfigs[2];
  157. config.scripts.forEach(script => {
  158. content += `
  159. <div class="alert alert-info text-break">
  160. <div class="text-center red-700 mb-5">${script.name}</div>
  161. (yum install curl 2> /dev/null || apt install curl 2> /dev/null) \\<br>
  162. && curl -L -s ${script.scriptUrl} \\<br>
  163. | WEB_API="${webApi}" \\<br>
  164. NODE_ID=${nodeId} \\<br>
  165. NODE_KEY=${nodeKey} \\<br>
  166. ${script.name.includes('Trojan') && nodeHost ? `NODE_HOST=${nodeHost} \\<br>` : ''}
  167. bash
  168. <br><br>
  169. <div class="text-center red-700 mb-5">{{ trans('admin.node.auth.deploy.command') }}</div>
  170. {{ trans('admin.node.auth.deploy.update') }}: ${script.commands.update}
  171. <br>
  172. {{ trans('admin.node.auth.deploy.uninstall') }}: ${script.commands.uninstall}
  173. <br>
  174. {{ trans('admin.node.auth.deploy.start') }}: ${script.commands.start}
  175. <br>
  176. {{ trans('admin.node.auth.deploy.stop') }}: ${script.commands.stop}
  177. <br>
  178. {{ trans('admin.node.auth.deploy.status') }}: ${script.commands.status}
  179. <br>
  180. {{ trans('admin.node.auth.deploy.recent_logs') }}: ${script.commands.recent_logs}
  181. <br>
  182. {{ trans('admin.node.auth.deploy.real_time_logs') }}: ${script.commands.real_time_logs}
  183. </div>
  184. `;
  185. });
  186. } else if (nodeType === 3) {
  187. // Trojan 节点
  188. const config = nodeConfigs[3];
  189. if (!nodeHost) {
  190. let url = jsRoute('{{ route('admin.node.edit', 'PLACEHOLDER') }}', nodeId)
  191. content = `<h3>{!! trans('admin.node.auth.deploy.trojan_hint', ['url' => '${url}']) !!}</h3>`;
  192. } else {
  193. content = `
  194. <div class="alert alert-info text-break">
  195. <div class="text-center red-700 mb-5">${config.name}</div>
  196. (yum install curl 2> /dev/null || apt install curl 2> /dev/null) \\<br>
  197. && curl -L -s ${config.scriptUrl} \\<br>
  198. | WEB_API="${webApi}" \\<br>
  199. NODE_ID=${nodeId} \\<br>
  200. NODE_KEY=${nodeKey} \\<br>
  201. NODE_HOST=${nodeHost} \\<br>
  202. bash
  203. <br><br>
  204. <div class="text-center red-700 mb-5">{{ trans('admin.node.auth.deploy.command') }}</div>
  205. {{ trans('admin.node.auth.deploy.update') }}: ${config.commands.update}
  206. <br>
  207. {{ trans('admin.node.auth.deploy.uninstall') }}: ${config.commands.uninstall}
  208. <br>
  209. {{ trans('admin.node.auth.deploy.start') }}: ${config.commands.start}
  210. <br>
  211. {{ trans('admin.node.auth.deploy.stop') }}: ${config.commands.stop}
  212. <br>
  213. {{ trans('admin.node.auth.deploy.status') }}: ${config.commands.status}
  214. <br>
  215. {{ trans('admin.node.auth.deploy.recent_logs') }}: ${config.commands.recent_logs}
  216. <br>
  217. {{ trans('admin.node.auth.deploy.real_time_logs') }}: ${config.commands.real_time_logs}
  218. </div>
  219. `;
  220. }
  221. } else {
  222. // 默认节点 (VNET)
  223. const config = nodeConfigs[1];
  224. content = `
  225. <div class="alert alert-info text-break">
  226. <div class="text-center red-700 mb-5">${config.name}</div>
  227. (yum install curl 2> /dev/null || apt install curl 2> /dev/null) \\<br>
  228. && curl -L -s ${config.scriptUrl} \\<br>
  229. | WEB_API="${webApi}" \\<br>
  230. NODE_ID=${nodeId} \\<br>
  231. NODE_KEY=${nodeKey} \\<br>
  232. bash
  233. <br><br>
  234. <div class="text-center red-700 mb-5">{{ trans('admin.node.auth.deploy.command') }}</div>
  235. {{ trans('admin.node.auth.deploy.update') }}: ${config.commands.update}
  236. <br>
  237. {{ trans('admin.node.auth.deploy.uninstall') }}: ${config.commands.uninstall}
  238. <br>
  239. {{ trans('admin.node.auth.deploy.start') }}: ${config.commands.start}
  240. <br>
  241. {{ trans('admin.node.auth.deploy.stop') }}: ${config.commands.stop}
  242. <br>
  243. {{ trans('admin.node.auth.deploy.restart') }}: ${config.commands.restart}
  244. <br>
  245. {{ trans('admin.node.auth.deploy.status') }}: ${config.commands.status}
  246. <br>
  247. {{ trans('admin.node.auth.deploy.recent_logs') }}: ${config.commands.recent_logs}
  248. <br>
  249. {{ trans('admin.node.auth.deploy.real_time_logs') }}: ${config.commands.real_time_logs}
  250. </div>
  251. `;
  252. }
  253. $('#deployModalBody').html(content);
  254. $('#deployModal').modal('show');
  255. }
  256. </script>
  257. @endpush