1
0

inbound_info_modal.html 13 KB

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