diff --git a/web/assets/js/model/setting.js b/web/assets/js/model/setting.js
index 86bea983..8b08fd4b 100644
--- a/web/assets/js/model/setting.js
+++ b/web/assets/js/model/setting.js
@@ -14,6 +14,7 @@ class AllSetting {
this.remarkModel = "-ieo";
this.tgBotEnable = false;
this.tgBotToken = "";
+ this.tgBotProxy = "";
this.tgBotChatId = "";
this.tgRunTime = "@daily";
this.tgBotBackup = false;
diff --git a/web/entity/entity.go b/web/entity/entity.go
index d00f51e1..3e26ffef 100644
--- a/web/entity/entity.go
+++ b/web/entity/entity.go
@@ -28,6 +28,7 @@ type AllSetting struct {
RemarkModel string `json:"remarkModel" form:"remarkModel"`
TgBotEnable bool `json:"tgBotEnable" form:"tgBotEnable"`
TgBotToken string `json:"tgBotToken" form:"tgBotToken"`
+ TgBotProxy string `json:"tgBotProxy" form:"tgBotProxy"`
TgBotChatId string `json:"tgBotChatId" form:"tgBotChatId"`
TgRunTime string `json:"tgRunTime" form:"tgRunTime"`
TgBotBackup bool `json:"tgBotBackup" form:"tgBotBackup"`
diff --git a/web/html/xui/settings.html b/web/html/xui/settings.html
index 65268870..a63f9dbb 100644
--- a/web/html/xui/settings.html
+++ b/web/html/xui/settings.html
@@ -243,6 +243,7 @@
+
diff --git a/web/service/setting.go b/web/service/setting.go
index 8b60d166..d2d49ba5 100644
--- a/web/service/setting.go
+++ b/web/service/setting.go
@@ -38,6 +38,7 @@ var defaultValueMap = map[string]string{
"timeLocation": "Asia/Tehran",
"tgBotEnable": "false",
"tgBotToken": "",
+ "tgBotProxy": "",
"tgBotChatId": "",
"tgRunTime": "@daily",
"tgBotBackup": "false",
@@ -244,6 +245,14 @@ func (s *SettingService) SetTgBotToken(token string) error {
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) {
return s.getString("tgBotChatId")
}
diff --git a/web/service/tgbot.go b/web/service/tgbot.go
index 0847e418..edbf3c03 100644
--- a/web/service/tgbot.go
+++ b/web/service/tgbot.go
@@ -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)
if err != nil {
fmt.Println("Get tgbot's api error:", err)
diff --git a/web/translation/translate.en_US.toml b/web/translation/translate.en_US.toml
index b6c30558..e23289d5 100644
--- a/web/translation/translate.en_US.toml
+++ b/web/translation/translate.en_US.toml
@@ -255,6 +255,8 @@
"telegramBotEnableDesc" = "Connect to the features of this panel through the Telegram bot"
"telegramToken" = "Telegram Token"
"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"
"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"
diff --git a/xray/api.go b/xray/api.go
index 10d22ae1..36b19875 100644
--- a/xray/api.go
+++ b/xray/api.go
@@ -50,7 +50,9 @@ func (x *XrayAPI) Init(apiPort int) (err error) {
}
func (x *XrayAPI) Close() {
- x.grpcClient.Close()
+ if x.grpcClient != nil {
+ x.grpcClient.Close()
+ }
x.HandlerServiceClient = nil
x.StatsServiceClient = nil
x.isConnected = false