1
0

inbound_info_modal.html 13 KB

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