controlclient/netmap: write our own b.ConciseDiffFrom(a) function.

This removes the need for go-cmp, which is extremely bloaty so we had
to leave it out of iOS. As a result, we had also left it out of macOS,
and so we didn't print netmap diffs at all on darwin-based platforms.
Oops.

As a bonus, the output format of the new function is way better.

Minor oddity: because I used the dumbest possible diff algorithm, the
sort order is a bit dumb. We print all "removed" lines and then print
all "added" lines, rather than doing the usual diff-like thing of
interspersing them. This probably doesn't matter (maybe it's an
improvement).
This commit is contained in:
Avery Pennarun
2020-03-12 23:01:08 -04:00
parent 96bb05ce2f
commit b4897e7de8
4 changed files with 32 additions and 25 deletions

View File

@@ -18,7 +18,6 @@ import (
"syscall"
"time"
"github.com/google/go-cmp/cmp"
"github.com/klauspost/compress/zstd"
"tailscale.com/control/controlclient"
"tailscale.com/ipn"
@@ -112,7 +111,6 @@ func Run(rctx context.Context, logf logger.Logf, logid string, opts Options, e w
b.SetDecompressor(func() (controlclient.Decompressor, error) {
return zstd.NewReader(nil)
})
b.SetCmpDiff(func(x, y interface{}) string { return cmp.Diff(x, y) })
var s net.Conn
serverToClient := func(b []byte) {