inbound_info_modal.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. {{define "inboundInfoModal"}}
  2. <a-modal id="inbound-info-modal"
  3. v-model="infoModal.visible" title='{{ i18n "pages.inbounds.details"}}'
  4. :closable="true"
  5. :mask-closable="true"
  6. :class="themeSwitcher.darkCardClass"
  7. :footer="null"
  8. width="600px"
  9. >
  10. <table style="margin-bottom: 10px; width: 100%;">
  11. <tr><td>
  12. <table>
  13. <tr><td>{{ i18n "protocol" }}</td><td><a-tag color="green">[[ dbInbound.protocol ]]</a-tag></td></tr>
  14. <tr><td>{{ i18n "pages.inbounds.address" }}</td><td><a-tag color="blue">[[ dbInbound.address ]]</a-tag></td></tr>
  15. <tr><td>{{ i18n "pages.inbounds.port" }}</td><td><a-tag color="green">[[ dbInbound.port ]]</a-tag></td></tr>
  16. </table>
  17. </td>
  18. <td v-if="dbInbound.isVMess || dbInbound.isVLess || dbInbound.isTrojan || dbInbound.isSS">
  19. <table>
  20. <tr>
  21. <td>{{ i18n "transmission" }}</td><td><a-tag color="green">[[ inbound.network ]]</a-tag></td>
  22. </tr>
  23. <template v-if="inbound.isTcp || inbound.isWs || inbound.isH2">
  24. <tr v-if="inbound.host"><td>{{ i18n "host" }}</td><td><a-tag color="green">[[ inbound.host ]]</a-tag></td></tr>
  25. <tr v-else><td>{{ i18n "host" }}</td><td><a-tag color="orange">{{ i18n "none" }}</a-tag></td></tr>
  26. <tr v-if="inbound.path"><td>{{ i18n "path" }}</td><td><a-tag color="green">[[ inbound.path ]]</a-tag></td></tr>
  27. <tr v-else><td>{{ i18n "path" }}</td><td><a-tag color="orange">{{ i18n "none" }}</a-tag></td></tr>
  28. </template>
  29. <template v-if="inbound.isQuic">
  30. <tr><td>quic {{ i18n "encryption" }}</td><td><a-tag color="green">[[ inbound.quicSecurity ]]</a-tag></td></tr>
  31. <tr><td>quic {{ i18n "password" }}</td><td><a-tag color="green">[[ inbound.quicKey ]]</a-tag></td></tr>
  32. <tr><td>quic {{ i18n "camouflage" }}</td><td><a-tag color="green">[[ inbound.quicType ]]</a-tag></td></tr>
  33. </template>
  34. <template v-if="inbound.isKcp">
  35. <tr><td>kcp {{ i18n "encryption" }}</td><td><a-tag color="green">[[ inbound.kcpType ]]</a-tag></td></tr>
  36. <tr><td>kcp {{ i18n "password" }}</td><td><a-tag color="green">[[ inbound.kcpSeed ]]</a-tag></td></tr>
  37. </template>
  38. <template v-if="inbound.isGrpc">
  39. <tr><td>grpc serviceName</td><td><a-tag color="green">[[ inbound.serviceName ]]</a-tag></td></tr>
  40. <tr><td>grpc multiMode</td><td><a-tag color="green">[[ inbound.stream.grpc.multiMode ]]</a-tag></td></tr>
  41. </template>
  42. </table>
  43. </td></tr>
  44. <tr colspan="2" v-if="dbInbound.hasLink()">
  45. <td v-if="inbound.tls">
  46. tls: <a-tag color="green">{{ i18n "enabled" }}</a-tag><br />
  47. tls {{ i18n "domainName" }}: <a-tag :color="inbound.serverName ? 'green' : 'orange'">[[ inbound.serverName ? inbound.serverName : '' ]]</a-tag>
  48. </td>
  49. <td v-else-if="inbound.xtls">
  50. xtls: <a-tag color="green">{{ i18n "enabled" }}</a-tag><br />
  51. xtls {{ i18n "domainName" }}: <a-tag :color="inbound.serverName ? 'green' : 'orange'">[[ inbound.serverName ? inbound.serverName : '' ]]</a-tag>
  52. </td>
  53. <td v-else-if="inbound.reality">
  54. reality: <a-tag color="green">{{ i18n "enabled" }}</a-tag><br />
  55. reality Destination: <a-tag :color="inbound.stream.reality.dest ? 'green' : 'orange'">[[ inbound.stream.reality.dest ]]</a-tag>
  56. </td>
  57. <td v-else>tls: <a-tag color="red">{{ i18n "disabled" }}</a-tag>
  58. </td>
  59. </tr>
  60. </table>
  61. <template v-if="infoModal.clientSettings">
  62. <a-divider>{{ i18n "pages.inbounds.client" }}</a-divider>
  63. <table style="margin-bottom: 10px;">
  64. <tr>
  65. <td>{{ i18n "pages.inbounds.email" }}</td>
  66. <td><a-tag color="green">[[ infoModal.clientSettings.email ]]</a-tag></td>
  67. </tr>
  68. <tr v-if="infoModal.clientSettings.id">
  69. <td>ID</td>
  70. <td><a-tag color="green">[[ infoModal.clientSettings.id ]]</a-tag></td>
  71. </tr>
  72. <tr v-if="infoModal.inbound.canEnableTlsFlow()">
  73. <td>Flow</td>
  74. <td><a-tag color="green">[[ infoModal.clientSettings.flow ]]</a-tag></td>
  75. </tr>
  76. <tr v-if="infoModal.clientSettings.password">
  77. <td>Password</td>
  78. <td><a-tag color="green">[[ infoModal.clientSettings.password ]]</a-tag></td>
  79. </tr>
  80. <tr>
  81. <td>{{ i18n "status" }}</td>
  82. <td>
  83. <a-tag v-if="isEnable" color="blue">{{ i18n "enabled" }}</a-tag>
  84. <a-tag v-else color="red">{{ i18n "disabled" }}</a-tag>
  85. <a-tag v-if="!isActive" color="red">{{ i18n "depleted" }}</a-tag>
  86. </td>
  87. </tr>
  88. <tr v-if="infoModal.clientStats">
  89. <td>{{ i18n "usage" }}</td>
  90. <td>
  91. <a-tag color="green">[[ sizeFormat(infoModal.clientStats.up + infoModal.clientStats.down) ]]</a-tag>
  92. <a-tag color="blue">↑ [[ sizeFormat(infoModal.clientStats.up) ]] / [[ sizeFormat(infoModal.clientStats.down) ]] ↓</a-tag>
  93. </td>
  94. </tr>
  95. </table>
  96. <table style="margin-bottom: 10px; width: 100%;">
  97. <tr>
  98. <th>{{ i18n "remained" }}</th>
  99. <th>{{ i18n "pages.inbounds.totalFlow" }}</th>
  100. <th>{{ i18n "pages.inbounds.expireDate" }}</th>
  101. </tr>
  102. <tr>
  103. <td>
  104. <a-tag v-if="infoModal.clientStats && infoModal.clientSettings.totalGB > 0" :color="statsColor(infoModal.clientStats)">
  105. [[ sizeFormat(infoModal.clientSettings.totalGB - infoModal.clientStats.up - infoModal.clientStats.down) ]]
  106. </a-tag>
  107. </td>
  108. <td>
  109. <a-tag v-if="infoModal.clientSettings.totalGB > 0" :color="statsColor(infoModal.clientStats)">
  110. [[ sizeFormat(infoModal.clientSettings.totalGB) ]]
  111. </a-tag>
  112. <a-tag v-else color="green">{{ i18n "indefinite" }}</a-tag>
  113. </td>
  114. <td>
  115. <template v-if="infoModal.clientSettings.expiryTime > 0">
  116. <a-tag :color="usageColor(new Date().getTime(), app.expireDiff, infoModal.clientSettings.expiryTime)">
  117. [[ DateUtil.formatMillis(infoModal.clientSettings.expiryTime) ]]
  118. </a-tag>
  119. </template>
  120. <a-tag v-else-if="infoModal.clientSettings.expiryTime < 0" color="cyan">[[ infoModal.clientSettings.expiryTime / -86400000 ]] {{ i18n "pages.client.days" }}</a-tag>
  121. <a-tag v-else color="green">{{ i18n "indefinite" }}</a-tag>
  122. </td>
  123. </tr>
  124. </table>
  125. <template v-if="app.subSettings.enable && infoModal.clientSettings.subId">
  126. <a-divider>Subscription link</a-divider>
  127. <a-row>
  128. <a-col :span="22"><a :href="[[ infoModal.subLink ]]" target="_blank">[[ infoModal.subLink ]]</a></a-col>
  129. <a-col :span="2">
  130. <a-tooltip title='{{ i18n "copy" }}'>
  131. <button class="ant-btn ant-btn-primary" id="copy-sub-link" @click="copyToClipboard('copy-sub-link', infoModal.subLink)">
  132. <a-icon type="snippets"></a-icon>
  133. </button>
  134. </a-tooltip>
  135. </a-col>
  136. </a-row>
  137. </template>
  138. <template v-if="app.tgBotEnable && infoModal.clientSettings.tgId">
  139. <a-divider>Telegram Username</a-divider>
  140. <a-row>
  141. <a-col :span="22"><a :href="[[ infoModal.tgLink ]]" target="_blank">@[[ infoModal.clientSettings.tgId ]]</a></a-col>
  142. <a-col :span="2">
  143. <a-tooltip title='{{ i18n "copy" }}'>
  144. <button class="ant-btn ant-btn-primary" id="copy-tg-link" @click="copyToClipboard('copy-tg-link', '@' + infoModal.clientSettings.tgId)">
  145. <a-icon type="snippets"></a-icon>
  146. </button>
  147. </a-tooltip>
  148. </a-col>
  149. </a-row>
  150. </template>
  151. <template v-if="dbInbound.hasLink()">
  152. <a-divider>URL</a-divider>
  153. <a-row v-for="(link,index) in infoModal.links">
  154. <a-col :span="22"><a-tag color="cyan">[[ link.remark ]]</a-tag><br />[[ link.link ]]</a-col>
  155. <a-col :span="2" style="text-align: right;">
  156. <a-tooltip title='{{ i18n "copy" }}'>
  157. <button class="ant-btn ant-btn-primary" :id="'copy-url-link-'+index" @click="copyToClipboard('copy-url-link-'+index, link.link)">
  158. <a-icon type="snippets"></a-icon>
  159. </button>
  160. </a-tooltip>
  161. </a-col>
  162. </a-row>
  163. </template>
  164. </template>
  165. <template v-else>
  166. <a-divider></a-divider>
  167. <table v-if="inbound.protocol == Protocols.SHADOWSOCKS" style="margin-bottom: 10px; width: 100%;">
  168. <tr>
  169. <th>{{ i18n "encryption" }}</th>
  170. <th>{{ i18n "password" }}</th>
  171. <th>{{ i18n "pages.inbounds.network" }}</th>
  172. </tr><tr>
  173. <td><a-tag color="green">[[ inbound.settings.method ]]</a-tag></td>
  174. <td><a-tag color="blue">[[ inbound.settings.password ]]</a-tag></td>
  175. <td><a-tag color="green">[[ inbound.settings.network ]]</a-tag></td>
  176. </tr>
  177. </table>
  178. <table v-if="inbound.protocol == Protocols.DOKODEMO" style="margin-bottom: 10px; width: 100%;">
  179. <tr>
  180. <th>{{ i18n "pages.inbounds.targetAddress" }}</th>
  181. <th>{{ i18n "pages.inbounds.destinationPort" }}</th>
  182. <th>{{ i18n "pages.inbounds.network" }}</th>
  183. <th>FollowRedirect</th>
  184. </tr><tr>
  185. <td><a-tag color="green">[[ inbound.settings.address ]]</a-tag></td>
  186. <td><a-tag color="blue">[[ inbound.settings.port ]]</a-tag></td>
  187. <td><a-tag color="green">[[ inbound.settings.network ]]</a-tag></td>
  188. <td><a-tag color="blue">[[ inbound.settings.followRedirect ]]</a-tag></td>
  189. </tr>
  190. </table>
  191. </table>
  192. <table v-if="inbound.protocol == Protocols.SOCKS" style="margin-bottom: 10px; width: 100%;">
  193. <tr>
  194. <th>{{ i18n "password" }} Auth</th>
  195. <th>{{ i18n "pages.inbounds.enable" }} udp</th>
  196. <th>IP</th>
  197. </tr><tr>
  198. <td><a-tag color="green">[[ inbound.settings.auth ]]</a-tag></td>
  199. <td><a-tag color="blue">[[ inbound.settings.udp]]</a-tag></td>
  200. <td><a-tag color="green">[[ inbound.settings.ip ]]</a-tag></td>
  201. </tr><tr v-if="inbound.settings.auth == 'password'">
  202. <td> </td>
  203. <td>{{ i18n "username" }}</td>
  204. <td>{{ i18n "password" }}</td>
  205. </tr><tr v-for="account,index in inbound.settings.accounts">
  206. <td><a-tag color="green">[[ index ]]</a-tag></td>
  207. <td><a-tag color="blue">[[ account.user ]]</a-tag></td>
  208. <td><a-tag color="green">[[ account.pass ]]</a-tag></td>
  209. </tr>
  210. </table>
  211. </table>
  212. <table v-if="inbound.protocol == Protocols.HTTP" style="margin-bottom: 10px; width: 100%;">
  213. <tr>
  214. <th> </th>
  215. <th>{{ i18n "username" }}</th>
  216. <th>{{ i18n "password" }}</th>
  217. </tr><tr v-for="account,index in inbound.settings.accounts">
  218. <td><a-tag color="green">[[ index ]]</a-tag></td>
  219. <td><a-tag color="blue">[[ account.user ]]</a-tag></td>
  220. <td><a-tag color="green">[[ account.pass ]]</a-tag></td>
  221. </tr>
  222. </table>
  223. </table>
  224. </template>
  225. </a-modal>
  226. <script>
  227. const infoModal = {
  228. visible: false,
  229. inbound: new Inbound(),
  230. dbInbound: new DBInbound(),
  231. settings: null,
  232. clientSettings: null,
  233. clientStats: [],
  234. upStats: 0,
  235. downStats: 0,
  236. clipboard: null,
  237. links: [],
  238. index: null,
  239. isExpired: false,
  240. subLink: '',
  241. tgLink: '',
  242. show(dbInbound, index) {
  243. this.index = index;
  244. this.inbound = dbInbound.toInbound();
  245. this.dbInbound = new DBInbound(dbInbound);
  246. this.settings = JSON.parse(this.inbound.settings);
  247. this.clientSettings = this.settings.clients ? Object.values(this.settings.clients)[index] : null;
  248. this.isExpired = this.inbound.isExpiry(index);
  249. this.clientStats = this.settings.clients ? this.dbInbound.clientStats.find(row => row.email === this.clientSettings.email) : [];
  250. remark = this.dbInbound.remark + "-" + this.clientSettings.email;
  251. address = this.dbInbound.address;
  252. this.links = [];
  253. if (this.inbound.tls && !ObjectUtil.isArrEmpty(this.inbound.stream.tls.settings.domains)) {
  254. this.inbound.stream.tls.settings.domains.forEach((domain) => {
  255. this.links.push({
  256. remark: remark + "-" + domain.remark,
  257. link: this.inbound.genLink(domain.domain, remark + "-" + domain.remark, index)
  258. });
  259. });
  260. } else {
  261. this.links.push({
  262. remark: remark,
  263. link: this.inbound.genLink(address, remark, index)
  264. });
  265. }
  266. if (this.clientSettings) {
  267. if (this.clientSettings.subId) {
  268. this.subLink = this.genSubLink(this.clientSettings.subId);
  269. }
  270. if (this.clientSettings.tgId) {
  271. this.tgLink = "https://t.me/" + this.clientSettings.tgId;
  272. }
  273. }
  274. this.visible = true;
  275. },
  276. close() {
  277. infoModal.visible = false;
  278. },
  279. genSubLink(subID) {
  280. const { domain: host, port, tls: isTLS, path: base } = app.subSettings;
  281. return buildURL({ host, port, isTLS, base, path: subID });
  282. }
  283. };
  284. const infoModalApp = new Vue({
  285. delimiters: ['[[', ']]'],
  286. el: '#inbound-info-modal',
  287. data: {
  288. infoModal,
  289. get dbInbound() {
  290. return this.infoModal.dbInbound;
  291. },
  292. get inbound() {
  293. return this.infoModal.inbound;
  294. },
  295. get isActive() {
  296. if (infoModal.clientStats) {
  297. return infoModal.clientStats.enable;
  298. }
  299. return infoModal.dbInbound.isEnable;
  300. },
  301. get isEnable() {
  302. if (infoModal.clientSettings) {
  303. return infoModal.clientSettings.enable;
  304. }
  305. return infoModal.dbInbound.isEnable;
  306. },
  307. },
  308. methods: {
  309. copyToClipboard(elmentId, content) {
  310. this.infoModal.clipboard = new ClipboardJS('#' + elmentId, {
  311. text: () => content,
  312. });
  313. this.infoModal.clipboard.on('success', () => {
  314. app.$message.success('{{ i18n "copied" }}')
  315. this.infoModal.clipboard.destroy();
  316. });
  317. },
  318. statsColor(stats) {
  319. return usageColor(stats.up + stats.down, app.trafficDiff, stats.total);
  320. }
  321. },
  322. });
  323. </script>
  324. {{end}}