package model

import (
	"go.mongodb.org/mongo-driver/bson/primitive"
	"time"
)

type UdpForWarding struct {
	Id                   int `gorm:"primary"`
	HostId               int `gorm:"not null"`
	WafUdpId             int `gorm:"not null"` // 修改为与TCP转发一致的命名
	Tag                  string `gorm:"null"`
	Port                 string `gorm:"not null"`
	WafGatewayGroupId    int `gorm:"not null"`
	UdpLimitRuleId       int `gorm:"not null"`
	CcPacketCount        int `gorm:"null"`
	CcPacketDuration     string `gorm:"null"`
	CcPacketBlockCount   int `gorm:"null"`
	CcPacketBlockDuration string `gorm:"null"`
	CcCount              int `gorm:"null"`
	CcDuration           string `gorm:"null"`
	CcBlockCount         int `gorm:"null"`
	CcBlockDuration      string `gorm:"null"`
	SessionTimeout       string `gorm:"null"`
	Comment              string `gorm:"null"`
	CreatedAt            time.Time
	UpdatedAt            time.Time
}

func (m *UdpForWarding) TableName() string {
    return "shd_waf_udp"
}

// UdpForwardingRule 用于存储UDP转发规则
type UdpForwardingRule struct {
	ID          primitive.ObjectID `bson:"_id,omitempty"`
	Uid         int                `bson:"uid" json:"uid"`
	HostId      int                `bson:"host_id" json:"host_id"`
	UdpId       int                `bson:"udp_id" json:"udp_id"`
	BackendList []string           `bson:"backend_list" json:"backend_list"`
	AllowIpList []string           `bson:"allow_ip_list" json:"allow_ip_list"`
	DenyIpList  []string           `bson:"deny_ip_list" json:"deny_ip_list"`
	AccessRule  string             `bson:"access_rule" json:"access_rule"`
	CreatedAt   time.Time          `bson:"created_at" json:"created_at"`
	UpdatedAt   time.Time          `bson:"updated_at" json:"updated_at"`
}

func (m *UdpForwardingRule) CollectionName() string {
	return "udp_forwarding_rules"
}
