summaryrefslogtreecommitdiffhomepage
path: root/wgengine
diff options
context:
space:
mode:
authorJosh Bleecher Snyder <josh@tailscale.com>2021-09-16 16:50:31 -0700
committerJosh Bleecher Snyder <josh@tailscale.com>2021-09-17 16:47:00 -0700
commitc7b75465871eb911df4e1ff91a57b9c91c279111 (patch)
tree0b7975a92a5f53ad27ee78525ae4e5660d34c7fe /wgengine
parentb14db5d943b84be3c9f3a909c18c9af4012523dd (diff)
downloadtailscale-josh/immutable-views.tar.xz
tailscale-josh/immutable-views.zip
Next up: view support for maps, etc.
Diffstat (limited to 'wgengine')
-rw-r--r--wgengine/filter/match.go1
-rw-r--r--wgengine/filter/match_view.go33
-rw-r--r--wgengine/netstack/netstack.go2
3 files changed, 35 insertions, 1 deletions
diff --git a/wgengine/filter/match.go b/wgengine/filter/match.go
index 74807dda7..2115be452 100644
--- a/wgengine/filter/match.go
+++ b/wgengine/filter/match.go
@@ -14,6 +14,7 @@ import (
)
//go:generate go run tailscale.com/cmd/cloner --type=Match --output=match_clone.go
+//go:generate go run tailscale.com/cmd/viewer --type=Match --output=match_view.go
// PortRange is a range of TCP and UDP ports.
type PortRange struct {
diff --git a/wgengine/filter/match_view.go b/wgengine/filter/match_view.go
new file mode 100644
index 000000000..c3c267a6e
--- /dev/null
+++ b/wgengine/filter/match_view.go
@@ -0,0 +1,33 @@
+// Copyright (c) 2021 Tailscale Inc & AUTHORS All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Code generated by the following command; DO NOT EDIT.
+// tailscale.com/cmd/viewer -type Match
+
+package filter
+
+import (
+ "inet.af/netaddr"
+ "tailscale.com/types/ipproto"
+)
+
+// View makes a readonly view of Match.
+func (src *Match) View() MatchView {
+ return MatchView{src}
+}
+
+// MatchView is a readonly view of Match.
+type MatchView struct{ ж *Match }
+
+func (v MatchView) Valid() bool { return v.ж != nil }
+func (v MatchView) IPProto() []ipproto.Proto { return v.ж.IPProto }
+func (v MatchView) Dsts() []NetPortRange { return v.ж.Dsts }
+func (v MatchView) Srcs() []netaddr.IPPrefix { return v.ж.Srcs }
+
+// A compilation failure here means this code must be regenerated, with the command at the top of this file.
+var _MatchViewNeedsRegeneration = Match(struct {
+ IPProto []ipproto.Proto
+ Dsts []NetPortRange
+ Srcs []netaddr.IPPrefix
+}{})
diff --git a/wgengine/netstack/netstack.go b/wgengine/netstack/netstack.go
index 791e030d0..f0bb7f6ff 100644
--- a/wgengine/netstack/netstack.go
+++ b/wgengine/netstack/netstack.go
@@ -176,7 +176,7 @@ type DNSMap map[string]netaddr.IP
func DNSMapFromNetworkMap(nm *netmap.NetworkMap) DNSMap {
ret := make(DNSMap)
- suffix := nm.MagicDNSSuffix()
+ suffix := nm.View().MagicDNSSuffix()
have4 := false
if nm.Name != "" && len(nm.Addresses) > 0 {
ip := nm.Addresses[0].IP()