mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-11 21:27:31 +00:00
tailcfg: add RawMessage
This adds a new RawMessage type backed by string instead of the json.RawMessage which is backed by []byte. The byte slice makes the generated views be a lot more defensive than the need to be which we can get around by using a string instead. Updates #cleanup Signed-off-by: Maisem Ali <maisem@tailscale.com>
This commit is contained in:
@@ -6,7 +6,6 @@
|
||||
package filter
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/netip"
|
||||
|
||||
"tailscale.com/tailcfg"
|
||||
@@ -49,12 +48,7 @@ func (src *CapMatch) Clone() *CapMatch {
|
||||
}
|
||||
dst := new(CapMatch)
|
||||
*dst = *src
|
||||
if src.Values != nil {
|
||||
dst.Values = make([]json.RawMessage, len(src.Values))
|
||||
for i := range dst.Values {
|
||||
dst.Values[i] = append(src.Values[i][:0:0], src.Values[i]...)
|
||||
}
|
||||
}
|
||||
dst.Values = append(src.Values[:0:0], src.Values...)
|
||||
return dst
|
||||
}
|
||||
|
||||
@@ -62,5 +56,5 @@ func (src *CapMatch) Clone() *CapMatch {
|
||||
var _CapMatchCloneNeedsRegeneration = CapMatch(struct {
|
||||
Dst netip.Prefix
|
||||
Cap tailcfg.PeerCapability
|
||||
Values []json.RawMessage
|
||||
Values []tailcfg.RawMessage
|
||||
}{})
|
||||
|
@@ -4,7 +4,6 @@
|
||||
package filter
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/netip"
|
||||
"strings"
|
||||
@@ -60,7 +59,7 @@ type CapMatch struct {
|
||||
|
||||
// Values are the raw JSON values of the capability.
|
||||
// See tailcfg.PeerCapability and tailcfg.PeerCapMap for details.
|
||||
Values []json.RawMessage
|
||||
Values []tailcfg.RawMessage
|
||||
}
|
||||
|
||||
// Match matches packets from any IP address in Srcs to any ip:port in
|
||||
|
Reference in New Issue
Block a user