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

Proposed by John Lenton on 2015-10-27
Status: Approved
Approved by: Sergio Schvezov on 2015-10-27
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 2015-10-27 Approve on 2015-10-27
Review via email: mp+275866@code.launchpad.net

Commit message

Handle IPv6 addresses better wrt mdns.

To post a comment you must log in.
Sergio Schvezov (sergiusens) wrote :

Thanks for this great improvement!

review: Approve

Unmerged revisions

166. By John Lenton on 2015-10-27

handle ipv6 better in the mdns rrs

165. By John Lenton on 2015-10-26

bump snappy revision

164. By John Lenton on 2015-10-26

also nuke the now-useless config

163. By John Lenton on 2015-10-01

fxi typo

162. By John Lenton on 2015-10-01

silly tweaks to build and package

161. By John Lenton on 2015-09-25

update package version

160. By John Lenton on 2015-09-25

build again, ok? ta

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'avahi/avahi.go'
2--- avahi/avahi.go 2015-05-07 23:00:26 +0000
3+++ avahi/avahi.go 2015-10-27 15:43:20 +0000
4@@ -39,18 +39,22 @@
5 )
6
7 const timeoutMinutes = 10
8-const inAddr = `%s.local. 60 IN A %s`
9-const inPtr = `%s.in-addr.arpa. 60 IN PTR %s.local.`
10+const in4Addr = `%s.local. 60 IN A %s`
11+const in6Addr = `%s.local. 60 in AAAA %s`
12
13 var mdnsPublish = mdns.Publish
14
15-func tryPublish(hostname, ip string) {
16- rr := fmt.Sprintf(inAddr, hostname, ip)
17+func tryPublish(hostname string, ip net.IP) {
18+ inAddr := in4Addr
19+ if ip.To4() == nil {
20+ inAddr = in6Addr
21+ }
22+ rr := fmt.Sprintf(inAddr, hostname, ip.String())
23
24 logger.Println("Publishing", rr)
25
26 if err := mdnsPublish(rr); err != nil {
27- logger.Printf(`Unable to publish record "%s": %v`, rr, err)
28+ logger.Printf(`Unable to publish record %q: %v`, rr, err)
29 return
30 }
31 }
32@@ -102,17 +106,17 @@
33 return
34 }
35
36- if strings.ContainsRune(hostname, '.') {
37- hostname = strings.Split(hostname, ".")[0]
38+ if idx := strings.IndexByte(hostname, '.'); idx > -1 {
39+ hostname = hostname[:idx]
40 }
41
42 if hostname == hostnameLocalhost {
43 hostname = hostnameWedbm
44 }
45
46- for _, ip := range addrs {
47- ip := strings.Split(ip.String(), "/")[0]
48- if strings.HasPrefix(ip, "127.") {
49+ for _, addr := range addrs {
50+ ip, _, err := net.ParseCIDR(addr.String())
51+ if ip == nil || err != nil || ip.IsLoopback() {
52 continue
53 }
54
55
56=== modified file 'pkg/meta/package.yaml'
57--- pkg/meta/package.yaml 2015-10-27 15:43:20 +0000
58+++ pkg/meta/package.yaml 2015-10-27 15:43:20 +0000
59@@ -3,7 +3,7 @@
60 icon: meta/webdm-icon.png
61 source: lp:webdm
62 type: framework
63-version: 0.9.3
64+version: 0.9.4
65 architectures: UNKNOWN_ARCH
66 services:
67 - name: snappyd

Subscribers

People subscribed via source and target branches

to all changes: