1
0

settings.html 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748
  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 2.5rem;
  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. <a-list-item>
  248. <a-row style="padding: 20px">
  249. <a-col :lg="24" :xl="12">
  250. <a-list-item-meta title="Telegram Bot Language" />
  251. </a-col>
  252. <a-col :lg="24" :xl="12">
  253. <template>
  254. <a-select ref="selectBotLang" v-model="allSetting.tgLang" :dropdown-class-name="themeSwitcher.currentTheme" style="width: 100%">
  255. <a-select-option :value="l.value" :label="l.value" v-for="l in supportLangs">
  256. <span role="img" :aria-label="l.name" v-text="l.icon"></span> &nbsp;&nbsp; <span v-text="l.name"></span>
  257. </a-select-option>
  258. </a-select>
  259. </template>
  260. </a-col>
  261. </a-row>
  262. </a-list-item>
  263. </a-list>
  264. </a-tab-pane>
  265. <a-tab-pane key="4" tab='{{ i18n "pages.settings.subSettings" }}'>
  266. <a-list item-layout="horizontal">
  267. <setting-list-item type="switch" title='{{ i18n "pages.settings.subEnable"}}' desc='{{ i18n "pages.settings.subEnableDesc"}}' v-model="allSetting.subEnable"></setting-list-item>
  268. <setting-list-item type="switch" title='{{ i18n "pages.settings.subEncrypt"}}' desc='{{ i18n "pages.settings.subEncryptDesc"}}' v-model="allSetting.subEncrypt"></setting-list-item>
  269. <setting-list-item type="switch" title='{{ i18n "pages.settings.subShowInfo"}}' desc='{{ i18n "pages.settings.subShowInfoDesc"}}' v-model="allSetting.subShowInfo"></setting-list-item>
  270. <setting-list-item type="text" title='{{ i18n "pages.settings.subListen"}}' desc='{{ i18n "pages.settings.subListenDesc"}}' v-model="allSetting.subListen"></setting-list-item>
  271. <setting-list-item type="text" title='{{ i18n "pages.settings.subDomain"}}' desc='{{ i18n "pages.settings.subDomainDesc"}}' v-model="allSetting.subDomain"></setting-list-item>
  272. <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>
  273. <setting-list-item type="text" title='{{ i18n "pages.settings.subPath"}}' desc='{{ i18n "pages.settings.subPathDesc"}}' v-model="allSetting.subPath"></setting-list-item>
  274. <setting-list-item type="text" title='{{ i18n "pages.settings.subCertPath"}}' desc='{{ i18n "pages.settings.subCertPathDesc"}}' v-model="allSetting.subCertFile"></setting-list-item>
  275. <setting-list-item type="text" title='{{ i18n "pages.settings.subKeyPath"}}' desc='{{ i18n "pages.settings.subKeyPathDesc"}}' v-model="allSetting.subKeyFile"></setting-list-item>
  276. <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>
  277. <setting-list-item type="number" title='{{ i18n "pages.settings.subUpdates"}}' desc='{{ i18n "pages.settings.subUpdatesDesc"}}' v-model="allSetting.subUpdates" :min="1"></setting-list-item>
  278. </a-list>
  279. </a-tab-pane>
  280. <a-tab-pane key="5" tab='{{ i18n "pages.settings.subSettings" }} Json' v-if="allSetting.subEnable">
  281. <a-list item-layout="horizontal">
  282. <setting-list-item type="text" title='{{ i18n "pages.settings.subPath"}}' desc='{{ i18n "pages.settings.subPathDesc"}}' v-model="allSetting.subJsonPath"></setting-list-item>
  283. <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>
  284. <a-list-item style="padding: 20px">
  285. <a-row>
  286. <a-col :lg="24" :xl="12">
  287. <a-list-item-meta title='{{ i18n "pages.settings.fragment"}}'>
  288. <template slot="description">{{ i18n "pages.settings.fragmentDesc"}}</template>
  289. </a-list-item-meta>
  290. </a-col>
  291. <a-col :lg="24" :xl="12">
  292. <a-switch v-model="fragment"></a-switch>
  293. </a-col>
  294. </a-row>
  295. <a-collapse v-if="fragment" style="margin-top: 14px;">
  296. <a-collapse-panel header='{{ i18n "pages.settings.fragmentSett"}}' v-if="fragment">
  297. <setting-list-item style="padding: 10px 20px" type="text" title='Packets' v-model="fragmentPackets" placeholder="1-1 | 1-3 | tlshello | ..."></setting-list-item>
  298. <setting-list-item style="padding: 10px 20px" type="text" title='Length' v-model="fragmentLength" placeholder="100-200"></setting-list-item>
  299. <setting-list-item style="padding: 10px 20px" type="text" title='Interval' v-model="fragmentInterval" placeholder="10-20"></setting-list-item>
  300. </a-collapse-panel>
  301. </a-collapse>
  302. </a-list-item>
  303. <a-list-item style="padding: 20px">
  304. <a-row>
  305. <a-col :lg="24" :xl="12">
  306. <a-list-item-meta title='Noise'>
  307. <template slot="description">{{ i18n "pages.settings.noiseDesc"}}</template>
  308. </a-list-item-meta>
  309. </a-col>
  310. <a-col :lg="24" :xl="12">
  311. <a-switch v-model="noise"></a-switch>
  312. </a-col>
  313. </a-row>
  314. <a-collapse v-if="noise" style="margin-top: 14px;">
  315. <a-collapse-panel header='{{ i18n "pages.settings.noiseSett"}}' v-if="noise">
  316. <setting-list-item style="padding: 10px 20px" type="text" title='Packet (ms)' v-model="noisePacket" placeholder="rand:5-10"></setting-list-item>
  317. <setting-list-item style="padding: 10px 20px" type="text" title='Delay (ms)' v-model="noiseDelay" placeholder="10-20"></setting-list-item>
  318. </a-collapse-panel>
  319. </a-collapse>
  320. </a-list-item>
  321. <a-list-item style="padding: 20px">
  322. <a-row>
  323. <a-col :lg="24" :xl="12">
  324. <a-list-item-meta title='{{ i18n "pages.settings.mux"}}'>
  325. <template slot="description">{{ i18n "pages.settings.muxDesc"}}</template>
  326. </a-list-item-meta>
  327. </a-col>
  328. <a-col :lg="24" :xl="12">
  329. <a-switch v-model="enableMux"></a-switch>
  330. </a-col>
  331. </a-row>
  332. <a-collapse v-if="enableMux" style="margin-top: 14px;">
  333. <a-collapse-panel header='{{ i18n "pages.settings.muxSett"}}'>
  334. <setting-list-item style="padding: 10px 20px" type="number" title='Concurrency' v-model="muxConcurrency" :min="-1" :max="1024"></setting-list-item>
  335. <setting-list-item style="padding: 10px 20px" type="number" title='xudp Concurrency' v-model="muxXudpConcurrency" :min="-1" :max="1024"></setting-list-item>
  336. <a-list-item style="padding: 10px 20px">
  337. <a-row>
  338. <a-col :lg="24" :xl="12">
  339. <a-list-item-meta title='xudp UDP 443'></a-list-item-meta>
  340. </a-col>
  341. <a-col :lg="24" :xl="12">
  342. <a-select v-model="muxXudpProxyUDP443" style="width: 100%" :dropdown-class-name="themeSwitcher.currentTheme">
  343. <a-select-option :value="p" :label="p" v-for="p in ['reject', 'allow', 'skip']"> [[ p ]] </a-select-option>
  344. </a-select>
  345. </a-col>
  346. </a-row>
  347. </a-list-item>
  348. </a-collapse-panel>
  349. </a-collapse>
  350. </a-list-item>
  351. <a-list-item style="padding: 20px">
  352. <a-row>
  353. <a-col :lg="24" :xl="12">
  354. <a-list-item-meta title='{{ i18n "pages.settings.direct"}}'>
  355. <template slot="description">{{ i18n "pages.settings.directDesc"}}</template>
  356. </a-list-item-meta>
  357. </a-col>
  358. <a-col :lg="24" :xl="12">
  359. <a-switch v-model="enableDirect"></a-switch>
  360. </a-col>
  361. </a-row>
  362. <a-collapse v-if="enableDirect" style="margin-top: 14px;">
  363. <a-collapse-panel header='{{ i18n "pages.settings.directSett"}}'>
  364. <a-list-item style="padding: 10px 20px">
  365. <a-checkbox-group v-model="directCountries" name="Countries" :options="countryOptions"></a-checkbox-group>
  366. </a-list-item>
  367. </a-collapse-panel>
  368. </a-collapse>
  369. </a-list-item>
  370. </a-list>
  371. </a-tab-pane>
  372. </a-tabs>
  373. </a-space>
  374. </a-spin>
  375. </a-layout-content>
  376. </a-layout>
  377. </a-layout>
  378. {{template "js" .}}
  379. <script src="{{ .base_path }}assets/js/model/setting.js?{{ .cur_ver }}"></script>
  380. {{template "component/themeSwitcher" .}}
  381. {{template "component/password" .}}
  382. {{template "component/setting"}}
  383. <script>
  384. const app = new Vue({
  385. delimiters: ['[[', ']]'],
  386. el: '#app',
  387. data: {
  388. siderDrawer,
  389. themeSwitcher,
  390. spinning: false,
  391. changeSecret: false,
  392. oldAllSetting: new AllSetting(),
  393. allSetting: new AllSetting(),
  394. saveBtnDisable: true,
  395. user: {},
  396. lang: getLang(),
  397. remarkModels: { i: 'Inbound', e: 'Email', o: 'Other' },
  398. remarkSeparators: [' ', '-', '_', '@', ':', '~', '|', ',', '.', '/'],
  399. datepickerList: [{ name: 'Gregorian (Standard)', value: 'gregorian' }, { name: 'Jalalian (شمسی)', value: 'jalalian' }],
  400. remarkSample: '',
  401. defaultFragment: {
  402. tag: "fragment",
  403. protocol: "freedom",
  404. settings: {
  405. domainStrategy: "AsIs",
  406. fragment: {
  407. packets: "tlshello",
  408. length: "100-200",
  409. interval: "10-20"
  410. }
  411. },
  412. streamSettings: {
  413. sockopt: {
  414. tcpKeepAliveIdle: 100,
  415. tcpMptcp: true,
  416. tcpNoDelay: true
  417. }
  418. }
  419. },
  420. defaultNoise: {
  421. tag: "noise",
  422. protocol: "freedom",
  423. settings: {
  424. domainStrategy: "AsIs",
  425. noise: {
  426. packet: "rand:5-10",
  427. delay: "10-20",
  428. }
  429. },
  430. },
  431. defaultMux: {
  432. enabled: true,
  433. concurrency: 8,
  434. xudpConcurrency: 16,
  435. xudpProxyUDP443: "reject"
  436. },
  437. defaultRules: [
  438. {
  439. type: "field",
  440. outboundTag: "direct",
  441. domain: [
  442. "geosite:category-ir",
  443. "geosite:cn"
  444. ],
  445. "enabled": true
  446. },
  447. {
  448. type: "field",
  449. outboundTag: "direct",
  450. ip: [
  451. "geoip:private",
  452. "geoip:ir",
  453. "geoip:cn"
  454. ],
  455. enabled: true
  456. },
  457. ],
  458. countryOptions: [
  459. { label: 'Private IP/Domain', value: 'private' },
  460. { label: '🇮🇷 Iran', value: 'ir' },
  461. { label: '🇨🇳 China', value: 'cn' },
  462. { label: '🇷🇺 Russia', value: 'ru' },
  463. ],
  464. get remarkModel() {
  465. rm = this.allSetting.remarkModel;
  466. return rm.length > 1 ? rm.substring(1).split('') : [];
  467. },
  468. set remarkModel(value) {
  469. rs = this.allSetting.remarkModel[0];
  470. this.allSetting.remarkModel = rs + value.join('');
  471. this.changeRemarkSample();
  472. },
  473. get remarkSeparator() {
  474. return this.allSetting.remarkModel.length > 1 ? this.allSetting.remarkModel.charAt(0) : '-';
  475. },
  476. set remarkSeparator(value) {
  477. this.allSetting.remarkModel = value + this.allSetting.remarkModel.substring(1);
  478. this.changeRemarkSample();
  479. },
  480. get datepicker() {
  481. return this.allSetting.datepicker ? this.allSetting.datepicker : 'gregorian';
  482. },
  483. set datepicker(value) {
  484. this.allSetting.datepicker = value;
  485. },
  486. changeRemarkSample() {
  487. sample = []
  488. this.remarkModel.forEach(r => sample.push(this.remarkModels[r]));
  489. this.remarkSample = sample.length == 0 ? '' : sample.join(this.remarkSeparator);
  490. }
  491. },
  492. methods: {
  493. loading(spinning = true) {
  494. this.spinning = spinning;
  495. },
  496. async getAllSetting() {
  497. this.loading(true);
  498. const msg = await HttpUtil.post("/panel/setting/all");
  499. this.loading(false);
  500. if (msg.success) {
  501. this.oldAllSetting = new AllSetting(msg.obj);
  502. this.allSetting = new AllSetting(msg.obj);
  503. app.changeRemarkSample();
  504. this.saveBtnDisable = true;
  505. }
  506. await this.fetchUserSecret();
  507. },
  508. async updateAllSetting() {
  509. this.loading(true);
  510. const msg = await HttpUtil.post("/panel/setting/update", this.allSetting);
  511. this.loading(false);
  512. if (msg.success) {
  513. await this.getAllSetting();
  514. }
  515. },
  516. async updateUser() {
  517. this.loading(true);
  518. const msg = await HttpUtil.post("/panel/setting/updateUser", this.user);
  519. this.loading(false);
  520. if (msg.success) {
  521. this.user = {};
  522. window.location.replace(basePath + "logout");
  523. }
  524. },
  525. async restartPanel() {
  526. await new Promise(resolve => {
  527. this.$confirm({
  528. title: '{{ i18n "pages.settings.restartPanel" }}',
  529. content: '{{ i18n "pages.settings.restartPanelDesc" }}',
  530. class: themeSwitcher.currentTheme,
  531. okText: '{{ i18n "sure" }}',
  532. cancelText: '{{ i18n "cancel" }}',
  533. onOk: () => resolve(),
  534. });
  535. });
  536. this.loading(true);
  537. const msg = await HttpUtil.post("/panel/setting/restartPanel");
  538. this.loading(false);
  539. if (msg.success) {
  540. this.loading(true);
  541. await PromiseUtil.sleep(5000);
  542. var { webCertFile, webKeyFile, webDomain: host, webPort: port, webBasePath: base } = this.allSetting;
  543. if (host == this.oldAllSetting.webDomain) host = null;
  544. if (port == this.oldAllSetting.webPort) port = null;
  545. const isTLS = webCertFile !== "" || webKeyFile !== "";
  546. const url = buildURL({ host, port, isTLS, base, path: "panel/settings" });
  547. window.location.replace(url);
  548. }
  549. },
  550. async fetchUserSecret() {
  551. this.loading(true);
  552. const userMessage = await HttpUtil.post("/panel/setting/getUserSecret", this.user);
  553. if (userMessage.success) {
  554. this.user = userMessage.obj;
  555. }
  556. this.loading(false);
  557. },
  558. async updateSecret() {
  559. this.loading(true);
  560. const msg = await HttpUtil.post("/panel/setting/updateUserSecret", this.user);
  561. if (msg && msg.obj) {
  562. this.user = msg.obj;
  563. }
  564. this.loading(false);
  565. await this.updateAllSetting();
  566. },
  567. generateRandomString(length) {
  568. var chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
  569. let randomString = "";
  570. for (let i = 0; i < length; i++) {
  571. randomString += chars[Math.floor(Math.random() * chars.length)];
  572. }
  573. return randomString;
  574. },
  575. async getNewSecret() {
  576. if (!this.changeSecret) {
  577. this.changeSecret = true;
  578. this.user.loginSecret = '';
  579. const newSecret = this.generateRandomString(64);
  580. await PromiseUtil.sleep(1000);
  581. this.user.loginSecret = newSecret;
  582. this.changeSecret = false;
  583. }
  584. },
  585. async toggleToken(value) {
  586. if (value) {
  587. await this.getNewSecret();
  588. } else {
  589. this.user.loginSecret = "";
  590. }
  591. },
  592. },
  593. computed: {
  594. fragment: {
  595. get: function () { return this.allSetting?.subJsonFragment != ""; },
  596. set: function (v) {
  597. this.allSetting.subJsonFragment = v ? JSON.stringify(this.defaultFragment) : "";
  598. }
  599. },
  600. fragmentPackets: {
  601. get: function () { return this.fragment ? JSON.parse(this.allSetting.subJsonFragment).settings.fragment.packets : ""; },
  602. set: function (v) {
  603. if (v != "") {
  604. newFragment = JSON.parse(this.allSetting.subJsonFragment);
  605. newFragment.settings.fragment.packets = v;
  606. this.allSetting.subJsonFragment = JSON.stringify(newFragment);
  607. }
  608. }
  609. },
  610. fragmentLength: {
  611. get: function () { return this.fragment ? JSON.parse(this.allSetting.subJsonFragment).settings.fragment.length : ""; },
  612. set: function (v) {
  613. if (v != "") {
  614. newFragment = JSON.parse(this.allSetting.subJsonFragment);
  615. newFragment.settings.fragment.length = v;
  616. this.allSetting.subJsonFragment = JSON.stringify(newFragment);
  617. }
  618. }
  619. },
  620. fragmentInterval: {
  621. get: function () { return this.fragment ? JSON.parse(this.allSetting.subJsonFragment).settings.fragment.interval : ""; },
  622. set: function (v) {
  623. if (v != "") {
  624. newFragment = JSON.parse(this.allSetting.subJsonFragment);
  625. newFragment.settings.fragment.interval = v;
  626. this.allSetting.subJsonFragment = JSON.stringify(newFragment);
  627. }
  628. }
  629. },
  630. noise: {
  631. get: function () { return this.allSetting?.subJsonNoise != ""; },
  632. set: function (v) {
  633. this.allSetting.subJsonNoise = v ? JSON.stringify(this.defaultNoise) : "";
  634. }
  635. },
  636. noisePacket: {
  637. get: function () { return this.noise ? JSON.parse(this.allSetting.subJsonNoise).settings.noise.packet : ""; },
  638. set: function (v) {
  639. if (v != "") {
  640. newNoise = JSON.parse(this.allSetting.subJsonNoise);
  641. newNoise.settings.noise.packet = v;
  642. this.allSetting.subJsonNoise = JSON.stringify(newNoise);
  643. }
  644. }
  645. },
  646. noiseDelay: {
  647. get: function () { return this.noise ? JSON.parse(this.allSetting.subJsonNoise).settings.noise.delay : ""; },
  648. set: function (v) {
  649. if (v != "") {
  650. newNoise = JSON.parse(this.allSetting.subJsonNoise);
  651. newNoise.settings.noise.delay = v;
  652. this.allSetting.subJsonNoise = JSON.stringify(newNoise);
  653. }
  654. }
  655. },
  656. enableMux: {
  657. get: function () { return this.allSetting?.subJsonMux != ""; },
  658. set: function (v) {
  659. this.allSetting.subJsonMux = v ? JSON.stringify(this.defaultMux) : "";
  660. }
  661. },
  662. muxConcurrency: {
  663. get: function () { return this.enableMux ? JSON.parse(this.allSetting.subJsonMux).concurrency : -1; },
  664. set: function (v) {
  665. newMux = JSON.parse(this.allSetting.subJsonMux);
  666. newMux.concurrency = v;
  667. this.allSetting.subJsonMux = JSON.stringify(newMux);
  668. }
  669. },
  670. muxXudpConcurrency: {
  671. get: function () { return this.enableMux ? JSON.parse(this.allSetting.subJsonMux).xudpConcurrency : -1; },
  672. set: function (v) {
  673. newMux = JSON.parse(this.allSetting.subJsonMux);
  674. newMux.xudpConcurrency = v;
  675. this.allSetting.subJsonMux = JSON.stringify(newMux);
  676. }
  677. },
  678. muxXudpProxyUDP443: {
  679. get: function () { return this.enableMux ? JSON.parse(this.allSetting.subJsonMux).xudpProxyUDP443 : "reject"; },
  680. set: function (v) {
  681. newMux = JSON.parse(this.allSetting.subJsonMux);
  682. newMux.xudpProxyUDP443 = v;
  683. this.allSetting.subJsonMux = JSON.stringify(newMux);
  684. }
  685. },
  686. enableDirect: {
  687. get: function () { return this.allSetting?.subJsonRules != ""; },
  688. set: function (v) {
  689. this.allSetting.subJsonRules = v ? JSON.stringify(this.defaultRules) : "";
  690. }
  691. },
  692. directCountries: {
  693. get: function () {
  694. if (!this.enableDirect) return [];
  695. rules = JSON.parse(this.allSetting.subJsonRules);
  696. return Array.isArray(rules) ? rules[1].ip.map(d => d.replace("geoip:", "")) : [];
  697. },
  698. set: function (v) {
  699. rules = JSON.parse(this.allSetting.subJsonRules);
  700. if (!Array.isArray(rules)) return;
  701. rules[0].domain = [];
  702. rules[1].ip = [];
  703. v.forEach(d => {
  704. let category = '';
  705. if (["cn", "private"].includes(d)) {
  706. category = "";
  707. } else if (d === 'ru') {
  708. category = "category-gov-";
  709. } else {
  710. category = "category-";
  711. }
  712. rules[0].domain.push("geosite:" + category + d);
  713. rules[1].ip.push("geoip:" + d);
  714. });
  715. this.allSetting.subJsonRules = JSON.stringify(rules);
  716. }
  717. },
  718. confAlerts: {
  719. get: function () {
  720. if (!this.allSetting) return [];
  721. var alerts = []
  722. if (window.location.protocol !== "https:") alerts.push('{{ i18n "secAlertSSL" }}');
  723. if (this.allSetting.webPort == 54321) alerts.push('{{ i18n "secAlertPanelPort" }}');
  724. panelPath = window.location.pathname.split('/').length < 4
  725. if (panelPath && this.allSetting.webBasePath == '/') alerts.push('{{ i18n "secAlertPanelURI" }}');
  726. if (this.allSetting.subEnable) {
  727. subPath = this.allSetting.subURI.length > 0 ? new URL(this.allSetting.subURI).pathname : this.allSetting.subPath;
  728. if (subPath == '/sub/') alerts.push('{{ i18n "secAlertSubURI" }}');
  729. subJsonPath = this.allSetting.subJsonURI.length > 0 ? new URL(this.allSetting.subJsonURI).pathname : this.allSetting.subJsonPath;
  730. if (subJsonPath == '/json/') alerts.push('{{ i18n "secAlertSubJsonURI" }}');
  731. }
  732. return alerts
  733. }
  734. }
  735. },
  736. async mounted() {
  737. await this.getAllSetting();
  738. while (true) {
  739. await PromiseUtil.sleep(1000);
  740. this.saveBtnDisable = this.oldAllSetting.equals(this.allSetting);
  741. }
  742. }
  743. });
  744. </script>
  745. </body>
  746. </html>