inbound_info_modal.html 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805
  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. <div
  264. style="max-height: 150px; overflow-y: auto; text-align: left;">
  265. <div
  266. v-if="infoModal.clientIpsArray && infoModal.clientIpsArray.length > 0">
  267. <a-tag
  268. v-for="(ipInfo, idx) in infoModal.clientIpsArray"
  269. :key="idx"
  270. color="blue"
  271. style="margin: 2px 0; display: block; font-family: monospace; font-size: 11px;">
  272. [[ formatIpInfo(ipInfo) ]]
  273. </a-tag>
  274. </div>
  275. <a-tag v-else>[[ infoModal.clientIps || 'No IP Record'
  276. ]]</a-tag>
  277. </div>
  278. <div style="margin-top: 5px;">
  279. <a-icon type="sync" :spin="refreshing" @click="refreshIPs"
  280. :style="{ margin: '0 5px' }"></a-icon>
  281. <a-tooltip>
  282. <template slot="title">
  283. <span>{{ i18n "pages.inbounds.IPLimitlogclear" }}</span>
  284. </template>
  285. <a-icon type="delete" @click="clearClientIps"></a-icon>
  286. </a-tooltip>
  287. </div>
  288. </td>
  289. </tr>
  290. </table>
  291. <table
  292. :style="{ display: 'inline-table', marginBlock: '10px', width: '100%', textAlign: 'center' }">
  293. <tr>
  294. <th>{{ i18n "remained" }}</th>
  295. <th>{{ i18n "pages.inbounds.totalFlow" }}</th>
  296. <th>{{ i18n "pages.inbounds.expireDate" }}</th>
  297. </tr>
  298. <tr>
  299. <td>
  300. <a-tag
  301. v-if="infoModal.clientStats && infoModal.clientSettings.totalGB > 0"
  302. :color="statsColor(infoModal.clientStats)"> [[ getRemStats()
  303. ]] </a-tag>
  304. </td>
  305. <td>
  306. <a-tag v-if="infoModal.clientSettings.totalGB > 0"
  307. :color="statsColor(infoModal.clientStats)"> [[
  308. SizeFormatter.sizeFormat(infoModal.clientSettings.totalGB) ]]
  309. </a-tag>
  310. <a-tag v-else color="purple" class="infinite-tag">
  311. <svg height="10px" width="14px" viewBox="0 0 640 512"
  312. fill="currentColor">
  313. <path
  314. 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"
  315. fill="currentColor"></path>
  316. </svg>
  317. </a-tag>
  318. </td>
  319. <td>
  320. <template v-if="infoModal.clientSettings.expiryTime > 0">
  321. <a-tag
  322. :color="ColorUtils.usageColor(new Date().getTime(), app.expireDiff, infoModal.clientSettings.expiryTime)">
  323. [[ IntlUtil.formatDate(infoModal.clientSettings.expiryTime)
  324. ]]
  325. </a-tag>
  326. </template>
  327. <a-tag v-else-if="infoModal.clientSettings.expiryTime < 0"
  328. color="green">[[ infoModal.clientSettings.expiryTime /
  329. -86400000 ]] {{ i18n "pages.client.days" }}
  330. </a-tag>
  331. <a-tag v-else color="purple" class="infinite-tag">
  332. <svg height="10px" width="14px" viewBox="0 0 640 512"
  333. fill="currentColor">
  334. <path
  335. 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"
  336. fill="currentColor"></path>
  337. </svg>
  338. </a-tag>
  339. </td>
  340. </tr>
  341. </table>
  342. <template
  343. v-if="app.subSettings.enable && infoModal.clientSettings.subId">
  344. <a-divider>Subscription URL</a-divider>
  345. <tr-info-row class="tr-info-row">
  346. <tr-info-title class="tr-info-title">
  347. <a-tag color="purple">Subscription Link</a-tag>
  348. <a-tooltip title='{{ i18n "copy" }}'>
  349. <a-button size="small" icon="snippets"
  350. @click="copy(infoModal.subLink)"></a-button>
  351. </a-tooltip>
  352. </tr-info-title>
  353. <a :href="[[ infoModal.subLink ]]" target="_blank">[[
  354. infoModal.subLink ]]</a>
  355. </tr-info-row>
  356. <tr-info-row class="tr-info-row"
  357. v-if="app.subSettings.subJsonEnable">
  358. <tr-info-title class="tr-info-title">
  359. <a-tag color="purple">Json Link</a-tag>
  360. <a-tooltip title='{{ i18n "copy" }}'>
  361. <a-button size="small" icon="snippets"
  362. @click="copy(infoModal.subJsonLink)"></a-button>
  363. </a-tooltip>
  364. </tr-info-title>
  365. <a :href="[[ infoModal.subJsonLink ]]" target="_blank">[[
  366. infoModal.subJsonLink ]]</a>
  367. </tr-info-row>
  368. </template>
  369. <template v-if="app.tgBotEnable && infoModal.clientSettings.tgId">
  370. <a-divider>Telegram ChatID</a-divider>
  371. <tr-info-row class="tr-info-row">
  372. <tr-info-title class="tr-info-title">
  373. <a-tag color="blue">[[ infoModal.clientSettings.tgId ]]</a-tag>
  374. <a-tooltip title='{{ i18n "copy" }}'>
  375. <a-button size="small" icon="snippets"
  376. @click="copy(infoModal.clientSettings.tgId)"></a-button>
  377. </a-tooltip>
  378. </tr-info-title>
  379. </tr-info-row>
  380. </template>
  381. <template v-if="dbInbound.hasLink()">
  382. <a-divider>URL</a-divider>
  383. <tr-info-row v-for="(link,index) in infoModal.links"
  384. class="tr-info-row">
  385. <tr-info-title class="tr-info-title">
  386. <a-tag class="tr-info-tag" color="green">[[ link.remark
  387. ]]</a-tag>
  388. <a-tooltip title='{{ i18n "copy" }}'>
  389. <a-button :style="{ minWidth: '24px' }" size="small"
  390. icon="snippets" @click="copy(link.link)"></a-button>
  391. </a-tooltip>
  392. </tr-info-title>
  393. <code>[[ link.link ]]</code>
  394. </tr-info-row>
  395. </template>
  396. </template>
  397. <template v-else>
  398. <template v-if="dbInbound.isSS && !inbound.isSSMultiUser">
  399. <a-divider>URL</a-divider>
  400. <tr-info-row v-for="(link,index) in infoModal.links"
  401. class="tr-info-row">
  402. <tr-info-title class="tr-info-title">
  403. <a-tag class="tr-info-tag" color="green">[[ link.remark
  404. ]]</a-tag>
  405. <a-tooltip title='{{ i18n "copy" }}'>
  406. <a-button :style="{ minWidth: '24px' }" size="small"
  407. icon="snippets" @click="copy(link.link)"></a-button>
  408. </a-tooltip>
  409. </tr-info-title>
  410. <code>[[ link.link ]]</code>
  411. </tr-info-row>
  412. </template>
  413. <table v-if="inbound.protocol == Protocols.TUNNEL"
  414. class="tr-info-table">
  415. <tr>
  416. <th>{{ i18n "pages.inbounds.targetAddress" }}</th>
  417. <th>{{ i18n "pages.inbounds.destinationPort" }}</th>
  418. <th>{{ i18n "pages.inbounds.network" }}</th>
  419. <th>FollowRedirect</th>
  420. </tr>
  421. <tr>
  422. <td>
  423. <a-tag color="green">[[ inbound.settings.address ]]</a-tag>
  424. </td>
  425. <td>
  426. <a-tag color="green">[[ inbound.settings.port ]]</a-tag>
  427. </td>
  428. <td>
  429. <a-tag color="green">[[ inbound.settings.network ]]</a-tag>
  430. </td>
  431. <td>
  432. <a-tag color="green">[[ inbound.settings.followRedirect
  433. ]]</a-tag>
  434. </td>
  435. </tr>
  436. </table>
  437. <table v-if="dbInbound.isMixed" class="tr-info-table">
  438. <tr>
  439. <th>{{ i18n "password" }} Auth</th>
  440. <th>{{ i18n "pages.inbounds.enable" }} udp</th>
  441. <th>IP</th>
  442. </tr>
  443. <tr>
  444. <td>
  445. <a-tag color="green">[[ inbound.settings.auth ]]</a-tag>
  446. </td>
  447. <td>
  448. <a-tag color="green">[[ inbound.settings.udp]]</a-tag>
  449. </td>
  450. <td>
  451. <a-tag color="green">[[ inbound.settings.ip ]]</a-tag>
  452. </td>
  453. </tr>
  454. <template v-if="inbound.settings.auth == 'password'">
  455. <tr>
  456. <td></td>
  457. <td>{{ i18n "username" }}</td>
  458. <td>{{ i18n "password" }}</td>
  459. </tr>
  460. <tr v-for="account,index in inbound.settings.accounts">
  461. <td>[[ index ]]</td>
  462. <td>
  463. <a-tag color="green">[[ account.user ]]</a-tag>
  464. </td>
  465. <td>
  466. <a-tag color="green">[[ account.pass ]]</a-tag>
  467. </td>
  468. </tr>
  469. </template>
  470. </table>
  471. <table v-if="dbInbound.isHTTP" class="tr-info-table">
  472. <tr>
  473. <th></th>
  474. <th>{{ i18n "username" }}</th>
  475. <th>{{ i18n "password" }}</th>
  476. </tr>
  477. <tr v-for="account,index in inbound.settings.accounts">
  478. <td>[[ index ]]</td>
  479. <td>
  480. <a-tag color="green">[[ account.user ]]</a-tag>
  481. </td>
  482. <td>
  483. <a-tag color="green">[[ account.pass ]]</a-tag>
  484. </td>
  485. </tr>
  486. </table>
  487. <table v-if="dbInbound.isWireguard" class="tr-info-table">
  488. <tr class="client-table-odd-row">
  489. <td>{{ i18n "pages.xray.wireguard.secretKey" }}</td>
  490. <td>[[ inbound.settings.secretKey ]]</td>
  491. </tr>
  492. <tr>
  493. <td>{{ i18n "pages.xray.wireguard.publicKey" }}</td>
  494. <td>[[ inbound.settings.pubKey ]]</td>
  495. </tr>
  496. <tr class="client-table-odd-row">
  497. <td>MTU</td>
  498. <td>[[ inbound.settings.mtu ]]</td>
  499. </tr>
  500. <tr>
  501. <td>No Kernel Tun</td>
  502. <td>[[ inbound.settings.noKernelTun ]]</td>
  503. </tr>
  504. <template v-for="(peer, index) in inbound.settings.peers">
  505. <tr>
  506. <td colspan="2">
  507. <a-divider>Peer [[ index + 1 ]]</a-divider>
  508. </td>
  509. </tr>
  510. <tr class="client-table-odd-row">
  511. <td>{{ i18n "pages.xray.wireguard.secretKey" }}</td>
  512. <td>[[ peer.privateKey ]]</td>
  513. </tr>
  514. <tr>
  515. <td>{{ i18n "pages.xray.wireguard.publicKey" }}</td>
  516. <td>[[ peer.publicKey ]]</td>
  517. </tr>
  518. <tr class="client-table-odd-row">
  519. <td>{{ i18n "pages.xray.wireguard.psk" }}</td>
  520. <td>[[ peer.psk ]]</td>
  521. </tr>
  522. <tr>
  523. <td>{{ i18n "pages.xray.wireguard.allowedIPs" }}</td>
  524. <td>[[ peer.allowedIPs.join(",") ]]</td>
  525. </tr>
  526. <tr class="client-table-odd-row">
  527. <td>Keep Alive</td>
  528. <td>[[ peer.keepAlive ]]</td>
  529. </tr>
  530. <tr>
  531. <td colspan="2">
  532. <tr-info-row class="tr-info-row">
  533. <tr-info-title class="tr-info-title">
  534. <a-tag color="blue">Config</a-tag>
  535. <a-tooltip title='{{ i18n "copy" }}'>
  536. <a-button :style="{ minWidth: '24px' }" size="small"
  537. icon="snippets"
  538. @click="copy(infoModal.links[index])"></a-button>
  539. </a-tooltip>
  540. <a-tooltip title='{{ i18n "download" }}'>
  541. <a-button :style="{ minWidth: '24px' }" size="small"
  542. icon="download"
  543. @click="FileManager.downloadTextFile(infoModal.links[index], `peer-${index + 1}.conf`)"></a-button>
  544. </a-tooltip>
  545. </tr-info-title>
  546. <div
  547. v-html="infoModal.links[index].replaceAll(`\n`,`<br />`)"
  548. :style="{ borderRadius: '1rem', padding: '0.5rem' }"
  549. class="client-table-odd-row">
  550. </div>
  551. </tr-info-row>
  552. </td>
  553. </tr>
  554. </table>
  555. </template>
  556. </template>
  557. </a-modal>
  558. <script>
  559. function refreshIPs(email) {
  560. return HttpUtil.post(`/panel/api/inbounds/clientIps/${email}`).then((msg) => {
  561. if (!msg.success) {
  562. return { text: 'No IP Record', array: [] };
  563. }
  564. const formatIpRecord = (record) => {
  565. if (record == null) {
  566. return '';
  567. }
  568. if (typeof record === 'string' || typeof record === 'number') {
  569. return String(record);
  570. }
  571. const ip = record.ip || record.IP || '';
  572. const timestamp = record.timestamp || record.Timestamp || 0;
  573. if (!ip) {
  574. return String(record);
  575. }
  576. if (!timestamp) {
  577. return String(ip);
  578. }
  579. const date = new Date(Number(timestamp) * 1000);
  580. const timeStr = date
  581. .toLocaleString('en-GB', {
  582. year: 'numeric',
  583. month: '2-digit',
  584. day: '2-digit',
  585. hour: '2-digit',
  586. minute: '2-digit',
  587. second: '2-digit',
  588. hour12: false,
  589. })
  590. .replace(',', '');
  591. return `${ip} (${timeStr})`;
  592. };
  593. try {
  594. let ips = msg.obj;
  595. // If msg.obj is a string, try to parse it
  596. if (typeof ips === 'string') {
  597. try {
  598. ips = JSON.parse(ips);
  599. } catch (e) {
  600. return { text: String(ips), array: [String(ips)] };
  601. }
  602. }
  603. // Normalize single object response to array
  604. if (ips && !Array.isArray(ips) && typeof ips === 'object') {
  605. ips = [ips];
  606. }
  607. // New format or object array
  608. if (Array.isArray(ips) && ips.length > 0 && typeof ips[0] === 'object') {
  609. const result = ips.map((item) => formatIpRecord(item)).filter(Boolean);
  610. return { text: result.join(' | '), array: result };
  611. }
  612. // Old format - simple array of IPs
  613. if (Array.isArray(ips) && ips.length > 0) {
  614. const result = ips.map((ip) => String(ip));
  615. return { text: result.join(', '), array: result };
  616. }
  617. // Fallback for any other format
  618. return { text: String(ips), array: [String(ips)] };
  619. } catch (e) {
  620. return { text: 'Error loading IPs', array: [] };
  621. }
  622. });
  623. }
  624. const infoModal = {
  625. visible: false,
  626. inbound: new Inbound(),
  627. dbInbound: new DBInbound(),
  628. clientSettings: null,
  629. clientStats: [],
  630. upStats: 0,
  631. downStats: 0,
  632. links: [],
  633. index: null,
  634. isExpired: false,
  635. subLink: '',
  636. subJsonLink: '',
  637. clientIps: '',
  638. clientIpsArray: [],
  639. show(dbInbound, index) {
  640. this.index = index;
  641. this.inbound = dbInbound.toInbound();
  642. this.dbInbound = new DBInbound(dbInbound);
  643. this.clientSettings = this.inbound.clients ? this.inbound.clients[index] : null;
  644. this.isExpired = this.inbound.clients ? this.inbound.isExpiry(index) : this.dbInbound.isExpiry;
  645. this.clientStats = this.inbound.clients ? (this.dbInbound.clientStats.find(row => row.email === this.clientSettings.email) || null) : null;
  646. if (
  647. [
  648. Protocols.VMESS,
  649. Protocols.VLESS,
  650. Protocols.TROJAN,
  651. Protocols.SHADOWSOCKS
  652. ].includes(this.inbound.protocol)
  653. ) {
  654. if (app.ipLimitEnable && this.clientSettings.limitIp) {
  655. refreshIPs(this.clientStats.email).then((result) => {
  656. this.clientIps = result.text;
  657. this.clientIpsArray = result.array;
  658. })
  659. }
  660. }
  661. if (this.inbound.protocol == Protocols.WIREGUARD) {
  662. this.links = this.inbound.genInboundLinks(dbInbound.remark).split('\r\n')
  663. } else {
  664. this.links = this.inbound.genAllLinks(this.dbInbound.remark, app.remarkModel, this.clientSettings);
  665. }
  666. if (this.clientSettings) {
  667. if (this.clientSettings.subId) {
  668. this.subLink = this.genSubLink(this.clientSettings.subId);
  669. this.subJsonLink = app.subSettings.subJsonEnable ? this.genSubJsonLink(this.clientSettings.subId) : '';
  670. }
  671. }
  672. this.visible = true;
  673. },
  674. close() {
  675. infoModal.visible = false;
  676. },
  677. genSubLink(subID) {
  678. return app.subSettings.subURI + subID;
  679. },
  680. genSubJsonLink(subID) {
  681. return app.subSettings.subJsonURI + subID;
  682. }
  683. };
  684. const infoModalApp = new Vue({
  685. delimiters: ['[[', ']]'],
  686. el: '#inbound-info-modal',
  687. data: {
  688. infoModal,
  689. refreshing: false,
  690. get dbInbound() {
  691. return this.infoModal.dbInbound;
  692. },
  693. get inbound() {
  694. return this.infoModal.inbound;
  695. },
  696. get isActive() {
  697. if (infoModal.clientStats) {
  698. return infoModal.clientStats.enable;
  699. }
  700. return true;
  701. },
  702. get isEnable() {
  703. if (infoModal.clientSettings) {
  704. return infoModal.clientSettings.enable;
  705. }
  706. return infoModal.dbInbound.isEnable;
  707. },
  708. get isDepleted() {
  709. const stats = infoModal.clientStats;
  710. const settings = infoModal.clientSettings;
  711. if (!stats || !settings) {
  712. return false;
  713. }
  714. const total = stats.total ?? 0;
  715. const used = (stats.up ?? 0) + (stats.down ?? 0);
  716. const hasTotal = total > 0;
  717. const exhausted = hasTotal && used >= total;
  718. const expiryTime = settings.expiryTime ?? 0;
  719. const hasExpiry = expiryTime > 0;
  720. const now = Date.now();
  721. const expired = hasExpiry && now >= expiryTime;
  722. return expired || exhausted;
  723. },
  724. },
  725. methods: {
  726. formatIpInfo(ipInfo) {
  727. if (ipInfo == null) {
  728. return '';
  729. }
  730. if (typeof ipInfo === 'string' || typeof ipInfo === 'number') {
  731. return String(ipInfo);
  732. }
  733. const ip = ipInfo.ip || ipInfo.IP || '';
  734. const timestamp = ipInfo.timestamp || ipInfo.Timestamp || 0;
  735. if (!ip) {
  736. return String(ipInfo);
  737. }
  738. if (!timestamp) {
  739. return String(ip);
  740. }
  741. const date = new Date(Number(timestamp) * 1000);
  742. const timeStr = date
  743. .toLocaleString('en-GB', {
  744. year: 'numeric',
  745. month: '2-digit',
  746. day: '2-digit',
  747. hour: '2-digit',
  748. minute: '2-digit',
  749. second: '2-digit',
  750. hour12: false,
  751. })
  752. .replace(',', '');
  753. return `${ip} (${timeStr})`;
  754. },
  755. copy(content) {
  756. ClipboardManager
  757. .copyText(content)
  758. .then(() => {
  759. app.$message.success('{{ i18n "copied" }}')
  760. })
  761. },
  762. statsColor(stats) {
  763. return ColorUtils.usageColor(stats.up + stats.down, app.trafficDiff, stats.total);
  764. },
  765. getRemStats() {
  766. remained = this.infoModal.clientStats.total - this.infoModal.clientStats.up - this.infoModal.clientStats.down;
  767. return remained > 0 ? SizeFormatter.sizeFormat(remained) : '-';
  768. },
  769. refreshIPs() {
  770. this.refreshing = true;
  771. refreshIPs(this.infoModal.clientStats.email)
  772. .then((result) => {
  773. this.infoModal.clientIps = result.text;
  774. this.infoModal.clientIpsArray = result.array;
  775. })
  776. .finally(() => {
  777. this.refreshing = false;
  778. });
  779. },
  780. clearClientIps() {
  781. HttpUtil.post(`/panel/api/inbounds/clearClientIps/${this.infoModal.clientStats.email}`)
  782. .then((msg) => {
  783. if (!msg.success) {
  784. return;
  785. }
  786. this.infoModal.clientIps = 'No IP Record';
  787. this.infoModal.clientIpsArray = [];
  788. })
  789. .catch(() => {});
  790. },
  791. },
  792. });
  793. </script>
  794. {{end}}