Merge lp:~chipaca/snapweb/mdns-nicer-with-ipv6 into lp:~snappy-dev/snapweb/trunk

Proposed by John Lenton
Status: Approved
Approved by: Sergio Schvezov
Approved revision: 166
Proposed branch: lp:~chipaca/snapweb/mdns-nicer-with-ipv6
Merge into: lp:~snappy-dev/snapweb/trunk
Prerequisite: lp:~chipaca/snapweb/old-branches
Diff against target: 67 lines (+15/-11)
2 files modified
avahi/avahi.go (+14/-10)
pkg/meta/package.yaml (+1/-1)
To merge this branch: bzr merge lp:~chipaca/snapweb/mdns-nicer-with-ipv6
Reviewer Review Type Date Requested Status
Sergio Schvezov Approve
Review via email: mp+275866@code.launchpad.net

Commit message

Handle IPv6 addresses better wrt mdns.

To post a comment you must log in.
Revision history for this message
Sergio Schvezov (sergiusens) wrote :

Thanks for this great improvement!

review: Approve

Unmerged revisions

166. By John Lenton

handle ipv6 better in the mdns rrs

165. By John Lenton

bump snappy revision

164. By John Lenton

also nuke the now-useless config

163. By John Lenton

fxi typo

162. By John Lenton

silly tweaks to build and package

161. By John Lenton

update package version

160. By John Lenton

build again, ok? ta

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'avahi/avahi.go'
--- avahi/avahi.go 2015-05-07 23:00:26 +0000
+++ avahi/avahi.go 2015-10-27 15:43:20 +0000
@@ -39,18 +39,22 @@
39)39)
4040
41const timeoutMinutes = 1041const timeoutMinutes = 10
42const inAddr = `%s.local. 60 IN A %s`42const in4Addr = `%s.local. 60 IN A %s`
43const inPtr = `%s.in-addr.arpa. 60 IN PTR %s.local.`43const in6Addr = `%s.local. 60 in AAAA %s`
4444
45var mdnsPublish = mdns.Publish45var mdnsPublish = mdns.Publish
4646
47func tryPublish(hostname, ip string) {47func tryPublish(hostname string, ip net.IP) {
48 rr := fmt.Sprintf(inAddr, hostname, ip)48 inAddr := in4Addr
49 if ip.To4() == nil {
50 inAddr = in6Addr
51 }
52 rr := fmt.Sprintf(inAddr, hostname, ip.String())
4953
50 logger.Println("Publishing", rr)54 logger.Println("Publishing", rr)
5155
52 if err := mdnsPublish(rr); err != nil {56 if err := mdnsPublish(rr); err != nil {
53 logger.Printf(`Unable to publish record "%s": %v`, rr, err)57 logger.Printf(`Unable to publish record %q: %v`, rr, err)
54 return58 return
55 }59 }
56}60}
@@ -102,17 +106,17 @@
102 return106 return
103 }107 }
104108
105 if strings.ContainsRune(hostname, '.') {109 if idx := strings.IndexByte(hostname, '.'); idx > -1 {
106 hostname = strings.Split(hostname, ".")[0]110 hostname = hostname[:idx]
107 }111 }
108112
109 if hostname == hostnameLocalhost {113 if hostname == hostnameLocalhost {
110 hostname = hostnameWedbm114 hostname = hostnameWedbm
111 }115 }
112116
113 for _, ip := range addrs {117 for _, addr := range addrs {
114 ip := strings.Split(ip.String(), "/")[0]118 ip, _, err := net.ParseCIDR(addr.String())
115 if strings.HasPrefix(ip, "127.") {119 if ip == nil || err != nil || ip.IsLoopback() {
116 continue120 continue
117 }121 }
118122
119123
=== modified file 'pkg/meta/package.yaml'
--- pkg/meta/package.yaml 2015-10-27 15:43:20 +0000
+++ pkg/meta/package.yaml 2015-10-27 15:43:20 +0000
@@ -3,7 +3,7 @@
3icon: meta/webdm-icon.png3icon: meta/webdm-icon.png
4source: lp:webdm4source: lp:webdm
5type: framework5type: framework
6version: 0.9.36version: 0.9.4
7architectures: UNKNOWN_ARCH7architectures: UNKNOWN_ARCH
8services:8services:
9 - name: snappyd9 - name: snappyd

Subscribers

People subscribed via source and target branches

to all changes: