mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-10-27 02:24:40 +00:00
refactor: remove unused traffic reset logic and clean up client model fields
This commit is contained in:
parent
b00de0a59b
commit
8cbbbeb5e8
3 changed files with 15 additions and 64 deletions
|
|
@ -92,23 +92,21 @@ type Setting struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Client struct {
|
type Client struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Security string `json:"security"`
|
Security string `json:"security"`
|
||||||
Password string `json:"password"`
|
Password string `json:"password"`
|
||||||
Flow string `json:"flow"`
|
Flow string `json:"flow"`
|
||||||
Email string `json:"email"`
|
Email string `json:"email"`
|
||||||
LimitIP int `json:"limitIp"`
|
LimitIP int `json:"limitIp"`
|
||||||
TotalGB int64 `json:"totalGB" form:"totalGB"`
|
TotalGB int64 `json:"totalGB" form:"totalGB"`
|
||||||
ExpiryTime int64 `json:"expiryTime" form:"expiryTime"`
|
ExpiryTime int64 `json:"expiryTime" form:"expiryTime"`
|
||||||
TrafficReset string `json:"trafficReset" form:"trafficReset" gorm:"default:never"`
|
Enable bool `json:"enable" form:"enable"`
|
||||||
LastTrafficResetTime int64 `json:"lastTrafficResetTime" form:"lastTrafficResetTime" gorm:"default:0"`
|
TgID int64 `json:"tgId" form:"tgId"`
|
||||||
Enable bool `json:"enable" form:"enable"`
|
SubID string `json:"subId" form:"subId"`
|
||||||
TgID int64 `json:"tgId" form:"tgId"`
|
Comment string `json:"comment" form:"comment"`
|
||||||
SubID string `json:"subId" form:"subId"`
|
Reset int `json:"reset" form:"reset"`
|
||||||
Comment string `json:"comment" form:"comment"`
|
CreatedAt int64 `json:"created_at,omitempty"`
|
||||||
Reset int `json:"reset" form:"reset"`
|
UpdatedAt int64 `json:"updated_at,omitempty"`
|
||||||
CreatedAt int64 `json:"created_at,omitempty"`
|
|
||||||
UpdatedAt int64 `json:"updated_at,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type VLESSSettings struct {
|
type VLESSSettings struct {
|
||||||
|
|
|
||||||
|
|
@ -237,12 +237,6 @@
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr v-if="infoModal.clientSettings.trafficReset">
|
|
||||||
<td>{{ i18n "pages.inbounds.periodicTrafficResetTitle" }}</td>
|
|
||||||
<td>
|
|
||||||
<a-tag color="blue">[[ i18n("pages.inbounds.periodicTrafficReset." + infoModal.clientSettings.trafficReset) ]]</a-tag>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr v-if="app.ipLimitEnable">
|
<tr v-if="app.ipLimitEnable">
|
||||||
<td>{{ i18n "pages.inbounds.IPLimit" }}</td>
|
<td>{{ i18n "pages.inbounds.IPLimit" }}</td>
|
||||||
<td>
|
<td>
|
||||||
|
|
|
||||||
|
|
@ -1706,47 +1706,6 @@ func (s *InboundService) ResetClientTrafficByEmail(clientEmail string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update lastTrafficResetTime in client settings
|
|
||||||
_, inbound, err := s.GetClientInboundByEmail(clientEmail)
|
|
||||||
if err != nil {
|
|
||||||
logger.Warning("Failed to get inbound for client", clientEmail, ":", err)
|
|
||||||
return nil // Don't fail the reset if we can't update the timestamp
|
|
||||||
}
|
|
||||||
|
|
||||||
if inbound != nil {
|
|
||||||
var settings map[string]any
|
|
||||||
err = json.Unmarshal([]byte(inbound.Settings), &settings)
|
|
||||||
if err != nil {
|
|
||||||
logger.Warning("Failed to parse inbound settings:", err)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
clientsSettings := settings["clients"].([]any)
|
|
||||||
now := time.Now().Unix() * 1000
|
|
||||||
|
|
||||||
for client_index := range clientsSettings {
|
|
||||||
c := clientsSettings[client_index].(map[string]any)
|
|
||||||
if c["email"] == clientEmail {
|
|
||||||
c["lastTrafficResetTime"] = now
|
|
||||||
c["updated_at"] = now
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
settings["clients"] = clientsSettings
|
|
||||||
modifiedSettings, err := json.MarshalIndent(settings, "", " ")
|
|
||||||
if err != nil {
|
|
||||||
logger.Warning("Failed to marshal inbound settings:", err)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
inbound.Settings = string(modifiedSettings)
|
|
||||||
err = db.Save(inbound).Error
|
|
||||||
if err != nil {
|
|
||||||
logger.Warning("Failed to save inbound with updated client settings:", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue