2024-10-17 09:03:03 -04:00
|
|
|
package model
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"gorm.io/gorm"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
ProviderDummy = iota
|
|
|
|
ProviderWebHook
|
|
|
|
ProviderCloudflare
|
|
|
|
ProviderTencentCloud
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
_Dummy = "dummy"
|
|
|
|
_WebHook = "webhook"
|
|
|
|
_Cloudflare = "cloudflare"
|
|
|
|
_TencentCloud = "tencentcloud"
|
|
|
|
)
|
|
|
|
|
|
|
|
var ProviderMap = map[uint8]string{
|
|
|
|
ProviderDummy: _Dummy,
|
|
|
|
ProviderWebHook: _WebHook,
|
|
|
|
ProviderCloudflare: _Cloudflare,
|
|
|
|
ProviderTencentCloud: _TencentCloud,
|
|
|
|
}
|
|
|
|
|
|
|
|
var ProviderList = []DDNSProvider{
|
|
|
|
{
|
|
|
|
Name: _Dummy,
|
|
|
|
ID: ProviderDummy,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: _Cloudflare,
|
|
|
|
ID: ProviderCloudflare,
|
|
|
|
AccessSecret: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: _TencentCloud,
|
|
|
|
ID: ProviderTencentCloud,
|
|
|
|
AccessID: true,
|
|
|
|
AccessSecret: true,
|
|
|
|
},
|
|
|
|
// Least frequently used, always place this at the end
|
|
|
|
{
|
|
|
|
Name: _WebHook,
|
|
|
|
ID: ProviderWebHook,
|
|
|
|
AccessID: true,
|
|
|
|
AccessSecret: true,
|
|
|
|
WebhookURL: true,
|
|
|
|
WebhookMethod: true,
|
2024-10-17 11:35:28 -04:00
|
|
|
WebhookRequestType: true,
|
2024-10-17 09:03:03 -04:00
|
|
|
WebhookRequestBody: true,
|
|
|
|
WebhookHeaders: true,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
type DDNSProfile struct {
|
|
|
|
Common
|
|
|
|
EnableIPv4 *bool
|
|
|
|
EnableIPv6 *bool
|
|
|
|
MaxRetries uint64
|
|
|
|
Name string
|
|
|
|
Provider uint8
|
|
|
|
AccessID string
|
|
|
|
AccessSecret string
|
|
|
|
WebhookURL string
|
|
|
|
WebhookMethod uint8
|
|
|
|
WebhookRequestType uint8
|
|
|
|
WebhookRequestBody string
|
|
|
|
WebhookHeaders string
|
|
|
|
|
|
|
|
Domains []string `gorm:"-"`
|
|
|
|
DomainsRaw string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d DDNSProfile) TableName() string {
|
|
|
|
return "ddns"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *DDNSProfile) AfterFind(tx *gorm.DB) error {
|
|
|
|
if d.DomainsRaw != "" {
|
|
|
|
d.Domains = strings.Split(d.DomainsRaw, ",")
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type DDNSProvider struct {
|
|
|
|
Name string
|
|
|
|
ID uint8
|
|
|
|
AccessID bool
|
|
|
|
AccessSecret bool
|
|
|
|
WebhookURL bool
|
|
|
|
WebhookMethod bool
|
2024-10-17 11:35:28 -04:00
|
|
|
WebhookRequestType bool
|
2024-10-17 09:03:03 -04:00
|
|
|
WebhookRequestBody bool
|
|
|
|
WebhookHeaders bool
|
|
|
|
}
|
2024-10-21 02:30:50 -04:00
|
|
|
|
|
|
|
type DDNSForm struct {
|
|
|
|
ID uint64
|
|
|
|
MaxRetries uint64
|
|
|
|
EnableIPv4 string
|
|
|
|
EnableIPv6 string
|
|
|
|
Name string
|
|
|
|
Provider uint8
|
|
|
|
DomainsRaw string
|
|
|
|
AccessID string
|
|
|
|
AccessSecret string
|
|
|
|
WebhookURL string
|
|
|
|
WebhookMethod uint8
|
|
|
|
WebhookRequestType uint8
|
|
|
|
WebhookRequestBody string
|
|
|
|
WebhookHeaders string
|
|
|
|
}
|