inbound_info_modal.html 13 KB

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