package vo

import (
	"wireguard-ui/global/constant"
	"wireguard-ui/model"
)

// SettingItem
// @description: 设置单项
type SettingItem struct {
	Code      string         `json:"code"`
	Data      string         `json:"data"`
	Describe  string         `json:"describe"`
	CreatedAt model.JsonTime `json:"createdAt"`
	UpdatedAt model.JsonTime `json:"updatedAt"`
}

type Export struct {
	Global  *Global  `json:"global" label:"全局配置" binding:"required"`
	Server  *Server  `json:"server" label:"服务端配置" binding:"required"`
	Clients []Client `json:"clients" label:"客户端" binding:"omitempty"`
	Other   []Other  `json:"other" label:"其他" binding:"omitempty"`
}

// Global
// @description: 全局配置
type Global struct {
	MTU                 int      `json:"MTU" label:"MTU" binding:"required"`
	ConfigFilePath      string   `json:"configFilePath" label:"配置文件路径" binding:"required"`
	DnsServer           []string `json:"dnsServer" label:"DNS" binding:"omitempty"`
	EndpointAddress     string   `json:"endpointAddress" label:"公网地址" binding:"required"`
	FirewallMark        string   `json:"firewallMark" label:"firewallMark" binding:"omitempty"`
	PersistentKeepalive int      `json:"persistentKeepalive" label:"persistentKeepalive" binding:"required"`
	Table               string   `json:"table" label:"table" binding:"omitempty"`
}

// Server
// @description: 服务端信息
type Server struct {
	IpScope        []string `json:"ipScope" label:"ipScope" binding:"min=1,dive,required"`
	ListenPort     int      `json:"listenPort" label:"listenPort" binding:"required"`
	PrivateKey     string   `json:"privateKey" label:"privateKey" binding:"required"`
	PublicKey      string   `json:"publicKey" label:"publicKey" binding:"required"`
	PostUpScript   string   `json:"postUpScript" label:"postUpScript" binding:"omitempty"`
	PostDownScript string   `json:"postDownScript" label:"postDownScript" binding:"omitempty"`
}

// Client
// @description: 客户端信息
type Client struct {
	Name            string           `json:"name" label:"name" binding:"required"`
	Email           string           `json:"email" label:"email" binding:"omitempty"`
	SubnetRange     string           `json:"subnetRange" label:"subnetRange" binding:"omitempty"`
	IpAllocation    []string         `json:"ipAllocation" label:"ipAllocation" binding:"min=1,dive,required"`
	AllowedIps      []string         `json:"allowedIps" label:"allowedIps" binding:"min=1,dive,required"`
	ExtraAllowedIps []string         `json:"extraAllowedIps" label:"extraAllowedIps" binding:"omitempty"`
	Endpoint        string           `json:"endpoint" label:"endpoint" binding:"endpoint"`
	UseServerDns    *constant.Status `json:"useServerDns" label:"useServerDns" binding:"omitempty"`
	Keys            struct {
		PresharedKey string `json:"presharedKey" label:"presharedKey" binding:"required"`
		PrivateKey   string `json:"privateKey" label:"privateKey" binding:"required"`
		PublicKey    string `json:"publicKey" label:"publicKey" binding:"required"`
	} `json:"keys" label:"keys" binding:"required"`
	Enabled           *constant.Status `json:"enabled" label:"enabled" binding:"required"`
	OfflineMonitoring *constant.Status `json:"offlineMonitoring" label:"offlineMonitoring" binding:"required"`
}

// Other
// @description: 其他配置
type Other struct {
	Code     string `json:"code" label:"code" binding:"required"`
	Data     string `json:"data" label:"data" binding:"required"`
	Describe string `json:"describe" label:"describe" binding:"omitempty"`
}
