limiter

package
v0.2.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2025 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteLimiter

func DeleteLimiter(tag string)

func Init

func Init()

Types

type Limiter

type Limiter struct {
	DomainRules   []*regexp.Regexp
	ProtocolRules []string
	SpeedLimit    int
	UserOnlineIP  *sync.Map      // Key: TagUUID, value: {Key: Ip, value: Uid}
	OldUserOnline *sync.Map      // Key: Ip, value: Uid
	UUIDtoUID     map[string]int // Key: UUID, value: Uid
	UserLimitInfo *sync.Map      // Key: TagUUID value: UserLimitInfo
	SpeedLimiter  *sync.Map      // key: TagUUID, value: *ratelimit.Bucket
	AliveList     map[int]int    // Key: Uid, value: alive_ip
}

func AddLimiter

func AddLimiter(tag string, users []panel.UserInfo, aliveList map[int]int) *Limiter

func GetLimiter

func GetLimiter(tag string) (info *Limiter, err error)

func (*Limiter) CheckLimit

func (l *Limiter) CheckLimit(taguuid string, ip string, isTcp bool, noSSUDP bool) (Bucket *ratelimit.Bucket, Reject bool)

func (*Limiter) GetOnlineDevice

func (l *Limiter) GetOnlineDevice() (*[]panel.OnlineUser, error)

func (*Limiter) UpdateDynamicSpeedLimit

func (l *Limiter) UpdateDynamicSpeedLimit(tag, uuid string, limit int, expire time.Time) error

func (*Limiter) UpdateUser

func (l *Limiter) UpdateUser(tag string, added []panel.UserInfo, deleted []panel.UserInfo)

type UserIpList

type UserIpList struct {
	Uid    int      `json:"Uid"`
	IpList []string `json:"Ips"`
}

type UserLimitInfo

type UserLimitInfo struct {
	UID               int
	SpeedLimit        int
	DeviceLimit       int
	DynamicSpeedLimit int
	ExpireTime        int64
	OverLimit         bool
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL