wgengine/magicsock: add new endpoint type used for discovery-supporting peers

This adds a new magicsock endpoint type only used when both sides
support discovery (that is, are advertising a discovery
key). Otherwise the old code is used.

So far the new code only communicates over DERP as proof that the new
code paths are wired up. None of the actually discovery messaging is
implemented yet.

Support for discovery (generating and advertising a key) are still
behind an environment variable for now.

Updates #483
This commit is contained in:
Brad Fitzpatrick
2020-06-28 11:53:37 -07:00
parent 72bfea2ece
commit a975e86bb8
5 changed files with 282 additions and 50 deletions

View File

@@ -8,8 +8,6 @@ import (
"context"
"errors"
"fmt"
"os"
"strconv"
"strings"
"sync"
"time"
@@ -362,7 +360,7 @@ func (b *LocalBackend) Start(opts Options) error {
b.updateFilter(nil)
var discoPublic tailcfg.DiscoKey
if useDisco, _ := strconv.ParseBool(os.Getenv("TS_DEBUG_USE_DISCO")); useDisco {
if controlclient.Debug.Disco {
discoPrivate := key.NewPrivate()
b.e.SetDiscoPrivateKey(discoPrivate)
discoPublic = tailcfg.DiscoKey(discoPrivate.Public())