add ddns file

This commit is contained in:
Jay 2019-05-08 22:44:28 +08:00
parent f828db0a38
commit e6f22deb49
4 changed files with 41 additions and 6 deletions

View File

@ -1,4 +1,6 @@
url: '' url:
v4: ''
v6: ''
verify_value: '' verify_value: ''
domains: domains:
- name: '' - name: ''

View File

@ -12,19 +12,22 @@ import (
// RecordData - // RecordData -
type RecordData struct { type RecordData struct {
Name string `yaml:"name"` Name string `yaml:"name" json:"name"`
Type string `yaml:"type"` Type string `yaml:"type" json:"type"`
} }
// DomainData - // DomainData -
type DomainData struct { type DomainData struct {
Name string `yaml:"name"` Name string `yaml:"name" json:"name"`
Records []RecordData `yaml:"records"` Records []RecordData `yaml:"records" json:"records"`
} }
// Config - // Config -
type Config struct { type Config struct {
URL string `yaml:"url"` URL struct {
V4 string `yaml:"v4"`
V6 string `yaml:"v6"`
} `yaml:"url"`
VerifyValue string `yaml:"verify_value"` VerifyValue string `yaml:"verify_value"`
Domains []DomainData `yaml:"domains"` Domains []DomainData `yaml:"domains"`
} }
@ -66,3 +69,6 @@ func LoadConfig(p ...string) error {
// GetConfig - // GetConfig -
func GetConfig() *Config { return conf } func GetConfig() *Config { return conf }
// GetV4Data -
func (p DomainData) GetV4Data() {}

25
module/ddns/ddns.go Normal file
View File

@ -0,0 +1,25 @@
package ddns
import (
"errors"
"git.trj.tw/golang/go-ddns-client/module/config"
)
// Errors
var (
ErrNoDomain = errors.New("No Domain Setting")
)
// SendDNSSetting -
func SendDNSSetting() error {
conf := config.GetConfig()
if len(conf.Domains) == 0 {
return ErrNoDomain
}
return nil
}
func parseConf(domains []config.DomainData) {
}

View File

@ -6,6 +6,7 @@ import "flag"
type Options struct { type Options struct {
Help bool Help bool
Config string Config string
Once bool
} }
var opts *Options var opts *Options
@ -16,6 +17,7 @@ func RegOptions() {
flag.StringVar(&opts.Config, "config", "", "config file path - default: `pwd/config.yml`") flag.StringVar(&opts.Config, "config", "", "config file path - default: `pwd/config.yml`")
flag.StringVar(&opts.Config, "f", "", "config file path - default: `pwd/config.yml`") flag.StringVar(&opts.Config, "f", "", "config file path - default: `pwd/config.yml`")
flag.BoolVar(&opts.Help, "help", false, "show help") flag.BoolVar(&opts.Help, "help", false, "show help")
flag.BoolVar(&opts.Once, "once", false, "run once")
flag.Parse() flag.Parse()
} }