settings.html 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. {{template "head" .}}
  4. <style>
  5. @media (min-width: 769px) {
  6. .ant-layout-content {
  7. margin: 24px 16px;
  8. }
  9. }
  10. @media (max-width: 768px) {
  11. .ant-tabs-nav .ant-tabs-tab {
  12. margin: 0;
  13. padding: 12px .5rem;
  14. }
  15. }
  16. .ant-tabs-bar {
  17. margin: 0;
  18. }
  19. .ant-list-item {
  20. display: block;
  21. }
  22. .alert-msg {
  23. color: rgb(194, 117, 18);
  24. font-weight: normal;
  25. font-size: 16px;
  26. padding: .5rem 1rem;
  27. text-align: center;
  28. background: rgb(255 145 0 / 15%);
  29. margin: 1.5rem 2.5rem 0rem;
  30. border-radius: .5rem;
  31. transition: all 0.5s;
  32. animation: signal 3s cubic-bezier(0.18, 0.89, 0.32, 1.28) infinite;
  33. }
  34. .alert-msg:hover {
  35. cursor: default;
  36. transition-duration: .3s;
  37. animation: signal 0.9s ease infinite;
  38. }
  39. @keyframes signal {
  40. 0% {
  41. box-shadow: 0 0 0 0 rgba(194, 118, 18, 0.5);
  42. }
  43. 50% {
  44. box-shadow: 0 0 0 6px rgba(0, 0, 0, 0);
  45. }
  46. 100% {
  47. box-shadow: 0 0 0 6px rgba(0, 0, 0, 0);
  48. }
  49. }
  50. .alert-msg>i {
  51. color: inherit;
  52. font-size: 24px;
  53. }
  54. .collapse-title {
  55. color: inherit;
  56. font-weight: bold;
  57. font-size: 18px;
  58. padding: 10px 20px;
  59. border-bottom: 2px solid;
  60. }
  61. .collapse-title>i {
  62. color: inherit;
  63. font-size: 24px;
  64. }
  65. .ant-collapse-content-box .ant-list-item {
  66. border-bottom: none !important;
  67. }
  68. </style>
  69. <body>
  70. <a-layout id="app" v-cloak :class="themeSwitcher.currentTheme">
  71. {{ template "commonSider" . }}
  72. <a-layout id="content-layout">
  73. <a-layout-content>
  74. <a-spin :spinning="spinning" :delay="500" tip='{{ i18n "loading"}}'>
  75. <transition name="list" appear>
  76. <a-alert type="error" v-if="confAlerts.length>0" style="margin-bottom: 10px;"
  77. message='{{ i18n "secAlertTitle" }}'
  78. color="red"
  79. show-icon closable>
  80. <template slot="description">
  81. <b>{{ i18n "secAlertConf" }}</b>
  82. <ul><li v-for="a in confAlerts">[[ a ]]</li></ul>
  83. </template>
  84. </a-alert>
  85. </transition>
  86. <a-space direction="vertical">
  87. <a-card hoverable style="margin-bottom: .5rem; overflow-x: hidden;">
  88. <a-row style="display: flex; flex-wrap: wrap; align-items: center;">
  89. <a-col :xs="24" :sm="10" style="padding: 4px;">
  90. <a-space direction="horizontal">
  91. <a-button type="primary" :disabled="saveBtnDisable" @click="updateAllSetting">{{ i18n "pages.settings.save" }}</a-button>
  92. <a-button type="danger" :disabled="!saveBtnDisable" @click="restartPanel">{{ i18n "pages.settings.restartPanel" }}</a-button>
  93. </a-space>
  94. </a-col>
  95. <a-col :xs="24" :sm="14">
  96. <template>
  97. <div>
  98. <a-back-top :target="() => document.getElementById('content-layout')" visibility-height="200"></a-back-top>
  99. <a-alert type="warning" style="float: right; width: fit-content"
  100. message='{{ i18n "pages.settings.infoDesc" }}'
  101. show-icon>
  102. </a-alert>
  103. </div>
  104. </template>
  105. </a-col>
  106. </a-row>
  107. </a-card>
  108. <a-tabs default-active-key="1">
  109. <a-tab-pane key="1" tab='{{ i18n "pages.settings.panelSettings"}}'>
  110. <a-list item-layout="horizontal">
  111. <a-list-item>
  112. <a-row style="padding: 20px">
  113. <a-col :lg="24" :xl="12">
  114. <a-list-item-meta title='{{ i18n "pages.settings.remarkModel"}}'>
  115. <template slot="description">{{ i18n "pages.settings.sampleRemark"}}: <i>#[[ remarkSample ]]</i></template>
  116. </a-list-item-meta>
  117. </a-col>
  118. <a-col :lg="24" :xl="12">
  119. <a-input-group style="width: 100%;">
  120. <a-select style="padding-right: .5rem; min-width: 80%; width: auto;"
  121. mode="multiple"
  122. v-model="remarkModel"
  123. :dropdown-class-name="themeSwitcher.currentTheme">
  124. <a-select-option v-for="(value, key) in remarkModels" :value="key">[[ value ]]</a-select-option>
  125. </a-select>
  126. <a-select style="width: 20%;" v-model="remarkSeparator" :dropdown-class-name="themeSwitcher.currentTheme">
  127. <a-select-option v-for="key in remarkSeparators" :value="key">[[ key ]]</a-select-option>
  128. </a-select>
  129. </a-input-group>
  130. </a-col>
  131. </a-row>
  132. </a-list-item>
  133. <setting-list-item type="text" title='{{ i18n "pages.settings.panelListeningIP"}}' desc='{{ i18n "pages.settings.panelListeningIPDesc"}}' v-model="allSetting.webListen"></setting-list-item>
  134. <setting-list-item type="text" title='{{ i18n "pages.settings.panelListeningDomain"}}' desc='{{ i18n "pages.settings.panelListeningDomainDesc"}}' v-model="allSetting.webDomain"></setting-list-item>
  135. <setting-list-item type="number" title='{{ i18n "pages.settings.panelPort"}}' desc='{{ i18n "pages.settings.panelPortDesc"}}' v-model="allSetting.webPort" :min="1" :max="65531"></setting-list-item>
  136. <setting-list-item type="text" title='{{ i18n "pages.settings.publicKeyPath"}}' desc='{{ i18n "pages.settings.publicKeyPathDesc"}}' v-model="allSetting.webCertFile"></setting-list-item>
  137. <setting-list-item type="text" title='{{ i18n "pages.settings.privateKeyPath"}}' desc='{{ i18n "pages.settings.privateKeyPathDesc"}}' v-model="allSetting.webKeyFile"></setting-list-item>
  138. <setting-list-item type="text" title='{{ i18n "pages.settings.panelUrlPath"}}' desc='{{ i18n "pages.settings.panelUrlPathDesc"}}' v-model="allSetting.webBasePath"></setting-list-item>
  139. <setting-list-item type="number" title='{{ i18n "pages.settings.sessionMaxAge" }}' desc='{{ i18n "pages.settings.sessionMaxAgeDesc" }}' v-model="allSetting.sessionMaxAge" :min="60"></setting-list-item>
  140. <setting-list-item type="number" title='{{ i18n "pages.settings.pageSize" }}' desc='{{ i18n "pages.settings.pageSizeDesc" }}' v-model="allSetting.pageSize" :min="0" :step="5"></setting-list-item>
  141. <setting-list-item type="number" title='{{ i18n "pages.settings.expireTimeDiff" }}' desc='{{ i18n "pages.settings.expireTimeDiffDesc" }}' v-model="allSetting.expireDiff" :min="0"></setting-list-item>
  142. <setting-list-item type="number" title='{{ i18n "pages.settings.trafficDiff" }}' desc='{{ i18n "pages.settings.trafficDiffDesc" }}' v-model="allSetting.trafficDiff" :min="0"></setting-list-item>
  143. <setting-list-item type="text" title='{{ i18n "pages.settings.timeZone"}}' desc='{{ i18n "pages.settings.timeZoneDesc"}}' v-model="allSetting.timeLocation"></setting-list-item>
  144. <a-list-item>
  145. <a-row style="padding: 20px">
  146. <a-col :lg="24" :xl="12">
  147. <a-list-item-meta title='{{ i18n "pages.settings.datepicker"}}'>
  148. <template slot="description">{{ i18n "pages.settings.datepickerDescription"}}</template>
  149. </a-list-item-meta>
  150. </a-col>
  151. <a-col :lg="24" :xl="12">
  152. <template>
  153. <a-select style="width: 100%" :dropdown-class-name="themeSwitcher.currentTheme" v-model="datepicker">
  154. <a-select-option v-for="item in datepickerList" :value="item.value">
  155. <span v-text="item.name"></span>
  156. </a-select-option>
  157. </a-select>
  158. </template>
  159. </a-col>
  160. </a-row>
  161. </a-list-item>
  162. <a-list-item>
  163. <a-row style="padding: 20px">
  164. <a-col :lg="24" :xl="12">
  165. <a-list-item-meta title="Language"></a-list-item-meta>
  166. </a-col>
  167. <a-col :lg="24" :xl="12">
  168. <template>
  169. <a-select ref="selectLang"
  170. v-model="lang"
  171. @change="setLang(lang)"
  172. :dropdown-class-name="themeSwitcher.currentTheme"
  173. style="width: 100%">
  174. <a-select-option :value="l.value" :label="l.value" v-for="l in supportLangs">
  175. <span role="img" :aria-label="l.name" v-text="l.icon"></span> &nbsp;&nbsp; <span v-text="l.name"></span>
  176. </a-select-option>
  177. </a-select>
  178. </template>
  179. </a-col>
  180. </a-row>
  181. </a-list-item>
  182. </a-list>
  183. </a-tab-pane>
  184. <a-tab-pane key="2" tab='{{ i18n "pages.settings.securitySettings"}}' style="padding: 20px;">
  185. <a-divider>{{ i18n "pages.settings.security.admin"}}</a-divider>
  186. <a-form layout="horizontal" :colon="false" style="float: left; margin-bottom: 2rem;" :label-col="{ md: {span:10} }" :wrapper-col="{ md: {span:14} }">
  187. <a-form-item label='{{ i18n "pages.settings.oldUsername"}}'>
  188. <a-input autocomplete="username" v-model="user.oldUsername"></a-input>
  189. </a-form-item>
  190. <a-form-item label='{{ i18n "pages.settings.currentPassword"}}'>
  191. <password-input autocomplete="current-password" v-model="user.oldPassword"></password-input>
  192. </a-form-item>
  193. <a-form-item label='{{ i18n "pages.settings.newUsername"}}'>
  194. <a-input v-model="user.newUsername"></a-input>
  195. </a-form-item>
  196. <a-form-item label='{{ i18n "pages.settings.newPassword"}}'>
  197. <password-input autocomplete="new-password" v-model="user.newPassword"></password-input>
  198. </a-form-item>
  199. <a-form-item label=" ">
  200. <a-button type="primary" @click="updateUser">{{ i18n "confirm" }}</a-button>
  201. </a-form-item>
  202. </a-form>
  203. <a-divider>{{ i18n "pages.settings.security.secret"}}</a-divider>
  204. <a-form style="padding: 0 20px;">
  205. <a-list-item>
  206. <a-row>
  207. <a-col :lg="24" :xl="12">
  208. <a-list-item-meta title='{{ i18n "pages.settings.security.loginSecurity" }}'
  209. description='{{ i18n "pages.settings.security.loginSecurityDesc" }}'>
  210. </a-list-item-meta>
  211. </a-col>
  212. <a-col :lg="24" :xl="12">
  213. <template>
  214. <a-switch @change="toggleToken(allSetting.secretEnable)" v-model="allSetting.secretEnable"></a-switch>
  215. <a-icon style="margin-left: 1rem;" v-if="allSetting.secretEnable" :spin="this.changeSecret" type="sync" @click="getNewSecret"></a-icon>
  216. </template>
  217. </a-col>
  218. </a-row>
  219. </a-list-item>
  220. <a-list-item>
  221. <a-row>
  222. <a-col :lg="24" :xl="12">
  223. <a-list-item-meta title='{{ i18n "pages.settings.security.secretToken" }}'
  224. description='{{ i18n "pages.settings.security.secretTokenDesc" }}'>
  225. </a-list-item-meta>
  226. </a-col>
  227. <a-col :lg="24" :xl="12">
  228. <template>
  229. <a-textarea type="text" :disabled="!allSetting.secretEnable" v-model="user.loginSecret"></a-textarea>
  230. </template>
  231. </a-col>
  232. </a-row>
  233. </a-list-item>
  234. <a-button type="primary" :loading="this.changeSecret" @click="updateSecret">{{ i18n "confirm" }}</a-button>
  235. </a-form>
  236. </a-tab-pane>
  237. <a-tab-pane key="3" tab='{{ i18n "pages.settings.TGBotSettings"}}'>
  238. <a-list item-layout="horizontal">
  239. <setting-list-item type="switch" title='{{ i18n "pages.settings.telegramBotEnable" }}' desc='{{ i18n "pages.settings.telegramBotEnableDesc" }}' v-model="allSetting.tgBotEnable"></setting-list-item>
  240. <setting-list-item type="text" title='{{ i18n "pages.settings.telegramToken"}}' desc='{{ i18n "pages.settings.telegramTokenDesc"}}' v-model="allSetting.tgBotToken"></setting-list-item>
  241. <setting-list-item type="text" title='{{ i18n "pages.settings.telegramChatId"}}' desc='{{ i18n "pages.settings.telegramChatIdDesc"}}' v-model="allSetting.tgBotChatId"></setting-list-item>
  242. <setting-list-item type="text" title='{{ i18n "pages.settings.telegramNotifyTime"}}' desc='{{ i18n "pages.settings.telegramNotifyTimeDesc"}}' v-model="allSetting.tgRunTime"></setting-list-item>
  243. <setting-list-item type="switch" title='{{ i18n "pages.settings.tgNotifyBackup" }}' desc='{{ i18n "pages.settings.tgNotifyBackupDesc" }}' v-model="allSetting.tgBotBackup"></setting-list-item>
  244. <setting-list-item type="switch" title='{{ i18n "pages.settings.tgNotifyLogin" }}' desc='{{ i18n "pages.settings.tgNotifyLoginDesc" }}' v-model="allSetting.tgBotLoginNotify"></setting-list-item>
  245. <setting-list-item type="number" title='{{ i18n "pages.settings.tgNotifyCpu" }}' desc='{{ i18n "pages.settings.tgNotifyCpuDesc" }}' v-model="allSetting.tgCpu" :min="0" :max="100"></setting-list-item>
  246. <setting-list-item type="text" title='{{ i18n "pages.settings.telegramProxy"}}' desc='{{ i18n "pages.settings.telegramProxyDesc"}}' v-model="allSetting.tgBotProxy" placeholder="socks5://user:pass@host:port"></setting-list-item>
  247. <setting-list-item type="text" title='{{ i18n "pages.settings.telegramAPIServer"}}' desc='{{ i18n "pages.settings.telegramAPIServerDesc"}}' v-model="allSetting.tgBotAPIServer" placeholder="https://api.example.com"></setting-list-item>
  248. <a-list-item>
  249. <a-row style="padding: 20px">
  250. <a-col :lg="24" :xl="12">
  251. <a-list-item-meta title="Telegram Bot Language" />
  252. </a-col>
  253. <a-col :lg="24" :xl="12">
  254. <template>
  255. <a-select ref="selectBotLang" v-model="allSetting.tgLang" :dropdown-class-name="themeSwitcher.currentTheme" style="width: 100%">
  256. <a-select-option :value="l.value" :label="l.value" v-for="l in supportLangs">
  257. <span role="img" :aria-label="l.name" v-text="l.icon"></span> &nbsp;&nbsp; <span v-text="l.name"></span>
  258. </a-select-option>
  259. </a-select>
  260. </template>
  261. </a-col>
  262. </a-row>
  263. </a-list-item>
  264. </a-list>
  265. </a-tab-pane>
  266. <a-tab-pane key="4" tab='{{ i18n "pages.settings.subSettings" }}'>
  267. <a-list item-layout="horizontal">
  268. <setting-list-item type="switch" title='{{ i18n "pages.settings.subEnable"}}' desc='{{ i18n "pages.settings.subEnableDesc"}}' v-model="allSetting.subEnable"></setting-list-item>
  269. <setting-list-item type="switch" title='{{ i18n "pages.settings.subEncrypt"}}' desc='{{ i18n "pages.settings.subEncryptDesc"}}' v-model="allSetting.subEncrypt"></setting-list-item>
  270. <setting-list-item type="switch" title='{{ i18n "pages.settings.subShowInfo"}}' desc='{{ i18n "pages.settings.subShowInfoDesc"}}' v-model="allSetting.subShowInfo"></setting-list-item>
  271. <setting-list-item type="text" title='{{ i18n "pages.settings.subListen"}}' desc='{{ i18n "pages.settings.subListenDesc"}}' v-model="allSetting.subListen"></setting-list-item>
  272. <setting-list-item type="text" title='{{ i18n "pages.settings.subDomain"}}' desc='{{ i18n "pages.settings.subDomainDesc"}}' v-model="allSetting.subDomain"></setting-list-item>
  273. <setting-list-item type="number" title='{{ i18n "pages.settings.subPort"}}' desc='{{ i18n "pages.settings.subPortDesc"}}' v-model.number="allSetting.subPort" :min="1" :max="65531"></setting-list-item>
  274. <setting-list-item type="text" title='{{ i18n "pages.settings.subPath"}}' desc='{{ i18n "pages.settings.subPathDesc"}}' v-model="allSetting.subPath"></setting-list-item>
  275. <setting-list-item type="text" title='{{ i18n "pages.settings.subCertPath"}}' desc='{{ i18n "pages.settings.subCertPathDesc"}}' v-model="allSetting.subCertFile"></setting-list-item>
  276. <setting-list-item type="text" title='{{ i18n "pages.settings.subKeyPath"}}' desc='{{ i18n "pages.settings.subKeyPathDesc"}}' v-model="allSetting.subKeyFile"></setting-list-item>
  277. <setting-list-item type="text" title='{{ i18n "pages.settings.subURI"}}' desc='{{ i18n "pages.settings.subURIDesc"}}' v-model="allSetting.subURI" placeholder="(http|https)://domain[:port]/path/"></setting-list-item>
  278. <setting-list-item type="number" title='{{ i18n "pages.settings.subUpdates"}}' desc='{{ i18n "pages.settings.subUpdatesDesc"}}' v-model="allSetting.subUpdates" :min="1"></setting-list-item>
  279. </a-list>
  280. </a-tab-pane>
  281. <a-tab-pane key="5" tab='{{ i18n "pages.settings.subSettings" }} Json' v-if="allSetting.subEnable">
  282. <a-list item-layout="horizontal">
  283. <setting-list-item type="text" title='{{ i18n "pages.settings.subPath"}}' desc='{{ i18n "pages.settings.subPathDesc"}}' v-model="allSetting.subJsonPath"></setting-list-item>
  284. <setting-list-item type="text" title='{{ i18n "pages.settings.subURI"}}' desc='{{ i18n "pages.settings.subURIDesc"}}' v-model="allSetting.subJsonURI" placeholder="(http|https)://domain[:port]/path/"></setting-list-item>
  285. <a-list-item style="padding: 20px">
  286. <a-row>
  287. <a-col :lg="24" :xl="12">
  288. <a-list-item-meta title='{{ i18n "pages.settings.fragment"}}'>
  289. <template slot="description">{{ i18n "pages.settings.fragmentDesc"}}</template>
  290. </a-list-item-meta>
  291. </a-col>
  292. <a-col :lg="24" :xl="12">
  293. <a-switch v-model="fragment"></a-switch>
  294. </a-col>
  295. </a-row>
  296. <a-collapse v-if="fragment" style="margin-top: 14px;">
  297. <a-collapse-panel header='{{ i18n "pages.settings.fragmentSett"}}' v-if="fragment">
  298. <setting-list-item style="padding: 10px 20px" type="text" title='Packets' v-model="fragmentPackets" placeholder="1-1 | 1-3 | tlshello | ..."></setting-list-item>
  299. <setting-list-item style="padding: 10px 20px" type="text" title='Length' v-model="fragmentLength" placeholder="100-200"></setting-list-item>
  300. <setting-list-item style="padding: 10px 20px" type="text" title='Interval' v-model="fragmentInterval" placeholder="10-20"></setting-list-item>
  301. </a-collapse-panel>
  302. </a-collapse>
  303. </a-list-item>
  304. <a-list-item style="padding: 20px">
  305. <a-row>
  306. <a-col :lg="24" :xl="12">
  307. <a-list-item-meta title='Noises'>
  308. <template slot="description">{{ i18n "pages.settings.noisesDesc"}}</template>
  309. </a-list-item-meta>
  310. </a-col>
  311. <a-col :lg="24" :xl="12">
  312. <a-switch v-model="noises"></a-switch>
  313. </a-col>
  314. </a-row>
  315. <a-collapse v-if="noises" style="margin-top: 14px;">
  316. <a-collapse-panel v-for="(noise, index) in noisesArray" :key="index" :header="`Noise ${index + 1}`">
  317. <a-list-item style="padding: 10px 20px">
  318. <a-row>
  319. <a-col :lg="24" :xl="12">
  320. <a-list-item-meta title='Type'></a-list-item-meta>
  321. </a-col>
  322. <a-col :lg="24" :xl="12">
  323. <a-select :value="noise.type" style="width: 100%" :dropdown-class-name="themeSwitcher.currentTheme"
  324. @change="(value) => updateNoiseType(index, value)">
  325. <a-select-option :value="p" :label="p" v-for="p in ['rand', 'base64', 'str']" :key="p">
  326. [[ p ]] </a-select-option>
  327. </a-select>
  328. </a-col>
  329. </a-row>
  330. </a-list-item>
  331. <setting-list-item style="padding: 10px 20px" type="text" title='Packet' :value="noise.packet"
  332. @input="(value) => updateNoisePacket(index, value)" placeholder="5-10"></setting-list-item>
  333. <setting-list-item style="padding: 10px 20px" type="text" title='Delay (ms)' :value="noise.delay"
  334. @input="(value) => updateNoiseDelay(index, value)" placeholder="10-20"></setting-list-item>
  335. <a-button v-if="noisesArray.length > 1" type="danger" @click="removeNoise(index)">Remove</a-button>
  336. </a-collapse-panel>
  337. </a-collapse>
  338. <a-button v-if="noises" type="primary" @click="addNoise" style="margin-top: 10px">Add Noise</a-button>
  339. </a-list-item>
  340. <a-list-item style="padding: 20px">
  341. <a-row>
  342. <a-col :lg="24" :xl="12">
  343. <a-list-item-meta title='{{ i18n "pages.settings.mux"}}'>
  344. <template slot="description">{{ i18n "pages.settings.muxDesc"}}</template>
  345. </a-list-item-meta>
  346. </a-col>
  347. <a-col :lg="24" :xl="12">
  348. <a-switch v-model="enableMux"></a-switch>
  349. </a-col>
  350. </a-row>
  351. <a-collapse v-if="enableMux" style="margin-top: 14px;">
  352. <a-collapse-panel header='{{ i18n "pages.settings.muxSett"}}'>
  353. <setting-list-item style="padding: 10px 20px" type="number" title='Concurrency' v-model="muxConcurrency" :min="-1" :max="1024"></setting-list-item>
  354. <setting-list-item style="padding: 10px 20px" type="number" title='xudp Concurrency' v-model="muxXudpConcurrency" :min="-1" :max="1024"></setting-list-item>
  355. <a-list-item style="padding: 10px 20px">
  356. <a-row>
  357. <a-col :lg="24" :xl="12">
  358. <a-list-item-meta title='xudp UDP 443'></a-list-item-meta>
  359. </a-col>
  360. <a-col :lg="24" :xl="12">
  361. <a-select v-model="muxXudpProxyUDP443" style="width: 100%" :dropdown-class-name="themeSwitcher.currentTheme">
  362. <a-select-option :value="p" :label="p" v-for="p in ['reject', 'allow', 'skip']"> [[ p ]] </a-select-option>
  363. </a-select>
  364. </a-col>
  365. </a-row>
  366. </a-list-item>
  367. </a-collapse-panel>
  368. </a-collapse>
  369. </a-list-item>
  370. <a-list-item style="padding: 20px">
  371. <a-row>
  372. <a-col :lg="24" :xl="12">
  373. <a-list-item-meta title='{{ i18n "pages.settings.direct"}}'>
  374. <template slot="description">{{ i18n "pages.settings.directDesc"}}</template>
  375. </a-list-item-meta>
  376. </a-col>
  377. <a-col :lg="24" :xl="12">
  378. <a-switch v-model="enableDirect"></a-switch>
  379. </a-col>
  380. </a-row>
  381. <a-collapse v-if="enableDirect" style="margin-top: 14px;">
  382. <a-collapse-panel header='{{ i18n "pages.settings.direct"}}'>
  383. <a-list-item>
  384. <a-row style="padding: 0 20px">
  385. <a-col :lg="24" :xl="12">
  386. <a-list-item-meta
  387. title='{{ i18n "pages.xray.directips" }}'/>
  388. </a-col>
  389. <a-col :lg="24" :xl="12">
  390. <a-select mode="tags" style="width: 100%"
  391. v-model="directIPs"
  392. :dropdown-class-name="themeSwitcher.currentTheme">
  393. <a-select-option :value="p.value" :label="p.label"
  394. v-for="p in directIPsOptions"> [[ p.label ]]
  395. </a-select-option>
  396. </a-select>
  397. </a-col>
  398. </a-row>
  399. </a-list-item>
  400. <a-list-item>
  401. <a-row style="padding: 0 20px">
  402. <a-col :lg="24" :xl="12">
  403. <a-list-item-meta
  404. title='{{ i18n "pages.xray.directdomains" }}'/>
  405. </a-col>
  406. <a-col :lg="24" :xl="12">
  407. <a-select mode="tags" style="width: 100%"
  408. v-model="directDomains"
  409. :dropdown-class-name="themeSwitcher.currentTheme">
  410. <a-select-option :value="p.value" :label="p.label"
  411. v-for="p in diretDomainsOptions"> [[ p.label ]]
  412. </a-select-option>
  413. </a-select>
  414. </a-col>
  415. </a-row>
  416. </a-list-item>
  417. </a-collapse-panel>
  418. </a-collapse>
  419. </a-list-item>
  420. </a-list>
  421. </a-tab-pane>
  422. </a-tabs>
  423. </a-space>
  424. </a-spin>
  425. </a-layout-content>
  426. </a-layout>
  427. </a-layout>
  428. {{template "js" .}}
  429. <script src="{{ .base_path }}assets/js/model/setting.js?{{ .cur_ver }}"></script>
  430. {{template "component/themeSwitcher" .}}
  431. {{template "component/password" .}}
  432. {{template "component/setting"}}
  433. <script>
  434. const app = new Vue({
  435. delimiters: ['[[', ']]'],
  436. el: '#app',
  437. data: {
  438. siderDrawer,
  439. themeSwitcher,
  440. spinning: false,
  441. changeSecret: false,
  442. oldAllSetting: new AllSetting(),
  443. allSetting: new AllSetting(),
  444. saveBtnDisable: true,
  445. user: {},
  446. lang: getLang(),
  447. remarkModels: { i: 'Inbound', e: 'Email', o: 'Other' },
  448. remarkSeparators: [' ', '-', '_', '@', ':', '~', '|', ',', '.', '/'],
  449. datepickerList: [{ name: 'Gregorian (Standard)', value: 'gregorian' }, { name: 'Jalalian (شمسی)', value: 'jalalian' }],
  450. remarkSample: '',
  451. defaultFragment: {
  452. tag: "fragment",
  453. protocol: "freedom",
  454. settings: {
  455. domainStrategy: "AsIs",
  456. fragment: {
  457. packets: "tlshello",
  458. length: "100-200",
  459. interval: "10-20"
  460. }
  461. },
  462. streamSettings: {
  463. sockopt: {
  464. tcpKeepAliveIdle: 100,
  465. tcpMptcp: true,
  466. penetrate: true
  467. }
  468. }
  469. },
  470. defaultNoises: {
  471. tag: "noises",
  472. protocol: "freedom",
  473. settings: {
  474. domainStrategy: "AsIs",
  475. noises: [
  476. { type: "rand", packet: "10-20", delay: "10-16" },
  477. ],
  478. },
  479. },
  480. defaultMux: {
  481. enabled: true,
  482. concurrency: 8,
  483. xudpConcurrency: 16,
  484. xudpProxyUDP443: "reject"
  485. },
  486. defaultRules: [
  487. {
  488. type: "field",
  489. outboundTag: "direct",
  490. domain: [
  491. "geosite:category-ir"
  492. ]
  493. },
  494. {
  495. type: "field",
  496. outboundTag: "direct",
  497. ip: [
  498. "geoip:private",
  499. "geoip:ir"
  500. ]
  501. },
  502. ],
  503. directIPsOptions: [
  504. { label: 'Private IP', value: 'geoip:private' },
  505. { label: '🇮🇷 Iran', value: 'geoip:ir' },
  506. { label: '🇨🇳 China', value: 'geoip:cn' },
  507. { label: '🇷🇺 Russia', value: 'geoip:ru' },
  508. { label: '🇻🇳 Vietnam', value: 'geoip:vn' },
  509. { label: '🇪🇸 Spain', value: 'geoip:es' },
  510. { label: '🇮🇩 Indonesia', value: 'geoip:id' },
  511. { label: '🇺🇦 Ukraine', value: 'geoip:ua' },
  512. { label: '🇹🇷 Türkiye', value: 'geoip:tr' },
  513. { label: '🇧🇷 Brazil', value: 'geoip:br' },
  514. ],
  515. diretDomainsOptions: [
  516. { label: 'Private DNS', value: 'geosite:private' },
  517. { label: '🇮🇷 Iran', value: 'geosite:category-ir' },
  518. { label: '🇨🇳 China', value: 'geosite:cn' },
  519. { label: '🇷🇺 Russia', value: 'geosite:category-ru' },
  520. { label: 'Apple', value: 'geosite:apple' },
  521. { label: 'Meta', value: 'geosite:meta' },
  522. { label: 'Google', value: 'geosite:google' },
  523. ],
  524. get remarkModel() {
  525. rm = this.allSetting.remarkModel;
  526. return rm.length > 1 ? rm.substring(1).split('') : [];
  527. },
  528. set remarkModel(value) {
  529. rs = this.allSetting.remarkModel[0];
  530. this.allSetting.remarkModel = rs + value.join('');
  531. this.changeRemarkSample();
  532. },
  533. get remarkSeparator() {
  534. return this.allSetting.remarkModel.length > 1 ? this.allSetting.remarkModel.charAt(0) : '-';
  535. },
  536. set remarkSeparator(value) {
  537. this.allSetting.remarkModel = value + this.allSetting.remarkModel.substring(1);
  538. this.changeRemarkSample();
  539. },
  540. get datepicker() {
  541. return this.allSetting.datepicker ? this.allSetting.datepicker : 'gregorian';
  542. },
  543. set datepicker(value) {
  544. this.allSetting.datepicker = value;
  545. },
  546. changeRemarkSample() {
  547. sample = []
  548. this.remarkModel.forEach(r => sample.push(this.remarkModels[r]));
  549. this.remarkSample = sample.length == 0 ? '' : sample.join(this.remarkSeparator);
  550. }
  551. },
  552. methods: {
  553. loading(spinning = true) {
  554. this.spinning = spinning;
  555. },
  556. async getAllSetting() {
  557. this.loading(true);
  558. const msg = await HttpUtil.post("/panel/setting/all");
  559. this.loading(false);
  560. if (msg.success) {
  561. this.oldAllSetting = new AllSetting(msg.obj);
  562. this.allSetting = new AllSetting(msg.obj);
  563. app.changeRemarkSample();
  564. this.saveBtnDisable = true;
  565. }
  566. await this.fetchUserSecret();
  567. },
  568. async updateAllSetting() {
  569. this.loading(true);
  570. const msg = await HttpUtil.post("/panel/setting/update", this.allSetting);
  571. this.loading(false);
  572. if (msg.success) {
  573. await this.getAllSetting();
  574. }
  575. },
  576. async updateUser() {
  577. this.loading(true);
  578. const msg = await HttpUtil.post("/panel/setting/updateUser", this.user);
  579. this.loading(false);
  580. if (msg.success) {
  581. this.user = {};
  582. window.location.replace(basePath + "logout");
  583. }
  584. },
  585. async restartPanel() {
  586. await new Promise(resolve => {
  587. this.$confirm({
  588. title: '{{ i18n "pages.settings.restartPanel" }}',
  589. content: '{{ i18n "pages.settings.restartPanelDesc" }}',
  590. class: themeSwitcher.currentTheme,
  591. okText: '{{ i18n "sure" }}',
  592. cancelText: '{{ i18n "cancel" }}',
  593. onOk: () => resolve(),
  594. });
  595. });
  596. this.loading(true);
  597. const msg = await HttpUtil.post("/panel/setting/restartPanel");
  598. this.loading(false);
  599. if (msg.success) {
  600. this.loading(true);
  601. await PromiseUtil.sleep(5000);
  602. var { webCertFile, webKeyFile, webDomain: host, webPort: port, webBasePath: base } = this.allSetting;
  603. if (host == this.oldAllSetting.webDomain) host = null;
  604. if (port == this.oldAllSetting.webPort) port = null;
  605. const isTLS = webCertFile !== "" || webKeyFile !== "";
  606. const url = buildURL({ host, port, isTLS, base, path: "panel/settings" });
  607. window.location.replace(url);
  608. }
  609. },
  610. async fetchUserSecret() {
  611. this.loading(true);
  612. const userMessage = await HttpUtil.post("/panel/setting/getUserSecret", this.user);
  613. if (userMessage.success) {
  614. this.user = userMessage.obj;
  615. }
  616. this.loading(false);
  617. },
  618. async updateSecret() {
  619. this.loading(true);
  620. const msg = await HttpUtil.post("/panel/setting/updateUserSecret", this.user);
  621. if (msg && msg.obj) {
  622. this.user = msg.obj;
  623. }
  624. this.loading(false);
  625. await this.updateAllSetting();
  626. },
  627. generateRandomString(length) {
  628. var chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
  629. let randomString = "";
  630. for (let i = 0; i < length; i++) {
  631. randomString += chars[Math.floor(Math.random() * chars.length)];
  632. }
  633. return randomString;
  634. },
  635. async getNewSecret() {
  636. if (!this.changeSecret) {
  637. this.changeSecret = true;
  638. this.user.loginSecret = '';
  639. const newSecret = this.generateRandomString(64);
  640. await PromiseUtil.sleep(1000);
  641. this.user.loginSecret = newSecret;
  642. this.changeSecret = false;
  643. }
  644. },
  645. async toggleToken(value) {
  646. if (value) {
  647. await this.getNewSecret();
  648. } else {
  649. this.user.loginSecret = "";
  650. }
  651. },
  652. addNoise() {
  653. const newNoise = { type: "rand", packet: "10-20", delay: "10-16" };
  654. this.noisesArray = [...this.noisesArray, newNoise];
  655. },
  656. removeNoise(index) {
  657. const newNoises = [...this.noisesArray];
  658. newNoises.splice(index, 1);
  659. this.noisesArray = newNoises;
  660. },
  661. updateNoiseType(index, value) {
  662. const updatedNoises = [...this.noisesArray];
  663. updatedNoises[index] = { ...updatedNoises[index], type: value };
  664. this.noisesArray = updatedNoises;
  665. },
  666. updateNoisePacket(index, value) {
  667. const updatedNoises = [...this.noisesArray];
  668. updatedNoises[index] = { ...updatedNoises[index], packet: value };
  669. this.noisesArray = updatedNoises;
  670. },
  671. updateNoiseDelay(index, value) {
  672. const updatedNoises = [...this.noisesArray];
  673. updatedNoises[index] = { ...updatedNoises[index], delay: value };
  674. this.noisesArray = updatedNoises;
  675. },
  676. },
  677. computed: {
  678. fragment: {
  679. get: function () { return this.allSetting?.subJsonFragment != ""; },
  680. set: function (v) {
  681. this.allSetting.subJsonFragment = v ? JSON.stringify(this.defaultFragment) : "";
  682. }
  683. },
  684. fragmentPackets: {
  685. get: function () { return this.fragment ? JSON.parse(this.allSetting.subJsonFragment).settings.fragment.packets : ""; },
  686. set: function (v) {
  687. if (v != "") {
  688. newFragment = JSON.parse(this.allSetting.subJsonFragment);
  689. newFragment.settings.fragment.packets = v;
  690. this.allSetting.subJsonFragment = JSON.stringify(newFragment);
  691. }
  692. }
  693. },
  694. fragmentLength: {
  695. get: function () { return this.fragment ? JSON.parse(this.allSetting.subJsonFragment).settings.fragment.length : ""; },
  696. set: function (v) {
  697. if (v != "") {
  698. newFragment = JSON.parse(this.allSetting.subJsonFragment);
  699. newFragment.settings.fragment.length = v;
  700. this.allSetting.subJsonFragment = JSON.stringify(newFragment);
  701. }
  702. }
  703. },
  704. fragmentInterval: {
  705. get: function () { return this.fragment ? JSON.parse(this.allSetting.subJsonFragment).settings.fragment.interval : ""; },
  706. set: function (v) {
  707. if (v != "") {
  708. newFragment = JSON.parse(this.allSetting.subJsonFragment);
  709. newFragment.settings.fragment.interval = v;
  710. this.allSetting.subJsonFragment = JSON.stringify(newFragment);
  711. }
  712. }
  713. },
  714. noises: {
  715. get() {
  716. return this.allSetting?.subJsonNoises != "";
  717. },
  718. set(v) {
  719. if (v) {
  720. this.allSetting.subJsonNoises = JSON.stringify(this.defaultNoises);
  721. } else {
  722. this.allSetting.subJsonNoises = "";
  723. }
  724. }
  725. },
  726. noisesArray: {
  727. get() {
  728. return this.noises ? JSON.parse(this.allSetting.subJsonNoises).settings.noises : [];
  729. },
  730. set(value) {
  731. if (this.noises) {
  732. const newNoises = JSON.parse(this.allSetting.subJsonNoises);
  733. newNoises.settings.noises = value;
  734. this.allSetting.subJsonNoises = JSON.stringify(newNoises);
  735. }
  736. }
  737. },
  738. enableMux: {
  739. get: function () { return this.allSetting?.subJsonMux != ""; },
  740. set: function (v) {
  741. this.allSetting.subJsonMux = v ? JSON.stringify(this.defaultMux) : "";
  742. }
  743. },
  744. muxConcurrency: {
  745. get: function () { return this.enableMux ? JSON.parse(this.allSetting.subJsonMux).concurrency : -1; },
  746. set: function (v) {
  747. newMux = JSON.parse(this.allSetting.subJsonMux);
  748. newMux.concurrency = v;
  749. this.allSetting.subJsonMux = JSON.stringify(newMux);
  750. }
  751. },
  752. muxXudpConcurrency: {
  753. get: function () { return this.enableMux ? JSON.parse(this.allSetting.subJsonMux).xudpConcurrency : -1; },
  754. set: function (v) {
  755. newMux = JSON.parse(this.allSetting.subJsonMux);
  756. newMux.xudpConcurrency = v;
  757. this.allSetting.subJsonMux = JSON.stringify(newMux);
  758. }
  759. },
  760. muxXudpProxyUDP443: {
  761. get: function () { return this.enableMux ? JSON.parse(this.allSetting.subJsonMux).xudpProxyUDP443 : "reject"; },
  762. set: function (v) {
  763. newMux = JSON.parse(this.allSetting.subJsonMux);
  764. newMux.xudpProxyUDP443 = v;
  765. this.allSetting.subJsonMux = JSON.stringify(newMux);
  766. }
  767. },
  768. enableDirect: {
  769. get: function () { return this.allSetting?.subJsonRules != ""; },
  770. set: function (v) {
  771. this.allSetting.subJsonRules = v ? JSON.stringify(this.defaultRules) : "";
  772. }
  773. },
  774. directIPs: {
  775. get: function () {
  776. if (!this.enableDirect) return [];
  777. const rules = JSON.parse(this.allSetting.subJsonRules);
  778. if (!Array.isArray(rules)) return [];
  779. const ipRule = rules.find(r => r.ip);
  780. return ipRule?.ip ?? [];
  781. },
  782. set: function (v) {
  783. let rules = JSON.parse(this.allSetting.subJsonRules);
  784. if (!Array.isArray(rules)) return;
  785. if (v.length == 0) {
  786. rules = rules.filter(r => !r.ip);
  787. } else {
  788. let ruleIndex = rules.findIndex(r => r.ip);
  789. if (ruleIndex == -1) ruleIndex = rules.push(this.defaultRules[1]) - 1;
  790. rules[ruleIndex].ip = [];
  791. v.forEach(d => {
  792. rules[ruleIndex].ip.push(d);
  793. });
  794. }
  795. this.allSetting.subJsonRules = JSON.stringify(rules);
  796. }
  797. },
  798. directDomains: {
  799. get: function () {
  800. if (!this.enableDirect) return [];
  801. const rules = JSON.parse(this.allSetting.subJsonRules);
  802. if (!Array.isArray(rules)) return [];
  803. const domainRule = rules.find(r => r.domain);
  804. return domainRule?.domain ?? [];
  805. },
  806. set: function (v) {
  807. let rules = JSON.parse(this.allSetting.subJsonRules);
  808. if (!Array.isArray(rules)) return;
  809. if (v.length == 0) {
  810. rules = rules.filter(r => !r.domain);
  811. } else {
  812. let ruleIndex = rules.findIndex(r => r.domain);
  813. if (ruleIndex == -1) ruleIndex = rules.push(this.defaultRules[0]) - 1;
  814. rules[ruleIndex].domain = v;
  815. }
  816. this.allSetting.subJsonRules = JSON.stringify(rules);
  817. }
  818. },
  819. confAlerts: {
  820. get: function () {
  821. if (!this.allSetting) return [];
  822. var alerts = []
  823. if (window.location.protocol !== "https:") alerts.push('{{ i18n "secAlertSSL" }}');
  824. if (this.allSetting.webPort == 54321) alerts.push('{{ i18n "secAlertPanelPort" }}');
  825. panelPath = window.location.pathname.split('/').length < 4
  826. if (panelPath && this.allSetting.webBasePath == '/') alerts.push('{{ i18n "secAlertPanelURI" }}');
  827. if (this.allSetting.subEnable) {
  828. subPath = this.allSetting.subURI.length > 0 ? new URL(this.allSetting.subURI).pathname : this.allSetting.subPath;
  829. if (subPath == '/sub/') alerts.push('{{ i18n "secAlertSubURI" }}');
  830. subJsonPath = this.allSetting.subJsonURI.length > 0 ? new URL(this.allSetting.subJsonURI).pathname : this.allSetting.subJsonPath;
  831. if (subJsonPath == '/json/') alerts.push('{{ i18n "secAlertSubJsonURI" }}');
  832. }
  833. return alerts
  834. }
  835. }
  836. },
  837. async mounted() {
  838. await this.getAllSetting();
  839. while (true) {
  840. await PromiseUtil.sleep(1000);
  841. this.saveBtnDisable = this.oldAllSetting.equals(this.allSetting);
  842. }
  843. }
  844. });
  845. </script>
  846. </body>
  847. </html>