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

@ -23,7 +23,6 @@ import (
"time"
"github.com/apenwarr/fixconsole"
"github.com/google/go-cmp/cmp"
"github.com/klauspost/compress/zstd"
"github.com/pborman/getopt/v2"
"github.com/tailscale/wireguard-go/wgcfg"
@ -103,9 +102,7 @@ func main() {
if m := new.NetMap; m != nil {
if lastNetMap != nil {
s1 := strings.Split(lastNetMap.Concise(), "\n")
s2 := strings.Split(new.NetMap.Concise(), "\n")
logf("netmap diff:\n%v\n", cmp.Diff(s1, s2))
logf("netmap diff:\n%v\n", new.NetMap.ConciseDiffFrom(lastNetMap))
}
lastNetMap = m