inbound_info_modal.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  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 v-for="col,index in Object.keys(infoModal.clientSettings).slice(0, 3)">
  67. <td>[[ col ]]</td>
  68. <td><a-tag color="green">[[ infoModal.clientSettings[col] ]]</a-tag></td>
  69. </tr>
  70. <tr>
  71. <td>{{ i18n "status" }}</td>
  72. <td>
  73. <a-tag v-if="isEnable" color="blue">{{ i18n "enabled" }}</a-tag>
  74. <a-tag v-else color="red">{{ i18n "disabled" }}</a-tag>
  75. <a-tag v-if="!isActive" color="red">{{ i18n "depleted" }}</a-tag>
  76. </td>
  77. </tr>
  78. </table>
  79. <table style="margin-bottom: 10px; width: 100%;">
  80. <tr>
  81. <th>{{ i18n "usage" }}</th>
  82. <th>{{ i18n "pages.inbounds.totalFlow" }}</th>
  83. <th>{{ i18n "pages.inbounds.expireDate" }}</th>
  84. <tr>
  85. <td>
  86. <a-tag v-if="infoModal.clientStats" color="green">
  87. [[ sizeFormat(infoModal.clientStats['up']) ]] /
  88. [[ sizeFormat(infoModal.clientStats['down']) ]]
  89. ([[ sizeFormat(infoModal.clientStats['up'] + infoModal.clientStats['down']) ]])
  90. </a-tag>
  91. </td>
  92. <td>
  93. <a-tag v-if="infoModal.clientSettings.totalGB > 0" :color="statsColor(infoModal.clientStats)">[[ sizeFormat(infoModal.clientSettings.totalGB) ]]</a-tag>
  94. <a-tag v-else color="green">{{ i18n "indefinite" }}</a-tag>
  95. </td>
  96. <td>
  97. <template v-if="infoModal.clientSettings.expiryTime > 0">
  98. <a-tag :color="usageColor(new Date().getTime(), app.expireDiff, infoModal.clientSettings.expiryTime)">
  99. [[ DateUtil.formatMillis(infoModal.clientSettings.expiryTime) ]]
  100. </a-tag>
  101. </template>
  102. <a-tag v-else-if="infoModal.clientSettings.expiryTime < 0" color="cyan">[[ infoModal.clientSettings.expiryTime / -86400000 ]] {{ i18n "pages.client.days" }}</a-tag>
  103. <a-tag v-else color="green">{{ i18n "indefinite" }}</a-tag>
  104. </td>
  105. </tr>
  106. </table>
  107. <template v-if="app.subSettings.enable && infoModal.clientSettings.subId">
  108. <a-divider>Subscription link</a-divider>
  109. <a :href="[[ infoModal.subLink ]]" target="_blank">[[ infoModal.subLink ]]</a>
  110. <a-icon id="copy-sub-link" type="snippets" @click="copyToClipboard('copy-sub-link', infoModal.subLink)"></a-icon>
  111. </template>
  112. <template v-if="app.tgBotEnable && infoModal.clientSettings.tgId">
  113. <a-divider>Telegram Username</a-divider>
  114. <a :href="[[ infoModal.tgLink ]]" target="_blank">@[[ infoModal.clientSettings.tgId ]]</a>
  115. <a-icon id="copy-tg-link" type="snippets" @click="copyToClipboard('copy-tg-link', '@' + infoModal.clientSettings.tgId)"></a-icon>
  116. </template>
  117. </template>
  118. <template v-else>
  119. <a-divider></a-divider>
  120. <table v-if="inbound.protocol == Protocols.SHADOWSOCKS" style="margin-bottom: 10px; width: 100%;">
  121. <tr>
  122. <th>{{ i18n "encryption" }}</th>
  123. <th>{{ i18n "password" }}</th>
  124. <th>{{ i18n "pages.inbounds.network" }}</th>
  125. </tr>
  126. <tr>
  127. <td><a-tag color="green">[[ inbound.settings.method ]]</a-tag></td>
  128. <td><a-tag color="blue">[[ inbound.settings.password ]]</a-tag></td>
  129. <td><a-tag color="green">[[ inbound.settings.network ]]</a-tag></td>
  130. </tr>
  131. </table>
  132. <table v-if="inbound.protocol == Protocols.DOKODEMO" style="margin-bottom: 10px; width: 100%;">
  133. <tr>
  134. <th>{{ i18n "pages.inbounds.targetAddress" }}</th>
  135. <th>{{ i18n "pages.inbounds.destinationPort" }}</th>
  136. <th>{{ i18n "pages.inbounds.network" }}</th>
  137. <th>FollowRedirect</th>
  138. </tr>
  139. <tr>
  140. <td><a-tag color="green">[[ inbound.settings.address ]]</a-tag></td>
  141. <td><a-tag color="blue">[[ inbound.settings.port ]]</a-tag></td>
  142. <td><a-tag color="green">[[ inbound.settings.network ]]</a-tag></td>
  143. <td><a-tag color="blue">[[ inbound.settings.followRedirect ]]</a-tag></td>
  144. </tr>
  145. </table>
  146. </table>
  147. <table v-if="inbound.protocol == Protocols.SOCKS" style="margin-bottom: 10px; width: 100%;">
  148. <tr>
  149. <th>{{ i18n "password" }} Auth</th>
  150. <th>{{ i18n "pages.inbounds.enable" }} udp</th>
  151. <th>IP</th>
  152. </tr>
  153. <tr>
  154. <td><a-tag color="green">[[ inbound.settings.auth ]]</a-tag></td>
  155. <td><a-tag color="blue">[[ inbound.settings.udp]]</a-tag></td>
  156. <td><a-tag color="green">[[ inbound.settings.ip ]]</a-tag></td>
  157. </tr>
  158. <tr v-if="inbound.settings.auth == 'password'">
  159. <td> </td>
  160. <td>{{ i18n "username" }}</td>
  161. <td>{{ i18n "password" }}</td>
  162. </tr>
  163. <tr v-for="account,index in inbound.settings.accounts">
  164. <td><a-tag color="green">[[ index ]]</a-tag></td>
  165. <td><a-tag color="blue">[[ account.user ]]</a-tag></td>
  166. <td><a-tag color="green">[[ account.pass ]]</a-tag></td>
  167. </tr>
  168. </table>
  169. </table>
  170. <table v-if="inbound.protocol == Protocols.HTTP" style="margin-bottom: 10px; width: 100%;">
  171. <tr>
  172. <th> </th>
  173. <th>{{ i18n "username" }}</th>
  174. <th>{{ i18n "password" }}</th>
  175. </tr>
  176. <tr v-for="account,index in inbound.settings.accounts">
  177. <td><a-tag color="green">[[ index ]]</a-tag></td>
  178. <td><a-tag color="blue">[[ account.user ]]</a-tag></td>
  179. <td><a-tag color="green">[[ account.pass ]]</a-tag></td>
  180. </tr>
  181. </table>
  182. </table>
  183. </template>
  184. <div v-if="dbInbound.hasLink()">
  185. <a-divider>URL</a-divider>
  186. <a-row v-for="(link,index) in infoModal.links">
  187. <a-col :span="21"><a-tag color="cyan">[[ link.remark ]]</a-tag><br />[[ link.link ]]</a-col>
  188. <a-col :span="3" style="text-align: right;">
  189. <button class="ant-btn ant-btn-primary" :id="'copy-url-link-'+index" @click="copyToClipboard('copy-url-link-'+index, link.link)">
  190. <a-icon type="snippets"></a-icon>{{ i18n "copy" }}
  191. </button>
  192. </a-col>
  193. </a-row>
  194. </div>
  195. </a-modal>
  196. <script>
  197. const infoModal = {
  198. visible: false,
  199. inbound: new Inbound(),
  200. dbInbound: new DBInbound(),
  201. settings: null,
  202. clientSettings: null,
  203. clientStats: [],
  204. upStats: 0,
  205. downStats: 0,
  206. clipboard: null,
  207. links: [],
  208. index: null,
  209. isExpired: false,
  210. subLink: '',
  211. tgLink: '',
  212. show(dbInbound, index) {
  213. this.index = index;
  214. this.inbound = dbInbound.toInbound();
  215. this.dbInbound = new DBInbound(dbInbound);
  216. this.settings = JSON.parse(this.inbound.settings);
  217. this.clientSettings = this.settings.clients ? Object.values(this.settings.clients)[index] : null;
  218. this.isExpired = this.inbound.isExpiry(index);
  219. this.clientStats = this.settings.clients ? this.dbInbound.clientStats.find(row => row.email === this.clientSettings.email) : [];
  220. remark = this.dbInbound.remark + "-" + this.clientSettings.email;
  221. address = this.dbInbound.address;
  222. this.links = [];
  223. if (this.inbound.tls && !ObjectUtil.isArrEmpty(this.inbound.stream.tls.settings.domains)) {
  224. this.inbound.stream.tls.settings.domains.forEach((domain) => {
  225. this.links.push({
  226. remark: remark + "-" + domain.remark,
  227. link: this.inbound.genLink(domain.domain, remark + "-" + domain.remark, index)
  228. });
  229. });
  230. } else {
  231. this.links.push({
  232. remark: remark,
  233. link: this.inbound.genLink(address, remark, index)
  234. });
  235. }
  236. if (this.clientSettings) {
  237. if (this.clientSettings.subId) {
  238. this.subLink = this.genSubLink(this.clientSettings.subId);
  239. }
  240. if (this.clientSettings.tgId) {
  241. this.tgLink = "https://t.me/" + this.clientSettings.tgId;
  242. }
  243. }
  244. this.visible = true;
  245. },
  246. close() {
  247. infoModal.visible = false;
  248. },
  249. genSubLink(subID) {
  250. protocol = app.subSettings.tls ? "https://" : "http://";
  251. hostName = app.subSettings.domain === "" ? window.location.hostname : app.subSettings.domain;
  252. subPort = app.subSettings.port;
  253. port = (subPort === 443 && app.subSettings.tls) || (subPort === 80 && !app.subSettings.tls) ? "" : ":" + String(subPort);
  254. subPath = app.subSettings.path;
  255. return protocol + hostName + port + subPath + subID;
  256. }
  257. };
  258. const infoModalApp = new Vue({
  259. delimiters: ['[[', ']]'],
  260. el: '#inbound-info-modal',
  261. data: {
  262. infoModal,
  263. get dbInbound() {
  264. return this.infoModal.dbInbound;
  265. },
  266. get inbound() {
  267. return this.infoModal.inbound;
  268. },
  269. get isActive() {
  270. if (infoModal.clientStats) {
  271. return infoModal.clientStats.enable;
  272. }
  273. return infoModal.dbInbound.isEnable;
  274. },
  275. get isEnable() {
  276. if (infoModal.clientSettings) {
  277. return infoModal.clientSettings.enable;
  278. }
  279. return infoModal.dbInbound.isEnable;
  280. },
  281. },
  282. methods: {
  283. copyToClipboard(elmentId, content) {
  284. this.infoModal.clipboard = new ClipboardJS('#' + elmentId, {
  285. text: () => content,
  286. });
  287. this.infoModal.clipboard.on('success', () => {
  288. app.$message.success('{{ i18n "copied" }}')
  289. this.infoModal.clipboard.destroy();
  290. });
  291. },
  292. statsColor(stats) {
  293. return usageColor(stats.up + stats.down, app.trafficDiff, stats.total);
  294. }
  295. },
  296. });
  297. </script>
  298. {{end}}