1
0

settings.html 42 KB

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