Documentation
¶
Index ¶
- type DeviceAdmission
- type Limiter
- func (l *Limiter) Acquire(ctx context.Context, tag, ip string) (*ratelimit.Bucket, func(), bool)
- func (l *Limiter) CheckLimit(tag, ip string, _ bool) (*ratelimit.Bucket, bool)
- func (l *Limiter) GetOnlineDevice() (*[]panel.OnlineUser, error)
- func (l *Limiter) OnlineReportAcknowledged(users []panel.OnlineUser, sentAt time.Time)
- func (l *Limiter) SetDeviceAdmission(admit DeviceAdmission)
- func (l *Limiter) UpdateAliveList(aliveList map[int]int)
- func (l *Limiter) UpdateUser(tag string, added []panel.UserInfo, deleted []panel.UserInfo)
- type Manager
- type UserIpList
- type UserLimitInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DeviceAdmission ¶ added in v1.1.14
type Limiter ¶
type Limiter struct {
NodeType string
SpeedLimit int
UUIDtoUID map[string]int // Key: UUID, value: Uid
UserLimitInfo *sync.Map // Key: TagUUID, value: UserLimitInfo
SpeedLimiter *sync.Map // key: TagUUID, value: *ratelimit.Bucket
// contains filtered or unexported fields
}
func (*Limiter) Acquire ¶ added in v1.1.14
Acquire counts canonical source IPs for TCP and UDP alike. New IPs of limited subscriptions require a successful atomic panel admission.
func (*Limiter) CheckLimit ¶
CheckLimit is the legacy check-and-record API. Runtime connections use Acquire so closing their writer or cancelling their context releases them.
func (*Limiter) GetOnlineDevice ¶
func (l *Limiter) GetOnlineDevice() (*[]panel.OnlineUser, error)
GetOnlineDevice is a non-destructive heartbeat snapshot. Idle but still open connections continue renewing their slot; closed connections do not.
func (*Limiter) OnlineReportAcknowledged ¶ added in v1.1.14
func (l *Limiter) OnlineReportAcknowledged(users []panel.OnlineUser, sentAt time.Time)
func (*Limiter) SetDeviceAdmission ¶ added in v1.1.14
func (l *Limiter) SetDeviceAdmission(admit DeviceAdmission)
func (*Limiter) UpdateAliveList ¶ added in v1.1.14
UpdateAliveList replaces the online counts with an owned snapshot. Callers may reuse their map after this method returns without changing the limiter.
type Manager ¶ added in v1.1.4
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶ added in v1.1.4
func NewManager() *Manager
type UserIpList ¶
Click to show internal directories.
Click to hide internal directories.