Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
bump tailscale, change api
  • Loading branch information
ethanndickson committed Jul 2, 2024
commit 598cad5266bd5939cbb7a71171b5be7658035eea
36 changes: 17 additions & 19 deletions cli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ const (
varNoFeatureWarning = "no-feature-warning"
varForceTty = "force-tty"
varVerbose = "verbose"
varOrganizationSelect = "organization"
varDisableDirect = "disable-direct-connections"
varDisableNetworkTelemetry = "disable-network-telemetry"

Expand Down Expand Up @@ -475,25 +474,24 @@ func (r *RootCmd) Command(subcommands []*serpent.Command) (*serpent.Command, err

// RootCmd contains parameters and helpers useful to all commands.
type RootCmd struct {
clientURL *url.URL
token string
globalConfig string
header []string
headerCommand string
agentToken string
agentTokenFile string
agentURL *url.URL
forceTTY bool
noOpen bool
verbose bool
organizationSelect string
versionFlag bool
disableDirect bool
debugHTTP bool
noNetworkTelemetry bool
clientURL *url.URL
token string
globalConfig string
header []string
headerCommand string
agentToken string
agentTokenFile string
agentURL *url.URL
forceTTY bool
noOpen bool
verbose bool
versionFlag bool
disableDirect bool
debugHTTP bool

noVersionCheck bool
noFeatureWarning bool
noNetworkTelemetry bool
noVersionCheck bool
noFeatureWarning bool
}

// InitClient authenticates the client with files from disk
Expand Down
2 changes: 1 addition & 1 deletion cli/speedtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func (r *RootCmd) speedtest() *serpent.Command {
outputResult.Intervals[i] = interval
}
}
_ = conn.Conn.SendSpeedtestTelemetry(outputResult.Overall.ThroughputMbits)
conn.Conn.SendSpeedtestTelemetry(outputResult.Overall.ThroughputMbits)
out, err := formatter.Format(inv.Context(), outputResult)
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions coderd/telemetry/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -1163,9 +1163,9 @@ type Netcheck struct {
IPv4 bool `json:"ipv4"`
IPv6CanSend bool `json:"ipv6_can_send"`
IPv4CanSend bool `json:"ipv4_can_send"`
OSHasIPv6 bool `json:"os_has_ipv6"`
ICMPv4 bool `json:"icmpv4"`

OSHasIPv6 *bool `json:"os_has_ipv6"`
MappingVariesByDestIP *bool `json:"mapping_varies_by_dest_ip"`
HairPinning *bool `json:"hair_pinning"`
UPnP *bool `json:"upnp"`
Expand Down Expand Up @@ -1210,9 +1210,9 @@ func netcheckFromProto(proto *tailnetproto.Netcheck) Netcheck {
IPv4: proto.IPv4,
IPv6CanSend: proto.IPv6CanSend,
IPv4CanSend: proto.IPv4CanSend,
OSHasIPv6: proto.OSHasIPv6,
ICMPv4: proto.ICMPv4,

OSHasIPv6: protoBool(proto.OSHasIPv6),
MappingVariesByDestIP: protoBool(proto.MappingVariesByDestIP),
HairPinning: protoBool(proto.HairPinning),
UPnP: protoBool(proto.UPnP),
Expand Down
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
name = "coder-${osArch}";
# Updated with ./scripts/update-flake.sh`.
# This should be updated whenever go.mod changes!
vendorHash = "sha256-e0L6osJwG0EF0M3TefxaAjDvN4jvQHxTGEUEECNO1Vw=";
vendorHash = "sha256-IbebvYg1E50elvojWbJICJiTzy5Y5bP7n57sGMENDFs=";
proxyVendor = true;
src = ./.;
nativeBuildInputs = with pkgs; [ getopt openssl zstd ];
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ replace github.com/dlclark/regexp2 => github.com/dlclark/regexp2 v1.7.0

// There are a few minor changes we make to Tailscale that we're slowly upstreaming. Compare here:
// https://github.com/tailscale/tailscale/compare/main...coder:tailscale:main
replace tailscale.com => github.com/coder/tailscale v1.1.1-0.20240530071520-1ac63d3a4ee3
replace tailscale.com => github.com/coder/tailscale v1.1.1-0.20240702054557-aa558fbe5374

// This is replaced to include
// 1. a fix for a data race: c.f. https://github.com/tailscale/wireguard-go/pull/25
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ github.com/coder/serpent v0.7.0 h1:zGpD2GlF3lKIVkMjNGKbkip88qzd5r/TRcc30X/SrT0=
github.com/coder/serpent v0.7.0/go.mod h1:REkJ5ZFHQUWFTPLExhXYZ1CaHFjxvGNRlLXLdsI08YA=
github.com/coder/ssh v0.0.0-20231128192721-70855dedb788 h1:YoUSJ19E8AtuUFVYBpXuOD6a/zVP3rcxezNsoDseTUw=
github.com/coder/ssh v0.0.0-20231128192721-70855dedb788/go.mod h1:aGQbuCLyhRLMzZF067xc84Lh7JDs1FKwCmF1Crl9dxQ=
github.com/coder/tailscale v1.1.1-0.20240530071520-1ac63d3a4ee3 h1:F2QRxrwPJyMPmX5qU7UpwEenhsk9qDqHyvYFxON1RkI=
github.com/coder/tailscale v1.1.1-0.20240530071520-1ac63d3a4ee3/go.mod h1:rp6BIJxCp127/hvvDWNkHC9MxAlKvQfoOtBr8s5sCqo=
github.com/coder/tailscale v1.1.1-0.20240702054557-aa558fbe5374 h1:a5Eg7D5e2oAc0tN56ee4yxtiTo76ztpRlk6geljaZp8=
github.com/coder/tailscale v1.1.1-0.20240702054557-aa558fbe5374/go.mod h1:rp6BIJxCp127/hvvDWNkHC9MxAlKvQfoOtBr8s5sCqo=
github.com/coder/terraform-provider-coder v0.23.0 h1:DuNLWxhnGlXyG0g+OCAZRI6xd8+bJjIEnE4F3hYgA4E=
github.com/coder/terraform-provider-coder v0.23.0/go.mod h1:wMun9UZ9HT2CzF6qPPBup1odzBpVUc0/xSFoXgdI3tk=
github.com/coder/wgtunnel v0.1.13-0.20240522110300-ade90dfb2da0 h1:C2/eCr+r0a5Auuw3YOiSyLNHkdMtyCZHPFBx7syN4rk=
Expand Down
63 changes: 16 additions & 47 deletions tailnet/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"github.com/google/uuid"
"golang.org/x/xerrors"
"google.golang.org/protobuf/types/known/durationpb"
"google.golang.org/protobuf/types/known/timestamppb"
"google.golang.org/protobuf/types/known/wrapperspb"
"gvisor.dev/gvisor/pkg/tcpip"
"gvisor.dev/gvisor/pkg/tcpip/adapters/gonet"
Expand Down Expand Up @@ -530,7 +529,7 @@ func (c *Conn) AwaitReachable(ctx context.Context, ip netip.Addr) bool {
case <-completedCtx.Done():
// TODO(ethanndickson): For now, I'm interpreting 'connected' as when the
// agent is reachable.
_ = c.sendConnectedTelemetry()
c.sendConnectedTelemetry()
return true
case <-t.C:
// Pings can take a while, so we can run multiple
Expand Down Expand Up @@ -720,50 +719,39 @@ func (c *Conn) MagicsockServeHTTPDebug(w http.ResponseWriter, r *http.Request) {
c.magicConn.ServeHTTPDebug(w, r)
}

func (c *Conn) sendConnectedTelemetry() error {
func (c *Conn) sendConnectedTelemetry() {
if c.telemetrySink == nil {
return nil
}
e, err := c.newTelemetryEvent()
if err != nil {
return xerrors.Errorf("create telemetry event: %w", err)
return
}
e := c.newTelemetryEvent()
e.Status = proto.TelemetryEvent_CONNECTED
c.telemetryWg.Add(1)
go func() {
defer c.telemetryWg.Done()
c.telemetrySink.SendTelemetryEvent(e)
}()
return nil
}

func (c *Conn) SendSpeedtestTelemetry(throughputMbits float64) error {
func (c *Conn) SendSpeedtestTelemetry(throughputMbits float64) {
if c.telemetrySink == nil {
return nil
}
e, err := c.newTelemetryEvent()
if err != nil {
return xerrors.Errorf("create telemetry event: %w", err)
return
}
e := c.newTelemetryEvent()
e.Status = proto.TelemetryEvent_CONNECTED
e.ThroughputMbits = wrapperspb.Float(float32(throughputMbits))
c.telemetryWg.Add(1)
go func() {
defer c.telemetryWg.Done()
c.telemetrySink.SendTelemetryEvent(e)
}()
return nil
}

// nolint: revive
func (c *Conn) sendPingTelemetry(latency time.Duration, p2p bool) error {
if c.telemetrySink == nil {
return nil
}
e, err := c.newTelemetryEvent()
if err != nil {
return xerrors.Errorf("create telemetry event: %w", err)
}
e := c.newTelemetryEvent()
e.Status = proto.TelemetryEvent_CONNECTED
if p2p {
e.P2PLatency = durationpb.New(latency)
Expand All @@ -779,33 +767,14 @@ func (c *Conn) sendPingTelemetry(latency time.Duration, p2p bool) error {
}

// The returned telemetry event will not have it's status set.
func (c *Conn) newTelemetryEvent() (*proto.TelemetryEvent, error) {
id, err := c.id.MarshalBinary()
if err != nil {
return nil, xerrors.Errorf("marshal uuid to bytes: %w", err)
}

logs, ips, dm, nc := c.telemeteryStore.getStore()
return &proto.TelemetryEvent{
Id: id,
Time: timestamppb.Now(),
ClientType: c.clientType,
NodeIdSelf: uint64(c.nodeID),
Logs: logs,
LogIpHashes: ips,
DerpMap: dm,
LatestNetcheck: nc,

// TODO:
Application: "",
NodeIdRemote: 0,
P2PEndpoint: &proto.TelemetryEvent_P2PEndpoint{},
HomeDerp: "",
ConnectionAge: &durationpb.Duration{},
ConnectionSetup: &durationpb.Duration{},
// TODO: We only calculate this in one place, do we really want it?
P2PSetup: &durationpb.Duration{},
}, nil
func (c *Conn) newTelemetryEvent() *proto.TelemetryEvent {
// Infallible
id, _ := c.id.MarshalBinary()
event := c.telemeteryStore.getStore()
event.ClientType = c.clientType
event.Id = id
event.NodeIdSelf = uint64(c.nodeID)
return event
}

// PeerDiagnostics is a checklist of human-readable conditions necessary to establish an encrypted
Expand Down
53 changes: 0 additions & 53 deletions tailnet/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@ package tailnet

import (
"net/netip"
"strconv"
"strings"
"time"

"github.com/google/uuid"
"golang.org/x/xerrors"
"google.golang.org/protobuf/types/known/durationpb"
"google.golang.org/protobuf/types/known/timestamppb"
"google.golang.org/protobuf/types/known/wrapperspb"
"tailscale.com/tailcfg"
"tailscale.com/types/key"

Expand Down Expand Up @@ -275,51 +270,3 @@ func DERPNodeFromProto(node *proto.DERPMap_Region_Node) *tailcfg.DERPNode {
CanPort80: node.CanPort_80,
}
}

func NetInfoToProto(netInfo *tailcfg.NetInfo) *proto.Netcheck {
if netInfo == nil {
return nil
}
rlv4 := make(map[int64]*durationpb.Duration)
rlv6 := make(map[int64]*durationpb.Duration)
for k, seconds := range netInfo.DERPLatency {
res := strings.Split(k, "-")
if len(res) != 2 {
continue
}

rid, err := strconv.ParseInt(res[0], 10, 64)
if err != nil {
continue
}

dur := time.Duration(seconds * float64(time.Second))

switch res[1] {
case "v4":
rlv4[rid] = durationpb.New(dur)
case "v6":
rlv6[rid] = durationpb.New(dur)
}
}
return &proto.Netcheck{
UDP: netInfo.WorkingUDP.EqualBool(true),
OSHasIPv6: netInfo.OSHasIPv6.EqualBool(true),
IPv6: netInfo.WorkingIPv6.EqualBool(true),
ICMPv4: netInfo.WorkingICMPv4.EqualBool(true),
MappingVariesByDestIP: wrapperspb.Bool(netInfo.MappingVariesByDestIP.EqualBool(true)),
HairPinning: wrapperspb.Bool(netInfo.HairPinning.EqualBool(true)),
UPnP: wrapperspb.Bool(netInfo.UPnP.EqualBool(true)),
PMP: wrapperspb.Bool(netInfo.PMP.EqualBool(true)),
PCP: wrapperspb.Bool(netInfo.PCP.EqualBool(true)),
PreferredDERP: int64(netInfo.PreferredDERP),
RegionV4Latency: rlv4,
RegionV6Latency: rlv6,
// TODO: These aren't yet exposed by Tailscale
IPv6CanSend: false,
IPv4CanSend: false,
IPv4: false,
GlobalV4: &proto.Netcheck_NetcheckIP{},
GlobalV6: &proto.Netcheck_NetcheckIP{},
}
}
Loading