1
0

inbound_info_modal.html 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695
  1. {{define "modals/inboundInfoModal"}}
  2. <a-modal id="inbound-info-modal" v-model="infoModal.visible"
  3. title='{{ i18n "pages.inbounds.details"}}' :closable="true"
  4. :mask-closable="true" :footer="null" width="600px"
  5. :class="themeSwitcher.currentTheme">
  6. <a-row>
  7. <a-col :xs="24" :md="12">
  8. <table>
  9. <tr>
  10. <td>{{ i18n "protocol" }}</td>
  11. <td>
  12. <a-tag color="purple">[[ dbInbound.protocol ]]</a-tag>
  13. </td>
  14. </tr>
  15. <tr>
  16. <td>{{ i18n "pages.inbounds.address" }}</td>
  17. <td>
  18. <a-tooltip :title="[[ dbInbound.address ]]">
  19. <a-tag class="info-large-tag">[[ dbInbound.address ]]</a-tag>
  20. </a-tooltip>
  21. </td>
  22. </tr>
  23. <tr>
  24. <td>{{ i18n "pages.inbounds.port" }}</td>
  25. <td>
  26. <a-tag>[[ dbInbound.port ]]</a-tag>
  27. </td>
  28. </tr>
  29. </table>
  30. </a-col>
  31. <a-col :xs="24" :md="12">
  32. <template
  33. v-if="dbInbound.isVMess || dbInbound.isVLess || dbInbound.isTrojan || dbInbound.isSS">
  34. <table>
  35. <tr>
  36. <td>{{ i18n "transmission" }}</td>
  37. <td>
  38. <a-tag color="green">[[ inbound.network ]]</a-tag>
  39. </td>
  40. </tr>
  41. <template
  42. v-if="inbound.isTcp || inbound.isWs || inbound.isHttpupgrade || inbound.isXHTTP">
  43. <tr>
  44. <td>{{ i18n "host" }}</td>
  45. <td v-if="inbound.host">
  46. <a-tooltip :title="[[ inbound.host ]]">
  47. <a-tag class="info-large-tag">[[ inbound.host ]]</a-tag>
  48. </a-tooltip>
  49. </td>
  50. <td v-else>
  51. <a-tag color="orange">{{ i18n "none" }}</a-tag>
  52. </td>
  53. </tr>
  54. </tr>
  55. <tr>
  56. <td>{{ i18n "path" }}</td>
  57. <td v-if="inbound.path">
  58. <a-tooltip :title="[[ inbound.path ]]">
  59. <a-tag class="info-large-tag">[[ inbound.path ]]</a-tag>
  60. </a-tooltip>
  61. <td v-else>
  62. <a-tag color="orange">{{ i18n "none" }}</a-tag>
  63. </td>
  64. </tr>
  65. </template>
  66. <template v-if="inbound.isXHTTP">
  67. <tr>
  68. <td>Mode</td>
  69. <td>
  70. <a-tag>[[ inbound.stream.xhttp.mode ]]</a-tag>
  71. </td>
  72. </tr>
  73. </template>
  74. <template v-if="inbound.isGrpc">
  75. <tr>
  76. <td>grpc serviceName</td>
  77. <td>
  78. <a-tooltip :title="[[ inbound.serviceName ]]">
  79. <a-tag class="info-large-tag">[[ inbound.serviceName
  80. ]]</a-tag>
  81. </a-tooltip>
  82. <tr>
  83. <td>grpc multiMode</td>
  84. <td>
  85. <a-tag>[[ inbound.stream.grpc.multiMode ]]</a-tag>
  86. </td>
  87. </tr>
  88. </template>
  89. </table>
  90. </template>
  91. </a-col>
  92. <template v-if="dbInbound.hasLink()">
  93. {{ i18n "security" }}
  94. <a-tag :color="inbound.stream.security == 'none' ? 'red' : 'green'">[[
  95. inbound.stream.security ]]</a-tag>
  96. <br />
  97. <td>Authentication</td>
  98. <a-tag v-if="inbound.settings.selectedAuth" color="green">[[
  99. inbound.settings.selectedAuth ? inbound.settings.selectedAuth : ''
  100. ]]</a-tag>
  101. <a-tag v-else color="red">{{ i18n "none" }}</a-tag>
  102. <br />
  103. {{ i18n "encryption" }}
  104. <a-tag class="info-large-tag"
  105. :color="inbound.settings.encryption ? 'green' : 'red'">[[
  106. inbound.settings.encryption ? inbound.settings.encryption : ''
  107. ]]</a-tag>
  108. <a-tooltip title='{{ i18n "copy" }}'>
  109. <a-button size="small" icon="snippets"
  110. @click="copy(inbound.settings.encryption)"></a-button>
  111. </a-tooltip>
  112. <br />
  113. <template v-if="inbound.stream.security != 'none'">
  114. {{ i18n "domainName" }}
  115. <a-tag v-if="inbound.serverName" color="green">[[ inbound.serverName
  116. ? inbound.serverName : '' ]]</a-tag>
  117. <a-tag v-else color="orange">{{ i18n "none" }}</a-tag>
  118. </template>
  119. </template>
  120. <table v-if="dbInbound.isSS"
  121. :style="{ marginBottom: '10px', width: '100%' }">
  122. <tr>
  123. <td>{{ i18n "encryption" }}</td>
  124. <td>
  125. <a-tag color="green">[[ inbound.settings.method ]]</a-tag>
  126. </td>
  127. </tr>
  128. <tr v-if="inbound.isSS2022">
  129. <td>{{ i18n "password" }}</td>
  130. <td>
  131. <a-tooltip :title="[[ inbound.settings.password ]]">
  132. <a-tag class="info-large-tag">[[ inbound.settings.password
  133. ]]</a-tag>
  134. </a-tooltip>
  135. </td>
  136. </tr>
  137. <tr>
  138. <td>{{ i18n "pages.inbounds.network" }}</td>
  139. <td>
  140. <a-tag color="green">[[ inbound.settings.network ]]</a-tag>
  141. </td>
  142. </tr>
  143. </table>
  144. <template v-if="infoModal.clientSettings">
  145. <a-divider>{{ i18n "pages.inbounds.client" }}</a-divider>
  146. <table :style="{ marginBottom: '10px' }">
  147. <tr>
  148. <td>{{ i18n "pages.inbounds.email" }}</td>
  149. <td v-if="infoModal.clientSettings.email">
  150. <a-tag color="green">[[ infoModal.clientSettings.email
  151. ]]</a-tag>
  152. </td>
  153. <td v-else>
  154. <a-tag color="red">{{ i18n "none" }}</a-tag>
  155. </td>
  156. </tr>
  157. <tr v-if="infoModal.clientSettings.id">
  158. <td>ID</td>
  159. <td>
  160. <a-tag>[[ infoModal.clientSettings.id ]]</a-tag>
  161. </td>
  162. </tr>
  163. <tr v-if="dbInbound.isVMess">
  164. <td>{{ i18n "security" }}</td>
  165. <td>
  166. <a-tag>[[ infoModal.clientSettings.security ]]</a-tag>
  167. </td>
  168. </tr>
  169. <tr v-if="infoModal.inbound.canEnableTlsFlow()">
  170. <td>Flow</td>
  171. <td v-if="infoModal.clientSettings.flow">
  172. <a-tag>[[ infoModal.clientSettings.flow ]]</a-tag>
  173. </td>
  174. <td v-else>
  175. <a-tag color="orange">{{ i18n "none" }}</a-tag>
  176. </td>
  177. </tr>
  178. <tr v-if="infoModal.clientSettings.password">
  179. <td>{{ i18n "password" }}</td>
  180. <td>
  181. <a-tooltip :title="[[ infoModal.clientSettings.password ]]">
  182. <a-tag class="info-large-tag">[[
  183. infoModal.clientSettings.password ]]</a-tag>
  184. </a-tooltip>
  185. </td>
  186. </tr>
  187. <tr>
  188. <td>{{ i18n "status" }}</td>
  189. <td>
  190. <a-tag v-if="isDepleted" color="red">{{ i18n "depleted"
  191. }}</a-tag>
  192. <a-tag v-else-if="isEnable" color="green">{{ i18n "enabled"
  193. }}</a-tag>
  194. <a-tag v-else>{{ i18n "disabled" }}</a-tag>
  195. </td>
  196. </tr>
  197. <tr v-if="infoModal.clientStats">
  198. <td>{{ i18n "usage" }}</td>
  199. <td>
  200. <a-tag color="green">[[
  201. SizeFormatter.sizeFormat(infoModal.clientStats.up +
  202. infoModal.clientStats.down) ]]</a-tag>
  203. <a-tag>↑ [[ SizeFormatter.sizeFormat(infoModal.clientStats.up)
  204. ]] / [[ SizeFormatter.sizeFormat(infoModal.clientStats.down)
  205. ]] ↓</a-tag>
  206. </td>
  207. </tr>
  208. <tr>
  209. <td>{{ i18n "pages.inbounds.createdAt" }}</td>
  210. <td>
  211. <template
  212. v-if="infoModal.clientSettings && infoModal.clientSettings.created_at">
  213. <a-tag>[[
  214. IntlUtil.formatDate(infoModal.clientSettings.created_at)
  215. ]]</a-tag>
  216. </template>
  217. <template v-else>
  218. <a-tag>-</a-tag>
  219. </template>
  220. </td>
  221. </tr>
  222. <tr>
  223. <td>{{ i18n "pages.inbounds.updatedAt" }}</td>
  224. <td>
  225. <template
  226. v-if="infoModal.clientSettings && infoModal.clientSettings.updated_at">
  227. <a-tag>[[
  228. IntlUtil.formatDate(infoModal.clientSettings.updated_at)
  229. ]]</a-tag>
  230. </template>
  231. <template v-else>
  232. <a-tag>-</a-tag>
  233. </template>
  234. </td>
  235. </tr>
  236. <tr>
  237. <td>{{ i18n "lastOnline" }}</td>
  238. <td>
  239. <a-tag>[[ app.formatLastOnline(infoModal.clientSettings &&
  240. infoModal.clientSettings.email ?
  241. infoModal.clientSettings.email : '') ]]</a-tag>
  242. </td>
  243. </tr>
  244. <tr v-if="infoModal.clientSettings.comment">
  245. <td>{{ i18n "comment" }}</td>
  246. <td>
  247. <a-tooltip :title="[[ infoModal.clientSettings.comment ]]">
  248. <a-tag class="info-large-tag">[[
  249. infoModal.clientSettings.comment ]]</a-tag>
  250. </a-tooltip>
  251. </td>
  252. </tr>
  253. <tr v-if="app.ipLimitEnable">
  254. <td>{{ i18n "pages.inbounds.IPLimit" }}</td>
  255. <td>
  256. <a-tag>[[ infoModal.clientSettings.limitIp ]]</a-tag>
  257. </td>
  258. </tr>
  259. <tr
  260. v-if="app.ipLimitEnable && infoModal.clientSettings.limitIp > 0">
  261. <td>{{ i18n "pages.inbounds.IPLimitlog" }}</td>
  262. <td>
  263. <a-tag>[[ infoModal.clientIps ]]</a-tag>
  264. <a-icon type="sync" :spin="refreshing" @click="refreshIPs"
  265. :style="{ margin: '0 5px' }"></a-icon>
  266. <a-tooltip :title="[[ dbInbound.address ]]">
  267. <template slot="title">
  268. <span>{{ i18n "pages.inbounds.IPLimitlogclear" }}</span>
  269. </template>
  270. <a-icon type="delete" @click="clearClientIps"></a-icon>
  271. </a-tooltip>
  272. </td>
  273. </tr>
  274. </table>
  275. <table
  276. :style="{ display: 'inline-table', marginBlock: '10px', width: '100%', textAlign: 'center' }">
  277. <tr>
  278. <th>{{ i18n "remained" }}</th>
  279. <th>{{ i18n "pages.inbounds.totalFlow" }}</th>
  280. <th>{{ i18n "pages.inbounds.expireDate" }}</th>
  281. </tr>
  282. <tr>
  283. <td>
  284. <a-tag
  285. v-if="infoModal.clientStats && infoModal.clientSettings.totalGB > 0"
  286. :color="statsColor(infoModal.clientStats)"> [[ getRemStats()
  287. ]] </a-tag>
  288. </td>
  289. <td>
  290. <a-tag v-if="infoModal.clientSettings.totalGB > 0"
  291. :color="statsColor(infoModal.clientStats)"> [[
  292. SizeFormatter.sizeFormat(infoModal.clientSettings.totalGB) ]]
  293. </a-tag>
  294. <a-tag v-else color="purple" class="infinite-tag">
  295. <svg height="10px" width="14px" viewBox="0 0 640 512"
  296. fill="currentColor">
  297. <path
  298. d="M484.4 96C407 96 349.2 164.1 320 208.5C290.8 164.1 233 96 155.6 96C69.75 96 0 167.8 0 256s69.75 160 155.6 160C233.1 416 290.8 347.9 320 303.5C349.2 347.9 407 416 484.4 416C570.3 416 640 344.2 640 256S570.3 96 484.4 96zM155.6 368C96.25 368 48 317.8 48 256s48.25-112 107.6-112c67.75 0 120.5 82.25 137.1 112C276 285.8 223.4 368 155.6 368zM484.4 368c-67.75 0-120.5-82.25-137.1-112C364 226.2 416.6 144 484.4 144C543.8 144 592 194.2 592 256S543.8 368 484.4 368z"
  299. fill="currentColor"></path>
  300. </svg>
  301. </a-tag>
  302. </td>
  303. <td>
  304. <template v-if="infoModal.clientSettings.expiryTime > 0">
  305. <a-tag
  306. :color="ColorUtils.usageColor(new Date().getTime(), app.expireDiff, infoModal.clientSettings.expiryTime)">
  307. [[ IntlUtil.formatDate(infoModal.clientSettings.expiryTime)
  308. ]]
  309. </a-tag>
  310. </template>
  311. <a-tag v-else-if="infoModal.clientSettings.expiryTime < 0"
  312. color="green">[[ infoModal.clientSettings.expiryTime /
  313. -86400000 ]] {{ i18n "pages.client.days" }}
  314. </a-tag>
  315. <a-tag v-else color="purple" class="infinite-tag">
  316. <svg height="10px" width="14px" viewBox="0 0 640 512"
  317. fill="currentColor">
  318. <path
  319. d="M484.4 96C407 96 349.2 164.1 320 208.5C290.8 164.1 233 96 155.6 96C69.75 96 0 167.8 0 256s69.75 160 155.6 160C233.1 416 290.8 347.9 320 303.5C349.2 347.9 407 416 484.4 416C570.3 416 640 344.2 640 256S570.3 96 484.4 96zM155.6 368C96.25 368 48 317.8 48 256s48.25-112 107.6-112c67.75 0 120.5 82.25 137.1 112C276 285.8 223.4 368 155.6 368zM484.4 368c-67.75 0-120.5-82.25-137.1-112C364 226.2 416.6 144 484.4 144C543.8 144 592 194.2 592 256S543.8 368 484.4 368z"
  320. fill="currentColor"></path>
  321. </svg>
  322. </a-tag>
  323. </td>
  324. </tr>
  325. </table>
  326. <template
  327. v-if="app.subSettings.enable && infoModal.clientSettings.subId">
  328. <a-divider>Subscription URL</a-divider>
  329. <tr-info-row class="tr-info-row">
  330. <tr-info-title class="tr-info-title">
  331. <a-tag color="purple">Subscription Link</a-tag>
  332. <a-tooltip title='{{ i18n "copy" }}'>
  333. <a-button size="small" icon="snippets"
  334. @click="copy(infoModal.subLink)"></a-button>
  335. </a-tooltip>
  336. </tr-info-title>
  337. <a :href="[[ infoModal.subLink ]]" target="_blank">[[
  338. infoModal.subLink ]]</a>
  339. </tr-info-row>
  340. <tr-info-row class="tr-info-row"
  341. v-if="app.subSettings.subJsonEnable">
  342. <tr-info-title class="tr-info-title">
  343. <a-tag color="purple">Json Link</a-tag>
  344. <a-tooltip title='{{ i18n "copy" }}'>
  345. <a-button size="small" icon="snippets"
  346. @click="copy(infoModal.subJsonLink)"></a-button>
  347. </a-tooltip>
  348. </tr-info-title>
  349. <a :href="[[ infoModal.subJsonLink ]]" target="_blank">[[
  350. infoModal.subJsonLink ]]</a>
  351. </tr-info-row>
  352. </template>
  353. <template v-if="app.tgBotEnable && infoModal.clientSettings.tgId">
  354. <a-divider>Telegram ChatID</a-divider>
  355. <tr-info-row class="tr-info-row">
  356. <tr-info-title class="tr-info-title">
  357. <a-tag color="blue">[[ infoModal.clientSettings.tgId ]]</a-tag>
  358. <a-tooltip title='{{ i18n "copy" }}'>
  359. <a-button size="small" icon="snippets"
  360. @click="copy(infoModal.clientSettings.tgId)"></a-button>
  361. </a-tooltip>
  362. </tr-info-title>
  363. </tr-info-row>
  364. </template>
  365. <template v-if="dbInbound.hasLink()">
  366. <a-divider>URL</a-divider>
  367. <tr-info-row v-for="(link,index) in infoModal.links"
  368. class="tr-info-row">
  369. <tr-info-title class="tr-info-title">
  370. <a-tag class="tr-info-tag" color="green">[[ link.remark
  371. ]]</a-tag>
  372. <a-tooltip title='{{ i18n "copy" }}'>
  373. <a-button :style="{ minWidth: '24px' }" size="small"
  374. icon="snippets" @click="copy(link.link)"></a-button>
  375. </a-tooltip>
  376. </tr-info-title>
  377. <code>[[ link.link ]]</code>
  378. </tr-info-row>
  379. </template>
  380. </template>
  381. <template v-else>
  382. <template v-if="dbInbound.isSS && !inbound.isSSMultiUser">
  383. <a-divider>URL</a-divider>
  384. <tr-info-row v-for="(link,index) in infoModal.links"
  385. class="tr-info-row">
  386. <tr-info-title class="tr-info-title">
  387. <a-tag class="tr-info-tag" color="green">[[ link.remark
  388. ]]</a-tag>
  389. <a-tooltip title='{{ i18n "copy" }}'>
  390. <a-button :style="{ minWidth: '24px' }" size="small"
  391. icon="snippets" @click="copy(link.link)"></a-button>
  392. </a-tooltip>
  393. </tr-info-title>
  394. <code>[[ link.link ]]</code>
  395. </tr-info-row>
  396. </template>
  397. <table v-if="inbound.protocol == Protocols.TUNNEL"
  398. class="tr-info-table">
  399. <tr>
  400. <th>{{ i18n "pages.inbounds.targetAddress" }}</th>
  401. <th>{{ i18n "pages.inbounds.destinationPort" }}</th>
  402. <th>{{ i18n "pages.inbounds.network" }}</th>
  403. <th>FollowRedirect</th>
  404. </tr>
  405. <tr>
  406. <td>
  407. <a-tag color="green">[[ inbound.settings.address ]]</a-tag>
  408. </td>
  409. <td>
  410. <a-tag color="green">[[ inbound.settings.port ]]</a-tag>
  411. </td>
  412. <td>
  413. <a-tag color="green">[[ inbound.settings.network ]]</a-tag>
  414. </td>
  415. <td>
  416. <a-tag color="green">[[ inbound.settings.followRedirect
  417. ]]</a-tag>
  418. </td>
  419. </tr>
  420. </table>
  421. <table v-if="dbInbound.isMixed" class="tr-info-table">
  422. <tr>
  423. <th>{{ i18n "password" }} Auth</th>
  424. <th>{{ i18n "pages.inbounds.enable" }} udp</th>
  425. <th>IP</th>
  426. </tr>
  427. <tr>
  428. <td>
  429. <a-tag color="green">[[ inbound.settings.auth ]]</a-tag>
  430. </td>
  431. <td>
  432. <a-tag color="green">[[ inbound.settings.udp]]</a-tag>
  433. </td>
  434. <td>
  435. <a-tag color="green">[[ inbound.settings.ip ]]</a-tag>
  436. </td>
  437. </tr>
  438. <template v-if="inbound.settings.auth == 'password'">
  439. <tr>
  440. <td></td>
  441. <td>{{ i18n "username" }}</td>
  442. <td>{{ i18n "password" }}</td>
  443. </tr>
  444. <tr v-for="account,index in inbound.settings.accounts">
  445. <td>[[ index ]]</td>
  446. <td>
  447. <a-tag color="green">[[ account.user ]]</a-tag>
  448. </td>
  449. <td>
  450. <a-tag color="green">[[ account.pass ]]</a-tag>
  451. </td>
  452. </tr>
  453. </template>
  454. </table>
  455. <table v-if="dbInbound.isHTTP" class="tr-info-table">
  456. <tr>
  457. <th></th>
  458. <th>{{ i18n "username" }}</th>
  459. <th>{{ i18n "password" }}</th>
  460. </tr>
  461. <tr v-for="account,index in inbound.settings.accounts">
  462. <td>[[ index ]]</td>
  463. <td>
  464. <a-tag color="green">[[ account.user ]]</a-tag>
  465. </td>
  466. <td>
  467. <a-tag color="green">[[ account.pass ]]</a-tag>
  468. </td>
  469. </tr>
  470. </table>
  471. <table v-if="dbInbound.isWireguard" class="tr-info-table">
  472. <tr class="client-table-odd-row">
  473. <td>{{ i18n "pages.xray.wireguard.secretKey" }}</td>
  474. <td>[[ inbound.settings.secretKey ]]</td>
  475. </tr>
  476. <tr>
  477. <td>{{ i18n "pages.xray.wireguard.publicKey" }}</td>
  478. <td>[[ inbound.settings.pubKey ]]</td>
  479. </tr>
  480. <tr class="client-table-odd-row">
  481. <td>MTU</td>
  482. <td>[[ inbound.settings.mtu ]]</td>
  483. </tr>
  484. <tr>
  485. <td>No Kernel Tun</td>
  486. <td>[[ inbound.settings.noKernelTun ]]</td>
  487. </tr>
  488. <template v-for="(peer, index) in inbound.settings.peers">
  489. <tr>
  490. <td colspan="2">
  491. <a-divider>Peer [[ index + 1 ]]</a-divider>
  492. </td>
  493. </tr>
  494. <tr class="client-table-odd-row">
  495. <td>{{ i18n "pages.xray.wireguard.secretKey" }}</td>
  496. <td>[[ peer.privateKey ]]</td>
  497. </tr>
  498. <tr>
  499. <td>{{ i18n "pages.xray.wireguard.publicKey" }}</td>
  500. <td>[[ peer.publicKey ]]</td>
  501. </tr>
  502. <tr class="client-table-odd-row">
  503. <td>{{ i18n "pages.xray.wireguard.psk" }}</td>
  504. <td>[[ peer.psk ]]</td>
  505. </tr>
  506. <tr>
  507. <td>{{ i18n "pages.xray.wireguard.allowedIPs" }}</td>
  508. <td>[[ peer.allowedIPs.join(",") ]]</td>
  509. </tr>
  510. <tr class="client-table-odd-row">
  511. <td>Keep Alive</td>
  512. <td>[[ peer.keepAlive ]]</td>
  513. </tr>
  514. <tr>
  515. <td colspan="2">
  516. <tr-info-row class="tr-info-row">
  517. <tr-info-title class="tr-info-title">
  518. <a-tag color="blue">Config</a-tag>
  519. <a-tooltip title='{{ i18n "copy" }}'>
  520. <a-button :style="{ minWidth: '24px' }" size="small"
  521. icon="snippets"
  522. @click="copy(infoModal.links[index])"></a-button>
  523. </a-tooltip>
  524. <a-tooltip title='{{ i18n "download" }}'>
  525. <a-button :style="{ minWidth: '24px' }" size="small"
  526. icon="download"
  527. @click="FileManager.downloadTextFile(infoModal.links[index], `peer-${index + 1}.conf`)"></a-button>
  528. </a-tooltip>
  529. </tr-info-title>
  530. <div
  531. v-html="infoModal.links[index].replaceAll(`\n`,`<br />`)"
  532. :style="{ borderRadius: '1rem', padding: '0.5rem' }"
  533. class="client-table-odd-row">
  534. </div>
  535. </tr-info-row>
  536. </td>
  537. </tr>
  538. </table>
  539. </template>
  540. </template>
  541. </a-modal>
  542. <script>
  543. function refreshIPs(email) {
  544. return HttpUtil.post(`/panel/api/inbounds/clientIps/${email}`).then((msg) => {
  545. if (msg.success) {
  546. try {
  547. return JSON.parse(msg.obj).join(', ');
  548. } catch (e) {
  549. return msg.obj;
  550. }
  551. }
  552. });
  553. }
  554. const infoModal = {
  555. visible: false,
  556. inbound: new Inbound(),
  557. dbInbound: new DBInbound(),
  558. clientSettings: null,
  559. clientStats: [],
  560. upStats: 0,
  561. downStats: 0,
  562. links: [],
  563. index: null,
  564. isExpired: false,
  565. subLink: '',
  566. subJsonLink: '',
  567. clientIps: '',
  568. show(dbInbound, index) {
  569. this.index = index;
  570. this.inbound = dbInbound.toInbound();
  571. this.dbInbound = new DBInbound(dbInbound);
  572. this.clientSettings = this.inbound.clients ? this.inbound.clients[index] : null;
  573. this.isExpired = this.inbound.clients ? this.inbound.isExpiry(index) : this.dbInbound.isExpiry;
  574. this.clientStats = this.inbound.clients ? (this.dbInbound.clientStats.find(row => row.email === this.clientSettings.email) || null) : null;
  575. if (
  576. [
  577. Protocols.VMESS,
  578. Protocols.VLESS,
  579. Protocols.TROJAN,
  580. Protocols.SHADOWSOCKS
  581. ].includes(this.inbound.protocol)
  582. ) {
  583. if (app.ipLimitEnable && this.clientSettings.limitIp) {
  584. refreshIPs(this.clientStats.email).then((ips) => {
  585. this.clientIps = ips;
  586. })
  587. }
  588. }
  589. if (this.inbound.protocol == Protocols.WIREGUARD) {
  590. this.links = this.inbound.genInboundLinks(dbInbound.remark).split('\r\n')
  591. } else {
  592. this.links = this.inbound.genAllLinks(this.dbInbound.remark, app.remarkModel, this.clientSettings);
  593. }
  594. if (this.clientSettings) {
  595. if (this.clientSettings.subId) {
  596. this.subLink = this.genSubLink(this.clientSettings.subId);
  597. this.subJsonLink = app.subSettings.subJsonEnable ? this.genSubJsonLink(this.clientSettings.subId) : '';
  598. }
  599. }
  600. this.visible = true;
  601. },
  602. close() {
  603. infoModal.visible = false;
  604. },
  605. genSubLink(subID) {
  606. return app.subSettings.subURI + subID;
  607. },
  608. genSubJsonLink(subID) {
  609. return app.subSettings.subJsonURI + subID;
  610. }
  611. };
  612. const infoModalApp = new Vue({
  613. delimiters: ['[[', ']]'],
  614. el: '#inbound-info-modal',
  615. data: {
  616. infoModal,
  617. refreshing: false,
  618. get dbInbound() {
  619. return this.infoModal.dbInbound;
  620. },
  621. get inbound() {
  622. return this.infoModal.inbound;
  623. },
  624. get isActive() {
  625. if (infoModal.clientStats) {
  626. return infoModal.clientStats.enable;
  627. }
  628. return true;
  629. },
  630. get isEnable() {
  631. if (infoModal.clientSettings) {
  632. return infoModal.clientSettings.enable;
  633. }
  634. return infoModal.dbInbound.isEnable;
  635. },
  636. get isDepleted() {
  637. const stats = infoModal.clientStats;
  638. const settings = infoModal.clientSettings;
  639. if (!stats || !settings) {
  640. return false;
  641. }
  642. const total = stats.total ?? 0;
  643. const used = (stats.up ?? 0) + (stats.down ?? 0);
  644. const hasTotal = total > 0;
  645. const exhausted = hasTotal && used >= total;
  646. const expiryTime = settings.expiryTime ?? 0;
  647. const hasExpiry = expiryTime > 0;
  648. const now = Date.now();
  649. const expired = hasExpiry && now >= expiryTime;
  650. return expired || exhausted;
  651. },
  652. },
  653. methods: {
  654. copy(content) {
  655. ClipboardManager
  656. .copyText(content)
  657. .then(() => {
  658. app.$message.success('{{ i18n "copied" }}')
  659. })
  660. },
  661. statsColor(stats) {
  662. return ColorUtils.usageColor(stats.up + stats.down, app.trafficDiff, stats.total);
  663. },
  664. getRemStats() {
  665. remained = this.infoModal.clientStats.total - this.infoModal.clientStats.up - this.infoModal.clientStats.down;
  666. return remained > 0 ? SizeFormatter.sizeFormat(remained) : '-';
  667. },
  668. refreshIPs() {
  669. this.refreshing = true;
  670. refreshIPs(this.infoModal.clientStats.email)
  671. .then((ips) => {
  672. this.infoModal.clientIps = ips;
  673. })
  674. .finally(() => {
  675. this.refreshing = false;
  676. });
  677. },
  678. clearClientIps() {
  679. HttpUtil.post(`/panel/api/inbounds/clearClientIps/${this.infoModal.clientStats.email}`)
  680. .then((msg) => {
  681. if (!msg.success) {
  682. return;
  683. }
  684. this.infoModal.clientIps = 'No IP Record';
  685. })
  686. .catch(() => {});
  687. },
  688. },
  689. });
  690. </script>
  691. {{end}}