add ddns file
This commit is contained in:
		
							parent
							
								
									f828db0a38
								
							
						
					
					
						commit
						e6f22deb49
					
				@ -1,4 +1,6 @@
 | 
			
		||||
url: ''
 | 
			
		||||
url:
 | 
			
		||||
  v4: ''
 | 
			
		||||
  v6: ''
 | 
			
		||||
verify_value: ''
 | 
			
		||||
domains:
 | 
			
		||||
  - name: ''
 | 
			
		||||
 | 
			
		||||
@ -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() {}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										25
									
								
								module/ddns/ddns.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								module/ddns/ddns.go
									
									
									
									
									
										Normal 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) {
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -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()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user