mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-08-23 19:36:54 +00:00
Typo fixed
This commit is contained in:
parent
cb975d19e0
commit
c82b207288
12 changed files with 33 additions and 35 deletions
6
main.go
6
main.go
|
@ -159,19 +159,19 @@ func showSetting(show bool) {
|
||||||
|
|
||||||
func updateTgbotEnableSts(status bool) {
|
func updateTgbotEnableSts(status bool) {
|
||||||
settingService := service.SettingService{}
|
settingService := service.SettingService{}
|
||||||
currentTgSts, err := settingService.GetTgbotenabled()
|
currentTgSts, err := settingService.GetTgbotEnabled()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
logger.Infof("current enabletgbot status[%v],need update to status[%v]", currentTgSts, status)
|
logger.Infof("current enabletgbot status[%v],need update to status[%v]", currentTgSts, status)
|
||||||
if currentTgSts != status {
|
if currentTgSts != status {
|
||||||
err := settingService.SetTgbotenabled(status)
|
err := settingService.SetTgbotEnabled(status)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
logger.Infof("SetTgbotenabled[%v] success", status)
|
logger.Infof("SetTgbotEnabled[%v] success", status)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -232,14 +232,12 @@ func (a *InboundController) resetClientTraffic(c *gin.Context) {
|
||||||
}
|
}
|
||||||
email := c.Param("email")
|
email := c.Param("email")
|
||||||
|
|
||||||
needRestart := true
|
needRestart, err := a.inboundService.ResetClientTraffic(id, email)
|
||||||
|
|
||||||
needRestart, err = a.inboundService.ResetClientTraffic(id, email)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
jsonMsg(c, "Something went wrong!", err)
|
jsonMsg(c, "Something went wrong!", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
jsonMsg(c, "traffic reseted", nil)
|
jsonMsg(c, "Traffic has been reset", nil)
|
||||||
if needRestart {
|
if needRestart {
|
||||||
a.xrayService.SetToNeedRestart()
|
a.xrayService.SetToNeedRestart()
|
||||||
}
|
}
|
||||||
|
@ -253,7 +251,7 @@ func (a *InboundController) resetAllTraffics(c *gin.Context) {
|
||||||
} else {
|
} else {
|
||||||
a.xrayService.SetToNeedRestart()
|
a.xrayService.SetToNeedRestart()
|
||||||
}
|
}
|
||||||
jsonMsg(c, "All traffics reseted", nil)
|
jsonMsg(c, "all traffic has been reset", nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *InboundController) resetAllClientTraffics(c *gin.Context) {
|
func (a *InboundController) resetAllClientTraffics(c *gin.Context) {
|
||||||
|
@ -270,7 +268,7 @@ func (a *InboundController) resetAllClientTraffics(c *gin.Context) {
|
||||||
} else {
|
} else {
|
||||||
a.xrayService.SetToNeedRestart()
|
a.xrayService.SetToNeedRestart()
|
||||||
}
|
}
|
||||||
jsonMsg(c, "All traffics of client reseted", nil)
|
jsonMsg(c, "All traffic from the client has been reset.", nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *InboundController) importInbound(c *gin.Context) {
|
func (a *InboundController) importInbound(c *gin.Context) {
|
||||||
|
@ -313,9 +311,9 @@ func (a *InboundController) delDepletedClients(c *gin.Context) {
|
||||||
jsonMsg(c, "Something went wrong!", err)
|
jsonMsg(c, "Something went wrong!", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
jsonMsg(c, "All delpeted clients are deleted", nil)
|
jsonMsg(c, "All depleted clients are deleted", nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *InboundController) onlines(c *gin.Context) {
|
func (a *InboundController) onlines(c *gin.Context) {
|
||||||
jsonObj(c, a.inboundService.GetOnlineClinets(), nil)
|
jsonObj(c, a.inboundService.GetOnlineClients(), nil)
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,7 +105,7 @@ func (a *ServerController) stopXrayService(c *gin.Context) {
|
||||||
jsonMsg(c, "", err)
|
jsonMsg(c, "", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
jsonMsg(c, "Xray stoped", err)
|
jsonMsg(c, "Xray stopped", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *ServerController) restartXrayService(c *gin.Context) {
|
func (a *ServerController) restartXrayService(c *gin.Context) {
|
||||||
|
|
|
@ -81,7 +81,7 @@ func (a *XraySettingController) warp(c *gin.Context) {
|
||||||
resp, err = a.XraySettingService.RegWarp(skey, pkey)
|
resp, err = a.XraySettingService.RegWarp(skey, pkey)
|
||||||
case "license":
|
case "license":
|
||||||
license := c.PostForm("license")
|
license := c.PostForm("license")
|
||||||
resp, err = a.XraySettingService.SetWarpLicence(license)
|
resp, err = a.XraySettingService.SetWarpLicense(license)
|
||||||
}
|
}
|
||||||
|
|
||||||
jsonObj(c, resp, err)
|
jsonObj(c, resp, err)
|
||||||
|
|
|
@ -79,8 +79,8 @@
|
||||||
qrModal: qrModal,
|
qrModal: qrModal,
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
copyToClipboard(elmentId, content) {
|
copyToClipboard(elementId, content) {
|
||||||
this.qrModal.clipboard = new ClipboardJS('#' + elmentId, {
|
this.qrModal.clipboard = new ClipboardJS('#' + elementId, {
|
||||||
text: () => content,
|
text: () => content,
|
||||||
});
|
});
|
||||||
this.qrModal.clipboard.on('success', () => {
|
this.qrModal.clipboard.on('success', () => {
|
||||||
|
@ -88,9 +88,9 @@
|
||||||
this.qrModal.clipboard.destroy();
|
this.qrModal.clipboard.destroy();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
setQrCode(elmentId, content) {
|
setQrCode(elementId, content) {
|
||||||
new QRious({
|
new QRious({
|
||||||
element: document.querySelector('#' + elmentId),
|
element: document.querySelector('#' + elementId),
|
||||||
size: 400,
|
size: 400,
|
||||||
value: content,
|
value: content,
|
||||||
background: 'white',
|
background: 'white',
|
||||||
|
|
|
@ -494,8 +494,8 @@
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
copyToClipboard(elmentId, content) {
|
copyToClipboard(elementId, content) {
|
||||||
this.infoModal.clipboard = new ClipboardJS('#' + elmentId, {
|
this.infoModal.clipboard = new ClipboardJS('#' + elementId, {
|
||||||
text: () => content,
|
text: () => content,
|
||||||
});
|
});
|
||||||
this.infoModal.clipboard.on('success', () => {
|
this.infoModal.clipboard.on('success', () => {
|
||||||
|
|
|
@ -1947,6 +1947,6 @@ func (s *InboundService) MigrateDB() {
|
||||||
s.MigrationRemoveOrphanedTraffics()
|
s.MigrationRemoveOrphanedTraffics()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *InboundService) GetOnlineClinets() []string {
|
func (s *InboundService) GetOnlineClients() []string {
|
||||||
return p.GetOnlineClients()
|
return p.GetOnlineClients()
|
||||||
}
|
}
|
||||||
|
|
|
@ -269,11 +269,11 @@ func (s *SettingService) SetTgBotChatId(chatIds string) error {
|
||||||
return s.setString("tgBotChatId", chatIds)
|
return s.setString("tgBotChatId", chatIds)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SettingService) GetTgbotenabled() (bool, error) {
|
func (s *SettingService) GetTgbotEnabled() (bool, error) {
|
||||||
return s.getBool("tgBotEnable")
|
return s.getBool("tgBotEnable")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SettingService) SetTgbotenabled(value bool) error {
|
func (s *SettingService) SetTgbotEnabled(value bool) error {
|
||||||
return s.setBool("tgBotEnable", value)
|
return s.setBool("tgBotEnable", value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -524,7 +524,7 @@ func (s *SettingService) GetDefaultSettings(host string) (interface{}, error) {
|
||||||
"pageSize": func() (interface{}, error) { return s.GetPageSize() },
|
"pageSize": func() (interface{}, error) { return s.GetPageSize() },
|
||||||
"defaultCert": func() (interface{}, error) { return s.GetCertFile() },
|
"defaultCert": func() (interface{}, error) { return s.GetCertFile() },
|
||||||
"defaultKey": func() (interface{}, error) { return s.GetKeyFile() },
|
"defaultKey": func() (interface{}, error) { return s.GetKeyFile() },
|
||||||
"tgBotEnable": func() (interface{}, error) { return s.GetTgbotenabled() },
|
"tgBotEnable": func() (interface{}, error) { return s.GetTgbotEnabled() },
|
||||||
"subEnable": func() (interface{}, error) { return s.GetSubEnable() },
|
"subEnable": func() (interface{}, error) { return s.GetSubEnable() },
|
||||||
"subURI": func() (interface{}, error) { return s.GetSubURI() },
|
"subURI": func() (interface{}, error) { return s.GetSubURI() },
|
||||||
"subJsonURI": func() (interface{}, error) { return s.GetSubJsonURI() },
|
"subJsonURI": func() (interface{}, error) { return s.GetSubJsonURI() },
|
||||||
|
|
|
@ -201,7 +201,7 @@ func (t *Tgbot) OnReceive() {
|
||||||
}, th.AnyCommand())
|
}, th.AnyCommand())
|
||||||
|
|
||||||
botHandler.HandleCallbackQuery(func(_ *telego.Bot, query telego.CallbackQuery) {
|
botHandler.HandleCallbackQuery(func(_ *telego.Bot, query telego.CallbackQuery) {
|
||||||
t.asnwerCallback(&query, checkAdmin(query.From.ID))
|
t.answerCallback(&query, checkAdmin(query.From.ID))
|
||||||
}, th.AnyCallbackQueryWithMessage())
|
}, th.AnyCallbackQueryWithMessage())
|
||||||
|
|
||||||
botHandler.HandleMessage(func(_ *telego.Bot, message telego.Message) {
|
botHandler.HandleMessage(func(_ *telego.Bot, message telego.Message) {
|
||||||
|
@ -286,7 +286,7 @@ func (t *Tgbot) answerCommand(message *telego.Message, chatId int64, isAdmin boo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Tgbot) asnwerCallback(callbackQuery *telego.CallbackQuery, isAdmin bool) {
|
func (t *Tgbot) answerCallback(callbackQuery *telego.CallbackQuery, isAdmin bool) {
|
||||||
chatId := callbackQuery.Message.GetChat().ID
|
chatId := callbackQuery.Message.GetChat().ID
|
||||||
|
|
||||||
if isAdmin {
|
if isAdmin {
|
||||||
|
@ -964,7 +964,7 @@ func (t *Tgbot) getServerUsage(chatId int64, messageID ...int) string {
|
||||||
return info
|
return info
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send server usage without an inline keyborad
|
// Send server usage without an inline keyboard
|
||||||
func (t *Tgbot) sendServerUsage() string {
|
func (t *Tgbot) sendServerUsage() string {
|
||||||
info := t.prepareServerUsageInfo()
|
info := t.prepareServerUsageInfo()
|
||||||
return info
|
return info
|
||||||
|
@ -1052,14 +1052,14 @@ func (t *Tgbot) UserLoginNotify(username string, password string, ip string, tim
|
||||||
func (t *Tgbot) getInboundUsages() string {
|
func (t *Tgbot) getInboundUsages() string {
|
||||||
info := ""
|
info := ""
|
||||||
// get traffic
|
// get traffic
|
||||||
inbouds, err := t.inboundService.GetAllInbounds()
|
inbounds, err := t.inboundService.GetAllInbounds()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Warning("GetAllInbounds run failed:", err)
|
logger.Warning("GetAllInbounds run failed:", err)
|
||||||
info += t.I18nBot("tgbot.answers.getInboundsFailed")
|
info += t.I18nBot("tgbot.answers.getInboundsFailed")
|
||||||
} else {
|
} else {
|
||||||
// NOTE:If there no any sessions here,need to notify here
|
// NOTE:If there no any sessions here,need to notify here
|
||||||
// TODO:Sub-node push, automatic conversion format
|
// TODO:Sub-node push, automatic conversion format
|
||||||
for _, inbound := range inbouds {
|
for _, inbound := range inbounds {
|
||||||
info += t.I18nBot("tgbot.messages.inbound", "Remark=="+inbound.Remark)
|
info += t.I18nBot("tgbot.messages.inbound", "Remark=="+inbound.Remark)
|
||||||
info += t.I18nBot("tgbot.messages.port", "Port=="+strconv.Itoa(inbound.Port))
|
info += t.I18nBot("tgbot.messages.port", "Port=="+strconv.Itoa(inbound.Port))
|
||||||
info += t.I18nBot("tgbot.messages.traffic", "Total=="+common.FormatTraffic((inbound.Up+inbound.Down)), "Upload=="+common.FormatTraffic(inbound.Up), "Download=="+common.FormatTraffic(inbound.Down))
|
info += t.I18nBot("tgbot.messages.traffic", "Total=="+common.FormatTraffic((inbound.Up+inbound.Down)), "Upload=="+common.FormatTraffic(inbound.Up), "Download=="+common.FormatTraffic(inbound.Down))
|
||||||
|
@ -1332,20 +1332,20 @@ func (t *Tgbot) searchClient(chatId int64, email string, messageID ...int) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Tgbot) searchInbound(chatId int64, remark string) {
|
func (t *Tgbot) searchInbound(chatId int64, remark string) {
|
||||||
inbouds, err := t.inboundService.SearchInbounds(remark)
|
inbounds, err := t.inboundService.SearchInbounds(remark)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Warning(err)
|
logger.Warning(err)
|
||||||
msg := t.I18nBot("tgbot.wentWrong")
|
msg := t.I18nBot("tgbot.wentWrong")
|
||||||
t.SendMsgToTgbot(chatId, msg)
|
t.SendMsgToTgbot(chatId, msg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if len(inbouds) == 0 {
|
if len(inbounds) == 0 {
|
||||||
msg := t.I18nBot("tgbot.noInbounds")
|
msg := t.I18nBot("tgbot.noInbounds")
|
||||||
t.SendMsgToTgbot(chatId, msg)
|
t.SendMsgToTgbot(chatId, msg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, inbound := range inbouds {
|
for _, inbound := range inbounds {
|
||||||
info := ""
|
info := ""
|
||||||
info += t.I18nBot("tgbot.messages.inbound", "Remark=="+inbound.Remark)
|
info += t.I18nBot("tgbot.messages.inbound", "Remark=="+inbound.Remark)
|
||||||
info += t.I18nBot("tgbot.messages.port", "Port=="+strconv.Itoa(inbound.Port))
|
info += t.I18nBot("tgbot.messages.port", "Port=="+strconv.Itoa(inbound.Port))
|
||||||
|
|
|
@ -128,7 +128,7 @@ func (s *XraySettingService) RegWarp(secretKey string, publicKey string) (string
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *XraySettingService) SetWarpLicence(license string) (string, error) {
|
func (s *XraySettingService) SetWarpLicense(license string) (string, error) {
|
||||||
var warpData map[string]string
|
var warpData map[string]string
|
||||||
warp, err := s.SettingService.GetWarp()
|
warp, err := s.SettingService.GetWarp()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
"monitor" = "Listen IP"
|
"monitor" = "Listen IP"
|
||||||
"certificate" = "Digital Certificate"
|
"certificate" = "Digital Certificate"
|
||||||
"fail" = " Failed"
|
"fail" = " Failed"
|
||||||
"success" = " Successful"
|
"success" = " Successfully"
|
||||||
"getVersion" = "Get Version"
|
"getVersion" = "Get Version"
|
||||||
"install" = "Install"
|
"install" = "Install"
|
||||||
"clients" = "Clients"
|
"clients" = "Clients"
|
||||||
|
|
|
@ -268,7 +268,7 @@ func (s *Server) startTask() {
|
||||||
|
|
||||||
// Make a traffic condition every day, 8:30
|
// Make a traffic condition every day, 8:30
|
||||||
var entry cron.EntryID
|
var entry cron.EntryID
|
||||||
isTgbotenabled, err := s.settingService.GetTgbotenabled()
|
isTgbotenabled, err := s.settingService.GetTgbotEnabled()
|
||||||
if (err == nil) && (isTgbotenabled) {
|
if (err == nil) && (isTgbotenabled) {
|
||||||
runtime, err := s.settingService.GetTgbotRuntime()
|
runtime, err := s.settingService.GetTgbotRuntime()
|
||||||
if err != nil || runtime == "" {
|
if err != nil || runtime == "" {
|
||||||
|
@ -364,7 +364,7 @@ func (s *Server) Start() (err error) {
|
||||||
|
|
||||||
s.startTask()
|
s.startTask()
|
||||||
|
|
||||||
isTgbotenabled, err := s.settingService.GetTgbotenabled()
|
isTgbotenabled, err := s.settingService.GetTgbotEnabled()
|
||||||
if (err == nil) && (isTgbotenabled) {
|
if (err == nil) && (isTgbotenabled) {
|
||||||
tgBot := s.tgbotService.NewTgbot()
|
tgBot := s.tgbotService.NewTgbot()
|
||||||
tgBot.Start(i18nFS)
|
tgBot.Start(i18nFS)
|
||||||
|
|
Loading…
Reference in a new issue