diff --git a/config.default.yml b/config.default.yml index de6be51..374ed4a 100644 --- a/config.default.yml +++ b/config.default.yml @@ -1,4 +1,6 @@ -url: '' +url: + v4: '' + v6: '' verify_value: '' domains: - name: '' diff --git a/module/config/config.go b/module/config/config.go index cc74588..a6d8887 100644 --- a/module/config/config.go +++ b/module/config/config.go @@ -12,19 +12,22 @@ import ( // RecordData - type RecordData struct { - Name string `yaml:"name"` - Type string `yaml:"type"` + Name string `yaml:"name" json:"name"` + Type string `yaml:"type" json:"type"` } // DomainData - type DomainData struct { - Name string `yaml:"name"` - Records []RecordData `yaml:"records"` + Name string `yaml:"name" json:"name"` + Records []RecordData `yaml:"records" json:"records"` } // Config - type Config struct { - URL string `yaml:"url"` + URL struct { + V4 string `yaml:"v4"` + V6 string `yaml:"v6"` + } `yaml:"url"` VerifyValue string `yaml:"verify_value"` Domains []DomainData `yaml:"domains"` } @@ -66,3 +69,6 @@ func LoadConfig(p ...string) error { // GetConfig - func GetConfig() *Config { return conf } + +// GetV4Data - +func (p DomainData) GetV4Data() {} diff --git a/module/ddns/ddns.go b/module/ddns/ddns.go new file mode 100644 index 0000000..a958bb9 --- /dev/null +++ b/module/ddns/ddns.go @@ -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) { + +} diff --git a/module/option/option.go b/module/option/option.go index 022246c..e35b4dc 100644 --- a/module/option/option.go +++ b/module/option/option.go @@ -6,6 +6,7 @@ import "flag" type Options struct { Help bool Config string + Once bool } 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, "f", "", "config file path - default: `pwd/config.yml`") flag.BoolVar(&opts.Help, "help", false, "show help") + flag.BoolVar(&opts.Once, "once", false, "run once") flag.Parse() }