ddns

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 21 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 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}
	Value  string `json:"value"`
	TTL    int    `json:"ttl"`
	Line   string `json:"line"`
	Remark string `json:"remark"`
}

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"`
}

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

type Settings

type Settings struct {
	Enable bool `json:"enable"`
}

Settings 是模块级配置。

type Task

type Task struct {
	Key         string                  `json:"key"`
	Name        string                  `json:"name"`
	Enable      bool                    `json:"enable"`
	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"`
}

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