Documentation
¶
Overview ¶
Copyright 2022 gdy, 272288813@qq.com
Copyright 2022 gdy, 272288813@qq.com
Copyright 2022 gdy, 272288813@qq.com
Copyright 2022 gdy, 272288813@qq.com
Index ¶
- Constants
- Variables
- func BlackListAdd(ip string, activelifeDuration int32) (string, error)
- func BlackListDelete(ip string) error
- func BlackListFlush(lock bool) error
- func CheckDDNSTaskAvalid(task *DDNSTask) error
- func CheckTCPPortAvalid(port int) bool
- func CleanIPUrlAddrMap()
- func DDNSTaskIPCacheCheck(taskKey, ip string) (bool, error)
- func DDNSTaskListAdd(task *DDNSTask) error
- func DDNSTaskListDelete(taskKey string) error
- func DDNSTaskListFlushDomainsDetails(taskKey string, state *DomainsState)
- func DDNSTaskListTaskDetailsInit()
- func DDNSTaskSetWebhookCallResult(taskKey string, result bool, message string)
- func DeleteAnyListlice(a []any, deleteIndex int) []any
- func EnableDDNSTaskByKey(taskKey string, enable bool) error
- func FlushLoginRandomKey()
- func GetAuthAccount() map[string]string
- func GetConfigureBytes() []byte
- func GetIPFromNetInterface(ipType, netinterface, ipreg string) string
- func GetLoginRandomKey() string
- func GetNetInterface() (ipv4NetInterfaces []NetInterface, ipv6NetInterfaces []NetInterface, err error)
- func GetRunMode() string
- func GetVersion() string
- func InitAppInfo(version, date string)
- func LoadDefault(proxyCountLimit int64, adminWebListenPort int, globalMaxConnections int64)
- func Read(filePath string) (err error)
- func SafeCheck(mode, ip string) bool
- func Save() (err error)
- func SetBaseConfigure(conf *BaseConfigure) error
- func SetConfig(p *ProgramConfigure) error
- func SetConfigRuleList(ruleList *[]ConfigureRelayRule)
- func SetDDNSConfigure(conf *DDNSConfigure) error
- func SetRunMode(mode string)
- func SetVersion(v string)
- func SetWhiteListBaseConfigure(activelifeDuration int32, url, account, password string) error
- func UpdateDomainsStateByTaskKey(taskKey string, status updateStatusType, message string)
- func UpdateTaskToDDNSTaskList(taskKey string, task DDNSTask) error
- func WebhookTest(d *DDNSTask, url, method, WebhookRequestBody, proxy, addr, user, passwd string, ...) (string, error)
- func WhiteListAdd(ip string, activelifeDuration int32) (string, error)
- func WhiteListDelete(ip string) error
- func WhiteListFlush(lock bool) error
- type AppInfo
- type BaseConfigure
- type BlackListConfigure
- type BlackListItem
- type ConfigureRelayRule
- type DDNSConfigure
- type DDNSTask
- type DDNSTaskDetails
- type DNSCallback
- type DNSConfig
- type Domain
- type DomainsState
- func (domains *DomainsState) CheckIPChange(recordType, taskKey string, getAddrFunc func() string) (ipAddr string, change bool, retDomains []*Domain)
- func (d *DomainsState) Init(domains []string)
- func (d *DomainsState) SetDomainUpdateStatus(status updateStatusType, message string)
- func (d *DomainsState) SetIPAddr(ipaddr string)
- func (d *DomainsState) SetWebhookResult(result bool, errMsg string)
- type IPAddrHistoryItem
- type NetInterface
- type ProgramConfigure
- type UpdateHistroyItem
- type Webhook
- type WebhookCallHistroyItem
- type WhiteListBaseConfigure
- type WhiteListConfigure
- type WhiteListItem
Constants ¶
View Source
const ( // UpdatedNothing 未改变 UpdatedNothing updateStatusType = "域名IP和公网IP一致" // UpdatedFailed 更新失败 UpdatedFailed = "失败" // UpdatedSuccess 更新成功 UpdatedSuccess = "成功" // UpdateStop 暂停 UpdateStop = "停止同步" //UpdatePause 暂停 获取IP失败时暂停 UpdatePause = "暂停同步" // UpdateWaiting UpdateWaiting = "等待更新" )
View Source
const Ipv4Reg = `((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
const Ipv6Reg = `` /* 1065-byte string literal not displayed */
Ipv6Reg IPv6正则
Variables ¶
View Source
var DefaultIPv4DNSServerList = []string{
"1.1.1.1:53",
"1.2.4.8:53",
"8.8.8.8:53",
"9.9.9.9:53",
"8.8.4.4:53",
"114.114.114.114:53",
"223.5.5.5:53",
"223.6.6.6:53",
"101.226.4.6:53",
"218.30.118.6:53",
"119.28.28.28:53",
}
View Source
var DefaultIPv6DNSServerList = []string{
"[2001:4860:4860::8888]:53",
"[2001:4860:4860::8844]:53",
"[2606:4700:4700::64]:53",
"[2606:4700:4700::6400]:53",
"[240C::6666]:53",
"[240C::6644]:53",
"[2402:4e00::]:53",
"[240e:4c:4008::1]:53",
"[240e:4c:4808::1]:53",
"[2408:8899::8]:53",
"[2408:8888::8]:53",
"[2409:8088::a]:53",
"[2409:8088::b]:53",
"[2001:dc7:1000::1]:53",
"[2400:da00::6666]:53",
}
Functions ¶
func BlackListDelete ¶
func BlackListFlush ¶
func CheckDDNSTaskAvalid ¶
func CheckTCPPortAvalid ¶
func CleanIPUrlAddrMap ¶
func CleanIPUrlAddrMap()
func DDNSTaskIPCacheCheck ¶
func DDNSTaskListAdd ¶
func DDNSTaskListDelete ¶
func DDNSTaskListFlushDomainsDetails ¶
func DDNSTaskListFlushDomainsDetails(taskKey string, state *DomainsState)
func DDNSTaskListTaskDetailsInit ¶
func DDNSTaskListTaskDetailsInit()
func DeleteAnyListlice ¶
func EnableDDNSTaskByKey ¶
func FlushLoginRandomKey ¶
func FlushLoginRandomKey()
func GetAuthAccount ¶
func GetConfigureBytes ¶ added in v1.1.8
func GetConfigureBytes() []byte
func GetIPFromNetInterface ¶
func GetLoginRandomKey ¶
func GetLoginRandomKey() string
func GetNetInterface ¶
func GetNetInterface() (ipv4NetInterfaces []NetInterface, ipv6NetInterfaces []NetInterface, err error)
GetNetInterface 获得网卡地址 返回ipv4, ipv6地址
func GetRunMode ¶
func GetRunMode() string
func GetVersion ¶
func GetVersion() string
func InitAppInfo ¶
func InitAppInfo(version, date string)
func LoadDefault ¶
func SetConfig ¶ added in v1.1.8
func SetConfig(p *ProgramConfigure) error
func SetConfigRuleList ¶
func SetConfigRuleList(ruleList *[]ConfigureRelayRule)
func SetDDNSConfigure ¶
func SetDDNSConfigure(conf *DDNSConfigure) error
func SetRunMode ¶
func SetRunMode(mode string)
func SetVersion ¶
func SetVersion(v string)
func WebhookTest ¶
func WhiteListDelete ¶
func WhiteListFlush ¶
Types ¶
type AppInfo ¶
type AppInfo struct { AppName string Version string OS string ARCH string Date string RunTime string }
func GetAppInfo ¶
func GetAppInfo() *AppInfo
type BaseConfigure ¶
type BaseConfigure struct { AdminWebListenPort int `json:"AdminWebListenPort"` //管理后台端口 ProxyCountLimit int64 `json:"ProxyCountLimit"` //全局代理数量限制 AdminAccount string `json:"AdminAccount"` //登录账号 AdminPassword string `json:"AdminPassword"` //登录密码 AllowInternetaccess bool `json:"AllowInternetaccess"` //允许外网访问 GlobalMaxConnections int64 `json:"GlobalMaxConnections"` //全局最大连接数 }
func GetBaseConfigure ¶
func GetBaseConfigure() BaseConfigure
type BlackListConfigure ¶
type BlackListConfigure struct {
BlackList []BlackListItem `json:"BlackList"` //黑名单列表
}
type BlackListItem ¶
type BlackListItem WhiteListItem
func DeleteBlackListlice ¶
func DeleteBlackListlice(a []BlackListItem, deleteIndex int) []BlackListItem
func GetBlackList ¶
func GetBlackList() []BlackListItem
type ConfigureRelayRule ¶
type ConfigureRelayRule struct { Name string `json:"Name"` Configurestr string `json:"Configurestr"` Enable bool `json:"Enable"` Options base.RelayRuleOptions `json:"Options"` }
type DDNSConfigure ¶
type DDNSConfigure struct { Enable bool `json:"Enable"` HttpClientSecureVerify bool `json:"HttpClientSecureVerify"` FirstCheckDelay int `json:"FirstCheckDelay"` //首次检查延迟时间 Intervals int `json:"Intervals"` }
func GetDDNSConfigure ¶
func GetDDNSConfigure() DDNSConfigure
type DDNSTask ¶
type DDNSTask struct { TaskName string `json:"TaskName"` TaskKey string `json:"TaskKey"` //添加任务时随机生成,方便管理任务(修改删除) //规则类型 IPv4/IPv6 TaskType string `json:"TaskType"` Enable bool GetType string `json:"GetType"` URL []string `json:"URL"` NetInterface string `json:"NetInterface"` IPReg string `json:"IPReg"` Domains []string `json:"Domains"` DNS DNSConfig `json:"DNS"` Webhook TTL string `json:"TTL"` HttpClientTimeout int `json:"HttpClientTimeout"` //------------------------------------- //IpCache IpCache `json:"-"` DomainsState DomainsState `json:"-"` }
func DeleteDDNSTaskListlice ¶
func (*DDNSTask) ExecWebhook ¶
func (d *DDNSTask) ExecWebhook(domains *DomainsState)
ExecWebhook 添加或更新IPv4/IPv6记录
func (*DDNSTask) IPChangeCheck ¶
Check 检测IP是否有改变
type DDNSTaskDetails ¶
type DDNSTaskDetails struct { DDNSTask TaskState DomainsState `json:"TaskState"` }
func GetDDNSTaskByKey ¶
func GetDDNSTaskByKey(taskKey string) *DDNSTaskDetails
func GetDDNSTaskList ¶
func GetDDNSTaskList() []DDNSTaskDetails
type DNSCallback ¶
type DNSConfig ¶
type DNSConfig struct { // 名称。如:alidns,webhook Name string `json:"Name"` ID string `json:"ID"` Secret string `json:"Secret"` ForceInterval int `json:"ForceInterval"` //(秒)即使IP没有变化,到一定时间后依然强制更新或先DNS解析比较IP再更新 ResolverDoaminCheck bool `json:"ResolverDoaminCheck"` //调用callback同步前先解析一次域名,如果IP相同就不同步 DNSServerList []string `json:"DNSServerList"` //DNS服务器列表 Callback DNSCallback `json:"Callback"` HttpClientProxyType string `json:"HttpClientProxyType"` //http client代理服务器设置 HttpClientProxyAddr string `json:"HttpClientProxyAddr"` //代理服务器IP HttpClientProxyUser string `json:"HttpClientProxyUser"` //代理用户 HttpClientProxyPassword string `json:"HttpClientProxyPassword"` //代理密码 }
DNSConfig DNS配置
type Domain ¶
type Domain struct { DomainName string SubDomain string UpdateStatus updateStatusType // 更新状态 LastUpdateStatusTime string //最后更新状态的时间 Message string UpdateHistroy []any // contains filtered or unexported fields }
Domain 域名实体
func (Domain) GetSubDomain ¶
GetSubDomain 获得子域名,为空返回@ 阿里云,dnspod需要
func (*Domain) SetDomainUpdateStatus ¶
type DomainsState ¶
type DomainsState struct { IpAddr string Domains []*Domain WebhookCallTime string `json:"WebhookCallTime"` //最后触发时间 WebhookCallResult bool `json:"WebhookCallResult"` //触发结果 WebhookCallErrorMsg string `json:"WebhookCallErrorMsg"` //触发错误信息 LastSyncTime time.Time `json:"-"` //记录最新一次同步操作时间 IPAddrHistory []any `json:"IPAddrHistory"` WebhookCallHistroy []any `json:"WebhookCallHistroy"` Mutex *sync.RWMutex `json:"-"` }
Domains Ipv4/Ipv6 DomainsState
func (*DomainsState) CheckIPChange ¶
func (domains *DomainsState) CheckIPChange(recordType, taskKey string, getAddrFunc func() string) (ipAddr string, change bool, retDomains []*Domain)
CheckIPChange 检测公网IP是否改变
func (*DomainsState) Init ¶
func (d *DomainsState) Init(domains []string)
func (*DomainsState) SetDomainUpdateStatus ¶
func (d *DomainsState) SetDomainUpdateStatus(status updateStatusType, message string)
func (*DomainsState) SetIPAddr ¶
func (d *DomainsState) SetIPAddr(ipaddr string)
func (*DomainsState) SetWebhookResult ¶
func (d *DomainsState) SetWebhookResult(result bool, errMsg string)
type IPAddrHistoryItem ¶
type NetInterface ¶
NetInterface 本机网络
type ProgramConfigure ¶
type ProgramConfigure struct { BaseConfigure BaseConfigure `json:"BaseConfigure"` RelayRuleList []ConfigureRelayRule `json:"RelayRuleList"` WhiteListConfigure WhiteListConfigure `json:"WhiteListConfigure"` BlackListConfigure BlackListConfigure `json:"BlackListConfigure"` DDNSConfigure DDNSConfigure `json:"DDNSConfigure"` //DDNS 参数设置 DDNSTaskList []DDNSTask `json:"DDNSTaskList"` }
func GetConfig ¶
func GetConfig() *ProgramConfigure
type UpdateHistroyItem ¶
type Webhook ¶
type Webhook struct { WebhookEnable bool `json:"WebhookEnable"` //Webhook开关 WebhookCallOnGetIPfail bool `json:"WebhookCallOnGetIPfail"` //获取IP失败时触发Webhook 开关 WebhookURL string `json:"WebhookURL"` WebhookMethod string `json:"WebhookMethod"` WebhookHeaders []string `json:"WebhookHeaders"` WebhookRequestBody string `json:"WebhookRequestBody"` WebhookSuccessContent []string `json:"WebhookSuccessContent"` //接口调用成功包含的内容 WebhookProxy string `json:"WebhookProxy"` //使用DNS代理设置 ""表示禁用,"dns"表示使用dns的代理设置 WebhookProxyAddr string `json:"WebhookProxyAddr"` //代理服务器IP WebhookProxyUser string `json:"WebhookProxyUser"` //代理用户 WebhookProxyPassword string `json:"WebhookProxyPassword"` //代理密码 }
type WebhookCallHistroyItem ¶
type WhiteListBaseConfigure ¶
type WhiteListBaseConfigure struct { URL string `json:"URL"` ActivelifeDuration int32 `json:"ActivelifeDuration"` //有效期限,小时 BasicAccount string `json:"BasicAccount"` BasicPassword string `json:"BasicPassword"` }
func GetWhiteListBaseConfigure ¶
func GetWhiteListBaseConfigure() WhiteListBaseConfigure
type WhiteListConfigure ¶
type WhiteListConfigure struct { BaseConfigure WhiteListBaseConfigure `json:"BaseConfigure` WhiteList []WhiteListItem `json:"WhiteList"` //白名单列表 }
type WhiteListItem ¶
type WhiteListItem struct { IP string `json:"IP"` EffectiveTime string `json:"Effectivetime"` //有效时间 }
func DeleteWhiteListlice ¶
func DeleteWhiteListlice(a []WhiteListItem, deleteIndex int) []WhiteListItem
func GetWhiteList ¶
func GetWhiteList() []WhiteListItem
Click to show internal directories.
Click to hide internal directories.