-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaccess_restriction.go
More file actions
29 lines (23 loc) · 887 Bytes
/
Copy pathaccess_restriction.go
File metadata and controls
29 lines (23 loc) · 887 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package model
// RestrictionType 限制类型
type RestrictionType string
const (
RestrictionTypeIP RestrictionType = "ip" // 单个 IP
RestrictionTypeCIDR RestrictionType = "cidr" // CIDR 段
RestrictionTypeCountry RestrictionType = "country" // 国家代码 ISO 3166-1 alpha-2
)
// RestrictionMode 允许/拒绝
type RestrictionMode string
const (
RestrictionAllow RestrictionMode = "allow"
RestrictionDeny RestrictionMode = "deny"
)
// AccessRestriction 订阅访问限制规则
type AccessRestriction struct {
Base
SubscriptionID uint `gorm:"not null;index" json:"subscription_id"`
Type RestrictionType `gorm:"not null" json:"type"`
Value string `gorm:"not null" json:"value"`
Mode RestrictionMode `gorm:"not null" json:"mode"`
Subscription Subscription `gorm:"foreignKey:SubscriptionID" json:"-"`
}