inbound_info_modal.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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="siderDrawer.isDarkTheme ? darkClass : ''"
  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. </template>
  41. </table>
  42. </td></tr>
  43. <tr colspan="2" v-if="dbInbound.hasLink()">
  44. <td v-if="inbound.tls">
  45. tls: <a-tag color="green">{{ i18n "enabled" }}</a-tag><br />
  46. tls {{ i18n "domainName" }}: <a-tag :color="inbound.serverName ? 'green' : 'orange'">[[ inbound.serverName ? inbound.serverName : '' ]]</a-tag>
  47. </td>
  48. <td v-else-if="inbound.xtls">
  49. xtls: <a-tag color="green">{{ i18n "enabled" }}</a-tag><br />
  50. xtls {{ i18n "domainName" }}: <a-tag :color="inbound.serverName ? 'green' : 'orange'">[[ inbound.serverName ? inbound.serverName : '' ]]</a-tag>
  51. </td>
  52. <td v-else>tls: <a-tag color="red">{{ i18n "disabled" }}</a-tag>
  53. </td>
  54. </tr>
  55. </table>
  56. <template v-if="infoModal.clientSettings">
  57. <a-divider>{{ i18n "pages.inbounds.client" }}</a-divider>
  58. <table style="margin-bottom: 10px; width: 100%;">
  59. <tr>
  60. <th v-for="col in Object.keys(infoModal.clientSettings).slice(0, 3)">[[ col ]]</th>
  61. </tr>
  62. <tr>
  63. <td v-for="col in Object.values(infoModal.clientSettings).slice(0, 3)"><a-tag color="green">[[ col ]]</a-tag></td>
  64. </table>
  65. <table style="margin-bottom: 10px; width: 100%;">
  66. <tr><th>{{ i18n "usage" }}</th><th>{{ i18n "pages.inbounds.totalFlow" }}</th><th>{{ i18n "pages.inbounds.expireDate" }}</th><th>{{ i18n "enable" }}</th></tr>
  67. <tr>
  68. <td>
  69. <a-tag v-if="infoModal.clientStats" :color="statsColor(infoModal.clientStats)">
  70. [[ sizeFormat(infoModal.clientStats['up']) ]] /
  71. [[ sizeFormat(infoModal.clientStats['down']) ]]
  72. ([[ sizeFormat(infoModal.clientStats['up'] + infoModal.clientStats['down']) ]])
  73. </a-tag>
  74. </td>
  75. <td>
  76. <a-tag v-if="infoModal.clientSettings.totalGB > 0" :color="statsColor(infoModal.clientStats)">[[ sizeFormat(infoModal.clientSettings.totalGB) ]]</a-tag>
  77. <a-tag v-else color="green">{{ i18n "indefinite" }}</a-tag>
  78. </td>
  79. <td>
  80. <template v-if="infoModal.clientSettings.expiryTime > 0">
  81. <a-tag :color="infoModal.isExpired ? 'red' : 'blue'">
  82. [[ DateUtil.formatMillis(infoModal.clientSettings.expiryTime) ]]
  83. </a-tag>
  84. </template>
  85. <a-tag v-else color="green">{{ i18n "indefinite" }}</a-tag>
  86. </td>
  87. <td>
  88. <a-tag v-if="isEnable" color="blue">{{ i18n "enabled" }}</a-tag>
  89. <a-tag v-else color="red">{{ i18n "disabled" }}</a-tag>
  90. </td>
  91. </tr>
  92. </table>
  93. </template>
  94. <template v-else>
  95. <a-divider></a-divider>
  96. <table v-if="inbound.protocol == Protocols.SHADOWSOCKS" style="margin-bottom: 10px; width: 100%;">
  97. <tr>
  98. <th>{{ i18n "encryption" }}</th>
  99. <th>{{ i18n "password" }}</th>
  100. <th>{{ i18n "pages.inbounds.network" }}</th>
  101. </tr><tr>
  102. <td><a-tag color="green">[[ inbound.settings.method ]]</a-tag></td>
  103. <td><a-tag color="blue">[[ inbound.settings.password ]]</a-tag></td>
  104. <td><a-tag color="green">[[ inbound.settings.network ]]</a-tag></td>
  105. </tr>
  106. </table>
  107. <table v-if="inbound.protocol == Protocols.DOKODEMO" style="margin-bottom: 10px; width: 100%;">
  108. <tr>
  109. <th>{{ i18n "pages.inbounds.targetAddress" }}</th>
  110. <th>{{ i18n "pages.inbounds.destinationPort" }}</th>
  111. <th>{{ i18n "pages.inbounds.network" }}</th>
  112. <th>FollowRedirect</th>
  113. </tr><tr>
  114. <td><a-tag color="green">[[ inbound.settings.address ]]</a-tag></td>
  115. <td><a-tag color="blue">[[ inbound.settings.port ]]</a-tag></td>
  116. <td><a-tag color="green">[[ inbound.settings.network ]]</a-tag></td>
  117. <td><a-tag color="blue">[[ inbound.settings.followRedirect ]]</a-tag></td>
  118. </tr>
  119. </table>
  120. </table>
  121. <table v-if="inbound.protocol == Protocols.SOCKS" style="margin-bottom: 10px; width: 100%;">
  122. <tr>
  123. <th>{{ i18n "password" }} Auth</th>
  124. <th>{{ i18n "pages.inbounds.enable" }} udp</th>
  125. <th>IP</th>
  126. </tr><tr>
  127. <td><a-tag color="green">[[ inbound.settings.auth ]]</a-tag></td>
  128. <td><a-tag color="blue">[[ inbound.settings.udp]]</a-tag></td>
  129. <td><a-tag color="green">[[ inbound.settings.ip ]]</a-tag></td>
  130. </tr><tr v-if="inbound.settings.auth == 'password'">
  131. <td> </td>
  132. <td>{{ i18n "username" }}</td>
  133. <td>{{ i18n "password" }}</td>
  134. </tr><tr v-for="account,index in inbound.settings.accounts">
  135. <td><a-tag color="green">[[ index ]]</a-tag></td>
  136. <td><a-tag color="blue">[[ account.user ]]</a-tag></td>
  137. <td><a-tag color="green">[[ account.pass ]]</a-tag></td>
  138. </tr>
  139. </table>
  140. </table>
  141. <table v-if="inbound.protocol == Protocols.HTTP" style="margin-bottom: 10px; width: 100%;">
  142. <tr>
  143. <th> </th>
  144. <th>{{ i18n "username" }}</th>
  145. <th>{{ i18n "password" }}</th>
  146. </tr><tr v-for="account,index in inbound.settings.accounts">
  147. <td><a-tag color="green">[[ index ]]</a-tag></td>
  148. <td><a-tag color="blue">[[ account.user ]]</a-tag></td>
  149. <td><a-tag color="green">[[ account.pass ]]</a-tag></td>
  150. </tr>
  151. </table>
  152. </table>
  153. </template>
  154. <div v-if="dbInbound.hasLink()">
  155. <a-divider>URL</a-divider>
  156. <p>[[ infoModal.link ]]</p>
  157. <button class="ant-btn ant-btn-primary" id="copy-url-link"><a-icon type="snippets"></a-icon>{{ i18n "copy" }}</button>
  158. </div>
  159. </a-modal>
  160. <script>
  161. const infoModal = {
  162. visible: false,
  163. inbound: new Inbound(),
  164. dbInbound: new DBInbound(),
  165. settings: null,
  166. clientSettings: new Inbound.Settings(),
  167. clientStats: [],
  168. upStats: 0,
  169. downStats: 0,
  170. clipboard: null,
  171. link: null,
  172. index: null,
  173. isExpired: false,
  174. show(dbInbound, index) {
  175. this.index = index;
  176. this.inbound = dbInbound.toInbound();
  177. this.dbInbound = new DBInbound(dbInbound);
  178. this.link = dbInbound.genLink(index);
  179. this.settings = JSON.parse(this.inbound.settings);
  180. this.clientSettings = this.settings.clients ? Object.values(this.settings.clients)[index] : null;
  181. this.isExpired = this.inbound.isExpiry(index);
  182. this.clientStats = this.settings.clients ? this.dbInbound.clientStats.find(row => row.email === this.clientSettings.email) : [];
  183. this.visible = true;
  184. infoModalApp.$nextTick(() => {
  185. if (this.clipboard === null) {
  186. this.clipboard = new ClipboardJS('#copy-url-link', {
  187. text: () => this.link,
  188. });
  189. this.clipboard.on('success', () => app.$message.success('{{ i18n "copied" }}'));
  190. }
  191. });
  192. },
  193. close() {
  194. infoModal.visible = false;
  195. },
  196. };
  197. const infoModalApp = new Vue({
  198. delimiters: ['[[', ']]'],
  199. el: '#inbound-info-modal',
  200. data: {
  201. infoModal,
  202. get dbInbound() {
  203. return this.infoModal.dbInbound;
  204. },
  205. get inbound() {
  206. return this.infoModal.inbound;
  207. },
  208. get isEnable() {
  209. if(infoModal.clientStats){
  210. return infoModal.clientStats.enable;
  211. }
  212. return infoModal.dbInbound.isEnable;
  213. }
  214. },
  215. methods: {
  216. copyTextToClipboard(elmentId,content) {
  217. this.infoModal.clipboard = new ClipboardJS('#' + elmentId, {
  218. text: () => content,
  219. });
  220. this.infoModal.clipboard.on('success', () => {
  221. app.$message.success('{{ i18n "copied" }}')
  222. this.infoModal.clipboard.destroy();
  223. });
  224. },
  225. statsColor(stats) {
  226. if(!stats) return 'blue'
  227. if(stats['total'] === 0) return 'blue'
  228. else if(stats['total'] > 0 && (stats['down']+stats['up']) < stats['total']) return 'cyan'
  229. else return 'red'
  230. }
  231. },
  232. });
  233. </script>
  234. {{end}}