ddns

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: Apache-2.0 Imports: 28 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ddns 实现动态域名解析模块。

Index

Constants

View Source
const (
	VarIPv4 = "{ipv4Addr}"
	VarIPv6 = "{ipv6Addr}"
)

记录值中可用的变量

View Source
const (

	// DefaultRemark 为记录备注与任务备注都留空时写到服务商处的备注
	DefaultRemark = "GatelyDDNS"
)
View Source
const ID = "ddns"

ID 是模块标识。

Variables

This section is empty.

Functions

This section is empty.

Types

type Module

type Module struct {
	// contains filtered or unexported fields
}

Module 是 DDNS 模块。

func New

func New() *Module

New 创建模块实例。

func (*Module) ID

func (m *Module) ID() string

ID 实现 module.Module。

func (*Module) ImportLucky

func (m *Module) ImportLucky(doc luckyimport.Document, opts luckyimport.Options) (*luckyimport.Report, error)

ImportLucky 实现 luckyimport.Importer。

func (*Module) Init

func (m *Module) Init(env module.Env) error

Init 实现 module.Module。

func (*Module) Metrics added in v0.5.0

func (m *Module) Metrics() []module.Sample

Metrics 实现 module.Metricer:每条启用记录最近一次同步是否成功及同步时间。

func (*Module) Routes

func (m *Module) Routes(r module.Router)

Routes 实现 module.Module。

func (*Module) SelfCheck added in v0.5.0

func (m *Module) SelfCheck(ctx context.Context, env module.CheckEnv) []module.CheckResult

SelfCheck 实现 module.SelfChecker:检查使用动态地址变量的记录,其域名当前解析结果是否等于本机出口公网地址。

func (*Module) Start

func (m *Module) Start(ctx context.Context) error

Start 实现 module.Module。

func (*Module) Stop

func (m *Module) Stop() error

Stop 实现 module.Module。

func (*Module) Summary

func (m *Module) Summary() []module.SummaryItem

Summary 实现 module.Summarizer。

func (*Module) Title

func (m *Module) Title() string

Title 实现 module.Module。

type Record

type Record struct {
	Key    string `json:"key"`
	Enable bool   `json:"enable"`
	// Zone 为主域名(在服务商处托管的域名),例如 example.com
	Zone string `json:"zone"`
	// Sub 为主机记录,根域名填 @
	Sub  string `json:"sub"`
	Type string `json:"type"`
	// Value 支持变量 {ipv4Addr} {ipv6Addr},以及 {STUN_规则名_PORT} {STUN_规则名_IP} {STUN_规则名_ADDR}
	Value string `json:"value"`
	TTL   int    `json:"ttl"`
	Line  string `json:"line"`
	// Remark 为记录备注,同步时写到支持备注的服务商处;留空时使用任务备注
	Remark string `json:"remark"`
	// Group 为任务内记录列表中的分组名称,只影响管理界面的展示,留空为未分组
	Group string `json:"group"`
}

Record 是任务中的一条解析记录。

type RecordState

type RecordState struct {
	Value    string    `json:"value,omitempty"`
	LastSync time.Time `json:"lastSync,omitzero"`
	// LastAction 为 created/updated/unchanged
	LastAction string    `json:"lastAction,omitempty"`
	LastError  string    `json:"lastError,omitempty"`
	LastCheck  time.Time `json:"lastCheck,omitzero"`
	// Remark 为最近一次成功同步到服务商的备注;与当前应写入的备注不同时重新同步一次,
	// 旧状态文件没有该字段,升级后会补同步一次,把服务商处的旧备注(如 LuckyDDNS)改掉
	Remark string `json:"remark,omitempty"`
	// FailCount 为连续失败的轮数,成功后清零;FirstFail 为这一串失败中第一次失败的时间;
	// Alerted 表示这一串失败已发过通知,恢复前不再重复发送。旧状态文件没有这些字段,按 0 处理
	FailCount int       `json:"failCount,omitempty"`
	FirstFail time.Time `json:"firstFail,omitzero"`
	Alerted   bool      `json:"alerted,omitempty"`
}

RecordState 是一条记录的同步状态。

type RemoteDeleteResult added in v0.6.3

type RemoteDeleteResult struct {
	Key    string `json:"key"`
	Domain string `json:"domain"`
	Type   string `json:"type"`
	// Deleted 为删除的解析条数,0 表示服务商处已经没有这条记录
	Deleted int    `json:"deleted"`
	Error   string `json:"error,omitempty"`
}

RemoteDeleteResult 是一条记录在服务商处的删除结果。

type Settings

type Settings struct {
	Enable bool `json:"enable"`
	// DeleteRemote 为删除记录或任务时“同时从服务商删除解析”勾选框的默认值
	DeleteRemote bool `json:"deleteRemote"`
}

Settings 是模块级配置。

type Task

type Task struct {
	Key    string `json:"key"`
	Name   string `json:"name"`
	Enable bool   `json:"enable"`
	// Group 为列表中的分组名称,只影响管理界面的展示,留空为未分组
	Group       string                  `json:"group"`
	IPv4        ipsource.Source         `json:"ipv4"`
	IPv6        ipsource.Source         `json:"ipv6"`
	Provider    string                  `json:"provider"`
	Credentials dnsprovider.Credentials `json:"credentials"`
	Records     []Record                `json:"records"`
	// Interval 为检查周期(秒)
	Interval int `json:"interval"`
	// ForceInterval 为强制向服务商同步的周期(秒),0 表示只在 IP 变化时同步
	ForceInterval int            `json:"forceInterval"`
	HTTPTimeout   int            `json:"httpTimeout"`
	Webhook       webhook.Config `json:"webhook"`
	Remark        string         `json:"remark"`
	// contains filtered or unexported fields
}

Task 是一个 DDNS 任务:一组记录共用 IP 来源与服务商凭据。

func (*Task) Validate

func (t *Task) Validate() error

Validate 校验并补全默认值。

type TaskState

type TaskState struct {
	IPv4      string                 `json:"ipv4,omitempty"`
	IPv6      string                 `json:"ipv6,omitempty"`
	IPError   string                 `json:"ipError,omitempty"`
	LastRun   time.Time              `json:"lastRun,omitzero"`
	NextRun   time.Time              `json:"nextRun,omitzero"`
	Running   bool                   `json:"running"`
	Records   map[string]RecordState `json:"records"`
	WebhookAt time.Time              `json:"webhookAt,omitzero"`
	WebhookOK bool                   `json:"webhookOk"`
}

TaskState 是任务的运行状态。

type TaskView

type TaskView struct {
	Task
	State TaskState `json:"state"`
}

TaskView 是带运行状态、凭据脱敏的任务。

Jump to

Keyboard shortcuts

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