Files
frp-panel/models/proxy.go
VaalaCat cdbaf032e7 feat: add traffic statistics
fix: frontend proxy config cache is not cleared when change client id
2024-11-30 05:27:49 +00:00

52 lines
1.6 KiB
Go

package models
import (
"time"
"gorm.io/gorm"
)
type Proxy struct {
*ProxyEntity
}
type ProxyEntity struct {
ProxyID int `json:"proxy_id" gorm:"primary_key;auto_increment"`
ServerID string `json:"server_id" gorm:"index"`
ClientID string `json:"client_id" gorm:"index"`
Name string `json:"name"`
Type string `json:"type"`
UserID int `json:"user_id" gorm:"index"`
TenantID int `json:"tenant_id" gorm:"index"`
TodayTrafficIn int64 `json:"today_traffic_in"`
TodayTrafficOut int64 `json:"today_traffic_out"`
HistoryTrafficIn int64 `json:"history_traffic_in"`
HistoryTrafficOut int64 `json:"history_traffic_out"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
}
func (*Proxy) TableName() string {
return "proxies"
}
// HistoryProxyStats 历史流量统计,不保证精准,只是为了展示。精准请使用 proxies 表中的 history_traffic_in/history_traffic_out
// 后续看看是否要改成时序类数据 https://github.com/nakabonne/tstorage
type HistoryProxyStats struct {
gorm.Model
ProxyID int `json:"proxy_id" gorm:"index"`
ServerID string `json:"server_id" gorm:"index"`
ClientID string `json:"client_id" gorm:"index"`
Name string `json:"name"`
Type string `json:"type"`
UserID int `json:"user_id" gorm:"index"`
TenantID int `json:"tenant_id" gorm:"index"`
TrafficIn int64 `json:"traffic_in"`
TrafficOut int64 `json:"traffic_out"`
}
func (*HistoryProxyStats) TableName() string {
return "history_proxy_stats"
}