mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-09-07 10:46:19 +00:00
add ui proxy setting
This commit is contained in:
parent
24a0b143ae
commit
b6c787f5d7
7 changed files with 24 additions and 1 deletions
|
@ -14,6 +14,7 @@ class AllSetting {
|
||||||
this.remarkModel = "-ieo";
|
this.remarkModel = "-ieo";
|
||||||
this.tgBotEnable = false;
|
this.tgBotEnable = false;
|
||||||
this.tgBotToken = "";
|
this.tgBotToken = "";
|
||||||
|
this.tgBotProxy = "";
|
||||||
this.tgBotChatId = "";
|
this.tgBotChatId = "";
|
||||||
this.tgRunTime = "@daily";
|
this.tgRunTime = "@daily";
|
||||||
this.tgBotBackup = false;
|
this.tgBotBackup = false;
|
||||||
|
|
|
@ -28,6 +28,7 @@ type AllSetting struct {
|
||||||
RemarkModel string `json:"remarkModel" form:"remarkModel"`
|
RemarkModel string `json:"remarkModel" form:"remarkModel"`
|
||||||
TgBotEnable bool `json:"tgBotEnable" form:"tgBotEnable"`
|
TgBotEnable bool `json:"tgBotEnable" form:"tgBotEnable"`
|
||||||
TgBotToken string `json:"tgBotToken" form:"tgBotToken"`
|
TgBotToken string `json:"tgBotToken" form:"tgBotToken"`
|
||||||
|
TgBotProxy string `json:"tgBotProxy" form:"tgBotProxy"`
|
||||||
TgBotChatId string `json:"tgBotChatId" form:"tgBotChatId"`
|
TgBotChatId string `json:"tgBotChatId" form:"tgBotChatId"`
|
||||||
TgRunTime string `json:"tgRunTime" form:"tgRunTime"`
|
TgRunTime string `json:"tgRunTime" form:"tgRunTime"`
|
||||||
TgBotBackup bool `json:"tgBotBackup" form:"tgBotBackup"`
|
TgBotBackup bool `json:"tgBotBackup" form:"tgBotBackup"`
|
||||||
|
|
|
@ -243,6 +243,7 @@
|
||||||
<setting-list-item type="switch" title='{{ i18n "pages.settings.tgNotifyBackup" }}' desc='{{ i18n "pages.settings.tgNotifyBackupDesc" }}' v-model="allSetting.tgBotBackup"></setting-list-item>
|
<setting-list-item type="switch" title='{{ i18n "pages.settings.tgNotifyBackup" }}' desc='{{ i18n "pages.settings.tgNotifyBackupDesc" }}' v-model="allSetting.tgBotBackup"></setting-list-item>
|
||||||
<setting-list-item type="switch" title='{{ i18n "pages.settings.tgNotifyLogin" }}' desc='{{ i18n "pages.settings.tgNotifyLoginDesc" }}' v-model="allSetting.tgBotLoginNotify"></setting-list-item>
|
<setting-list-item type="switch" title='{{ i18n "pages.settings.tgNotifyLogin" }}' desc='{{ i18n "pages.settings.tgNotifyLoginDesc" }}' v-model="allSetting.tgBotLoginNotify"></setting-list-item>
|
||||||
<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>
|
<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>
|
||||||
|
<setting-list-item type="text" title='{{ i18n "pages.settings.telegramProxy"}}' desc='{{ i18n "pages.settings.telegramProxyDesc"}}' v-model="allSetting.tgBotProxy"></setting-list-item>
|
||||||
<a-list-item>
|
<a-list-item>
|
||||||
<a-row style="padding: 20px">
|
<a-row style="padding: 20px">
|
||||||
<a-col :lg="24" :xl="12">
|
<a-col :lg="24" :xl="12">
|
||||||
|
|
|
@ -38,6 +38,7 @@ var defaultValueMap = map[string]string{
|
||||||
"timeLocation": "Asia/Tehran",
|
"timeLocation": "Asia/Tehran",
|
||||||
"tgBotEnable": "false",
|
"tgBotEnable": "false",
|
||||||
"tgBotToken": "",
|
"tgBotToken": "",
|
||||||
|
"tgBotProxy": "",
|
||||||
"tgBotChatId": "",
|
"tgBotChatId": "",
|
||||||
"tgRunTime": "@daily",
|
"tgRunTime": "@daily",
|
||||||
"tgBotBackup": "false",
|
"tgBotBackup": "false",
|
||||||
|
@ -244,6 +245,14 @@ func (s *SettingService) SetTgBotToken(token string) error {
|
||||||
return s.setString("tgBotToken", token)
|
return s.setString("tgBotToken", token)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *SettingService) GetTgBotProxy() (string, error) {
|
||||||
|
return s.getString("tgBotProxy")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *SettingService) SetTgBotProxy(token string) error {
|
||||||
|
return s.setString("tgBotProxy", token)
|
||||||
|
}
|
||||||
|
|
||||||
func (s *SettingService) GetTgBotChatId() (string, error) {
|
func (s *SettingService) GetTgBotChatId() (string, error) {
|
||||||
return s.getString("tgBotChatId")
|
return s.getString("tgBotChatId")
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,6 +89,13 @@ func (t *Tgbot) Start(i18nFS embed.FS) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tgBotProxy, err := t.settingService.GetTgBotProxy()
|
||||||
|
if err != nil || tgBotProxy == "" {
|
||||||
|
logger.Warning("Telegram proxy not valid use direct connection")
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
bot, err = telego.NewBot(tgBottoken)
|
bot, err = telego.NewBot(tgBottoken)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Get tgbot's api error:", err)
|
fmt.Println("Get tgbot's api error:", err)
|
||||||
|
|
|
@ -255,6 +255,8 @@
|
||||||
"telegramBotEnableDesc" = "Connect to the features of this panel through the Telegram bot"
|
"telegramBotEnableDesc" = "Connect to the features of this panel through the Telegram bot"
|
||||||
"telegramToken" = "Telegram Token"
|
"telegramToken" = "Telegram Token"
|
||||||
"telegramTokenDesc" = "You must get the token from the manager of Telegram bots @botfather"
|
"telegramTokenDesc" = "You must get the token from the manager of Telegram bots @botfather"
|
||||||
|
"telegramProxy" = "Telegram Socks5 Proxy"
|
||||||
|
"telegramProxyDesc" = "If you need Telegram to connect through a socks5 proxy. (socks5://user:pass@host:port)"
|
||||||
"telegramChatId" = "Telegram Admin Chat IDs"
|
"telegramChatId" = "Telegram Admin Chat IDs"
|
||||||
"telegramChatIdDesc" = "Multiple Chat IDs separated by comma. use @userinfobot or use '/id' command in bot to get your Chat IDs."
|
"telegramChatIdDesc" = "Multiple Chat IDs separated by comma. use @userinfobot or use '/id' command in bot to get your Chat IDs."
|
||||||
"telegramNotifyTime" = "Telegram bot notification time"
|
"telegramNotifyTime" = "Telegram bot notification time"
|
||||||
|
|
|
@ -50,7 +50,9 @@ func (x *XrayAPI) Init(apiPort int) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *XrayAPI) Close() {
|
func (x *XrayAPI) Close() {
|
||||||
x.grpcClient.Close()
|
if x.grpcClient != nil {
|
||||||
|
x.grpcClient.Close()
|
||||||
|
}
|
||||||
x.HandlerServiceClient = nil
|
x.HandlerServiceClient = nil
|
||||||
x.StatsServiceClient = nil
|
x.StatsServiceClient = nil
|
||||||
x.isConnected = false
|
x.isConnected = false
|
||||||
|
|
Loading…
Reference in a new issue