- Notifications
You must be signed in to change notification settings - Fork907
chore(vpn): send ping results over tunnel#18200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
13 commits Select commitHold shift + click to select a range
72db567
chore(vpn): send ping results over tunnel
ethanndickson91f3ba0
fixup
ethanndickson896548d
add pingctx
ethanndickson176a375
review
ethanndicksonf30bd12
forgot to goroutine
ethanndicksona472f56
remove wg
ethanndickson91f8009
lock for conn read
ethanndickson90f619d
fixup
ethanndickson6b5ea62
actually fixed with extra tests
ethanndickson50d3ef5
const version string
ethanndickson1ac2328
lint
ethanndickson3f49238
potential nil deref
ethanndickson208fcc2
review
ethanndicksonFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
45 changes: 8 additions & 37 deletionscli/ssh.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
8 changes: 0 additions & 8 deletionscoderd/database/db2sdk/db2sdk.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletionscoderd/util/maps/maps.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletionstailnet/derpmap.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -8,8 +8,11 @@ import ( | ||
"net/http" | ||
"os" | ||
"strconv" | ||
"strings" | ||
"time" | ||
"golang.org/x/xerrors" | ||
"tailscale.com/ipn/ipnstate" | ||
"tailscale.com/tailcfg" | ||
) | ||
@@ -152,6 +155,49 @@ regionLoop: | ||
return derpMap, nil | ||
} | ||
func ExtractPreferredDERPName(pingResult *ipnstate.PingResult, node *Node, derpMap *tailcfg.DERPMap) string { | ||
// Sometimes the preferred DERP doesn't match the one we're actually | ||
// connected with. Perhaps because the agent prefers a different DERP and | ||
// we're using that server instead. | ||
preferredDerpID := node.PreferredDERP | ||
if pingResult.DERPRegionID != 0 { | ||
preferredDerpID = pingResult.DERPRegionID | ||
} | ||
preferredDerp, ok := derpMap.Regions[preferredDerpID] | ||
preferredDerpName := fmt.Sprintf("Unnamed %d", preferredDerpID) | ||
if ok { | ||
preferredDerpName = preferredDerp.RegionName | ||
} | ||
return preferredDerpName | ||
} | ||
ethanndickson marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
// ExtractDERPLatency extracts a map of derp region names to their latencies | ||
func ExtractDERPLatency(node *Node, derpMap *tailcfg.DERPMap) map[string]time.Duration { | ||
latencyMs := make(map[string]time.Duration) | ||
// Convert DERP region IDs to friendly names for display in the UI. | ||
for rawRegion, latency := range node.DERPLatency { | ||
regionParts := strings.SplitN(rawRegion, "-", 2) | ||
regionID, err := strconv.Atoi(regionParts[0]) | ||
if err != nil { | ||
continue | ||
} | ||
region, found := derpMap.Regions[regionID] | ||
if !found { | ||
// It's possible that a workspace agent is using an old DERPMap | ||
// and reports regions that do not exist. If that's the case, | ||
// report the region as unknown! | ||
region = &tailcfg.DERPRegion{ | ||
RegionID: regionID, | ||
RegionName: fmt.Sprintf("Unnamed %d", regionID), | ||
} | ||
} | ||
latencyMs[region.RegionName] = time.Duration(latency * float64(time.Second)) | ||
} | ||
return latencyMs | ||
} | ||
// CompareDERPMaps returns true if the given DERPMaps are equivalent. Ordering | ||
// of slices is ignored. | ||
// | ||
109 changes: 109 additions & 0 deletionstailnet/derpmap_test.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletionsvpn/client.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
9 changes: 2 additions & 7 deletionsvpn/speaker_internal_test.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.