Documentation
¶
Index ¶
- func GenerateCode() string
- type AuditLog
- type CreditCode
- type Node
- type PortAllocator
- type Rule
- type Store
- func (s *Store) AddNode(n *Node) error
- func (s *Store) Close()
- func (s *Store) CreateCreditCodes(level, days int, count int, expireAt time.Time) ([]string, error)
- func (s *Store) CreateUser(u *User, password string) error
- func (s *Store) GetUserByUsername(username string) (*User, error)
- func (s *Store) ListAuditLogs(limit, offset int) ([]AuditLog, error)
- func (s *Store) ListNodes() ([]Node, error)
- func (s *Store) ListRulesByUser(userID int64) ([]Rule, error)
- func (s *Store) LogAction(userID int64, action, ip, ua string)
- func (s *Store) ProcessBilling(userID int64, nodeID string, bytes int64) (int64, error)
- func (s *Store) RedeemCode(userID int64, code string) error
- func (s *Store) UpdateRuleStatus(id string, status string) error
- func (s *Store) UpdateUserStatus(id int64, status string) error
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CreditCode ¶
type CreditCode struct {
Code string `json:"code"`
Level int `json:"level"`
DurationDays int `json:"duration_days"`
ExpireAt time.Time `json:"expire_at"`
Status string `json:"status"` // unused, used, disabled
UsedBy int64 `json:"used_by"`
UsedAt *time.Time `json:"used_at"`
CreatedAt time.Time `json:"created_at"`
}
type Node ¶
type Node struct {
ID string `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
Addr string `json:"addr"`
Protocol string `json:"protocol"`
Multiplier float64 `json:"multiplier"`
PortRange string `json:"port_range"`
IsSelfHosted bool `json:"is_self_hosted"`
AgentID string `json:"agent_id"`
CreatedAt time.Time `json:"created_at"`
}
type PortAllocator ¶
type PortAllocator struct {
// contains filtered or unexported fields
}
func NewPortAllocator ¶
func NewPortAllocator(min, max int, s *Store) *PortAllocator
type Rule ¶
type Rule struct {
ID string `json:"id"`
UserID int64 `json:"user_id"`
Name string `json:"name"`
Mode string `json:"mode"`
EntryNodeID string `json:"entry_node_id"`
ExitNodeID string `json:"exit_node_id"`
HopChain []string `json:"hop_chain"` // 中继节点 ID 序列
Status string `json:"status"`
SyncState string `json:"sync_state"`
CreatedAt time.Time `json:"created_at"`
}
type Store ¶
func (*Store) CreateCreditCodes ¶
func (*Store) ProcessBilling ¶
ProcessBilling 执行流量扣费
func (*Store) RedeemCode ¶
RedeemCode 执行权益码兑换 (原子操作)
type User ¶
type User struct {
ID int64 `json:"id"`
Username string `json:"username"`
Email string `json:"email"`
PasswordHash string `json:"-"`
Role string `json:"role"`
Permissions []string `json:"permissions"`
Status string `json:"status"`
TGID int64 `json:"tg_id"`
TGUsername string `json:"tg_username"`
VIPLevel int `json:"vip_level"`
QuotaUsed int64 `json:"quota_used"`
QuotaTotal int64 `json:"quota_total"`
ExpireAt *time.Time `json:"expire_at"`
CreatedAt time.Time `json:"created_at"`
}
Click to show internal directories.
Click to hide internal directories.