1
0

inbound_info_modal.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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. </tr>
  113. <tr v-if="infoModal.clientSettings.tgId">
  114. <td>Telegram ID</td>
  115. <td><a :href="[[ tgBase + infoModal.clientSettings.tgId ]]" target="_blank">@[[ infoModal.clientSettings.tgId ]]</a></td>
  116. </tr>
  117. </table>
  118. </template>
  119. <template v-else>
  120. <a-divider></a-divider>
  121. <table v-if="inbound.protocol == Protocols.SHADOWSOCKS" style="margin-bottom: 10px; width: 100%;">
  122. <tr>
  123. <th>{{ i18n "encryption" }}</th>
  124. <th>{{ i18n "password" }}</th>
  125. <th>{{ i18n "pages.inbounds.network" }}</th>
  126. </tr>
  127. <tr>
  128. <td><a-tag color="green">[[ inbound.settings.method ]]</a-tag></td>
  129. <td><a-tag color="blue">[[ inbound.settings.password ]]</a-tag></td>
  130. <td><a-tag color="green">[[ inbound.settings.network ]]</a-tag></td>
  131. </tr>
  132. </table>
  133. <table v-if="inbound.protocol == Protocols.DOKODEMO" style="margin-bottom: 10px; width: 100%;">
  134. <tr>
  135. <th>{{ i18n "pages.inbounds.targetAddress" }}</th>
  136. <th>{{ i18n "pages.inbounds.destinationPort" }}</th>
  137. <th>{{ i18n "pages.inbounds.network" }}</th>
  138. <th>FollowRedirect</th>
  139. </tr>
  140. <tr>
  141. <td><a-tag color="green">[[ inbound.settings.address ]]</a-tag></td>
  142. <td><a-tag color="blue">[[ inbound.settings.port ]]</a-tag></td>
  143. <td><a-tag color="green">[[ inbound.settings.network ]]</a-tag></td>
  144. <td><a-tag color="blue">[[ inbound.settings.followRedirect ]]</a-tag></td>
  145. </tr>
  146. </table>
  147. </table>
  148. <table v-if="inbound.protocol == Protocols.SOCKS" style="margin-bottom: 10px; width: 100%;">
  149. <tr>
  150. <th>{{ i18n "password" }} Auth</th>
  151. <th>{{ i18n "pages.inbounds.enable" }} udp</th>
  152. <th>IP</th>
  153. </tr>
  154. <tr>
  155. <td><a-tag color="green">[[ inbound.settings.auth ]]</a-tag></td>
  156. <td><a-tag color="blue">[[ inbound.settings.udp]]</a-tag></td>
  157. <td><a-tag color="green">[[ inbound.settings.ip ]]</a-tag></td>
  158. </tr>
  159. <tr v-if="inbound.settings.auth == 'password'">
  160. <td> </td>
  161. <td>{{ i18n "username" }}</td>
  162. <td>{{ i18n "password" }}</td>
  163. </tr>
  164. <tr v-for="account,index in inbound.settings.accounts">
  165. <td><a-tag color="green">[[ index ]]</a-tag></td>
  166. <td><a-tag color="blue">[[ account.user ]]</a-tag></td>
  167. <td><a-tag color="green">[[ account.pass ]]</a-tag></td>
  168. </tr>
  169. </table>
  170. </table>
  171. <table v-if="inbound.protocol == Protocols.HTTP" style="margin-bottom: 10px; width: 100%;">
  172. <tr>
  173. <th> </th>
  174. <th>{{ i18n "username" }}</th>
  175. <th>{{ i18n "password" }}</th>
  176. </tr>
  177. <tr v-for="account,index in inbound.settings.accounts">
  178. <td><a-tag color="green">[[ index ]]</a-tag></td>
  179. <td><a-tag color="blue">[[ account.user ]]</a-tag></td>
  180. <td><a-tag color="green">[[ account.pass ]]</a-tag></td>
  181. </tr>
  182. </table>
  183. </table>
  184. </template>
  185. <div v-if="dbInbound.hasLink()">
  186. <a-divider>URL</a-divider>
  187. <p>[[ infoModal.link ]]</p>
  188. <button class="ant-btn ant-btn-primary" id="copy-url-link"><a-icon type="snippets"></a-icon>{{ i18n "copy" }}</button>
  189. </div>
  190. </a-modal>
  191. <script>
  192. const infoModal = {
  193. visible: false,
  194. inbound: new Inbound(),
  195. dbInbound: new DBInbound(),
  196. settings: null,
  197. clientSettings: null,
  198. clientStats: [],
  199. upStats: 0,
  200. downStats: 0,
  201. clipboard: null,
  202. link: null,
  203. index: null,
  204. isExpired: false,
  205. show(dbInbound, index) {
  206. this.index = index;
  207. this.inbound = dbInbound.toInbound();
  208. this.dbInbound = new DBInbound(dbInbound);
  209. this.link = dbInbound.genLink(index);
  210. this.settings = JSON.parse(this.inbound.settings);
  211. this.clientSettings = this.settings.clients ? Object.values(this.settings.clients)[index] : null;
  212. this.isExpired = this.inbound.isExpiry(index);
  213. this.clientStats = this.settings.clients ? this.dbInbound.clientStats.find(row => row.email === this.clientSettings.email) : [];
  214. this.visible = true;
  215. infoModalApp.$nextTick(() => {
  216. if (this.clipboard === null) {
  217. this.clipboard = new ClipboardJS('#copy-url-link', {
  218. text: () => this.link,
  219. });
  220. this.clipboard.on('success', () => app.$message.success('{{ i18n "copied" }}'));
  221. }
  222. });
  223. },
  224. close() {
  225. infoModal.visible = false;
  226. },
  227. };
  228. const infoModalApp = new Vue({
  229. delimiters: ['[[', ']]'],
  230. el: '#inbound-info-modal',
  231. data: {
  232. infoModal,
  233. get dbInbound() {
  234. return this.infoModal.dbInbound;
  235. },
  236. get inbound() {
  237. return this.infoModal.inbound;
  238. },
  239. get isActive() {
  240. if (infoModal.clientStats) {
  241. return infoModal.clientStats.enable;
  242. }
  243. return infoModal.dbInbound.isEnable;
  244. },
  245. get isEnable() {
  246. if (infoModal.clientSettings) {
  247. return infoModal.clientSettings.enable;
  248. }
  249. return infoModal.dbInbound.isEnable;
  250. },
  251. get subBase() {
  252. return window.location.protocol + "//" + window.location.hostname + (window.location.port ? ":" + window.location.port : "") + basePath + "sub/";
  253. },
  254. get tgBase() {
  255. return "https://t.me/"
  256. },
  257. },
  258. methods: {
  259. copyTextToClipboard(elmentId, content) {
  260. this.infoModal.clipboard = new ClipboardJS('#' + elmentId, {
  261. text: () => content,
  262. });
  263. this.infoModal.clipboard.on('success', () => {
  264. app.$message.success('{{ i18n "copied" }}')
  265. this.infoModal.clipboard.destroy();
  266. });
  267. },
  268. statsColor(stats) {
  269. if (!stats) return 'blue'
  270. if (stats['total'] === 0) return 'blue'
  271. else if (stats['total'] > 0 && (stats['down'] + stats['up']) < stats['total']) return 'cyan'
  272. else return 'red'
  273. }
  274. },
  275. });
  276. </script>
  277. {{end}}