config

package
v5.7.1 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// UpdatedNothing 未改变
	UpdatedNothing updateStatusType = "未改变"
	// UpdatedFailed 更新失败
	UpdatedFailed = "失败"
	// UpdatedSuccess 更新成功
	UpdatedSuccess = "成功"
)

Variables

View Source
var Ipv4Reg = regexp.MustCompile(`((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])`)

Ipv4Reg IPv4正则

View Source
var Ipv6Reg = regexp.MustCompile(`((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))`)

Ipv6Reg IPv6正则

Functions

func ExecWebhook

func ExecWebhook(domains *Domains, conf *Config) (v4Status updateStatusType, v6Status updateStatusType)

ExecWebhook 添加或更新IPv4/IPv6记录, 返回是否有更新失败的

func GetNetInterface

func GetNetInterface() (ipv4NetInterfaces []NetInterface, ipv6NetInterfaces []NetInterface, err error)

GetNetInterface 获得网卡地址 返回ipv4, ipv6地址

Types

type Config

type Config struct {
	DnsConf []DnsConfig
	User
	Webhook
	// 禁止公网访问
	NotAllowWanAccess bool
}

func GetConfigCached

func GetConfigCached() (conf Config, err error)

GetConfigCached 获得缓存的配置

func (*Config) CompatibleConfig

func (conf *Config) CompatibleConfig()

CompatibleConfig 兼容v5.0.0之前的配置文件

func (*Config) SaveConfig

func (conf *Config) SaveConfig() (err error)

SaveConfig 保存配置

type DNS

type DNS struct {
	// 名称。如:alidns,webhook
	Name   string
	ID     string
	Secret string
}

DNS DNS配置

type DnsConfig

type DnsConfig struct {
	Ipv4 struct {
		Enable bool
		// 获取IP类型 url/netInterface
		GetType      string
		URL          string
		NetInterface string
		Cmd          string
		Domains      []string
	}
	Ipv6 struct {
		Enable bool
		// 获取IP类型 url/netInterface
		GetType      string
		URL          string
		NetInterface string
		Cmd          string
		IPv6Reg      string // ipv6匹配正则表达式
		Domains      []string
	}
	DNS DNS
	TTL string
}

DnsConfig 配置

func (*DnsConfig) GetIpv4Addr

func (conf *DnsConfig) GetIpv4Addr() string

GetIpv4Addr 获得IPv4地址

func (*DnsConfig) GetIpv6Addr

func (conf *DnsConfig) GetIpv6Addr() (result string)

GetIpv6Addr 获得IPv6地址

type Domain

type Domain struct {
	// DomainName 根域名
	DomainName string
	// SubDomain 子域名
	SubDomain    string
	CustomParams string
	UpdateStatus updateStatusType // 更新状态
}

Domain 域名实体

func (Domain) GetCustomParams

func (d Domain) GetCustomParams() url.Values

GetCustomParams not be nil

func (Domain) GetFullDomain

func (d Domain) GetFullDomain() string

GetFullDomain 获得全部的,子域名

func (Domain) GetSubDomain

func (d Domain) GetSubDomain() string

GetSubDomain 获得子域名,为空返回@ 阿里云/腾讯云/dnspod/GoDaddy/namecheap 需要

func (Domain) String

func (d Domain) String() string

type Domains

type Domains struct {
	Ipv4Addr    string
	Ipv4Cache   *util.IpCache
	Ipv4Domains []*Domain
	Ipv6Addr    string
	Ipv6Cache   *util.IpCache
	Ipv6Domains []*Domain
}

Domains Ipv4/Ipv6 domains

func (*Domains) GetNewIp

func (domains *Domains) GetNewIp(dnsConf *DnsConfig)

GetNewIp 接口/网卡/命令获得 ip 并校验用户输入的域名

func (*Domains) GetNewIpResult

func (domains *Domains) GetNewIpResult(recordType string) (ipAddr string, retDomains []*Domain)

GetNewIpResult 获得GetNewIp结果

type NetInterface

type NetInterface struct {
	Name    string
	Address []string
}

NetInterface 本机网络

type User

type User struct {
	Username string
	Password string
}

User 登录用户

type Webhook

type Webhook struct {
	WebhookURL         string
	WebhookRequestBody string
	WebhookHeaders     string
}

Webhook Webhook

Jump to

Keyboard shortcuts

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