inbound_info_modal.html 13 KB

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