From 6acc13e01076dd042f22d5c156b586b57d80523d Mon Sep 17 00:00:00 2001 From: Tero Marttila Date: Sun, 19 Jun 2016 22:50:21 +0300 Subject: [PATCH] go fmt --- addr.go | 16 ++++++++-------- dns.go | 7 ++++--- main.go | 31 ++++++++++++++++--------------- netlink.go | 6 ++---- update.go | 36 ++++++++++++++++++------------------ 5 files changed, 48 insertions(+), 48 deletions(-) diff --git a/addr.go b/addr.go index c99a94c..6b90c4a 100644 --- a/addr.go +++ b/addr.go @@ -1,19 +1,19 @@ package main import ( - "net" - "github.com/vishvananda/netlink" "fmt" - "log" + "github.com/vishvananda/netlink" "io" + "log" + "net" ) type AddrSet struct { - linkAttrs netlink.LinkAttrs - linkChan chan netlink.LinkUpdate - addrChan chan netlink.AddrUpdate + linkAttrs netlink.LinkAttrs + linkChan chan netlink.LinkUpdate + addrChan chan netlink.AddrUpdate - addrs map[string]net.IP + addrs map[string]net.IP } func (addrs *AddrSet) String() string { @@ -21,7 +21,7 @@ func (addrs *AddrSet) String() string { } func (addrs *AddrSet) testFlag(flag net.Flags) bool { - return addrs.linkAttrs.Flags & flag != 0 + return addrs.linkAttrs.Flags&flag != 0 } func (addrs *AddrSet) Up() bool { diff --git a/dns.go b/dns.go index ff3a109..e4128c5 100644 --- a/dns.go +++ b/dns.go @@ -1,18 +1,19 @@ package main import ( - "github.com/miekg/dns" "fmt" - "time" + "github.com/miekg/dns" "log" "net" + "time" ) const TSIG_FUDGE_SECONDS = 300 + type TSIGAlgorithm string func (t *TSIGAlgorithm) UnmarshalFlag(value string) error { - switch (value) { + switch value { case "hmac-md5", "md5": *t = dns.HmacMD5 case "hmac-sha1", "sha1": diff --git a/main.go b/main.go index 6cc5b0c..a6c2733 100644 --- a/main.go +++ b/main.go @@ -8,24 +8,25 @@ import ( ) type Options struct { - Verbose bool `long:"verbose" short:"v"` - Watch bool `long:"watch" description:"Watch for interface changes"` + Verbose bool `long:"verbose" short:"v"` + Watch bool `long:"watch" description:"Watch for interface changes"` - Interface string `long:"interface" short:"i" value-name:"IFACE" description:"Use address from interface"` - InterfaceFamily Family `long:"interface-family" value-name:"ipv4|ipv6|all" description:"Limit to interface addreses of given family"` + // Netlink Interface + Interface string `long:"interface" short:"i" value-name:"IFACE" description:"Use address from interface"` + InterfaceFamily Family `long:"interface-family" value-name:"ipv4|ipv6|all" description:"Limit to interface addreses of given family"` - Server string `long:"server" value-name:"HOST[:PORT]" description:"Server for UPDATE query, default is discovered from zone SOA"` - Timeout time.Duration `long:"timeout" value-name:"DURATION" default:"10s" description:"Timeout for sever queries"` - Retry time.Duration `long:"retry" value-name:"DURATION" default:"30s" description:"Retry interval, increased for each retry attempt"` - TSIGName string `long:"tsig-name" value-name:"FQDN"` - TSIGSecret string `long:"tsig-secret" value-name:"BASE-64" env:"TSIG_SECRET" description:"base64-encoded shared TSIG secret key"` + // DNS Update + Server string `long:"server" value-name:"HOST[:PORT]" description:"Server for UPDATE query, default is discovered from zone SOA"` + Timeout time.Duration `long:"timeout" value-name:"DURATION" default:"10s" description:"Timeout for sever queries"` + Retry time.Duration `long:"retry" value-name:"DURATION" default:"30s" description:"Retry interval, increased for each retry attempt"` + TSIGName string `long:"tsig-name" value-name:"FQDN"` + TSIGSecret string `long:"tsig-secret" value-name:"BASE-64" env:"TSIG_SECRET" description:"base64-encoded shared TSIG secret key"` TSIGAlgorithm TSIGAlgorithm `long:"tsig-algorithm" value-name:"hmac-{md5,sha1,sha256,sha512}" default:"hmac-sha1."` + Zone string `long:"zone" value-name:"FQDN" description:"Zone to update, default is derived from name"` + TTL time.Duration `long:"ttl" value-name:"DURATION" default:"60s" description:"TTL for updated records"` - Zone string `long:"zone" value-name:"FQDN" description:"Zone to update, default is derived from name"` - TTL time.Duration `long:"ttl" value-name:"DURATION" default:"60s" description:"TTL for updated records"` - - Args struct { - Name string `value-name:"FQDN" description:"DNS Name to update"` + Args struct { + Name string `value-name:"FQDN" description:"DNS Name to update"` } `positional-args:"yes"` } @@ -38,7 +39,7 @@ func main() { } var update = Update{ - ttl: int(options.TTL.Seconds()), + ttl: int(options.TTL.Seconds()), timeout: options.Timeout, retry: options.Retry, verbose: options.Verbose, diff --git a/netlink.go b/netlink.go index 028c9df..ed33e89 100644 --- a/netlink.go +++ b/netlink.go @@ -1,15 +1,15 @@ package main import ( - "github.com/vishvananda/netlink" "fmt" + "github.com/vishvananda/netlink" ) // zero value is unspec=all type Family int func (f *Family) UnmarshalFlag(value string) error { - switch (value) { + switch value { case "unspec", "all": *f = netlink.FAMILY_ALL case "inet", "ipv4": @@ -22,5 +22,3 @@ func (f *Family) UnmarshalFlag(value string) error { return nil } - - diff --git a/update.go b/update.go index e9750a7..2e37108 100644 --- a/update.go +++ b/update.go @@ -1,31 +1,31 @@ package main import ( - "github.com/miekg/dns" - "time" "fmt" - "net" + "github.com/miekg/dns" "log" + "net" + "time" ) type updateState struct { - updateZone string - removeNames []dns.RR - inserts []dns.RR + updateZone string + removeNames []dns.RR + inserts []dns.RR } type Update struct { - ttl int - timeout time.Duration - retry time.Duration - verbose bool + ttl int + timeout time.Duration + retry time.Duration + verbose bool - zone string - name string + zone string + name string - tsig map[string]string + tsig map[string]string tsigAlgo TSIGAlgorithm - server string + server string updateChan chan updateState doneChan chan error @@ -77,7 +77,7 @@ func (u *Update) buildAddr(ip net.IP) dns.RR { if ip4 := ip.To4(); ip4 != nil { return &dns.A{ Hdr: dns.RR_Header{Name: u.name, Rrtype: dns.TypeA, Class: dns.ClassINET, Ttl: uint32(u.ttl)}, - A: ip4, + A: ip4, } } @@ -93,10 +93,10 @@ func (u *Update) buildAddr(ip net.IP) dns.RR { func (u *Update) buildState(addrs *AddrSet) (state updateState, err error) { state.updateZone = u.zone state.removeNames = []dns.RR{ - &dns.RR_Header{Name:u.name}, + &dns.RR_Header{Name: u.name}, } - addrs.Each(func(ip net.IP){ + addrs.Each(func(ip net.IP) { state.inserts = append(state.inserts, u.buildAddr(ip)) }) @@ -173,7 +173,7 @@ func (u *Update) run() { var updateChan = u.updateChan var updateError error - defer func(){u.doneChan <-updateError}() + defer func() { u.doneChan <- updateError }() for { select {