1
0

inbound_info_modal.html 15 KB

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