1
0

inbound_info_modal.html 29 KB

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