wgengine/tsdns: truncate Map.PrettyDiffFrom string at 1KB
Hello's were painful. Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
@@ -92,6 +92,9 @@ func (m *Map) PrettyDiffFrom(old *Map) string {
|
||||
}
|
||||
|
||||
buf := new(strings.Builder)
|
||||
space := func() bool {
|
||||
return buf.Len() < (1 << 10)
|
||||
}
|
||||
|
||||
for len(oldNames) > 0 && len(newNames) > 0 {
|
||||
var name string
|
||||
@@ -109,6 +112,9 @@ func (m *Map) PrettyDiffFrom(old *Map) string {
|
||||
oldNames = oldNames[1:]
|
||||
newNames = newNames[1:]
|
||||
}
|
||||
if !space() {
|
||||
continue
|
||||
}
|
||||
|
||||
ipOld, inOld := oldNameToIP[name]
|
||||
ipNew, inNew := newNameToIP[name]
|
||||
@@ -128,6 +134,9 @@ func (m *Map) PrettyDiffFrom(old *Map) string {
|
||||
}
|
||||
|
||||
for _, name := range oldNames {
|
||||
if !space() {
|
||||
break
|
||||
}
|
||||
if _, ok := newNameToIP[name]; !ok {
|
||||
buf.WriteByte('-')
|
||||
printSingleNameIP(buf, name, oldNameToIP[name])
|
||||
@@ -135,11 +144,17 @@ func (m *Map) PrettyDiffFrom(old *Map) string {
|
||||
}
|
||||
|
||||
for _, name := range newNames {
|
||||
if !space() {
|
||||
break
|
||||
}
|
||||
if _, ok := oldNameToIP[name]; !ok {
|
||||
buf.WriteByte('+')
|
||||
printSingleNameIP(buf, name, newNameToIP[name])
|
||||
}
|
||||
}
|
||||
if !space() {
|
||||
buf.WriteString("... [truncated]\n")
|
||||
}
|
||||
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user