1
0

inbound_info_modal.html 28 KB

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